Completed
Push — master ( 9d054b...106a1b )
by Klaus
23:45 queued 04:19
created
api/src/Etemplate/Widget/Box.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -42,17 +42,17 @@  discard block
 block discarded – undo
42 42
 	 * @param array $params =array('') parameter(s) first parameter has to be cname!
43 43
 	 * @param boolean $respect_disabled =false false (default): ignore disabled, true: method is NOT run for disabled widgets AND their children
44 44
 	 */
45
-	public function run($method_name, $params=array(''), $respect_disabled=false)
45
+	public function run($method_name, $params = array(''), $respect_disabled = false)
46 46
 	{
47
-		$cname =& $params[0];
48
-		$expand =& $params[1];
47
+		$cname = & $params[0];
48
+		$expand = & $params[1];
49 49
 		$old_cname = $params[0];
50 50
 		$old_expand = $params[1];
51 51
 
52 52
 		if ($this->id && $this->type != 'groupbox') $cname = self::form_name($cname, $this->id, $params[1]);
53 53
 		if ($expand['cname'] !== $cname && $cname)
54 54
 		{
55
-			$expand['cont'] =& self::get_array(self::$request->content, $cname);
55
+			$expand['cont'] = & self::get_array(self::$request->content, $cname);
56 56
 			$expand['cname'] = $cname;
57 57
 		}
58 58
 		if ($respect_disabled && ($disabled = $this->attrs['disabled'] && self::check_disabled($this->attrs['disabled'], $expand)))
@@ -67,11 +67,11 @@  discard block
 block discarded – undo
67 67
 
68 68
 		// Expand children
69 69
 		$columns_disabled = null;
70
-		for($n = 0; ; ++$n)
70
+		for ($n = 0; ; ++$n)
71 71
 		{
72 72
 			if (isset($this->children[$n]))
73 73
 			{
74
-				$child =& $this->children[$n];
74
+				$child = & $this->children[$n];
75 75
 				// If type has something that can be expanded, we need to expand it so the correct method is run
76 76
 				$this->expand_widget($child, $expand);
77 77
 			}
@@ -107,17 +107,17 @@  discard block
 block discarded – undo
107 107
 	 */
108 108
 	private function need_autorepeat(Etemplate\Widget $widget, $cname, array $expand)
109 109
 	{
110
-		foreach(array($widget) + $widget->children as $check_widget)
110
+		foreach (array($widget) + $widget->children as $check_widget)
111 111
 		{
112 112
 			$pat = $check_widget->id;
113
-			while(($pattern = strstr($pat, '$')))
113
+			while (($pattern = strstr($pat, '$')))
114 114
 			{
115
-				$pat = substr($pattern,$pattern[1] == '{' ? 2 : 1);
115
+				$pat = substr($pattern, $pattern[1] == '{' ? 2 : 1);
116 116
 
117
-				$Ok = $pat[0] == 'r' && !(substr($pat,0,2) == 'r_' ||
118
-					substr($pat,0,4) == 'row_' && substr($pat,0,8) != 'row_cont');
117
+				$Ok = $pat[0] == 'r' && !(substr($pat, 0, 2) == 'r_' ||
118
+					substr($pat, 0, 4) == 'row_' && substr($pat, 0, 8) != 'row_cont');
119 119
 
120
-				if ($Ok && ($fname=self::form_name($cname, $check_widget->id, $expand)) &&
120
+				if ($Ok && ($fname = self::form_name($cname, $check_widget->id, $expand)) &&
121 121
 					// need to break if fname ends in [] as get_array() will ignore it and returns whole array
122 122
 					// for an id like "run[$row_cont[appname]]"
123 123
 					substr($fname, -2) != '[]' &&
Please login to merge, or discard this patch.
Braces   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -49,7 +49,10 @@  discard block
 block discarded – undo
49 49
 		$old_cname = $params[0];
50 50
 		$old_expand = $params[1];
51 51
 
52
-		if ($this->id && $this->type != 'groupbox') $cname = self::form_name($cname, $this->id, $params[1]);
52
+		if ($this->id && $this->type != 'groupbox')
53
+		{
54
+			$cname = self::form_name($cname, $this->id, $params[1]);
55
+		}
53 56
 		if ($expand['cname'] !== $cname && $cname)
54 57
 		{
55 58
 			$expand['cont'] =& self::get_array(self::$request->content, $cname);
@@ -121,10 +124,13 @@  discard block
 block discarded – undo
121 124
 					// need to break if fname ends in [] as get_array() will ignore it and returns whole array
122 125
 					// for an id like "run[$row_cont[appname]]"
123 126
 					substr($fname, -2) != '[]' &&
124
-					($value = self::get_array(self::$request->content, $fname)) !== null)	// null = not found (can be false!)
127
+					($value = self::get_array(self::$request->content, $fname)) !== null)
128
+				{
129
+					// null = not found (can be false!)
125 130
 				{
126 131
 					//error_log(__METHOD__."($widget,$cname) $this autorepeating row $expand[row] because of $check_widget->id = '$fname' is ".array2string($value));
127 132
 					unset($value);
133
+				}
128 134
 					return true;
129 135
 				}
130 136
 			}
Please login to merge, or discard this patch.
api/src/Etemplate/Widget/AjaxSelect.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	 * @param string $cname
27 27
 	 * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont'
28 28
 	 */
29
-	public function beforeSendToClient($cname, array $expand=null)
29
+	public function beforeSendToClient($cname, array $expand = null)
30 30
 	{
31 31
 		$matches = null;
32 32
 		if ($cname == '$row')	// happens eg. with custom-fields: $cname='$row', this->id='#something'
@@ -55,13 +55,13 @@  discard block
 block discarded – undo
55 55
 
56 56
 		// Make sure  s, etc.  are properly encoded when sent, and not double-encoded
57 57
 		$options = (isset(self::$request->sel_options[$form_name]) ? $form_name : $this->id);
58
-		if(is_array(self::$request->sel_options[$options]))
58
+		if (is_array(self::$request->sel_options[$options]))
59 59
 		{
60 60
 
61 61
 			// Fix any custom options from application
62
-			self::fix_encoded_options(self::$request->sel_options[$options],true);
62
+			self::fix_encoded_options(self::$request->sel_options[$options], true);
63 63
 
64
-			if(!self::$request->sel_options[$options])
64
+			if (!self::$request->sel_options[$options])
65 65
 			{
66 66
 				unset(self::$request->sel_options[$options]);
67 67
 			}
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,10 +29,13 @@
 block discarded – undo
29 29
 	public function beforeSendToClient($cname, array $expand=null)
30 30
 	{
31 31
 		$matches = null;
32
-		if ($cname == '$row')	// happens eg. with custom-fields: $cname='$row', this->id='#something'
32
+		if ($cname == '$row')
33
+		{
34
+			// happens eg. with custom-fields: $cname='$row', this->id='#something'
33 35
 		{
34 36
 			$form_name = $this->id;
35 37
 		}
38
+		}
36 39
 		// happens with fields in nm-header: $cname='nm', this->id='${row}[something]' or '{$row}[something]'
37 40
 		elseif (preg_match('/(\${row}|{\$row})\[([^]]+)\]$/', $this->id, $matches))
38 41
 		{
Please login to merge, or discard this patch.
api/src/Etemplate/Widget/Nextmatch/Accountfilter.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
 	 * @param string|XMLReader $xml
27 27
 	 * @param boolean $cloned =true true: object does NOT need to be cloned, false: to set attribute, set them in cloned object
28 28
 	 */
29
-	public function set_attrs($xml, $cloned=true)
29
+	public function set_attrs($xml, $cloned = true)
30 30
 	{
31 31
 		parent::set_attrs($xml, $cloned);
32 32
 
Please login to merge, or discard this patch.
api/src/Etemplate/Widget/Nextmatch/Customfilter.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,18 +29,18 @@  discard block
 block discarded – undo
29 29
 	 * @param string $cname
30 30
 	 * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont'
31 31
 	 */
32
-	public function beforeSendToClient($cname, array $expand=null)
32
+	public function beforeSendToClient($cname, array $expand = null)
33 33
 	{
34
-		switch($this->attrs['type'])
34
+		switch ($this->attrs['type'])
35 35
 		{
36 36
 			case "link-entry":
37 37
 				self::$transformation['type'] = $this->attrs['type'] = 'nextmatch-entryheader';
38 38
 				break;
39 39
 			default:
40
-				list($type) = explode('-',$this->attrs['type']);
41
-				if($type == 'select')
40
+				list($type) = explode('-', $this->attrs['type']);
41
+				if ($type == 'select')
42 42
 				{
43
-					if(in_array($this->attrs['type'], Widget\Select::$cached_types))
43
+					if (in_array($this->attrs['type'], Widget\Select::$cached_types))
44 44
 					{
45 45
 						$widget_type = $this->attrs['type'];
46 46
 					}
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 		$this->setElementAttribute($form_name, 'options', trim($this->attrs['widget_options']) != '' ? $this->attrs['widget_options'] : '');
54 54
 
55 55
 		$this->setElementAttribute($form_name, 'type', $this->attrs['type']);
56
-		if($widget_type)
56
+		if ($widget_type)
57 57
 		{
58 58
 			$this->setElementAttribute($form_name, 'widget_type', $widget_type);
59 59
 		}
@@ -69,11 +69,11 @@  discard block
 block discarded – undo
69 69
 	 * @param array $content
70 70
 	 * @param array &$validated=array() validated content
71 71
 	 */
72
-	public function validate($cname, array $expand, array $content, &$validated=array())
72
+	public function validate($cname, array $expand, array $content, &$validated = array())
73 73
 	{
74 74
 		$value = $value_in = self::get_array($content, $form_name);
75 75
 
76
-		$valid =& self::get_array($validated, $form_name, true);
76
+		$valid = & self::get_array($validated, $form_name, true);
77 77
 		// returning null instead of array(), as array() will be overwritten by etemplate_new::complete_array_merge()
78 78
 		// with preserved old content and therefore user can not empty a taglist
79 79
 		$valid = $value ? $value : null;
Please login to merge, or discard this patch.
api/src/Etemplate/Widget/Link.php 3 patches
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 */
38 38
 	public function __construct($xml = '')
39 39
 	{
40
-		if($xml) {
40
+		if ($xml) {
41 41
 			parent::__construct($xml);
42 42
 		}
43 43
 	}
@@ -62,20 +62,20 @@  discard block
 block discarded – undo
62 62
 	 * @param string $cname
63 63
 	 * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont'
64 64
 	 */
65
-	public function beforeSendToClient($cname, array $expand=null)
65
+	public function beforeSendToClient($cname, array $expand = null)
66 66
 	{
67 67
 		$attrs = $this->attrs;
68 68
 		$form_name = self::form_name($cname, $this->id, $expand);
69
-		$value =& self::get_array(self::$request->content, $form_name, true);
69
+		$value = & self::get_array(self::$request->content, $form_name, true);
70 70
 
71
-		if($value && !is_array($value) && !$this->attrs['only_app'])
71
+		if ($value && !is_array($value) && !$this->attrs['only_app'])
72 72
 		{
73 73
 			// Try to explode
74
-			if(count(explode(':',$value)) < 2)
74
+			if (count(explode(':', $value)) < 2)
75 75
 			{
76 76
 				throw new Api\Exception\WrongParameter("Wrong value sent to $this, needs to be an array. ".array2string($value));
77 77
 			}
78
-			list($app, $id) = explode(':', $value,2);
78
+			list($app, $id) = explode(':', $value, 2);
79 79
 			$value = array('app' => $app, 'id' => $id);
80 80
 		}
81 81
 		elseif (!$value)
@@ -87,12 +87,12 @@  discard block
 block discarded – undo
87 87
 		// ToDo: implement on client-side
88 88
 		if (!$attrs['help']) self::setElementAttribute($form_name, 'help', 'view this linked entry in its application');
89 89
 
90
-		if($attrs['type'] == 'link-list')
90
+		if ($attrs['type'] == 'link-list')
91 91
 		{
92 92
 			$app = $value['to_app'];
93 93
 			$id  = $value['to_id'];
94
-			$links = Api\Link::get_links($app,$id,'','link_lastmod DESC',true, $value['show_deleted']);
95
-			foreach($links as $link) {
94
+			$links = Api\Link::get_links($app, $id, '', 'link_lastmod DESC', true, $value['show_deleted']);
95
+			foreach ($links as $link) {
96 96
 				$value[] = $link;
97 97
 			}
98 98
 		}
@@ -101,10 +101,10 @@  discard block
 block discarded – undo
101 101
 	/**
102 102
 	 * Find links that match the given parameters
103 103
 	 */
104
-	public static function ajax_link_search($app, $type, $pattern, $options=array())
104
+	public static function ajax_link_search($app, $type, $pattern, $options = array())
105 105
 	{
106 106
 		$options['type'] = $type ? $type : $options['type'];
107
-		if(!$options['num_rows']) $options['num_rows'] = 1000;
107
+		if (!$options['num_rows']) $options['num_rows'] = 1000;
108 108
 
109 109
 		$links = Api\Link::query($app, $pattern, $options);
110 110
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	 * @param string|int $id
125 125
 	 * @return string|boolean string with title, boolean false of permission denied or null if not found
126 126
 	 */
127
-	public static function ajax_link_title($app,$id)
127
+	public static function ajax_link_title($app, $id)
128 128
 	{
129 129
 		$title = Api\Link::title($app, $id);
130 130
 		//error_log(__METHOD__."('$app', '$id') = ".array2string($title));
@@ -140,15 +140,15 @@  discard block
 block discarded – undo
140 140
 	public static function ajax_link_titles(array $app_ids)
141 141
 	{
142 142
 		$response = array();
143
-		foreach($app_ids as $app => $ids)
143
+		foreach ($app_ids as $app => $ids)
144 144
 		{
145
-			if(count($ids))
145
+			if (count($ids))
146 146
 			{
147 147
 				$response[$app] = Api\Link::titles($app, $ids);
148 148
 			}
149 149
 			else
150 150
 			{
151
-				error_log(__METHOD__."(".array2string($app_ids).") got invalid title request: app=$app, ids=" . array2string($ids));
151
+				error_log(__METHOD__."(".array2string($app_ids).") got invalid title request: app=$app, ids=".array2string($ids));
152 152
 			}
153 153
 		}
154 154
 		Api\Json\Response::get()->data($response);
@@ -160,11 +160,11 @@  discard block
 block discarded – undo
160 160
 	public static function ajax_link($app, $id, Array $links)
161 161
 	{
162 162
 		// Files need to know full path in tmp directory
163
-		foreach($links as $key => $link) {
164
-			if($link['app'] == Api\Link::VFS_APPNAME) {
163
+		foreach ($links as $key => $link) {
164
+			if ($link['app'] == Api\Link::VFS_APPNAME) {
165 165
 				if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir']))
166 166
 				{
167
-					$path = $GLOBALS['egw_info']['server']['temp_dir'] . '/' . $link['id'];
167
+					$path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.$link['id'];
168 168
 				}
169 169
 				else
170 170
 				{
@@ -185,20 +185,20 @@  discard block
 block discarded – undo
185 185
 		$app = $value['to_app'];
186 186
 		$id  = $value['to_id'];
187 187
 
188
-		$links = Api\Link::get_links($app,$id,$value['only_app'],'link_lastmod DESC',true, $value['show_deleted']);
189
-		foreach($links as &$link)
188
+		$links = Api\Link::get_links($app, $id, $value['only_app'], 'link_lastmod DESC', true, $value['show_deleted']);
189
+		foreach ($links as &$link)
190 190
 		{
191
-			$link['title'] = Api\Link::title($link['app'],$link['id'],$link);
191
+			$link['title'] = Api\Link::title($link['app'], $link['id'], $link);
192 192
 			if ($link['app'] == Api\Link::VFS_APPNAME)
193 193
 			{
194 194
 				$link['target'] = '_blank';
195 195
 				$link['label'] = 'Delete';
196 196
 				$link['help'] = lang('Delete this file');
197 197
 				$link['title'] = Api\Vfs::decodePath($link['title']);
198
-				$link['icon'] = Api\Link::vfs_path($link['app2'],$link['id2'],$link['id'],true);
198
+				$link['icon'] = Api\Link::vfs_path($link['app2'], $link['id2'], $link['id'], true);
199 199
 				$link['download_url'] = Api\Vfs::download_url($link['icon']);
200 200
 				// Make links to directories load in filemanager
201
-				if($link['type'] == Api\Vfs::DIR_MIME_TYPE)
201
+				if ($link['type'] == Api\Vfs::DIR_MIME_TYPE)
202 202
 				{
203 203
 					$link['target'] = 'filemanager';
204 204
 				}
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 	public static function ajax_link_comment($link_id, $comment)
223 223
 	{
224 224
 		$result = false;
225
-		if((int)$link_id > 0)
225
+		if ((int)$link_id > 0)
226 226
 		{
227 227
 			Api\Link::update_remark((int)$link_id, $comment);
228 228
 			$result = true;
@@ -230,11 +230,11 @@  discard block
 block discarded – undo
230 230
 		else
231 231
 		{
232 232
 			$link = Api\Link::get_link((int)$link_id);
233
-			if($link && $link['app'] == Api\Link::VFS_APPNAME)
233
+			if ($link && $link['app'] == Api\Link::VFS_APPNAME)
234 234
 			{
235
-				$files = Api\Link::list_attached($link['app2'],$link['id2']);
235
+				$files = Api\Link::list_attached($link['app2'], $link['id2']);
236 236
 				$file = $files[(int)$link_id];
237
-				$path = Api\Link::vfs_path($link['app2'],$link['id2'],$file['id']);
237
+				$path = Api\Link::vfs_path($link['app2'], $link['id2'], $file['id']);
238 238
 				$result = Api\Vfs::proppatch($path, array(array('name' => 'comment', 'val' => $comment)));
239 239
 			}
240 240
 		}
@@ -248,13 +248,13 @@  discard block
 block discarded – undo
248 248
 	public static function link_existing($app_id, $files)
249 249
 	{
250 250
 		list($app, $id, $dest_file) = explode(':', $app_id);
251
-		if($id && $dest_file && trim($dest_file) !== '')
251
+		if ($id && $dest_file && trim($dest_file) !== '')
252 252
 		{
253 253
 			$id .= "/$dest_file";
254 254
 		}
255 255
 
256
-		if(!is_array($files)) $files = array($files);
257
-		foreach($files as $target)
256
+		if (!is_array($files)) $files = array($files);
257
+		foreach ($files as $target)
258 258
 		{
259 259
 			Api\Link::link_file($app, $id, $target);
260 260
 		}
@@ -278,13 +278,13 @@  discard block
 block discarded – undo
278 278
 	{
279 279
 		$app = $_GET['app'];
280 280
 		$id = $_GET['id'];
281
-		if(Api\Link::file_access($app, $id))
281
+		if (Api\Link::file_access($app, $id))
282 282
 		{
283
-			$app_path = Api\Link::vfs_path($app,$id,'',true);
283
+			$app_path = Api\Link::vfs_path($app, $id, '', true);
284 284
 
285 285
 			// Pass the files linked, not the entry path
286 286
 			$files = Api\Vfs::find($app_path);
287
-			if($files[0] == $app_path)
287
+			if ($files[0] == $app_path)
288 288
 			{
289 289
 				array_shift($files);
290 290
 			}
@@ -308,13 +308,13 @@  discard block
 block discarded – undo
308 308
 	 * @param array $content
309 309
 	 * @param array &$validated=array() validated content
310 310
 	 */
311
-	public function validate($cname, array $expand, array $content, &$validated=array())
311
+	public function validate($cname, array $expand, array $content, &$validated = array())
312 312
 	{
313 313
 		$form_name = self::form_name($cname, $this->id, $expand);
314 314
 
315 315
 		if (!$this->is_readonly($cname, $form_name))
316 316
 		{
317
-			$value = $value_in =& self::get_array($content, $form_name);
317
+			$value = $value_in = & self::get_array($content, $form_name);
318 318
 
319 319
 			// keep values added into request by other ajax-functions, eg. files draged into htmlarea (Vfs)
320 320
 			if ((!$value || !$value['to_id']) && is_array($expand['cont'][$this->id]) && !empty($expand['cont'][$this->id]['to_id']))
@@ -323,44 +323,44 @@  discard block
 block discarded – undo
323 323
 			}
324 324
 
325 325
 			// Link widgets can share IDs, make sure to preserve values from others
326
-			$already = self::get_array($validated,$form_name);
327
-			if($already != null)
326
+			$already = self::get_array($validated, $form_name);
327
+			if ($already != null)
328 328
 			{
329
-				$value = array_merge($value,$already);
329
+				$value = array_merge($value, $already);
330 330
 			}
331 331
 			// Automatically do link if user selected entry but didn't click 'Link' button
332
-			$link = self::get_array($content, self::form_name($cname, $this->id . '_link_entry'));
333
-			if($this->type =='link-to' && is_array($link) && $link['app'] && $link['id'] )
332
+			$link = self::get_array($content, self::form_name($cname, $this->id.'_link_entry'));
333
+			if ($this->type == 'link-to' && is_array($link) && $link['app'] && $link['id'])
334 334
 			{
335 335
 				// Do we have enough information to link automatically?
336
-				if(is_array($value) && $value['to_id'])
336
+				if (is_array($value) && $value['to_id'])
337 337
 				{
338 338
 					Api\Link::link($value['to_app'], $value['to_id'], $link['app'], $link['id']);
339 339
 				}
340 340
 				else
341 341
 				{
342 342
 					// Not enough information, leave it to the application
343
-					if(!is_array($value['to_id'])) $value['to_id'] = array();
343
+					if (!is_array($value['to_id'])) $value['to_id'] = array();
344 344
 					$value['to_id'][] = $link;
345 345
 				}
346 346
 			}
347 347
 
348 348
 			// Look for files - normally handled by ajax
349
-			$files = self::get_array($content, self::form_name($cname, $this->id . '_file'));
350
-			if(is_array($files) && !(is_array($value) && $value['to_id']))
349
+			$files = self::get_array($content, self::form_name($cname, $this->id.'_file'));
350
+			if (is_array($files) && !(is_array($value) && $value['to_id']))
351 351
 			{
352 352
 				$value = array();
353 353
 				if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir']))
354 354
 				{
355
-					$path = $GLOBALS['egw_info']['server']['temp_dir'] . '/';
355
+					$path = $GLOBALS['egw_info']['server']['temp_dir'].'/';
356 356
 				}
357 357
 				else
358 358
 				{
359 359
 					$path = '';
360 360
 				}
361
-				foreach($files as $name => $attrs)
361
+				foreach ($files as $name => $attrs)
362 362
 				{
363
-					if(!is_array($value['to_id'])) $value['to_id'] = array();
363
+					if (!is_array($value['to_id'])) $value['to_id'] = array();
364 364
 					$value['to_id'][] = array(
365 365
 						'app'	=> Api\Link::VFS_APPNAME,
366 366
 						'id'	=> array(
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 					);
372 372
 				}
373 373
 			}
374
-			$valid =& self::get_array($validated, $form_name, true);
374
+			$valid = & self::get_array($validated, $form_name, true);
375 375
 			if (true) $valid = $value;
376 376
 			//error_log($this);
377 377
 			//error_log("   " . array2string($valid));
Please login to merge, or discard this patch.
Braces   +32 added lines, -10 removed lines patch added patch discarded remove patch
@@ -37,7 +37,8 @@  discard block
 block discarded – undo
37 37
 	 */
38 38
 	public function __construct($xml = '')
39 39
 	{
40
-		if($xml) {
40
+		if($xml)
41
+		{
41 42
 			parent::__construct($xml);
42 43
 		}
43 44
 	}
@@ -85,14 +86,18 @@  discard block
 block discarded – undo
85 86
 
86 87
 
87 88
 		// ToDo: implement on client-side
88
-		if (!$attrs['help']) self::setElementAttribute($form_name, 'help', 'view this linked entry in its application');
89
+		if (!$attrs['help'])
90
+		{
91
+			self::setElementAttribute($form_name, 'help', 'view this linked entry in its application');
92
+		}
89 93
 
90 94
 		if($attrs['type'] == 'link-list')
91 95
 		{
92 96
 			$app = $value['to_app'];
93 97
 			$id  = $value['to_id'];
94 98
 			$links = Api\Link::get_links($app,$id,'','link_lastmod DESC',true, $value['show_deleted']);
95
-			foreach($links as $link) {
99
+			foreach($links as $link)
100
+			{
96 101
 				$value[] = $link;
97 102
 			}
98 103
 		}
@@ -104,7 +109,10 @@  discard block
 block discarded – undo
104 109
 	public static function ajax_link_search($app, $type, $pattern, $options=array())
105 110
 	{
106 111
 		$options['type'] = $type ? $type : $options['type'];
107
-		if(!$options['num_rows']) $options['num_rows'] = 1000;
112
+		if(!$options['num_rows'])
113
+		{
114
+			$options['num_rows'] = 1000;
115
+		}
108 116
 
109 117
 		$links = Api\Link::query($app, $pattern, $options);
110 118
 
@@ -160,8 +168,10 @@  discard block
 block discarded – undo
160 168
 	public static function ajax_link($app, $id, Array $links)
161 169
 	{
162 170
 		// Files need to know full path in tmp directory
163
-		foreach($links as $key => $link) {
164
-			if($link['app'] == Api\Link::VFS_APPNAME) {
171
+		foreach($links as $key => $link)
172
+		{
173
+			if($link['app'] == Api\Link::VFS_APPNAME)
174
+			{
165 175
 				if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir']))
166 176
 				{
167 177
 					$path = $GLOBALS['egw_info']['server']['temp_dir'] . '/' . $link['id'];
@@ -253,7 +263,10 @@  discard block
 block discarded – undo
253 263
 			$id .= "/$dest_file";
254 264
 		}
255 265
 
256
-		if(!is_array($files)) $files = array($files);
266
+		if(!is_array($files))
267
+		{
268
+			$files = array($files);
269
+		}
257 270
 		foreach($files as $target)
258 271
 		{
259 272
 			Api\Link::link_file($app, $id, $target);
@@ -340,7 +353,10 @@  discard block
 block discarded – undo
340 353
 				else
341 354
 				{
342 355
 					// Not enough information, leave it to the application
343
-					if(!is_array($value['to_id'])) $value['to_id'] = array();
356
+					if(!is_array($value['to_id']))
357
+					{
358
+						$value['to_id'] = array();
359
+					}
344 360
 					$value['to_id'][] = $link;
345 361
 				}
346 362
 			}
@@ -360,7 +376,10 @@  discard block
 block discarded – undo
360 376
 				}
361 377
 				foreach($files as $name => $attrs)
362 378
 				{
363
-					if(!is_array($value['to_id'])) $value['to_id'] = array();
379
+					if(!is_array($value['to_id']))
380
+					{
381
+						$value['to_id'] = array();
382
+					}
364 383
 					$value['to_id'][] = array(
365 384
 						'app'	=> Api\Link::VFS_APPNAME,
366 385
 						'id'	=> array(
@@ -372,7 +391,10 @@  discard block
 block discarded – undo
372 391
 				}
373 392
 			}
374 393
 			$valid =& self::get_array($validated, $form_name, true);
375
-			if (true) $valid = $value;
394
+			if (true)
395
+			{
396
+				$valid = $value;
397
+			}
376 398
 			//error_log($this);
377 399
 			//error_log("   " . array2string($valid));
378 400
 		}
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -157,7 +157,7 @@
 block discarded – undo
157 157
 	/**
158 158
 	 * Create links
159 159
 	 */
160
-	public static function ajax_link($app, $id, Array $links)
160
+	public static function ajax_link($app, $id, array $links)
161 161
 	{
162 162
 		// Files need to know full path in tmp directory
163 163
 		foreach($links as $key => $link) {
Please login to merge, or discard this patch.
api/src/Etemplate/Widget/File.php 4 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -238,10 +238,10 @@
 block discarded – undo
238 238
 	}
239 239
 
240 240
 	/**
241
-	* Delete a directory RECURSIVELY
242
-	* @param string $dir - directory path
243
-	* @link http://php.net/manual/en/function.rmdir.php
244
-	*/
241
+	 * Delete a directory RECURSIVELY
242
+	 * @param string $dir - directory path
243
+	 * @link http://php.net/manual/en/function.rmdir.php
244
+	 */
245 245
 	private static function rrmdir($dir)
246 246
 	{
247 247
 		if (is_dir($dir))
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -27,12 +27,12 @@  discard block
 block discarded – undo
27 27
 	 *
28 28
 	 * @param string $xml
29 29
 	 */
30
-	public function __construct($xml='')
30
+	public function __construct($xml = '')
31 31
 	{
32
-		if($xml) parent::__construct($xml);
32
+		if ($xml) parent::__construct($xml);
33 33
 
34 34
 		// Legacy multiple - id ends in []
35
-		if(substr($this->id,-2) == '[]')
35
+		if (substr($this->id, -2) == '[]')
36 36
 		{
37 37
 			$this->setElementAttribute($this->id, 'multiple', true);
38 38
 		}
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 		$response = Api\Json\Response::get();
53 53
 		$request_id = str_replace(' ', '+', rawurldecode($_REQUEST['request_id']));
54 54
 		$widget_id = $_REQUEST['widget_id'];
55
-		if(!self::$request = Etemplate\Request::read($request_id)) {
55
+		if (!self::$request = Etemplate\Request::read($request_id)) {
56 56
 			$response->error("Could not read session");
57 57
 			return;
58 58
 		}
@@ -70,20 +70,20 @@  discard block
 block discarded – undo
70 70
 		foreach ($_FILES as $field => &$files)
71 71
 		{
72 72
 			$widget = $template->getElementById($widget_id ? $widget_id : $field);
73
-			if($widget && $widget->attrs['mime']) {
73
+			if ($widget && $widget->attrs['mime']) {
74 74
 				$mime = $widget->attrs['mime'];
75 75
 			}
76 76
 
77 77
 			// Check for legacy [] in id to indicate multiple - it changes format
78
-			if(is_array($files['name'])) {
78
+			if (is_array($files['name'])) {
79 79
 				$file_list = array();
80
-				foreach($files as $f_field => $values)
80
+				foreach ($files as $f_field => $values)
81 81
 				{
82
-					foreach($values as $key => $f_value) {
82
+					foreach ($values as $key => $f_value) {
83 83
 						$file_list[$key][$f_field] = $f_value;
84 84
 					}
85 85
 				}
86
-				foreach($file_list as $file)
86
+				foreach ($file_list as $file)
87 87
 				{
88 88
 					self::process_uploaded_file($field, $file, $mime, $file_data);
89 89
 				}
@@ -99,13 +99,13 @@  discard block
 block discarded – undo
99 99
 		$response->data($file_data);
100 100
 
101 101
 		// Check for a callback, call it if there is one
102
-		foreach($_FILES as $field => $file)
102
+		foreach ($_FILES as $field => $file)
103 103
 		{
104
-			if(($element = $template->getElementById($field)))
104
+			if (($element = $template->getElementById($field)))
105 105
 			{
106 106
 				$callback = $element->attrs['callback'];
107
-				if(!$callback) $callback = $template->getElementAttribute($field, 'callback');
108
-				if($callback)
107
+				if (!$callback) $callback = $template->getElementAttribute($field, 'callback');
108
+				if ($callback)
109 109
 				{
110 110
 					ExecMethod($callback, $_FILES[$field]);
111 111
 				}
@@ -118,10 +118,10 @@  discard block
 block discarded – undo
118 118
 	 */
119 119
 	protected static function process_uploaded_file($field, Array &$file, $mime, Array &$file_data)
120 120
 	{
121
-		unset($field);	// not used
121
+		unset($field); // not used
122 122
 
123 123
 		// Chunks get mangled a little
124
-		if($file['name'] == 'blob')
124
+		if ($file['name'] == 'blob')
125 125
 		{
126 126
 			$file['name'] = $_POST['resumableFilename'];
127 127
 			$file['type'] = $_POST['resumableType'];
@@ -129,14 +129,14 @@  discard block
 block discarded – undo
129 129
 
130 130
 		if ($file['error'] == UPLOAD_ERR_OK && trim($file['name']) != '' && $file['size'] > 0 && is_uploaded_file($file['tmp_name'])) {
131 131
 			// Mime check
132
-			if($mime)
132
+			if ($mime)
133 133
 			{
134 134
 				$type = $file['type'];
135 135
 				$is_preg = $mime[0] == '/';
136
-				if (!$is_preg && strcasecmp($mime,$type) ||
137
-					$is_preg && !preg_match($mime,$type))
136
+				if (!$is_preg && strcasecmp($mime, $type) ||
137
+					$is_preg && !preg_match($mime, $type))
138 138
 				{
139
-					$file_data[$file['name']] = $file['name'].':'.lang('File is of wrong type (%1 != %2)!',$type,$mime);
139
+					$file_data[$file['name']] = $file['name'].':'.lang('File is of wrong type (%1 != %2)!', $type, $mime);
140 140
 					//error_log(__METHOD__.__LINE__.array2string($file_data[$file['name']]));
141 141
 					return false;
142 142
 				}
@@ -145,8 +145,8 @@  discard block
 block discarded – undo
145 145
 			// Resumable / chunked uploads
146 146
 			// init the destination file (format <filename.ext>.part<#chunk>
147 147
 			// the file is stored in a temporary directory
148
-			$temp_dir = $GLOBALS['egw_info']['server']['temp_dir'].'/'.str_replace('/','_',$_POST['resumableIdentifier']);
149
-			$dest_file = $temp_dir.'/'.str_replace('/','_',$_POST['resumableFilename']).'.part'.(int)$_POST['resumableChunkNumber'];
148
+			$temp_dir = $GLOBALS['egw_info']['server']['temp_dir'].'/'.str_replace('/', '_', $_POST['resumableIdentifier']);
149
+			$dest_file = $temp_dir.'/'.str_replace('/', '_', $_POST['resumableFilename']).'.part'.(int)$_POST['resumableChunkNumber'];
150 150
 
151 151
 			// create the temporary directory
152 152
 			if (!is_dir($temp_dir))
@@ -162,10 +162,10 @@  discard block
 block discarded – undo
162 162
 			else
163 163
 			{
164 164
 				// check if all the parts present, and create the final destination file
165
-				$new_file = self::createFileFromChunks($temp_dir, str_replace('/','_',$_POST['resumableFilename']),
165
+				$new_file = self::createFileFromChunks($temp_dir, str_replace('/', '_', $_POST['resumableFilename']),
166 166
 						$_POST['resumableChunkSize'], $_POST['resumableTotalSize']);
167 167
 			}
168
-			if( $new_file) {
168
+			if ($new_file) {
169 169
 				$file['tmp_name'] = $new_file;
170 170
 
171 171
 				// Data to send back to client
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 
195 195
 		// count all the parts of this file
196 196
 		$total_files = 0;
197
-		foreach(scandir($temp_dir) as $file) {
197
+		foreach (scandir($temp_dir) as $file) {
198 198
 			if (stripos($file, $fileName) !== false) {
199 199
 				$total_files++;
200 200
 			}
@@ -202,10 +202,10 @@  discard block
 block discarded – undo
202 202
 
203 203
 		// check that all the parts are present
204 204
 		// the size of the last part is between chunkSize and 2*$chunkSize
205
-		if ($total_files * $chunkSize >=  ($totalSize - $chunkSize + 1)) {
205
+		if ($total_files * $chunkSize >= ($totalSize - $chunkSize + 1)) {
206 206
 			if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir']))
207 207
 			{
208
-				$new_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'egw_');
208
+				$new_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'], 'egw_');
209 209
 			}
210 210
 			else
211 211
 			{
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 
215 215
 			// create the final destination file
216 216
 			if (($fp = fopen($new_file, 'w')) !== false) {
217
-				for ($i=1; $i<=$total_files; $i++) {
217
+				for ($i = 1; $i <= $total_files; $i++) {
218 218
 					fwrite($fp, file_get_contents($temp_dir.'/'.$fileName.'.part'.$i));
219 219
 				}
220 220
 				fclose($fp);
@@ -250,13 +250,13 @@  discard block
 block discarded – undo
250 250
 			{
251 251
 				if ($object != "." && $object != "..")
252 252
 				{
253
-					if (filetype($dir . "/" . $object) == "dir")
253
+					if (filetype($dir."/".$object) == "dir")
254 254
 					{
255
-						self::rrmdir($dir . "/" . $object);
255
+						self::rrmdir($dir."/".$object);
256 256
 					}
257 257
 					else
258 258
 					{
259
-						unlink($dir . "/" . $object);
259
+						unlink($dir."/".$object);
260 260
 					}
261 261
 				}
262 262
 			}
@@ -273,23 +273,23 @@  discard block
 block discarded – undo
273 273
 	 * @param array $content
274 274
 	 * @param array &$validated=array() validated content
275 275
 	 */
276
-	public function validate($cname, array $expand, array $content, &$validated=array())
276
+	public function validate($cname, array $expand, array $content, &$validated = array())
277 277
 	{
278 278
 		$form_name = self::form_name($cname, $this->id, $expand);
279 279
 
280 280
 		if (!$this->is_readonly($cname, $form_name))
281 281
 		{
282 282
 			$value = $value_in = self::get_array($content, $form_name);
283
-			$valid =& self::get_array($validated, $form_name, true);
283
+			$valid = & self::get_array($validated, $form_name, true);
284 284
 
285
-			if(!is_array($value)) $value = array();
285
+			if (!is_array($value)) $value = array();
286 286
 
287 287
 			// Incoming values indexed by temp name
288
-			if($value[0]) $value = $value[0];
288
+			if ($value[0]) $value = $value[0];
289 289
 
290
-			foreach($value as $tmp => $file)
290
+			foreach ($value as $tmp => $file)
291 291
 			{
292
-				if(!$file) continue;
292
+				if (!$file) continue;
293 293
 				if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir']))
294 294
 				{
295 295
 					$path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.$tmp;
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 				);
310 310
 			}
311 311
 
312
-			if($valid && !$this->attrs['multiple']) $valid = $valid[0];
312
+			if ($valid && !$this->attrs['multiple']) $valid = $valid[0];
313 313
 		}
314 314
 	}
315 315
 }
Please login to merge, or discard this patch.
Braces   +58 added lines, -22 removed lines patch added patch discarded remove patch
@@ -29,7 +29,10 @@  discard block
 block discarded – undo
29 29
 	 */
30 30
 	public function __construct($xml='')
31 31
 	{
32
-		if($xml) parent::__construct($xml);
32
+		if($xml)
33
+		{
34
+			parent::__construct($xml);
35
+		}
33 36
 
34 37
 		// Legacy multiple - id ends in []
35 38
 		if(substr($this->id,-2) == '[]')
@@ -48,11 +51,13 @@  discard block
 block discarded – undo
48 51
 	 *
49 52
 	 * @note Currently, no attempt is made to clean up files automatically.
50 53
 	 */
51
-	public static function ajax_upload() {
54
+	public static function ajax_upload()
55
+	{
52 56
 		$response = Api\Json\Response::get();
53 57
 		$request_id = str_replace(' ', '+', rawurldecode($_REQUEST['request_id']));
54 58
 		$widget_id = $_REQUEST['widget_id'];
55
-		if(!self::$request = Etemplate\Request::read($request_id)) {
59
+		if(!self::$request = Etemplate\Request::read($request_id))
60
+		{
56 61
 			$response->error("Could not read session");
57 62
 			return;
58 63
 		}
@@ -70,16 +75,19 @@  discard block
 block discarded – undo
70 75
 		foreach ($_FILES as $field => &$files)
71 76
 		{
72 77
 			$widget = $template->getElementById($widget_id ? $widget_id : $field);
73
-			if($widget && $widget->attrs['mime']) {
78
+			if($widget && $widget->attrs['mime'])
79
+			{
74 80
 				$mime = $widget->attrs['mime'];
75 81
 			}
76 82
 
77 83
 			// Check for legacy [] in id to indicate multiple - it changes format
78
-			if(is_array($files['name'])) {
84
+			if(is_array($files['name']))
85
+			{
79 86
 				$file_list = array();
80 87
 				foreach($files as $f_field => $values)
81 88
 				{
82
-					foreach($values as $key => $f_value) {
89
+					foreach($values as $key => $f_value)
90
+					{
83 91
 						$file_list[$key][$f_field] = $f_value;
84 92
 					}
85 93
 				}
@@ -104,7 +112,10 @@  discard block
 block discarded – undo
104 112
 			if(($element = $template->getElementById($field)))
105 113
 			{
106 114
 				$callback = $element->attrs['callback'];
107
-				if(!$callback) $callback = $template->getElementAttribute($field, 'callback');
115
+				if(!$callback)
116
+				{
117
+					$callback = $template->getElementAttribute($field, 'callback');
118
+				}
108 119
 				if($callback)
109 120
 				{
110 121
 					ExecMethod($callback, $_FILES[$field]);
@@ -127,7 +138,8 @@  discard block
 block discarded – undo
127 138
 			$file['type'] = $_POST['resumableType'];
128 139
 		}
129 140
 
130
-		if ($file['error'] == UPLOAD_ERR_OK && trim($file['name']) != '' && $file['size'] > 0 && is_uploaded_file($file['tmp_name'])) {
141
+		if ($file['error'] == UPLOAD_ERR_OK && trim($file['name']) != '' && $file['size'] > 0 && is_uploaded_file($file['tmp_name']))
142
+		{
131 143
 			// Mime check
132 144
 			if($mime)
133 145
 			{
@@ -165,7 +177,8 @@  discard block
 block discarded – undo
165 177
 				$new_file = self::createFileFromChunks($temp_dir, str_replace('/','_',$_POST['resumableFilename']),
166 178
 						$_POST['resumableChunkSize'], $_POST['resumableTotalSize']);
167 179
 			}
168
-			if( $new_file) {
180
+			if( $new_file)
181
+			{
169 182
 				$file['tmp_name'] = $new_file;
170 183
 
171 184
 				// Data to send back to client
@@ -190,19 +203,23 @@  discard block
 block discarded – undo
190 203
 	 * @param string $chunkSize - each chunk size (in bytes)
191 204
 	 * @param string $totalSize - original file size (in bytes)
192 205
 	 */
193
-	private static function createFileFromChunks($temp_dir, $fileName, $chunkSize, $totalSize) {
206
+	private static function createFileFromChunks($temp_dir, $fileName, $chunkSize, $totalSize)
207
+	{
194 208
 
195 209
 		// count all the parts of this file
196 210
 		$total_files = 0;
197
-		foreach(scandir($temp_dir) as $file) {
198
-			if (stripos($file, $fileName) !== false) {
211
+		foreach(scandir($temp_dir) as $file)
212
+		{
213
+			if (stripos($file, $fileName) !== false)
214
+			{
199 215
 				$total_files++;
200 216
 			}
201 217
 		}
202 218
 
203 219
 		// check that all the parts are present
204 220
 		// the size of the last part is between chunkSize and 2*$chunkSize
205
-		if ($total_files * $chunkSize >=  ($totalSize - $chunkSize + 1)) {
221
+		if ($total_files * $chunkSize >=  ($totalSize - $chunkSize + 1))
222
+		{
206 223
 			if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir']))
207 224
 			{
208 225
 				$new_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'egw_');
@@ -213,21 +230,28 @@  discard block
 block discarded – undo
213 230
 			}
214 231
 
215 232
 			// create the final destination file
216
-			if (($fp = fopen($new_file, 'w')) !== false) {
217
-				for ($i=1; $i<=$total_files; $i++) {
233
+			if (($fp = fopen($new_file, 'w')) !== false)
234
+			{
235
+				for ($i=1; $i<=$total_files; $i++)
236
+				{
218 237
 					fwrite($fp, file_get_contents($temp_dir.'/'.$fileName.'.part'.$i));
219 238
 				}
220 239
 				fclose($fp);
221
-			} else {
240
+			}
241
+			else
242
+			{
222 243
 				_log('cannot create the destination file');
223 244
 				return false;
224 245
 			}
225 246
 
226 247
 			// rename the temporary directory (to avoid access from other
227 248
 			// concurrent chunks uploads) and than delete it
228
-			if (rename($temp_dir, $temp_dir.'_UNUSED')) {
249
+			if (rename($temp_dir, $temp_dir.'_UNUSED'))
250
+			{
229 251
 				self::rrmdir($temp_dir.'_UNUSED');
230
-			} else {
252
+			}
253
+			else
254
+			{
231 255
 				self::rrmdir($temp_dir);
232 256
 			}
233 257
 
@@ -282,14 +306,23 @@  discard block
 block discarded – undo
282 306
 			$value = $value_in = self::get_array($content, $form_name);
283 307
 			$valid =& self::get_array($validated, $form_name, true);
284 308
 
285
-			if(!is_array($value)) $value = array();
309
+			if(!is_array($value))
310
+			{
311
+				$value = array();
312
+			}
286 313
 
287 314
 			// Incoming values indexed by temp name
288
-			if($value[0]) $value = $value[0];
315
+			if($value[0])
316
+			{
317
+				$value = $value[0];
318
+			}
289 319
 
290 320
 			foreach($value as $tmp => $file)
291 321
 			{
292
-				if(!$file) continue;
322
+				if(!$file)
323
+				{
324
+					continue;
325
+				}
293 326
 				if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir']))
294 327
 				{
295 328
 					$path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.$tmp;
@@ -309,7 +342,10 @@  discard block
 block discarded – undo
309 342
 				);
310 343
 			}
311 344
 
312
-			if($valid && !$this->attrs['multiple']) $valid = $valid[0];
345
+			if($valid && !$this->attrs['multiple'])
346
+			{
347
+				$valid = $valid[0];
348
+			}
313 349
 		}
314 350
 	}
315 351
 }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -116,7 +116,7 @@
 block discarded – undo
116 116
 	/**
117 117
 	 * Process one uploaded file.  There should only be one per request...
118 118
 	 */
119
-	protected static function process_uploaded_file($field, Array &$file, $mime, Array &$file_data)
119
+	protected static function process_uploaded_file($field, array &$file, $mime, array &$file_data)
120 120
 	{
121 121
 		unset($field);	// not used
122 122
 
Please login to merge, or discard this patch.
api/src/Etemplate/Widget/Button.php 3 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	 * @param array &$validated=array() validated content
45 45
 	 * @return boolean true if no validation error, false otherwise
46 46
 	 */
47
-	public function validate($cname, array $expand, array $content, &$validated=array())
47
+	public function validate($cname, array $expand, array $content, &$validated = array())
48 48
 	{
49 49
 		$form_name = self::form_name($cname, $this->id, $expand);
50 50
 		//error_log(__METHOD__."('$cname', ".array2string($expand).", ...) $this: get_array(\$content, '$form_name')=".array2string(self::get_array($content, $form_name)));
@@ -53,18 +53,18 @@  discard block
 block discarded – undo
53 53
 		{
54 54
 			$value = self::get_array($content, $form_name);
55 55
 
56
-			if(
56
+			if (
57 57
 				// Handle case of not existing $row_cont[id], eg: create[]
58 58
 				is_array($value) && count($value) == 1 ||
59 59
 				// check === true, as get_array() ignores a "[]" postfix and returns array() eg. for a not existing $row_cont[id] in "delete[$row_cont[id]]"
60 60
 				$value == true
61 61
 			)
62 62
 			{
63
-				$valid =& self::get_array($validated, $form_name, true);
63
+				$valid = & self::get_array($validated, $form_name, true);
64 64
 				if (true) $valid = is_array($value) ? $value : 'pressed';
65 65
 
66 66
 				// recorded pressed button globally, was in the template object before, put now as static on this object
67
-				if ($this->type == 'cancel' || $form_name == 'cancel' || substr($form_name,-10) == '[cancel]')
67
+				if ($this->type == 'cancel' || $form_name == 'cancel' || substr($form_name, -10) == '[cancel]')
68 68
 				{
69 69
 					self::$canceled = true;
70 70
 				}
@@ -76,4 +76,4 @@  discard block
 block discarded – undo
76 76
 		}
77 77
 	}
78 78
 }
79
-Etemplate\Widget::registerWidget(__NAMESPACE__.'\\Button', array('button','buttononly'));
79
+Etemplate\Widget::registerWidget(__NAMESPACE__.'\\Button', array('button', 'buttononly'));
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@
 block discarded – undo
42 42
 	 * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont'
43 43
 	 * @param array $content
44 44
 	 * @param array &$validated=array() validated content
45
-	 * @return boolean true if no validation error, false otherwise
45
+	 * @return boolean|null true if no validation error, false otherwise
46 46
 	 */
47 47
 	public function validate($cname, array $expand, array $content, &$validated=array())
48 48
 	{
Please login to merge, or discard this patch.
Braces   +5 added lines, -3 removed lines patch added patch discarded remove patch
@@ -58,10 +58,12 @@
 block discarded – undo
58 58
 				is_array($value) && count($value) == 1 ||
59 59
 				// check === true, as get_array() ignores a "[]" postfix and returns array() eg. for a not existing $row_cont[id] in "delete[$row_cont[id]]"
60 60
 				$value == true
61
-			)
62
-			{
61
+			) {
63 62
 				$valid =& self::get_array($validated, $form_name, true);
64
-				if (true) $valid = is_array($value) ? $value : 'pressed';
63
+				if (true)
64
+				{
65
+					$valid = is_array($value) ? $value : 'pressed';
66
+				}
65 67
 
66 68
 				// recorded pressed button globally, was in the template object before, put now as static on this object
67 69
 				if ($this->type == 'cancel' || $form_name == 'cancel' || substr($form_name,-10) == '[cancel]')
Please login to merge, or discard this patch.
api/src/Etemplate/Widget/Grid.php 2 patches
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -65,11 +65,11 @@  discard block
 block discarded – undo
65 65
 	 * @param boolean $respect_disabled =false false (default): ignore disabled, true: method is NOT run for disabled widgets AND their children
66 66
 	 * @param array $columns_disabled=array() disabled columns
67 67
 	 */
68
-	public function run($method_name, $params=array(''), $respect_disabled=false, &$columns_disabled=array())
68
+	public function run($method_name, $params = array(''), $respect_disabled = false, &$columns_disabled = array())
69 69
 	{
70 70
 		// maintain $expand array name-expansion
71
-		$cname =& $params[0];
72
-		$expand =& $params[1];
71
+		$cname = & $params[0];
72
+		$expand = & $params[1];
73 73
 		$old_cname = $params[0];
74 74
 		$old_expand = $params[1];
75 75
 
@@ -85,13 +85,13 @@  discard block
 block discarded – undo
85 85
 			//error_log(__METHOD__."('$method_name', ".array2string($params).', '.array2string($respect_disabled).") $this disabled='{$this->attrs['disabled']}'=".array2string($disabled).": NOT running");
86 86
 			$params[0] = $old_cname;
87 87
 			$params[1] = $old_expand;
88
-			return false;	// return
88
+			return false; // return
89 89
 		}
90 90
 
91 91
 		if ($this->id) $cname = self::form_name($cname, $this->id, $expand);
92 92
 		if ($expand['cname'] !== $cname && $cname)
93 93
 		{
94
-			$expand['cont'] =& self::get_array(self::$request->content, $cname);
94
+			$expand['cont'] = & self::get_array(self::$request->content, $cname);
95 95
 			$expand['cname'] = $cname;
96 96
 		}
97 97
 
@@ -101,10 +101,10 @@  discard block
 block discarded – undo
101 101
 		}
102 102
 		//foreach($this->children as $n => $child)
103 103
 		$repeat_child = null;
104
-		for($n = 0; ; ++$n)
104
+		for ($n = 0; ; ++$n)
105 105
 		{
106 106
 			// maintain $expand array name-expansion
107
-			switch($this->type)
107
+			switch ($this->type)
108 108
 			{
109 109
 				case 'rows':
110 110
 					$expand['row'] = $n;
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 			if (isset($this->children[$n]))
117 117
 			{
118 118
 				$child = $this->children[$n];
119
-				if($this->type == 'rows' || $this->type == 'columns')
119
+				if ($this->type == 'rows' || $this->type == 'columns')
120 120
 				{
121 121
 					/*
122 122
 					 * We store a clone of the repeated child, because at the end
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 				if (in_array($n, $columns_disabled))
144 144
 				{
145 145
 					//error_log(__METHOD__."('$method_name', ".array2string($params).', '.array2string($respect_disabled).") $this column $n is disabled: NOT running");
146
-					continue;	// do NOT run $method_name on disabled columns
146
+					continue; // do NOT run $method_name on disabled columns
147 147
 				}
148 148
 			}
149 149
 			//error_log('Running ' . $method_name . ' on child ' . $n . '(' . $child . ') ['.$expand['row'] . ','.$expand['c'] . ']');
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 
152 152
 			if ($this->type == 'columns' && $disabled)
153 153
 			{
154
-				$columns_disabled[] = $n;	// mark column as disabled
154
+				$columns_disabled[] = $n; // mark column as disabled
155 155
 			}
156 156
 		}
157 157
 		if ($this->type == 'grid')
@@ -175,34 +175,34 @@  discard block
 block discarded – undo
175 175
 	private function need_autorepeat($cname, array $expand)
176 176
 	{
177 177
 		// check id's of children
178
-		foreach($this->children as $n => $direct_child)
178
+		foreach ($this->children as $n => $direct_child)
179 179
 		{
180
-			foreach(array_merge(array($direct_child), $n ? array() : $direct_child->children) as $child)
180
+			foreach (array_merge(array($direct_child), $n ? array() : $direct_child->children) as $child)
181 181
 			{
182 182
 				$pat = $child->id;
183
-				while(($patstr = strstr($pat, '$')))
183
+				while (($patstr = strstr($pat, '$')))
184 184
 				{
185
-					$pat = substr($patstr,$patstr[1] == '{' ? 2 : 1);
185
+					$pat = substr($patstr, $patstr[1] == '{' ? 2 : 1);
186 186
 
187 187
 					switch ($this->type)
188 188
 					{
189 189
 						case 'column':
190
-							$Ok = $pat[0] == 'c' && !(substr($pat,0,4) == 'cont' || substr($pat,0,2) == 'c_' ||
191
-								substr($pat,0,4) == 'col_');
190
+							$Ok = $pat[0] == 'c' && !(substr($pat, 0, 4) == 'cont' || substr($pat, 0, 2) == 'c_' ||
191
+								substr($pat, 0, 4) == 'col_');
192 192
 							break;
193 193
 						case 'row':
194
-							$Ok = $pat[0] == 'r' && !(substr($pat,0,2) == 'r_' ||
195
-								substr($pat,0,4) == 'row_' && substr($pat,0,8) != 'row_cont');
194
+							$Ok = $pat[0] == 'r' && !(substr($pat, 0, 2) == 'r_' ||
195
+								substr($pat, 0, 4) == 'row_' && substr($pat, 0, 8) != 'row_cont');
196 196
 							//error_log(__METHOD__."() pat='$pat' --> Ok=".array2string($Ok));
197 197
 							break;
198 198
 						default:
199 199
 							return false;
200 200
 					}
201
-					if ($Ok && ($fname=self::form_name($cname, $child->id, $expand)) &&
201
+					if ($Ok && ($fname = self::form_name($cname, $child->id, $expand)) &&
202 202
 						// need to break if fname ends in [] as get_array() will ignore it and returns whole array
203 203
 						// for an id like "run[$row_cont[appname]]"
204 204
 						substr($fname, -2) != '[]' &&
205
-						($value = self::get_array(self::$request->content,$fname)) !== null)	// null = not found (can be false!)
205
+						($value = self::get_array(self::$request->content, $fname)) !== null)	// null = not found (can be false!)
206 206
 					{
207 207
 						//error_log(__METHOD__."('$cname', ) $this autorepeating row $expand[row] because of $child->id = '$fname' is ".array2string($value));
208 208
 						unset($value);
Please login to merge, or discard this patch.
Braces   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -88,7 +88,10 @@  discard block
 block discarded – undo
88 88
 			return false;	// return
89 89
 		}
90 90
 
91
-		if ($this->id) $cname = self::form_name($cname, $this->id, $expand);
91
+		if ($this->id)
92
+		{
93
+			$cname = self::form_name($cname, $this->id, $expand);
94
+		}
92 95
 		if ($expand['cname'] !== $cname && $cname)
93 96
 		{
94 97
 			$expand['cont'] =& self::get_array(self::$request->content, $cname);
@@ -202,10 +205,13 @@  discard block
 block discarded – undo
202 205
 						// need to break if fname ends in [] as get_array() will ignore it and returns whole array
203 206
 						// for an id like "run[$row_cont[appname]]"
204 207
 						substr($fname, -2) != '[]' &&
205
-						($value = self::get_array(self::$request->content,$fname)) !== null)	// null = not found (can be false!)
208
+						($value = self::get_array(self::$request->content,$fname)) !== null)
209
+					{
210
+						// null = not found (can be false!)
206 211
 					{
207 212
 						//error_log(__METHOD__."('$cname', ) $this autorepeating row $expand[row] because of $child->id = '$fname' is ".array2string($value));
208 213
 						unset($value);
214
+					}
209 215
 						return true;
210 216
 					}
211 217
 				}
Please login to merge, or discard this patch.
api/src/Etemplate/Widget/HtmlArea.php 3 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -38,16 +38,16 @@  discard block
 block discarded – undo
38 38
 		$form_name = self::form_name($cname, $this->id);
39 39
 
40 40
 		$config = Api\Html\CkEditorConfig::get_ckeditor_config_array($this->attrs['mode'], $this->attrs['height'],
41
-			$this->attrs['expand_toolbar'],$this->attrs['base_href']
41
+			$this->attrs['expand_toolbar'], $this->attrs['base_href']
42 42
 		);
43 43
 		// User preferences
44 44
 		$font = $GLOBALS['egw_info']['user']['preferences']['common']['rte_font'];
45 45
 		$font_size = Api\Html\CkEditorConfig::font_size_from_prefs();
46 46
 		$font_span = '<span style="width: 100%; display: inline; '.
47
-			($font?'font-family:'.$font.'; ':'').($font_size?'font-size:'.$font_size.'; ':'').
47
+			($font ? 'font-family:'.$font.'; ' : '').($font_size ? 'font-size:'.$font_size.'; ' : '').
48 48
 			'">&#8203;</span>';
49 49
 		if (empty($font) && empty($font_size)) $font_span = '';
50
-		if($font_span)
50
+		if ($font_span)
51 51
 		{
52 52
 			$config['preference_style'] = $font_span;
53 53
 		}
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	 * @param array &$validated=array() validated content
66 66
 	 * @return boolean true if no validation error, false otherwise
67 67
 	 */
68
-	public function validate($cname, array $expand, array $content, &$validated=array())
68
+	public function validate($cname, array $expand, array $content, &$validated = array())
69 69
 	{
70 70
 		$form_name = self::form_name($cname, $this->id, $expand);
71 71
 
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 			{
78 78
 				$value = Api\Html\HtmLawed::purify($value, $this->attrs['validation_rules']);
79 79
 			}
80
-			$valid =& self::get_array($validated, $form_name, true);
80
+			$valid = & self::get_array($validated, $form_name, true);
81 81
 			if (true) $valid = $value;
82 82
 		}
83 83
 	}
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@
 block discarded – undo
42 42
 	 * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont'
43 43
 	 * @param array $content
44 44
 	 * @param array &$validated=array() validated content
45
-	 * @return boolean true if no validation error, false otherwise
45
+	 * @return boolean|null true if no validation error, false otherwise
46 46
 	 */
47 47
 	public function validate($cname, array $expand, array $content, &$validated=array())
48 48
 	{
Please login to merge, or discard this patch.
Braces   +8 added lines, -2 removed lines patch added patch discarded remove patch
@@ -46,7 +46,10 @@  discard block
 block discarded – undo
46 46
 		$font_span = '<span style="width: 100%; display: inline; '.
47 47
 			($font?'font-family:'.$font.'; ':'').($font_size?'font-size:'.$font_size.'; ':'').
48 48
 			'">&#8203;</span>';
49
-		if (empty($font) && empty($font_size)) $font_span = '';
49
+		if (empty($font) && empty($font_size))
50
+		{
51
+			$font_span = '';
52
+		}
50 53
 		if($font_span)
51 54
 		{
52 55
 			$config['preference_style'] = $font_span;
@@ -78,7 +81,10 @@  discard block
 block discarded – undo
78 81
 				$value = Api\Html\HtmLawed::purify($value, $this->attrs['validation_rules']);
79 82
 			}
80 83
 			$valid =& self::get_array($validated, $form_name, true);
81
-			if (true) $valid = $value;
84
+			if (true)
85
+			{
86
+				$valid = $value;
87
+			}
82 88
 		}
83 89
 	}
84 90
 }
Please login to merge, or discard this patch.