Completed
Push — 14.2 ( 8c75f3...7aeda4 )
by Ralf
108:06 queued 84:21
created
etemplate/inc/class.tab_widget.inc.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,6 @@
 block discarded – undo
55 55
 		 *
56 56
 		 * This function is called before the extension gets rendered
57 57
 		 *
58
-		 * @param string $name form-name of the control
59 58
 		 * @param mixed &$value value / existing content, can be modified
60 59
 		 * @param array &$cell array with the widget, can be modified for ui-independent widgets
61 60
 		 * @param array &$readonlys names of widgets as key, to be made readonly
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -33,13 +33,13 @@  discard block
 block discarded – undo
33 33
 		var $public_functions = array(
34 34
 			'pre_process' => True,
35 35
 			'post_process' => True,
36
-			'noReadonlysALL' => true,	// mark extension as not to set readonly for $readonlys['__ALL__']
36
+			'noReadonlysALL' => true, // mark extension as not to set readonly for $readonlys['__ALL__']
37 37
 		);
38 38
 		/**
39 39
 		 * availible extensions and there names for the editor
40 40
 		 * @var string
41 41
 		 */
42
-		var $human_name = 'Tabs';	// this is the name for the editor
42
+		var $human_name = 'Tabs'; // this is the name for the editor
43 43
 
44 44
 		/**
45 45
 		 * Constructor of the extension
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 		 * @param etemplate &$tmpl reference to the template we belong too
64 64
 		 * @return boolean true if extra label is allowed, false otherwise
65 65
 		 */
66
-		function pre_process($form_name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl)
66
+		function pre_process($form_name, &$value, &$cell, &$readonlys, &$extension_data, &$tmpl)
67 67
 		{
68 68
 			//echo "<p>tab_widget::pre_process('$form_name',".array2string($value).','.array2string($readonlys).','.array2string($extension_data).")</p>\n";
69 69
 
@@ -71,38 +71,38 @@  discard block
 block discarded – undo
71 71
 			{
72 72
 				$dom_enabled = true;
73 73
 			}
74
-			if (strpos($cell_name=$tab_names=$cell['name'],'=') !== false)
74
+			if (strpos($cell_name = $tab_names = $cell['name'], '=') !== false)
75 75
 			{
76
-				list($cell_name,$tab_names) = explode('=',$cell['name']);
76
+				list($cell_name, $tab_names) = explode('=', $cell['name']);
77 77
 				$cell['name'] = $cell_name;
78 78
 			}
79 79
 			$labels = $helps = $names = $templates = $ids = array();
80 80
 			if ($cell['tabs'])	// set via etemplate::setElementAttribute()
81 81
 			{
82
-				foreach($cell['tabs'] as $tab)
82
+				foreach ($cell['tabs'] as $tab)
83 83
 				{
84 84
 					$labels[] = $tab['label'];
85 85
 					$helps[] = $tab['help'];
86 86
 					$names[] = $tab['id'] ? $tab['id'] : $tab['template'];
87
-					if ($tab['template']) $templates[count($names)-1] = $tab['template'];
88
-					if ($tab['id']) $ids[count($names)-1] = $tab['id'];
87
+					if ($tab['template']) $templates[count($names) - 1] = $tab['template'];
88
+					if ($tab['id']) $ids[count($names) - 1] = $tab['id'];
89 89
 				}
90 90
 			}
91 91
 			else
92 92
 			{
93
-				$labels = explode('|',$cell['label']);
94
-				$helps = explode('|',$cell['help']);
95
-				$names = explode('|',$tab_names);
93
+				$labels = explode('|', $cell['label']);
94
+				$helps = explode('|', $cell['help']);
95
+				$names = explode('|', $tab_names);
96 96
 			}
97 97
 
98 98
 			$short_names = array();
99
-			foreach($names as $name)
99
+			foreach ($names as $name)
100 100
 			{
101 101
 				$nparts = explode('.', $name);
102 102
 				$short_names[] = array_pop($nparts);
103 103
 			}
104 104
 			// disable tab mentioned in readonlys
105
-			foreach(is_array($readonlys) ? $readonlys : array($readonlys => true) as $name => $disable)
105
+			foreach (is_array($readonlys) ? $readonlys : array($readonlys => true) as $name => $disable)
106 106
 			{
107 107
 				if ($name && $disable && (($key = array_search($name, $names)) !== false ||
108 108
 					($key = array_search($name, $short_names)) !== false))
@@ -125,34 +125,34 @@  discard block
 block discarded – undo
125 125
 			$tab_widget = new etemplate('etemplate.tab_widget');
126 126
 			$tab_widget->no_onclick = true;
127 127
 
128
-			if ($value && strpos($value,'.') === false)
128
+			if ($value && strpos($value, '.') === false)
129 129
 			{
130
-				$value = $tmpl->name . '.' . $value;
130
+				$value = $tmpl->name.'.'.$value;
131 131
 			}
132
-			foreach($names as $k => $name)
132
+			foreach ($names as $k => $name)
133 133
 			{
134
-				if (strpos($name,'.') === false)
134
+				if (strpos($name, '.') === false)
135 135
 				{
136
-					$name = $names[$k] = $tmpl->name . '.' . $name;
136
+					$name = $names[$k] = $tmpl->name.'.'.$name;
137 137
 				}
138 138
 				if ($value == $name)
139 139
 				{
140 140
 					$selected_tab = $name;
141 141
 				}
142 142
 			}
143
-			$all_names = implode('|',$names);
143
+			$all_names = implode('|', $names);
144 144
 
145 145
 			if (empty($selected_tab))
146 146
 			{
147 147
 				$value = $selected_tab = $names[0];
148 148
 			}
149
-			$extension_data = $value;	// remember the active tab in the extension_data
149
+			$extension_data = $value; // remember the active tab in the extension_data
150 150
 
151
-			foreach($names as $k => $name)
151
+			foreach ($names as $k => $name)
152 152
 			{
153
-				if (strpos($name,'.') === false)
153
+				if (strpos($name, '.') === false)
154 154
 				{
155
-					$name = $names[$k] = $tmpl->name . '.' . $name;
155
+					$name = $names[$k] = $tmpl->name.'.'.$name;
156 156
 				}
157 157
 				$tcell = boetemplate::empty_cell();
158 158
 				if ($value == $name)
@@ -177,44 +177,44 @@  discard block
 block discarded – undo
177 177
 				$tcell['label'] = '<div>'.lang($labels[$k]).'</div>';
178 178
 				$tcell['help'] = $helps[$k];
179 179
 
180
-				$tab_widget->set_cell_attribute('tabs',1+$k,$tcell);
180
+				$tab_widget->set_cell_attribute('tabs', 1 + $k, $tcell);
181 181
 			}
182
-			$tab_widget->set_cell_attribute('tabs','type','hbox');
183
-			$tab_widget->set_cell_attribute('tabs','size',count($names));
184
-			$tab_widget->set_cell_attribute('tabs','name','');
182
+			$tab_widget->set_cell_attribute('tabs', 'type', 'hbox');
183
+			$tab_widget->set_cell_attribute('tabs', 'size', count($names));
184
+			$tab_widget->set_cell_attribute('tabs', 'name', '');
185 185
 
186 186
 			if ($dom_enabled)
187 187
 			{
188
-				foreach($names as $n => $name)
188
+				foreach ($names as $n => $name)
189 189
 				{
190
-					$bcell = boetemplate::empty_cell('template',$name);
191
-					$bcell['obj'] = new etemplate(empty($templates[$n]) ? $name : $templates[$n],$tmpl->as_array());
190
+					$bcell = boetemplate::empty_cell('template', $name);
191
+					$bcell['obj'] = new etemplate(empty($templates[$n]) ? $name : $templates[$n], $tmpl->as_array());
192 192
 					// hack to set id / content attribute on first grid, as it's not supported on template itself
193 193
 					if (!empty($ids[$n]) && $bcell['obj']->children[0]['type'] == 'grid')
194 194
 					{
195 195
 						$bcell['obj']->children[0]['name'] = $ids[$n];
196 196
 					}
197
-					$tab_widget->set_cell_attribute('body',$n+1,$bcell);
197
+					$tab_widget->set_cell_attribute('body', $n + 1, $bcell);
198 198
 				}
199
-				$tab_widget->set_cell_attribute('body','type','deck');
200
-				$tab_widget->set_cell_attribute('body','size',count($names));
201
-				$tab_widget->set_cell_attribute('body','span',',tab_body');
202
-				$tab_widget->set_cell_attribute('body','name',$cell_name);
199
+				$tab_widget->set_cell_attribute('body', 'type', 'deck');
200
+				$tab_widget->set_cell_attribute('body', 'size', count($names));
201
+				$tab_widget->set_cell_attribute('body', 'span', ',tab_body');
202
+				$tab_widget->set_cell_attribute('body', 'name', $cell_name);
203 203
 			}
204 204
 			else
205 205
 			{
206
-				$stab = new etemplate($selected_tab,$tmpl->as_array());
207
-				$tab_widget->set_cell_attribute('body','type','template');
208
-				$tab_widget->set_cell_attribute('body','size','');	// the deck has a '1' there
209
-				$tab_widget->set_cell_attribute('body','obj',$stab);
206
+				$stab = new etemplate($selected_tab, $tmpl->as_array());
207
+				$tab_widget->set_cell_attribute('body', 'type', 'template');
208
+				$tab_widget->set_cell_attribute('body', 'size', ''); // the deck has a '1' there
209
+				$tab_widget->set_cell_attribute('body', 'obj', $stab);
210 210
 			}
211
-			$tab_widget->set_cell_attribute('body','name',$selected_tab);
211
+			$tab_widget->set_cell_attribute('body', 'name', $selected_tab);
212 212
 
213 213
 			$cell['type'] = 'template';
214 214
 			$cell['obj'] = &$tab_widget;
215 215
 			$cell['label'] = $cell['help'] = '';
216 216
 
217
-			return False;	// NO extra Label
217
+			return False; // NO extra Label
218 218
 		}
219 219
 
220 220
 		/**
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 		 * @param mixed &value_in the posted values (already striped of magic-quotes)
235 235
 		 * @return boolean true if $value has valid content, on false no content will be returned!
236 236
 		 */
237
-		function post_process($name,&$value,&$extension_data,&$loop,&$tmpl,$value_in)
237
+		function post_process($name, &$value, &$extension_data, &$loop, &$tmpl, $value_in)
238 238
 		{
239 239
 			//echo "<p>tab_widget::post_process($name): value_in = "; _debug_array($value_in);
240 240
 
Please login to merge, or discard this patch.
Braces   +16 added lines, -4 removed lines patch added patch discarded remove patch
@@ -67,25 +67,37 @@
 block discarded – undo
67 67
 		{
68 68
 			//echo "<p>tab_widget::pre_process('$form_name',".array2string($value).','.array2string($readonlys).','.array2string($extension_data).")</p>\n";
69 69
 
70
-			if (!$cell['onchange'])	// onchange allows to use the old behavior (submit for each new tab)
70
+			if (!$cell['onchange'])
71
+			{
72
+				// onchange allows to use the old behavior (submit for each new tab)
71 73
 			{
72 74
 				$dom_enabled = true;
73 75
 			}
76
+			}
74 77
 			if (strpos($cell_name=$tab_names=$cell['name'],'=') !== false)
75 78
 			{
76 79
 				list($cell_name,$tab_names) = explode('=',$cell['name']);
77 80
 				$cell['name'] = $cell_name;
78 81
 			}
79 82
 			$labels = $helps = $names = $templates = $ids = array();
80
-			if ($cell['tabs'])	// set via etemplate::setElementAttribute()
83
+			if ($cell['tabs'])
84
+			{
85
+				// set via etemplate::setElementAttribute()
81 86
 			{
82 87
 				foreach($cell['tabs'] as $tab)
83 88
 				{
84 89
 					$labels[] = $tab['label'];
90
+			}
85 91
 					$helps[] = $tab['help'];
86 92
 					$names[] = $tab['id'] ? $tab['id'] : $tab['template'];
87
-					if ($tab['template']) $templates[count($names)-1] = $tab['template'];
88
-					if ($tab['id']) $ids[count($names)-1] = $tab['id'];
93
+					if ($tab['template'])
94
+					{
95
+						$templates[count($names)-1] = $tab['template'];
96
+					}
97
+					if ($tab['id'])
98
+					{
99
+						$ids[count($names)-1] = $tab['id'];
100
+					}
89 101
 				}
90 102
 			}
91 103
 			else
Please login to merge, or discard this patch.
etemplate/inc/class.uietemplate_gtk.inc.php 3 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -259,7 +259,6 @@  discard block
 block discarded – undo
259 259
 		 * @param $readonlys array with names of cells/form-elements to be not allowed to change
260 260
 		 * @param            This is to facilitate complex ACL's which denies access on field-level !!!
261 261
 		 * @param $cname basename of names for form-elements, means index in $_POST
262
-		 * @param        eg. $cname='cont', element-name = 'name' returned content in $_POST['cont']['name']
263 262
 		 * @param $show_xxx row,col name/index for name expansion
264 263
 		 * @return the generated HTML
265 264
 		 */
@@ -431,6 +430,8 @@  discard block
 block discarded – undo
431 430
 		 * calls show to generate included eTemplates. Again only an INTERMAL function.
432 431
 		 * @param $cell array with data of the cell: name, type, ...
433 432
 		 * @param for rest see show
433
+		 * @param string $cname
434
+		 * @param integer $show_row
434 435
 		 * @return the generated HTML
435 436
 		 */
436 437
 		function show_cell($cell,$content,$sel_options,$readonlys,$cname,$show_c,$show_row,&$span,&$result)
Please login to merge, or discard this patch.
Spacing   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 	 * @version $Id$
10 10
 	 */
11 11
 
12
-	include_once(EGW_INCLUDE_ROOT . '/etemplate/inc/class.boetemplate.inc.php');
12
+	include_once(EGW_INCLUDE_ROOT.'/etemplate/inc/class.boetemplate.inc.php');
13 13
 
14 14
 	/**
15 15
 	 * @author ralfbecker
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	 */
27 27
 	class gtk_etemplate extends boetemplate
28 28
 	{
29
-		var $debug;//='etemplate.editor.edit'; // 1=calls to show and process_show, 2=content after process_show,
29
+		var $debug; //='etemplate.editor.edit'; // 1=calls to show and process_show, 2=content after process_show,
30 30
 						// 3=calls to show_cell and process_show_cell, or template-name or cell-type
31 31
 
32 32
 		var $no_result = array(	// field-types which generate no direct result
@@ -36,23 +36,23 @@  discard block
 block discarded – undo
36 36
 			'raw' => True,
37 37
 			'template' => True
38 38
 		);
39
-		var $font_width=8;
39
+		var $font_width = 8;
40 40
 
41 41
 		/**
42 42
 		 * constructor of etemplate class, reads an eTemplate if $name is given
43 43
 		 *
44 44
 		 * @param as soetemplate.read
45 45
 		 */
46
-		function etemplate($name='',$template='default',$lang='default',$group=0,$version='',$rows=2,$cols=2)
46
+		function etemplate($name = '', $template = 'default', $lang = 'default', $group = 0, $version = '', $rows = 2, $cols = 2)
47 47
 		{
48 48
 			$this->public_functions += array(
49 49
 				'exec'			=> True,
50 50
 			);
51 51
 			$this->boetemplate();
52 52
 
53
-			if (!$this->read($name,$template,$lang,$group,$version))
53
+			if (!$this->read($name, $template, $lang, $group, $version))
54 54
 			{
55
-				$this->init($name,$template,$lang,$group,$version,$rows,$cols);
55
+				$this->init($name, $template, $lang, $group, $version, $rows, $cols);
56 56
 				return False;
57 57
 			}
58 58
 			return True;
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 		 * @param $preserv Array with vars which should be transported to the $method-call (eg. an id) array('id' => $id) sets $_POST['id'] for the $method-call
78 78
 		 * @return nothing
79 79
 		 */
80
-		function exec($method,$content,$sel_options='',$readonlys='',$preserv='')
80
+		function exec($method, $content, $sel_options = '', $readonlys = '', $preserv = '')
81 81
 		{
82 82
 			if (!$sel_options)
83 83
 			{
@@ -109,10 +109,10 @@  discard block
 block discarded – undo
109 109
 			if (!$GLOBALS['egw_info']['etemplate']['window'])
110 110
 			{
111 111
 				$window = new GtkWindow();
112
-				$window->connect('destroy',array('etemplate','destroy'));
113
-				$window->connect('delete-event',array('etemplate','delete_event'));
112
+				$window->connect('destroy', array('etemplate', 'destroy'));
113
+				$window->connect('delete-event', array('etemplate', 'delete_event'));
114 114
 				$window->set_title('eGroupWareGTK: '.$GLOBALS['egw_info']['server']['site_title']);
115
-				$window->set_default_size(1024,600);
115
+				$window->set_default_size(1024, 600);
116 116
 
117 117
 				$GLOBALS['egw_info']['etemplate']['window'] = &$window;
118 118
 			}
@@ -121,12 +121,12 @@  discard block
 block discarded – undo
121 121
 				$window = &$GLOBALS['egw_info']['etemplate']['window'];
122 122
 			}
123 123
 			$this->result = array('test' => 'test');
124
-			$table = &$this->show($this->result,$content,$sel_options,$readonlys);
124
+			$table = &$this->show($this->result, $content, $sel_options, $readonlys);
125 125
 			$table->set_border_width(10);
126 126
 			$table->show();
127 127
 
128
-			$swindow = new GtkScrolledWindow(null,null);
129
-			$swindow->set_policy(GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
128
+			$swindow = new GtkScrolledWindow(null, null);
129
+			$swindow->set_policy(GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
130 130
 			$swindow->add_with_viewport($table);
131 131
 			$swindow->show();
132 132
 
@@ -144,9 +144,9 @@  discard block
 block discarded – undo
144 144
 			unset($this->widgets);
145 145
 
146 146
 			// set application name so that lang, etc. works
147
-			list($GLOBALS['egw_info']['flags']['currentapp']) = explode('.',$method);
147
+			list($GLOBALS['egw_info']['flags']['currentapp']) = explode('.', $method);
148 148
 
149
-			ExecMethod($method,array_merge($this->result,$preserv));
149
+			ExecMethod($method, array_merge($this->result, $preserv));
150 150
 		}
151 151
 
152 152
 		/**
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 		 *
155 155
 		 * @return the adjusted content (in the simplest case that would be $content)
156 156
 		 */
157
-		function process_show(&$content,$readonlys='')
157
+		function process_show(&$content, $readonlys = '')
158 158
 		{
159 159
 		}
160 160
 
@@ -173,12 +173,12 @@  discard block
 block discarded – undo
173 173
 		function destroy()
174 174
 		{
175 175
 			Gtk::main_quit();
176
-			$GLOBALS['egw']->session->destroy($GLOBALS['egw_info']['user']['sessionid'],$GLOBALS['egw_info']['user']['kp3']);
176
+			$GLOBALS['egw']->session->destroy($GLOBALS['egw_info']['user']['sessionid'], $GLOBALS['egw_info']['user']['kp3']);
177 177
 			$GLOBALS['egw_info']['flags']['nodisplay'] = True;
178 178
 			exit;
179 179
 		}
180 180
 
181
-		function button_clicked(&$var,$form_name)
181
+		function button_clicked(&$var, $form_name)
182 182
 		{
183 183
 			echo "button '$form_name' pressed\n";
184 184
 			$var = 'pressed';
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 
194 194
 		function collect_results()
195 195
 		{
196
-			for($i=0; isset($this->widgets[$i]); ++$i)
196
+			for ($i = 0; isset($this->widgets[$i]); ++$i)
197 197
 			{
198 198
 				$set = &$this->widgets[$i];
199 199
 				$widget = &$set['widget'];
@@ -203,13 +203,13 @@  discard block
 block discarded – undo
203 203
 				switch ($set['type'])
204 204
 				{
205 205
 					case 'button':	// is set to 'pressed' or is '' (not unset !!!)
206
-						$val_is_set = ($val = $this->get_array($this->result,$set['name']));
206
+						$val_is_set = ($val = $this->get_array($this->result, $set['name']));
207 207
 						break;
208 208
 					case 'int':
209 209
 					case 'float':
210 210
 					case 'text':
211 211
 					case 'textarea':
212
-						$val = $widget->get_chars(0,-1);
212
+						$val = $widget->get_chars(0, -1);
213 213
 						$val_is_set = True;
214 214
 						break;
215 215
 					case 'checkbox':
@@ -225,10 +225,10 @@  discard block
 block discarded – undo
225 225
 						break;
226 226
 					case 'select':
227 227
 						$entry = $widget->entry;
228
-						$selected = $entry->get_chars(0,-1);
228
+						$selected = $entry->get_chars(0, -1);
229 229
 						$options = $set['set_val'];
230 230
 						reset($options);
231
-						while (list($key,$val) = each($options))
231
+						while (list($key, $val) = each($options))
232 232
 						{
233 233
 							if ($val == $selected)
234 234
 							{
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 				}
243 243
 				echo $val_is_set && !$set['readonly'] ? " = '$val'\n" : " NOT SET\n";
244 244
 
245
-				$this->set_array($this->result,$set['name'],$val,$val_is_set && !$set['readonly']);
245
+				$this->set_array($this->result, $set['name'], $val, $val_is_set && !$set['readonly']);
246 246
 			}
247 247
 		}
248 248
 
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 		 * @param $show_xxx row,col name/index for name expansion
264 264
 		 * @return the generated HTML
265 265
 		 */
266
-		function show(&$result,$content,$sel_options='',$readonlys='',$cname='',$show_c=0,$show_row=0)
266
+		function show(&$result, $content, $sel_options = '', $readonlys = '', $cname = '', $show_c = 0, $show_row = 0)
267 267
 		{
268 268
 			if (!$sel_options)
269 269
 			{
@@ -279,15 +279,15 @@  discard block
 block discarded – undo
279 279
 			}
280 280
 			if (!is_array($content))
281 281
 			{
282
-				$content = array();	// happens if incl. template has no content
282
+				$content = array(); // happens if incl. template has no content
283 283
 			}
284 284
 			$content += array(	// for var-expansion in names in show_cell
285 285
 				'.c' => $show_c,
286
-				'.col' => $this->num2chrs($show_c-1),
286
+				'.col' => $this->num2chrs($show_c - 1),
287 287
 				'.row' => $show_row
288 288
 			);
289 289
 
290
-			$table = new GtkTable($this->rows,$this->cols,False);
290
+			$table = new GtkTable($this->rows, $this->cols, False);
291 291
 			$table->set_row_spacings(2);
292 292
 			$table->set_col_spacings(5);
293 293
 			$table->show();
@@ -295,31 +295,31 @@  discard block
 block discarded – undo
295 295
 			reset($this->data);
296 296
 			if (isset($this->data[0]))
297 297
 			{
298
-				list($nul,$width) = each($this->data);
298
+				list($nul, $width) = each($this->data);
299 299
 			}
300 300
 			else
301 301
 			{
302 302
 				$width = array();
303 303
 			}
304
-			for ($r = 0; $row = 1+$r /*list($row,$cols) = each($this->data)*/; ++$r)
304
+			for ($r = 0; $row = 1 + $r /*list($row,$cols) = each($this->data)*/; ++$r)
305 305
 			{
306 306
 				$old_cols = $cols; $old_class = $class; $old_height = $height;
307
-				if (!(list($nul,$cols) = each($this->data)))	// no further row
307
+				if (!(list($nul, $cols) = each($this->data)))	// no further row
308 308
 				{
309 309
 					$cols = $old_cols; $class = $old_class; $height = $old_height;
310
-					list($nul,$cell) = each($cols); reset($cols);
311
-					if (!($this->autorepeat_idx($cols['A'],0,$r,$idx,$idx_cname) && $idx_cname) &&
312
-						!($this->autorepeat_idx($cols['B'],1,$r,$idx,$idx_cname) && $idx_cname) ||
313
-						!$this->isset_array($content,$idx))
310
+					list($nul, $cell) = each($cols); reset($cols);
311
+					if (!($this->autorepeat_idx($cols['A'], 0, $r, $idx, $idx_cname) && $idx_cname) &&
312
+						!($this->autorepeat_idx($cols['B'], 1, $r, $idx, $idx_cname) && $idx_cname) ||
313
+						!$this->isset_array($content, $idx))
314 314
 					{
315
-						break;                     	// no auto-row-repeat
315
+						break; // no auto-row-repeat
316 316
 					}
317 317
 				}
318 318
 				else
319 319
 				{
320 320
 					$height = $this->data[0]["h$row"];
321
-					list($class,$valign) = explode(',',$this->data[0]["c$row"]);
322
-					switch($valign)
321
+					list($class, $valign) = explode(',', $this->data[0]["c$row"]);
322
+					switch ($valign)
323 323
 					{
324 324
 						case 'top':
325 325
 							$valign = 0.0;
@@ -335,21 +335,21 @@  discard block
 block discarded – undo
335 335
 				for ($c = 0; True /*list($col,$cell) = each($cols)*/; ++$c)
336 336
 				{
337 337
 					$old_cell = $cell;
338
-					if (!(list($nul,$cell) = each($cols)))		// no further cols
338
+					if (!(list($nul, $cell) = each($cols)))		// no further cols
339 339
 					{
340 340
 						$cell = $old_cell;
341
-						if (!$this->autorepeat_idx($cell,$c,$r,$idx,$idx_cname,True) ||
342
-							!$this->isset_array($content,$idx))
341
+						if (!$this->autorepeat_idx($cell, $c, $r, $idx, $idx_cname, True) ||
342
+							!$this->isset_array($content, $idx))
343 343
 						{
344
-							break;	// no auto-col-repeat
344
+							break; // no auto-col-repeat
345 345
 						}
346 346
 					}
347 347
 					$col = $this->num2chrs($c);
348 348
 
349 349
 					//$row_data[$col] = $this->show_cell($cell,$content,$sel_options,$readonlys,$cname,$c,$r,$span);
350
-					$widget = &$this->show_cell($cell,$content,$sel_options,$readonlys,$cname,$c,$r,$span,$result);
350
+					$widget = &$this->show_cell($cell, $content, $sel_options, $readonlys, $cname, $c, $r, $span, $result);
351 351
 
352
-					if (($colspan = $span == 'all' ? $this->cols-$c : 0+$span) < 1)
352
+					if (($colspan = $span == 'all' ? $this->cols - $c : 0 + $span) < 1)
353 353
 					{
354 354
 						$colspan = 1;
355 355
 					}
@@ -369,22 +369,22 @@  discard block
 block discarded – undo
369 369
 								default:
370 370
 									$align = 0.0;
371 371
 							}
372
-							$align = new GtkAlignment($align,$valign,$cell['type'] == 'hrule' ? 1.0 : 0.0,0.0);
372
+							$align = new GtkAlignment($align, $valign, $cell['type'] == 'hrule' ? 1.0 : 0.0, 0.0);
373 373
 							$align->add($widget);
374 374
 						}
375
-						$table->attach($align ? $align : $widget, $c, $c+$colspan, $r, $r+1,GTK_FILL,GTK_FILL,0,0);
375
+						$table->attach($align ? $align : $widget, $c, $c + $colspan, $r, $r + 1, GTK_FILL, GTK_FILL, 0, 0);
376 376
 					}
377 377
 					if ($row_data[$col] == '' && $this->rows == 1)
378 378
 					{
379
-						unset($row_data[$col]);	// omit empty/disabled cells if only one row
379
+						unset($row_data[$col]); // omit empty/disabled cells if only one row
380 380
 						continue;
381 381
 					}
382 382
 					if ($colspan > 1)
383 383
 					{
384 384
 						$row_data[".$col"] .= " COLSPAN=$colspan";
385
-						for ($i = 1; $i < $colspan; ++$i,++$c)
385
+						for ($i = 1; $i < $colspan; ++$i, ++$c)
386 386
 						{
387
-							each($cols);	// skip next cell(s)
387
+							each($cols); // skip next cell(s)
388 388
 						}
389 389
 					}
390 390
 					elseif ($width[$col])	// width only once for a non colspan cell
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 				$rows[$row] = $row_data;
399 399
 
400 400
 //				$rows[".$row"] .= $this->html->formatOptions($height,'HEIGHT');
401
-				list($cl) = explode(',',$class);
401
+				list($cl) = explode(',', $class);
402 402
 				if ($cl == 'nmr')
403 403
 				{
404 404
 					$cl .= $nmr_alternate++ & 1; // alternate color
@@ -433,23 +433,23 @@  discard block
 block discarded – undo
433 433
 		 * @param for rest see show
434 434
 		 * @return the generated HTML
435 435
 		 */
436
-		function show_cell($cell,$content,$sel_options,$readonlys,$cname,$show_c,$show_row,&$span,&$result)
436
+		function show_cell($cell, $content, $sel_options, $readonlys, $cname, $show_c, $show_row, &$span, &$result)
437 437
 		{
438 438
 			if ($this->debug >= 3 || $this->debug == $cell['type'])
439 439
 			{
440 440
 				echo "<p>etemplate.show_cell($this->name,name='${cell['name']}',type='${cell['type']}',cname='$cname')</p>\n";
441 441
 			}
442
-			list($span) = explode(',',$cell['span']);	// evtl. overriten later for type template
442
+			list($span) = explode(',', $cell['span']); // evtl. overriten later for type template
443 443
 
444
-			$name = $this->expand_name($cell['name'],$show_c,$show_row,$content['.c'],$content['.row'],$content);
444
+			$name = $this->expand_name($cell['name'], $show_c, $show_row, $content['.c'], $content['.row'], $content);
445 445
 
446 446
 			// building the form-field-name depending on prefix $cname and possibl. Array-subscript in name
447
-			if (preg_match('/^([^[]*)(\\[.*\\])$/',$name,$regs))	// name contains array-index
447
+			if (preg_match('/^([^[]*)(\\[.*\\])$/', $name, $regs))	// name contains array-index
448 448
 			{
449 449
 				$form_name = $cname == '' ? $name : $cname.'['.$regs[1].']'.$regs[2];
450
-				eval(str_replace(']',"']",str_replace('[',"['",'$value = $content['.$regs[1].']'.$regs[2].';')));
451
-				$org_name = substr($regs[2],1,-1);
452
-				eval(str_replace(']',"']",str_replace('[',"['",'$var = &$result['.$regs[1].']'.$regs[2].';')));
450
+				eval(str_replace(']', "']", str_replace('[', "['", '$value = $content['.$regs[1].']'.$regs[2].';')));
451
+				$org_name = substr($regs[2], 1, -1);
452
+				eval(str_replace(']', "']", str_replace('[', "['", '$var = &$result['.$regs[1].']'.$regs[2].';')));
453 453
 			}
454 454
 			else
455 455
 			{
@@ -463,21 +463,21 @@  discard block
 block discarded – undo
463 463
 			if ($cell['disabled'] || $cell['type'] == 'button' && $readonly)
464 464
 			{
465 465
 				if ($this->rows == 1) {
466
-					return '';	// if only one row omit cell
466
+					return ''; // if only one row omit cell
467 467
 				}
468 468
 				$cell = $this->empty_cell(); // show nothing
469 469
 				$value = '';
470 470
 			}
471 471
 			if ($cell['onchange'])	// values != '1' can only set by a program (not in the editor so far)
472 472
 			{
473
-				$options .= ' onChange="'.($cell['onchange']=='1'?'this.form.submit();':$cell['onchange']).'"';
473
+				$options .= ' onChange="'.($cell['onchange'] == '1' ? 'this.form.submit();' : $cell['onchange']).'"';
474 474
 			}
475 475
 
476 476
 			if (strlen($label = $cell['label']) > 1)
477 477
 			{
478 478
 				$label = lang($label);
479 479
 			}
480
-			list($left_label,$right_label) = explode('%s',$label);
480
+			list($left_label, $right_label) = explode('%s', $label);
481 481
 
482 482
 			//echo "show_cell: type='$cell[type]', name='$cell[name]'-->'$name', value='$value'\n";
483 483
 			$widget = False;
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
 					break;
505 505
 				case 'int':		// size: [min][,[max][,len]]
506 506
 				case 'float':
507
-					list($min,$max,$cell['size']) = explode(',',$cell['size']);
507
+					list($min, $max, $cell['size']) = explode(',', $cell['size']);
508 508
 					if ($cell['size'] == '')
509 509
 					{
510 510
 						$cell['size'] = $cell['type'] == 'int' ? 5 : 8;
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
 					{
520 520
 						//$html .= $this->html->input($form_name,$value,'',$options.$this->html->formatOptions($cell['size'],'SIZE,MAXLENGTH'));
521 521
 					}
522
-					list($len,$max) = explode(',',$cell['size']);
522
+					list($len, $max) = explode(',', $cell['size']);
523 523
 					$widget = new GtkEntry();
524 524
 					$widget->set_text($value);
525 525
 					if ($max)
@@ -529,13 +529,13 @@  discard block
 block discarded – undo
529 529
 					$widget->set_editable(!$readonly);
530 530
 					if ($len)
531 531
 					{
532
-						$widget->set_usize($len*$this->font_width,0);
532
+						$widget->set_usize($len * $this->font_width, 0);
533 533
 					}
534 534
 					break;
535 535
 				case 'textarea':	// Multiline Text Input, size: [rows][,cols]
536 536
 					//$html .= $this->html->textarea($form_name,$value,$options.$this->html->formatOptions($cell['size'],'ROWS,COLS'));
537
-					$widget = new GtkText(null,null);
538
-					$widget->insert_text($value,strlen($value));
537
+					$widget = new GtkText(null, null);
538
+					$widget->insert_text($value, strlen($value));
539 539
 					$widget->set_editable(!$readonly);
540 540
 					break;
541 541
 /*				case 'date':
@@ -584,11 +584,11 @@  discard block
 block discarded – undo
584 584
 					//$html .= $this->html->input($form_name,$cell['size'],'RADIO',$options);
585 585
 					if (isset($this->buttongroup[$form_name]))
586 586
 					{
587
-						$widget = new GtkRadioButton($this->buttongroup[$form_name],$right_label);
587
+						$widget = new GtkRadioButton($this->buttongroup[$form_name], $right_label);
588 588
 					}
589 589
 					else
590 590
 					{
591
-						$this->buttongroup[$form_name] = $widget = new GtkRadioButton(null,$right_label);
591
+						$this->buttongroup[$form_name] = $widget = new GtkRadioButton(null, $right_label);
592 592
 					}
593 593
 					$right_label = '';
594 594
 					$widget->set_active($value == $cell['size']);
@@ -596,18 +596,18 @@  discard block
 block discarded – undo
596 596
 				case 'button':
597 597
 					//$html .= $this->html->submit_button($form_name,$cell['label'],'',strlen($cell['label']) <= 1 || $cell['no_lang'],$options);
598 598
 					$widget = new GtkButton(strlen($cell['label']) > 1 ? lang($cell['label']) : $cell['label']);
599
-					$widget->connect_object('clicked', array('etemplate', 'button_clicked'),&$var,$form_name);
599
+					$widget->connect_object('clicked', array('etemplate', 'button_clicked'), &$var, $form_name);
600 600
 					break;
601 601
 				case 'hrule':
602 602
 					//$html .= $this->html->hr($cell['size']);
603 603
 					$widget = new GtkHSeparator();
604 604
 					break;
605 605
 				case 'template':	// size: index in content-array (if not full content is past further on)
606
-					if ($this->autorepeat_idx($cell,$show_c,$show_row,$idx,$idx_cname) || $cell['size'] != '')
606
+					if ($this->autorepeat_idx($cell, $show_c, $show_row, $idx, $idx_cname) || $cell['size'] != '')
607 607
 					{
608 608
 						if ($span == '' && isset($content[$idx]['span']))
609 609
 						{	// this allows a colspan in autorepeated cells like the editor
610
-							$span = explode(',',$content[$idx]['span']); $span = $span[0];
610
+							$span = explode(',', $content[$idx]['span']); $span = $span[0];
611 611
 							if ($span == 'all')
612 612
 							{
613 613
 								$span = 1 + $content['cols'] - $show_c;
@@ -633,7 +633,7 @@  discard block
 block discarded – undo
633 633
 					$templ = is_object($cell['name']) ? $cell['name'] : new etemplate($name);
634 634
 					$templ->widgets = &$this->widgets;
635 635
 					//$html .= $templ->show($content,$sel_options,$readonlys,$cname,$show_c,$show_row);
636
-					$widget = $templ->show($var,$content,$sel_options,$readonlys,$cname,$show_c,$show_row);
636
+					$widget = $templ->show($var, $content, $sel_options, $readonlys, $cname, $show_c, $show_row);
637 637
 					break;
638 638
 				case 'select':	// size:[linesOnMultiselect]
639 639
 					if (isset($sel_options[$name]))
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
 					//$html .= $this->sbox->getArrayItem($form_name.'[]',$value,$sel_options,$cell['no_lang'],$options,$cell['size']);
651 651
 
652 652
 					reset($sel_options);
653
-					for ($maxlen=0; list($key,$val) = each($sel_options); )
653
+					for ($maxlen = 0; list($key, $val) = each($sel_options);)
654 654
 					{
655 655
 						if (!$cell['no_lang'])
656 656
 						{
@@ -666,10 +666,10 @@  discard block
 block discarded – undo
666 666
 					$entry = $widget->entry;
667 667
 					$entry->set_text($sel_options[$value]);
668 668
 					$entry->set_editable(False);
669
-					$entry->set_usize($maxlen*$this->font_width,0);
669
+					$entry->set_usize($maxlen * $this->font_width, 0);
670 670
 					if ($cell['onchange'] == '1')
671 671
 					{
672
-						$entry->connect('changed',array('etemplate', 'submit'));
672
+						$entry->connect('changed', array('etemplate', 'submit'));
673 673
 					}
674 674
 					break;
675 675
 /*				case 'select-percent':
@@ -700,8 +700,8 @@  discard block
 block discarded – undo
700 700
 					$html .= $this->sbox->getAccount($form_name.'[]',$value,2,$type,0+$cell['size'],$options);
701 701
 					break;
702 702
 */				case 'image':
703
-					if (!($path = $GLOBALS['egw']->common->image(substr($this->name,0,strpos($this->name,'.')),$cell['label'])))
704
-						$path = $cell['label'];		// name may already contain absolut path
703
+					if (!($path = $GLOBALS['egw']->common->image(substr($this->name, 0, strpos($this->name, '.')), $cell['label'])))
704
+						$path = $cell['label']; // name may already contain absolut path
705 705
 					if (!isset($GLOBALS['egw_info']['etemplate']['pixbufs'][$path]))
706 706
 					{
707 707
 						$GLOBALS['egw_info']['etemplate']['pixbufs'][$path] = GdkPixbuf::new_from_file('../..'.$path);
@@ -710,8 +710,8 @@  discard block
 block discarded – undo
710 710
 					if ($pixbuf)
711 711
 					{
712 712
 						$widget = new GtkDrawingArea();
713
-						$widget->size($pixbuf->get_width(),$pixbuf->get_height());
714
-						$widget->connect('expose_event',array('etemplate','draw_image'),$pixbuf);
713
+						$widget->size($pixbuf->get_width(), $pixbuf->get_height());
714
+						$widget->connect('expose_event', array('etemplate', 'draw_image'), $pixbuf);
715 715
 					}
716 716
 					else
717 717
 					{
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
 				}
743 743
 				else
744 744
 				{
745
-					$hbox = new GtkHBox(False,5);
745
+					$hbox = new GtkHBox(False, 5);
746 746
 					if ($left_label)
747 747
 					{
748 748
 						$left = new GtkLabel($left_label);
@@ -768,7 +768,7 @@  discard block
 block discarded – undo
768 768
 				{
769 769
 					$this->tooltips = new GtkTooltips();
770 770
 				}
771
-				$this->tooltips->set_tip($widget,lang($cell['help']),$this->name.'/'.$form_name);
771
+				$this->tooltips->set_tip($widget, lang($cell['help']), $this->name.'/'.$form_name);
772 772
 			}
773 773
 			return $hbox ? $hbox : $widget;
774 774
 		}
Please login to merge, or discard this patch.
Braces   +36 added lines, -11 removed lines patch added patch discarded remove patch
@@ -91,11 +91,14 @@  discard block
 block discarded – undo
91 91
 			{
92 92
 				$preserv = array();
93 93
 			}
94
-			if (!class_exists('gtk'))	// load the gtk extension
94
+			if (!class_exists('gtk'))
95
+			{
96
+				// load the gtk extension
95 97
 			{
96 98
 				if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN')
97 99
 				{
98 100
 					dl('php_gtk.dll');
101
+			}
99 102
 				}
100 103
 				else
101 104
 				{
@@ -304,9 +307,13 @@  discard block
 block discarded – undo
304 307
 			for ($r = 0; $row = 1+$r /*list($row,$cols) = each($this->data)*/; ++$r)
305 308
 			{
306 309
 				$old_cols = $cols; $old_class = $class; $old_height = $height;
307
-				if (!(list($nul,$cols) = each($this->data)))	// no further row
310
+				if (!(list($nul,$cols) = each($this->data)))
311
+				{
312
+					// no further row
308 313
 				{
309
-					$cols = $old_cols; $class = $old_class; $height = $old_height;
314
+					$cols = $old_cols;
315
+				}
316
+				$class = $old_class; $height = $old_height;
310 317
 					list($nul,$cell) = each($cols); reset($cols);
311 318
 					if (!($this->autorepeat_idx($cols['A'],0,$r,$idx,$idx_cname) && $idx_cname) &&
312 319
 						!($this->autorepeat_idx($cols['B'],1,$r,$idx,$idx_cname) && $idx_cname) ||
@@ -335,9 +342,12 @@  discard block
 block discarded – undo
335 342
 				for ($c = 0; True /*list($col,$cell) = each($cols)*/; ++$c)
336 343
 				{
337 344
 					$old_cell = $cell;
338
-					if (!(list($nul,$cell) = each($cols)))		// no further cols
345
+					if (!(list($nul,$cell) = each($cols)))
346
+					{
347
+						// no further cols
339 348
 					{
340 349
 						$cell = $old_cell;
350
+					}
341 351
 						if (!$this->autorepeat_idx($cell,$c,$r,$idx,$idx_cname,True) ||
342 352
 							!$this->isset_array($content,$idx))
343 353
 						{
@@ -387,9 +397,12 @@  discard block
 block discarded – undo
387 397
 							each($cols);	// skip next cell(s)
388 398
 						}
389 399
 					}
390
-					elseif ($width[$col])	// width only once for a non colspan cell
400
+					elseif ($width[$col])
401
+					{
402
+						// width only once for a non colspan cell
391 403
 					{
392 404
 						$row_data[".$col"] .= ' WIDTH='.$width[$col];
405
+					}
393 406
 						$width[$col] = 0;
394 407
 					}
395 408
 //					$row_data[".$col"] .= $this->html->formatOptions($cell['align'],'ALIGN');
@@ -444,9 +457,12 @@  discard block
 block discarded – undo
444 457
 			$name = $this->expand_name($cell['name'],$show_c,$show_row,$content['.c'],$content['.row'],$content);
445 458
 
446 459
 			// building the form-field-name depending on prefix $cname and possibl. Array-subscript in name
447
-			if (preg_match('/^([^[]*)(\\[.*\\])$/',$name,$regs))	// name contains array-index
460
+			if (preg_match('/^([^[]*)(\\[.*\\])$/',$name,$regs))
461
+			{
462
+				// name contains array-index
448 463
 			{
449 464
 				$form_name = $cname == '' ? $name : $cname.'['.$regs[1].']'.$regs[2];
465
+			}
450 466
 				eval(str_replace(']',"']",str_replace('[',"['",'$value = $content['.$regs[1].']'.$regs[2].';')));
451 467
 				$org_name = substr($regs[2],1,-1);
452 468
 				eval(str_replace(']',"']",str_replace('[',"['",'$var = &$result['.$regs[1].']'.$regs[2].';')));
@@ -462,16 +478,20 @@  discard block
 block discarded – undo
462 478
 
463 479
 			if ($cell['disabled'] || $cell['type'] == 'button' && $readonly)
464 480
 			{
465
-				if ($this->rows == 1) {
481
+				if ($this->rows == 1)
482
+				{
466 483
 					return '';	// if only one row omit cell
467 484
 				}
468 485
 				$cell = $this->empty_cell(); // show nothing
469 486
 				$value = '';
470 487
 			}
471
-			if ($cell['onchange'])	// values != '1' can only set by a program (not in the editor so far)
488
+			if ($cell['onchange'])
489
+			{
490
+				// values != '1' can only set by a program (not in the editor so far)
472 491
 			{
473 492
 				$options .= ' onChange="'.($cell['onchange']=='1'?'this.form.submit();':$cell['onchange']).'"';
474 493
 			}
494
+			}
475 495
 
476 496
 			if (strlen($label = $cell['label']) > 1)
477 497
 			{
@@ -606,7 +626,8 @@  discard block
 block discarded – undo
606 626
 					if ($this->autorepeat_idx($cell,$show_c,$show_row,$idx,$idx_cname) || $cell['size'] != '')
607 627
 					{
608 628
 						if ($span == '' && isset($content[$idx]['span']))
609
-						{	// this allows a colspan in autorepeated cells like the editor
629
+						{
630
+// this allows a colspan in autorepeated cells like the editor
610 631
 							$span = explode(',',$content[$idx]['span']); $span = $span[0];
611 632
 							if ($span == 'all')
612 633
 							{
@@ -643,7 +664,8 @@  discard block
 block discarded – undo
643 664
 					elseif (isset($sel_options[$org_name]))
644 665
 					{
645 666
 						$sel_options = $sel_options[$org_name];
646
-					} elseif (isset($content["options-$name"]))
667
+					}
668
+					elseif (isset($content["options-$name"]))
647 669
 					{
648 670
 						$sel_options = $content["options-$name"];
649 671
 					}
@@ -701,7 +723,10 @@  discard block
 block discarded – undo
701 723
 					break;
702 724
 */				case 'image':
703 725
 					if (!($path = $GLOBALS['egw']->common->image(substr($this->name,0,strpos($this->name,'.')),$cell['label'])))
704
-						$path = $cell['label'];		// name may already contain absolut path
726
+					{
727
+											$path = $cell['label'];
728
+					}
729
+					// name may already contain absolut path
705 730
 					if (!isset($GLOBALS['egw_info']['etemplate']['pixbufs'][$path]))
706 731
 					{
707 732
 						$GLOBALS['egw_info']['etemplate']['pixbufs'][$path] = GdkPixbuf::new_from_file('../..'.$path);
Please login to merge, or discard this patch.
etemplate/inc/class.uilangfile.inc.php 3 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -484,6 +484,9 @@  discard block
 block discarded – undo
484 484
 		return str_replace(array('[',']','&','"'),array('%5B','%5D','&amp;','&quot;'),$id);
485 485
 	}
486 486
 
487
+	/**
488
+	 * @return string
489
+	 */
487 490
 	function recode_id($id)
488 491
 	{
489 492
 		if (get_magic_quotes_gpc())
@@ -493,6 +496,9 @@  discard block
 block discarded – undo
493 496
 		return str_replace(array('%5B','%5D'),array('[',']'),$id);	// &amp; + &quot; are recode by php
494 497
 	}
495 498
 
499
+	/**
500
+	 * @param string $which
501
+	 */
496 502
 	function download($which,$userlang)
497 503
 	{
498 504
 		switch ($which)
Please login to merge, or discard this patch.
Spacing   +209 added lines, -209 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	function __construct()
48 48
 	{
49 49
 		$this->template = new Template(EGW_SERVER_ROOT.'/etemplate/templates/default');
50
-		$this->template->egroupware_hack = False;	// else the phrases got translated
50
+		$this->template->egroupware_hack = False; // else the phrases got translated
51 51
 		$this->bo = new bolangfile();
52 52
 		$this->nextmatchs = new nextmatchs();
53 53
 		translation::add_app('developer_tools');
@@ -62,19 +62,19 @@  discard block
 block discarded – undo
62 62
 
63 63
 	function addphrase()
64 64
 	{
65
-		$app_name   = get_var('app_name',array('POST','GET'));
66
-		$sourcelang = get_var('sourcelang',array('POST','GET'));
67
-		$targetlang = get_var('targetlang',array('POST','GET'));
65
+		$app_name   = get_var('app_name', array('POST', 'GET'));
66
+		$sourcelang = get_var('sourcelang', array('POST', 'GET'));
67
+		$targetlang = get_var('targetlang', array('POST', 'GET'));
68 68
 		$entry      = $_POST['entry'];
69 69
 
70 70
 		$this->bo->read_sessiondata();
71
-		if($_POST['add'] || $_POST['cancel'] || $_POST['more'])
71
+		if ($_POST['add'] || $_POST['cancel'] || $_POST['more'])
72 72
 		{
73
-			if($_POST['add'] || $_POST['more'])
73
+			if ($_POST['add'] || $_POST['more'])
74 74
 			{
75 75
 				if (get_magic_quotes_gpc())
76 76
 				{
77
-					foreach(array('message_id','content','target') as $name)
77
+					foreach (array('message_id', 'content', 'target') as $name)
78 78
 					{
79 79
 						$entry[$name] = stripslashes($entry[$name]);
80 80
 					}
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 			}
89 89
 			if (!$_POST['more'])
90 90
 			{
91
-				$GLOBALS['egw']->redirect_link('/index.php',array(
91
+				$GLOBALS['egw']->redirect_link('/index.php', array(
92 92
 					'menuaction' => $this->use_app.'.uilangfile.edit',
93 93
 					'app_name'   => $app_name,
94 94
 					'sourcelang' => $sourcelang,
@@ -102,42 +102,42 @@  discard block
 block discarded – undo
102 102
 		common::egw_header();
103 103
 		echo parse_navbar();
104 104
 
105
-		$this->template->set_var('form_action',$GLOBALS['egw']->link('/index.php', "menuaction=$this->use_app.uilangfile.addphrase"));
106
-		$this->template->set_var('sourcelang',$sourcelang);
107
-		$this->template->set_var('targetlang',$targetlang);
108
-		$this->template->set_var('app_name',$app_name);
105
+		$this->template->set_var('form_action', $GLOBALS['egw']->link('/index.php', "menuaction=$this->use_app.uilangfile.addphrase"));
106
+		$this->template->set_var('sourcelang', $sourcelang);
107
+		$this->template->set_var('targetlang', $targetlang);
108
+		$this->template->set_var('app_name', $app_name);
109 109
 
110 110
 		$this->template->set_file(array('form' => 'addphrase.tpl'));
111
-		$this->template->set_var('message_id_field','<textarea rows="5" style="width: 100%;" name="entry[message_id]"></textarea>');
111
+		$this->template->set_var('message_id_field', '<textarea rows="5" style="width: 100%;" name="entry[message_id]"></textarea>');
112 112
 		if ($app_name == 'api') $app_name = 'common';
113
-		$this->template->set_var('app_field',$this->lang_option($app_name,isset($entry)?$entry['app_name']:$app_name,'entry[app_name]'));
114
-		$this->template->set_var('translation_field','<textarea rows="5" style="width: 100%;"  name="entry[content]"></textarea>');
115
-		$this->template->set_var('target_field','<textarea rows="5" style="width: 100%;" name="entry[target]"></textarea>');
116
-
117
-		$this->template->set_var('lang_message_id',lang('message_id in English'));
118
-		$this->template->set_var('lang_app',lang('Application'));
119
-		$this->template->set_var('lang_translation',lang('Phrase in English (or empty if identical)'));
120
-		$this->template->set_var('lang_target',lang('Translation of phrase'));
121
-		$this->template->set_var('lang_add',lang('Add'));
122
-		$this->template->set_var('lang_more',lang('Add more'));
123
-		$this->template->set_var('lang_cancel',lang('Cancel'));
124
-
125
-		$this->template->pfp('phpgw_body','form');
113
+		$this->template->set_var('app_field', $this->lang_option($app_name, isset($entry) ? $entry['app_name'] : $app_name, 'entry[app_name]'));
114
+		$this->template->set_var('translation_field', '<textarea rows="5" style="width: 100%;"  name="entry[content]"></textarea>');
115
+		$this->template->set_var('target_field', '<textarea rows="5" style="width: 100%;" name="entry[target]"></textarea>');
116
+
117
+		$this->template->set_var('lang_message_id', lang('message_id in English'));
118
+		$this->template->set_var('lang_app', lang('Application'));
119
+		$this->template->set_var('lang_translation', lang('Phrase in English (or empty if identical)'));
120
+		$this->template->set_var('lang_target', lang('Translation of phrase'));
121
+		$this->template->set_var('lang_add', lang('Add'));
122
+		$this->template->set_var('lang_more', lang('Add more'));
123
+		$this->template->set_var('lang_cancel', lang('Cancel'));
124
+
125
+		$this->template->pfp('phpgw_body', 'form');
126 126
 	}
127 127
 
128 128
 	function missingphrase()
129 129
 	{
130
-		$app_name    = get_var('app_name',array('POST','GET'));
131
-		$sourcelang  = get_var('sourcelang',array('POST','GET'));
132
-		$targetlang  = get_var('targetlang',array('POST','GET'));
130
+		$app_name    = get_var('app_name', array('POST', 'GET'));
131
+		$sourcelang  = get_var('sourcelang', array('POST', 'GET'));
132
+		$targetlang  = get_var('targetlang', array('POST', 'GET'));
133 133
 
134 134
 		$this->bo->read_sessiondata();
135
-		$this->bo->missing_app($app_name,$sourcelang);
135
+		$this->bo->missing_app($app_name, $sourcelang);
136 136
 		$this->bo->save_sessiondata();
137 137
 
138 138
 		// we have to redirect here, as solangfile defines function sidebox_menu, which clashes with the iDots func.
139 139
 		//
140
-		$GLOBALS['egw']->redirect_link('/index.php',array(
140
+		$GLOBALS['egw']->redirect_link('/index.php', array(
141 141
 			'menuaction' => $this->use_app.'.uilangfile.missingphrase2',
142 142
 			'app_name'   => $app_name,
143 143
 			'sourcelang' => $sourcelang,
@@ -147,9 +147,9 @@  discard block
 block discarded – undo
147 147
 
148 148
 	function missingphrase2()
149 149
 	{
150
-		$app_name    = get_var('app_name',array('POST','GET'));
151
-		$sourcelang  = get_var('sourcelang',array('POST','GET'));
152
-		$targetlang  = get_var('targetlang',array('POST','GET'));
150
+		$app_name    = get_var('app_name', array('POST', 'GET'));
151
+		$sourcelang  = get_var('sourcelang', array('POST', 'GET'));
152
+		$targetlang  = get_var('targetlang', array('POST', 'GET'));
153 153
 		$newlang     = $_POST['newlang'];
154 154
 		$dlsource    = $_POST['dlsource'];
155 155
 		$writesource = $_POST['writesource'];
@@ -161,16 +161,16 @@  discard block
 block discarded – undo
161 161
 		$this->bo->read_sessiondata();
162 162
 
163 163
 		$this->template->set_file(array('langfile' => 'langmissing.tpl'));
164
-		$this->template->set_block('langfile','header','header');
165
-		$this->template->set_block('langfile','postheader','postheader');
166
-		$this->template->set_block('langfile','detail','detail');
167
-		$this->template->set_block('langfile','prefooter','prefooter');
168
-		$this->template->set_block('langfile','footer','footer');
169
-		if(!$sourcelang)
164
+		$this->template->set_block('langfile', 'header', 'header');
165
+		$this->template->set_block('langfile', 'postheader', 'postheader');
166
+		$this->template->set_block('langfile', 'detail', 'detail');
167
+		$this->template->set_block('langfile', 'prefooter', 'prefooter');
168
+		$this->template->set_block('langfile', 'footer', 'footer');
169
+		if (!$sourcelang)
170 170
 		{
171 171
 			$sourcelang = 'en';
172 172
 		}
173
-		if(!$targetlang)
173
+		if (!$targetlang)
174 174
 		{
175 175
 			$targetlang = 'en';
176 176
 		}
@@ -178,12 +178,12 @@  discard block
 block discarded – undo
178 178
 		//echo "missingarray=<pre>"; print_r($this->bo->missing_langarray); echo "</pre>\n";
179 179
 		if ($update)
180 180
 		{
181
-			$deleteme     = $_POST['delete'];
181
+			$deleteme = $_POST['delete'];
182 182
 			//echo "deleteme=<pre>"; print_r($deleteme); echo "</pre>\n";
183 183
 
184
-			while (list($_mess,$_checked) = @each($deleteme))
184
+			while (list($_mess, $_checked) = @each($deleteme))
185 185
 			{
186
-				if($_checked == 'on')
186
+				if ($_checked == 'on')
187 187
 				{
188 188
 					$_mess = $this->recode_id($_mess);
189 189
 					$this->bo->movephrase($_mess);
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 			unset($deleteme);
196 196
 
197 197
 			$this->bo->save_sessiondata();
198
-			$GLOBALS['egw']->redirect_link('/index.php',array(
198
+			$GLOBALS['egw']->redirect_link('/index.php', array(
199 199
 				'menuaction' => $this->use_app.'.uilangfile.edit',
200 200
 				'app_name'   => $app_name,
201 201
 				'sourcelang' => $sourcelang,
@@ -205,40 +205,40 @@  discard block
 block discarded – undo
205 205
 		common::egw_header();
206 206
 		echo parse_navbar();
207 207
 
208
-		$this->template->set_var('lang_remove',lang('Add phrase'));
209
-		$this->template->set_var('lang_application',lang('Application'));
210
-		$this->template->set_var('lang_update',lang('Add'));
211
-		$this->template->set_var('lang_view',lang('Cancel'));
212
-
213
-		$this->template->set_var('action_url',$GLOBALS['egw']->link('/index.php', "menuaction=$this->use_app.uilangfile.missingphrase2"));
214
-		$this->template->set_var('sourcelang',$sourcelang);
215
-		$this->template->set_var('targetlang',$targetlang);
216
-		$this->template->set_var('app_name',$app_name);
217
-		$this->template->set_var('app_title',$GLOBALS['egw_info']['apps'][$app_name]['title']);
218
-		$this->template->pfp('out','header');
219
-		if($sourcelang && $targetlang)
220
-		{
221
-			$this->template->set_var('lang_appname',lang('Application'));
222
-			$this->template->set_var('lang_message',lang('Message'));
223
-			$this->template->set_var('lang_original',lang('Original'));
208
+		$this->template->set_var('lang_remove', lang('Add phrase'));
209
+		$this->template->set_var('lang_application', lang('Application'));
210
+		$this->template->set_var('lang_update', lang('Add'));
211
+		$this->template->set_var('lang_view', lang('Cancel'));
212
+
213
+		$this->template->set_var('action_url', $GLOBALS['egw']->link('/index.php', "menuaction=$this->use_app.uilangfile.missingphrase2"));
214
+		$this->template->set_var('sourcelang', $sourcelang);
215
+		$this->template->set_var('targetlang', $targetlang);
216
+		$this->template->set_var('app_name', $app_name);
217
+		$this->template->set_var('app_title', $GLOBALS['egw_info']['apps'][$app_name]['title']);
218
+		$this->template->pfp('out', 'header');
219
+		if ($sourcelang && $targetlang)
220
+		{
221
+			$this->template->set_var('lang_appname', lang('Application'));
222
+			$this->template->set_var('lang_message', lang('Message'));
223
+			$this->template->set_var('lang_original', lang('Original'));
224 224
 			$this->template->set_var('view_link',
225 225
 				$GLOBALS['egw']->link(
226 226
 					'/index.php',
227
-					"menuaction=$this->use_app.uilangfile.edit&app_name=".$app_name.'&sourcelang=' . $sourcelang . '&targetlang=' . $targetlang
227
+					"menuaction=$this->use_app.uilangfile.edit&app_name=".$app_name.'&sourcelang='.$sourcelang.'&targetlang='.$targetlang
228 228
 				)
229 229
 			);
230
-			$this->template->pfp('out','postheader');
231
-			while(list($key,$data) = @each($missingarray))
230
+			$this->template->pfp('out', 'postheader');
231
+			while (list($key, $data) = @each($missingarray))
232 232
 			{
233
-				$mess_id  = $this->encode_id($key);
234
-				$this->template->set_var('mess_id',$mess_id);
235
-				$this->template->set_var('source_content',html::htmlspecialchars($data['content']));
236
-				$this->template->set_var('transapp',$this->lang_option($app_name,$data['app_name'],"transapp[$mess_id]"));
237
-				$this->template->set_var('tr_class',$this->nextmatchs->alternate_row_color('',true));
238
-				$this->template->pfp('out','detail');
233
+				$mess_id = $this->encode_id($key);
234
+				$this->template->set_var('mess_id', $mess_id);
235
+				$this->template->set_var('source_content', html::htmlspecialchars($data['content']));
236
+				$this->template->set_var('transapp', $this->lang_option($app_name, $data['app_name'], "transapp[$mess_id]"));
237
+				$this->template->set_var('tr_class', $this->nextmatchs->alternate_row_color('', true));
238
+				$this->template->pfp('out', 'detail');
239 239
 			}
240
-			$this->template->pfp('out','prefooter');
241
-			$this->template->pfp('out','footer');
240
+			$this->template->pfp('out', 'prefooter');
241
+			$this->template->pfp('out', 'footer');
242 242
 		}
243 243
 		/* _debug_array($this->bo->loaded_apps); */
244 244
 		$this->bo->save_sessiondata();
@@ -250,15 +250,15 @@  discard block
 block discarded – undo
250 250
 		{
251 251
 			$GLOBALS['egw']->redirect_link('/index.php', "menuaction=$this->use_app.uilangfile.index");
252 252
 		}
253
-		$app_name   = get_var('app_name',array('POST','GET'));
254
-		$sourcelang = get_var('sourcelang',array('POST','GET'));
255
-		$targetlang = get_var('targetlang',array('POST','GET'));
256
-		$entry       = $_POST['entry'];
253
+		$app_name   = get_var('app_name', array('POST', 'GET'));
254
+		$sourcelang = get_var('sourcelang', array('POST', 'GET'));
255
+		$targetlang = get_var('targetlang', array('POST', 'GET'));
256
+		$entry = $_POST['entry'];
257 257
 
258
-		if($_POST['addphrase'] || $_POST['missingphrase'])
258
+		if ($_POST['addphrase'] || $_POST['missingphrase'])
259 259
 		{
260
-			$GLOBALS['egw']->redirect_link('/index.php',array(
261
-				'menuaction' => $this->use_app.'.uilangfile.'.($_POST['addphrase']?'addphrase':'missingphrase'),
260
+			$GLOBALS['egw']->redirect_link('/index.php', array(
261
+				'menuaction' => $this->use_app.'.uilangfile.'.($_POST['addphrase'] ? 'addphrase' : 'missingphrase'),
262 262
 				'app_name'   => $app_name,
263 263
 				'sourcelang' => $sourcelang,
264 264
 				'targetlang' => $targetlang
@@ -270,95 +270,95 @@  discard block
 block discarded – undo
270 270
 		}
271 271
 		$this->bo->read_sessiondata();
272 272
 
273
-		if($_POST['dlsource'])
273
+		if ($_POST['dlsource'])
274 274
 		{
275
-			$this->download('source',$sourcelang);
275
+			$this->download('source', $sourcelang);
276 276
 		}
277
-		if($_POST['dltarget'])
277
+		if ($_POST['dltarget'])
278 278
 		{
279
-			$this->download('target',$targetlang);
279
+			$this->download('target', $targetlang);
280 280
 		}
281 281
 		$GLOBALS['egw_info']['flags']['css'] .= ".untranslated { background-color: #dab0b0; }\n";
282 282
 		common::egw_header();
283 283
 		echo parse_navbar();
284 284
 
285 285
 		$this->template->set_file(array('langfile' => 'langfile.tpl'));
286
-		$this->template->set_block('langfile','header','header');
287
-		$this->template->set_block('langfile','postheader','postheader');
288
-		$this->template->set_block('langfile','detail','detail');
289
-		$this->template->set_block('langfile','detail_long','detail_long');
290
-		$this->template->set_block('langfile','footer','footer');
291
-
292
-		$this->template->set_var('action_url',$GLOBALS['egw']->link('/index.php', "menuaction=$this->use_app.uilangfile.edit"));
293
-		$this->template->set_var('lang_remove',lang('Remove'));
294
-		$this->template->set_var('lang_application',lang('Application'));
295
-		$this->template->set_var('lang_source',lang('Source Language'));
296
-		$this->template->set_var('lang_target',lang('Target Language'));
297
-		$this->template->set_var('lang_submit',lang('Load'));
298
-		$this->template->set_var('lang_update',lang('Save'));
299
-		$this->template->set_var('lang_revert',lang('Revert'));
300
-		$this->template->set_var('lang_cancel',lang('Cancel'));
301
-		$this->template->set_var('lang_step',lang('Step'));
286
+		$this->template->set_block('langfile', 'header', 'header');
287
+		$this->template->set_block('langfile', 'postheader', 'postheader');
288
+		$this->template->set_block('langfile', 'detail', 'detail');
289
+		$this->template->set_block('langfile', 'detail_long', 'detail_long');
290
+		$this->template->set_block('langfile', 'footer', 'footer');
291
+
292
+		$this->template->set_var('action_url', $GLOBALS['egw']->link('/index.php', "menuaction=$this->use_app.uilangfile.edit"));
293
+		$this->template->set_var('lang_remove', lang('Remove'));
294
+		$this->template->set_var('lang_application', lang('Application'));
295
+		$this->template->set_var('lang_source', lang('Source Language'));
296
+		$this->template->set_var('lang_target', lang('Target Language'));
297
+		$this->template->set_var('lang_submit', lang('Load'));
298
+		$this->template->set_var('lang_update', lang('Save'));
299
+		$this->template->set_var('lang_revert', lang('Revert'));
300
+		$this->template->set_var('lang_cancel', lang('Cancel'));
301
+		$this->template->set_var('lang_step', lang('Step'));
302 302
 		$help = 'onMouseOver="self.status=\'%s\'; return true;" onMouseOut="self.status=\'\'; return true;"';
303
-		$this->template->set_var('cancel_help',sprintf($help,str_replace("'","\\'",lang('Returns to the application list, not saved changes get lost !!!'))));
304
-		$this->template->set_var('load_help',sprintf($help,str_replace("'","\\'",lang('Loads the selected lang-files, to be modified in the next steps'))));
305
-		$this->template->set_var('update_help',sprintf($help,str_replace("'","\\'",lang('Saves the added/changed translations to an internal buffer, to be used in further steps'))));
306
-		$this->template->set_var('search_help',sprintf($help,str_replace("'","\\'",lang('Searches the source-code for phrases not in the actual source-lang-file'))));
307
-		$this->template->set_var('add_help',sprintf($help,str_replace("'","\\'",lang('Allows you to add a single phrase'))));
308
-		$this->template->set_var('revert_help',sprintf($help,str_replace("'","\\'",lang('Clears the internal buffer, all changes made sofar are lost'))));
309
-		$this->template->set_var('download_help',sprintf($help,str_replace("'","\\'",lang('Download the lang-file to be saved in the apps setup-dir'))));
310
-		$this->template->set_var('write_help',sprintf($help,str_replace("'","\\'",lang('Write the lang-file to the apps setup-dir'))));
303
+		$this->template->set_var('cancel_help', sprintf($help, str_replace("'", "\\'", lang('Returns to the application list, not saved changes get lost !!!'))));
304
+		$this->template->set_var('load_help', sprintf($help, str_replace("'", "\\'", lang('Loads the selected lang-files, to be modified in the next steps'))));
305
+		$this->template->set_var('update_help', sprintf($help, str_replace("'", "\\'", lang('Saves the added/changed translations to an internal buffer, to be used in further steps'))));
306
+		$this->template->set_var('search_help', sprintf($help, str_replace("'", "\\'", lang('Searches the source-code for phrases not in the actual source-lang-file'))));
307
+		$this->template->set_var('add_help', sprintf($help, str_replace("'", "\\'", lang('Allows you to add a single phrase'))));
308
+		$this->template->set_var('revert_help', sprintf($help, str_replace("'", "\\'", lang('Clears the internal buffer, all changes made sofar are lost'))));
309
+		$this->template->set_var('download_help', sprintf($help, str_replace("'", "\\'", lang('Download the lang-file to be saved in the apps setup-dir'))));
310
+		$this->template->set_var('write_help', sprintf($help, str_replace("'", "\\'", lang('Write the lang-file to the apps setup-dir'))));
311 311
 
312
-		if(!$sourcelang)
312
+		if (!$sourcelang)
313 313
 		{
314 314
 			$sourcelang = 'en';
315 315
 		}
316
-		if(!$targetlang)
316
+		if (!$targetlang)
317 317
 		{
318 318
 			$targetlang = $GLOBALS['egw_info']['user']['preferences']['common']['lang'];
319 319
 		}
320 320
 
321
-		foreach(translation::list_langs() as $lang_id => $lang_name)
321
+		foreach (translation::list_langs() as $lang_id => $lang_name)
322 322
 		{
323
-			$sourcelangs .= '      <option value="' . $lang_id . '"';
323
+			$sourcelangs .= '      <option value="'.$lang_id.'"';
324 324
 			if ($lang_id == $sourcelang || !$sourcelang && $lang_id == 'en')
325 325
 			{
326 326
 				$sourcelangs .= ' selected="selected"';
327 327
 			}
328
-			$sourcelangs .= '>' . $lang_name . '</option>' . "\n";
328
+			$sourcelangs .= '>'.$lang_name.'</option>'."\n";
329 329
 
330
-			$targetlangs .= '      <option value="' . $lang_id . '"';
330
+			$targetlangs .= '      <option value="'.$lang_id.'"';
331 331
 			if ($lang_id == $targetlang || !$targetlang && $lang_id == 'en')
332 332
 			{
333 333
 				$targetlangs .= ' selected="selected"';
334 334
 			}
335
-			$targetlangs .= '>' . $lang_name . '</option>' . "\n";
335
+			$targetlangs .= '>'.$lang_name.'</option>'."\n";
336 336
 		}
337
-		$this->template->set_var('sourcelangs',$sourcelangs);
338
-		$this->template->set_var('targetlangs',$targetlangs);
339
-		$this->template->set_var('app_name',$app_name);
340
-		$this->template->set_var('app_title',$GLOBALS['egw_info']['apps'][$app_name]['title']);
341
-		$this->template->pfp('out','header');
337
+		$this->template->set_var('sourcelangs', $sourcelangs);
338
+		$this->template->set_var('targetlangs', $targetlangs);
339
+		$this->template->set_var('app_name', $app_name);
340
+		$this->template->set_var('app_title', $GLOBALS['egw_info']['apps'][$app_name]['title']);
341
+		$this->template->pfp('out', 'header');
342 342
 
343
-		foreach($GLOBALS['egw_info']['apps']+array('setup' => array('title' => lang('Setup'))) as $app => $data)
343
+		foreach ($GLOBALS['egw_info']['apps'] + array('setup' => array('title' => lang('Setup'))) as $app => $data)
344 344
 		{
345
-			$userapps .= '<option value="' . $userapp . '"';
345
+			$userapps .= '<option value="'.$userapp.'"';
346 346
 			if ($application_name == $userapp)
347 347
 			{
348 348
 				$userapps .= ' selected="selected"';
349 349
 			}
350
-			$userapps .= '>' . $data['title'] . '</option>' . "\n";
350
+			$userapps .= '>'.$data['title'].'</option>'."\n";
351 351
 		}
352
-		$this->template->set_var('userapps',$userapps);
352
+		$this->template->set_var('userapps', $userapps);
353 353
 
354 354
 		if ($_POST['update'] || $_POST['update_too'])
355 355
 		{
356 356
 			$transapp     = $_POST['transapp'];
357 357
 			$translations = $_POST['translations'];
358 358
 			$deleteme     = $_POST['delete'];
359
-			foreach($transapp as $_mess => $_app)
359
+			foreach ($transapp as $_mess => $_app)
360 360
 			{
361
-				if($_mess)
361
+				if ($_mess)
362 362
 				{
363 363
 					$_mess = strtolower(trim($this->recode_id($_mess)));
364 364
 					$this->bo->source_langarray[$_mess]['app_name'] = $_app;
@@ -369,9 +369,9 @@  discard block
 block discarded – undo
369 369
 			{
370 370
 				$this->bo->target_langarray = array();
371 371
 			}
372
-			foreach($translations as $_mess => $_cont)
372
+			foreach ($translations as $_mess => $_cont)
373 373
 			{
374
-				if($_mess && $_cont)
374
+				if ($_mess && $_cont)
375 375
 				{
376 376
 					$_mess = strtolower(trim($this->recode_id($_mess)));
377 377
 					$this->bo->target_langarray[$_mess]['message_id'] = $_mess;
@@ -381,16 +381,16 @@  discard block
 block discarded – undo
381 381
 						$_cont = stripslashes($_cont);
382 382
 					}
383 383
 					$this->bo->target_langarray[$_mess]['content'] = $_cont;
384
-					if($sourcelang == $targetlang)
384
+					if ($sourcelang == $targetlang)
385 385
 					{
386 386
 						$this->bo->source_langarray[$_mess]['content'] = $_cont;
387 387
 					}
388 388
 				}
389 389
 			}
390 390
 			if ($deleteme)
391
-			foreach($deleteme as $_mess => $_checked)
391
+			foreach ($deleteme as $_mess => $_checked)
392 392
 			{
393
-				if($_checked == 'on')
393
+				if ($_checked == 'on')
394 394
 				{
395 395
 					$_mess = strtolower(trim($this->recode_id($_mess)));
396 396
 					unset($this->bo->source_langarray[$_mess]);
@@ -402,78 +402,78 @@  discard block
 block discarded – undo
402 402
 			/* $this->bo->save_sessiondata($this->bo->source_langarray,$this->bo->target_langarray); */
403 403
 			unset($transapp);
404 404
 			unset($translations);
405
-			if($deleteme)
405
+			if ($deleteme)
406 406
 			{
407 407
 				$this->bo->save_sessiondata();
408 408
 			}
409 409
 			unset($deleteme);
410 410
 		}
411
-		if($_POST['writesource'] || $_POST['writesource_too'])
411
+		if ($_POST['writesource'] || $_POST['writesource_too'])
412 412
 		{
413
-			echo '<br>'.lang("Writing langfile for '%1' ...",$sourcelang);
414
-			$this->bo->write_file('source',$app_name,$sourcelang);
413
+			echo '<br>'.lang("Writing langfile for '%1' ...", $sourcelang);
414
+			$this->bo->write_file('source', $app_name, $sourcelang);
415 415
 		}
416
-		if($_POST['writetarget'] || $_POST['writetarget_too'])
416
+		if ($_POST['writetarget'] || $_POST['writetarget_too'])
417 417
 		{
418
-			echo '<br>'.lang("Writing langfile for '%1' ...",$targetlang);
419
-			$this->bo->write_file('target',$app_name,$targetlang);
418
+			echo '<br>'.lang("Writing langfile for '%1' ...", $targetlang);
419
+			$this->bo->write_file('target', $app_name, $targetlang);
420 420
 		}
421 421
 
422
-		if($sourcelang && $targetlang)
422
+		if ($sourcelang && $targetlang)
423 423
 		{
424
-			$this->template->set_var('lang_appname',lang('Application'));
425
-			$this->template->set_var('lang_message',lang('Message'));
426
-			$this->template->set_var('lang_original',lang('Original'));
427
-			$this->template->set_var('lang_translation',lang('Translation'));
428
-			$this->template->set_var('lang_missingphrase',lang('Search new phrases'));
429
-			$this->template->set_var('lang_addphrase',lang('Add new phrase'));
430
-			$this->template->set_var('sourcelang',$sourcelang);
431
-			$this->template->set_var('targetlang',$targetlang);
432
-			$this->template->pfp('out','postheader');
424
+			$this->template->set_var('lang_appname', lang('Application'));
425
+			$this->template->set_var('lang_message', lang('Message'));
426
+			$this->template->set_var('lang_original', lang('Original'));
427
+			$this->template->set_var('lang_translation', lang('Translation'));
428
+			$this->template->set_var('lang_missingphrase', lang('Search new phrases'));
429
+			$this->template->set_var('lang_addphrase', lang('Add new phrase'));
430
+			$this->template->set_var('sourcelang', $sourcelang);
431
+			$this->template->set_var('targetlang', $targetlang);
432
+			$this->template->pfp('out', 'postheader');
433 433
 
434
-			$langarray = $this->bo->add_app($app_name,$sourcelang);
435
-			$translation = $this->bo->load_app($app_name,$targetlang);
434
+			$langarray = $this->bo->add_app($app_name, $sourcelang);
435
+			$translation = $this->bo->load_app($app_name, $targetlang);
436 436
 
437
-			while(list($key,$data) = @each($langarray))
437
+			while (list($key, $data) = @each($langarray))
438 438
 			{
439 439
 				$mess_id  = $this->encode_id($key);
440 440
 				$content  = html::htmlspecialchars($mess_id == 'charset' ? $mess_id : $data['content']);
441 441
 				$transy   = html::htmlspecialchars($translation[$key]['content']);
442
-				$this->template->set_var('mess_id',$mess_id);
443
-				$this->template->set_var('source_content',$content);
444
-				$this->template->set_var('content',$transy);
445
-				$this->template->set_var('transapp',$this->lang_option($app_name,$data['app_name'],"transapp[$mess_id]"));
446
-				$this->template->set_var('tr_class',empty($transy) ? 'untranslated' : $this->nextmatchs->alternate_row_color('',true));
447
-				if (($len = max(strlen($key),strlen($content))) > 50)
442
+				$this->template->set_var('mess_id', $mess_id);
443
+				$this->template->set_var('source_content', $content);
444
+				$this->template->set_var('content', $transy);
445
+				$this->template->set_var('transapp', $this->lang_option($app_name, $data['app_name'], "transapp[$mess_id]"));
446
+				$this->template->set_var('tr_class', empty($transy) ? 'untranslated' : $this->nextmatchs->alternate_row_color('', true));
447
+				if (($len = max(strlen($key), strlen($content))) > 50)
448 448
 				{
449
-					$this->template->set_var('rows',min(intval($len/80+0.5),10));
450
-					$this->template->pfp('out','detail_long');
449
+					$this->template->set_var('rows', min(intval($len / 80 + 0.5), 10));
450
+					$this->template->pfp('out', 'detail_long');
451 451
 				}
452 452
 				else
453 453
 				{
454
-					$this->template->pfp('out','detail');
454
+					$this->template->pfp('out', 'detail');
455 455
 				}
456 456
 			}
457
-			$this->template->set_var('sourcelang',$sourcelang);
458
-			$this->template->set_var('targetlang',$targetlang);
459
-			$this->template->set_var('lang_write',lang('Write'));
460
-			$this->template->set_var('lang_download',lang('Download'));
461
-			$this->template->set_var('src_file',$this->bo->src_file);
462
-			if(!$this->bo->loaded_apps[$sourcelang]['writeable'])
457
+			$this->template->set_var('sourcelang', $sourcelang);
458
+			$this->template->set_var('targetlang', $targetlang);
459
+			$this->template->set_var('lang_write', lang('Write'));
460
+			$this->template->set_var('lang_download', lang('Download'));
461
+			$this->template->set_var('src_file', $this->bo->src_file);
462
+			if (!$this->bo->loaded_apps[$sourcelang]['writeable'])
463 463
 			{
464
-				$this->template->set_block('footer','srcwrite','srcwrite');
465
-				$this->template->set_var('srcwrite','');
464
+				$this->template->set_block('footer', 'srcwrite', 'srcwrite');
465
+				$this->template->set_var('srcwrite', '');
466 466
 			}
467
-			$this->template->set_var('tgt_file',$this->bo->tgt_file);
468
-			$this->template->set_var('targetlang',$targetlang);
469
-			if(!$this->bo->loaded_apps[$targetlang]['writeable'])
467
+			$this->template->set_var('tgt_file', $this->bo->tgt_file);
468
+			$this->template->set_var('targetlang', $targetlang);
469
+			if (!$this->bo->loaded_apps[$targetlang]['writeable'])
470 470
 			{
471
-				$this->template->set_block('footer','tgtwrite','tgtwrite');
472
-				$this->template->set_var('tgtwrite','');
471
+				$this->template->set_block('footer', 'tgtwrite', 'tgtwrite');
472
+				$this->template->set_var('tgtwrite', '');
473 473
 			}
474 474
 
475
-			$this->template->set_var('helpmsg',lang('you have to [Save] every manual change in the above fields, before you can go to the next step !!!'));
476
-			$this->template->pfp('out','footer');
475
+			$this->template->set_var('helpmsg', lang('you have to [Save] every manual change in the above fields, before you can go to the next step !!!'));
476
+			$this->template->pfp('out', 'footer');
477 477
 		}
478 478
 		/* _debug_array($this->bo->loaded_apps); */
479 479
 		$this->bo->save_sessiondata();
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
 
482 482
 	function encode_id($id)
483 483
 	{
484
-		return str_replace(array('[',']','&','"'),array('%5B','%5D','&amp;','&quot;'),$id);
484
+		return str_replace(array('[', ']', '&', '"'), array('%5B', '%5D', '&amp;', '&quot;'), $id);
485 485
 	}
486 486
 
487 487
 	function recode_id($id)
@@ -490,10 +490,10 @@  discard block
 block discarded – undo
490 490
 		{
491 491
 			$id = stripslashes($id);
492 492
 		}
493
-		return str_replace(array('%5B','%5D'),array('[',']'),$id);	// &amp; + &quot; are recode by php
493
+		return str_replace(array('%5B', '%5D'), array('[', ']'), $id); // &amp; + &quot; are recode by php
494 494
 	}
495 495
 
496
-	function download($which,$userlang)
496
+	function download($which, $userlang)
497 497
 	{
498 498
 		switch ($which)
499 499
 		{
@@ -502,20 +502,20 @@  discard block
 block discarded – undo
502 502
 				break;
503 503
 			case 'target':
504 504
 				// removing phrases not in the source language
505
-				$langarray = $this->bo->target_langarray = array_intersect_assoc($this->bo->target_langarray,$this->bo->source_langarray);
505
+				$langarray = $this->bo->target_langarray = array_intersect_assoc($this->bo->target_langarray, $this->bo->source_langarray);
506 506
 				break;
507 507
 			default:
508 508
 				break;
509 509
 		}
510
-		html::content_header(translation::LANGFILE_PREFIX . $userlang . '.lang');
510
+		html::content_header(translation::LANGFILE_PREFIX.$userlang.'.lang');
511 511
 		$to = translation::charset($userlang);
512 512
 		$from = translation::charset();
513
-		while(list($mess_id,$data) = @each($langarray))
513
+		while (list($mess_id, $data) = @each($langarray))
514 514
 		{
515
-			$content = translation::convert(trim($data['content']),$from,$to);
515
+			$content = translation::convert(trim($data['content']), $from, $to);
516 516
 			if (!empty($content))
517 517
 			{
518
-				echo $mess_id . "\t" . $data['app_name'] . "\t" . $userlang . "\t" . $content . "\n";
518
+				echo $mess_id."\t".$data['app_name']."\t".$userlang."\t".$content."\n";
519 519
 			}
520 520
 		}
521 521
 		common::egw_exit();
@@ -528,15 +528,15 @@  discard block
 block discarded – undo
528 528
 		$order = $_POST['order'];
529 529
 		$query = $_POST['query'];
530 530
 
531
-		$this->bo->save_sessiondata('','');
531
+		$this->bo->save_sessiondata('', '');
532 532
 		$GLOBALS['egw_info']['flags']['app_header'] = $GLOBALS['egw_info']['apps'][$GLOBALS['egw_info']['flags']['currentapp']]['title'].
533 533
 			' - '.lang('Installed applications');
534 534
 		common::egw_header();
535 535
 		echo parse_navbar();
536 536
 
537 537
 		$this->template->set_file(array('applications' => 'applications.tpl'));
538
-		$this->template->set_block('applications','list','list');
539
-		$this->template->set_block('applications','row','row');
538
+		$this->template->set_block('applications', 'list', 'list');
539
+		$this->template->set_block('applications', 'row', 'row');
540 540
 
541 541
 		$offset = $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs'];
542 542
 
@@ -546,18 +546,18 @@  discard block
 block discarded – undo
546 546
 				'title' => lang('Setup')
547 547
 			)
548 548
 		);
549
-		foreach($GLOBALS['egw_info']['apps'] as $app => $data)
549
+		foreach ($GLOBALS['egw_info']['apps'] as $app => $data)
550 550
 		{
551 551
 			$apps[strtolower($data['title'])] = $data;
552 552
 		}
553 553
 		$total = count($apps);
554 554
 
555
-		if(!$sort)
555
+		if (!$sort)
556 556
 		{
557 557
 			$sort = 'ASC';
558 558
 		}
559 559
 
560
-		if($sort == 'ASC')
560
+		if ($sort == 'ASC')
561 561
 		{
562 562
 			ksort($apps);
563 563
 		}
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
 		{
575 575
 			$limit = $start;
576 576
 		}
577
-		elseif(!$start && !$offset)
577
+		elseif (!$start && !$offset)
578 578
 		{
579 579
 			$limit = $total;
580 580
 		}
@@ -589,39 +589,39 @@  discard block
 block discarded – undo
589 589
 			$limit = $total;
590 590
 		}
591 591
 
592
-		$this->template->set_var('sort_title',$this->nextmatchs->show_sort_order($sort,'title','title','/index.php',lang('Title'),"&menuaction=$this->use_app.uilangfile.index"));
593
-		$this->template->set_var('lang_showing',$this->nextmatchs->show_hits($total,$start));
594
-		$this->template->set_var('left',$this->nextmatchs->left('/index.php',$start,$total,"&menuaction=$this->use_app.uilangfile.index"));
595
-		$this->template->set_var('right',$this->nextmatchs->right('/index.php',$start,$total,"&menuaction=$this->use_app.uilangfile.index"));
592
+		$this->template->set_var('sort_title', $this->nextmatchs->show_sort_order($sort, 'title', 'title', '/index.php', lang('Title'), "&menuaction=$this->use_app.uilangfile.index"));
593
+		$this->template->set_var('lang_showing', $this->nextmatchs->show_hits($total, $start));
594
+		$this->template->set_var('left', $this->nextmatchs->left('/index.php', $start, $total, "&menuaction=$this->use_app.uilangfile.index"));
595
+		$this->template->set_var('right', $this->nextmatchs->right('/index.php', $start, $total, "&menuaction=$this->use_app.uilangfile.index"));
596 596
 
597
-		$this->template->set_var('lang_edit',lang('Edit'));
597
+		$this->template->set_var('lang_edit', lang('Edit'));
598 598
 		//$this->template->set_var('lang_translate',lang('Translate'));
599
-		$this->template->set_var('new_action',$GLOBALS['egw']->link('/index.php', "menuaction=$this->use_app.uilangfile.create"));
600
-		$this->template->set_var('create_new',lang('Create New Language File'));
599
+		$this->template->set_var('new_action', $GLOBALS['egw']->link('/index.php', "menuaction=$this->use_app.uilangfile.create"));
600
+		$this->template->set_var('create_new', lang('Create New Language File'));
601 601
 
602 602
 		$i = 0;
603
-		foreach($apps as $data)
603
+		foreach ($apps as $data)
604 604
 		{
605
-			if($start <= $i && $i < $limit)
605
+			if ($start <= $i && $i < $limit)
606 606
 			{
607
-				$this->template->set_var('tr_class',$this->nextmatchs->alternate_row_color('',true));
607
+				$this->template->set_var('tr_class', $this->nextmatchs->alternate_row_color('', true));
608 608
 
609
-				$this->template->set_var('name',$data['title']);
609
+				$this->template->set_var('name', $data['title']);
610 610
 
611
-				$this->template->set_var('edit','<a href="' . $GLOBALS['egw']->link('/index.php', "menuaction=$this->use_app.uilangfile.edit&app_name=" . urlencode($data['name'])) . '"> ' . lang('Edit') . ' </a>');
611
+				$this->template->set_var('edit', '<a href="'.$GLOBALS['egw']->link('/index.php', "menuaction=$this->use_app.uilangfile.edit&app_name=".urlencode($data['name'])).'"> '.lang('Edit').' </a>');
612 612
 			//	$this->template->set_var('translate','<a href="' . $GLOBALS['egw']->link('/index.php',"menuaction=$this->use_app.uilangfile.translate&app_name=" . urlencode($app['name'])) . '"> ' . lang('Translate') . ' </a>');
613 613
 
614
-				$this->template->set_var('status',$status);
614
+				$this->template->set_var('status', $status);
615 615
 
616
-				$this->template->parse('rows','row',True);
616
+				$this->template->parse('rows', 'row', True);
617 617
 			}
618 618
 			++$i;
619 619
 		}
620 620
 
621
-		$this->template->pparse('phpgw_body','list');
621
+		$this->template->pparse('phpgw_body', 'list');
622 622
 	}
623 623
 
624
-	function lang_option($app_name,$current,$name)
624
+	function lang_option($app_name, $current, $name)
625 625
 	{
626 626
 		$list = (is_array($this->bo->src_apps) ? $this->bo->src_apps : array()) + array(
627 627
 			$app_name     => $app_name,
@@ -631,15 +631,15 @@  discard block
 block discarded – undo
631 631
 			'preferences' => 'preferences'
632 632
 		);
633 633
 
634
-		$select  = "\n" .'<select name="' . $name . '">' . "\n";
635
-		foreach($list as $key => $val)
634
+		$select = "\n".'<select name="'.$name.'">'."\n";
635
+		foreach ($list as $key => $val)
636 636
 		{
637
-			$select .= '<option value="' . $key . '"';
637
+			$select .= '<option value="'.$key.'"';
638 638
 			if ($key == $current && $current != '')
639 639
 			{
640 640
 				$select .= ' selected="selected"';
641 641
 			}
642
-			$select .= '>' . $val . '</option>'."\n";
642
+			$select .= '>'.$val.'</option>'."\n";
643 643
 		}
644 644
 
645 645
 		$select .= '</select>'."\n";
Please login to merge, or discard this patch.
Braces   +7 added lines, -2 removed lines patch added patch discarded remove patch
@@ -109,7 +109,10 @@  discard block
 block discarded – undo
109 109
 
110 110
 		$this->template->set_file(array('form' => 'addphrase.tpl'));
111 111
 		$this->template->set_var('message_id_field','<textarea rows="5" style="width: 100%;" name="entry[message_id]"></textarea>');
112
-		if ($app_name == 'api') $app_name = 'common';
112
+		if ($app_name == 'api')
113
+		{
114
+			$app_name = 'common';
115
+		}
113 116
 		$this->template->set_var('app_field',$this->lang_option($app_name,isset($entry)?$entry['app_name']:$app_name,'entry[app_name]'));
114 117
 		$this->template->set_var('translation_field','<textarea rows="5" style="width: 100%;"  name="entry[content]"></textarea>');
115 118
 		$this->template->set_var('target_field','<textarea rows="5" style="width: 100%;" name="entry[target]"></textarea>');
@@ -388,11 +391,13 @@  discard block
 block discarded – undo
388 391
 				}
389 392
 			}
390 393
 			if ($deleteme)
391
-			foreach($deleteme as $_mess => $_checked)
394
+			{
395
+						foreach($deleteme as $_mess => $_checked)
392 396
 			{
393 397
 				if($_checked == 'on')
394 398
 				{
395 399
 					$_mess = strtolower(trim($this->recode_id($_mess)));
400
+			}
396 401
 					unset($this->bo->source_langarray[$_mess]);
397 402
 					unset($this->bo->target_langarray[$_mess]);
398 403
 				}
Please login to merge, or discard this patch.
etemplate/inc/class.url_widget.inc.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -230,7 +230,7 @@
 block discarded – undo
230 230
 	 * replaces '%1' with the phonenumber to call, '%u' with the user's account_lid and '%t' with his work-phone-number
231 231
 	 *
232 232
 	 * @param string $number phone number
233
-	 * @return string|boolean string with link or false if no no telephony integration configured
233
+	 * @return false|string string with link or false if no no telephony integration configured
234 234
 	 */
235 235
 	static function phone2link($number)
236 236
 	{
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -78,15 +78,15 @@  discard block
 block discarded – undo
78 78
 	 * @param object &$tmpl reference to the template we belong too
79 79
 	 * @return boolean true if extra label is allowed, false otherwise
80 80
 	 */
81
-	function pre_process($name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl)
81
+	function pre_process($name, &$value, &$cell, &$readonlys, &$extension_data, &$tmpl)
82 82
 	{
83 83
 		$readonly = $cell['readonly'] || $readonlys;
84 84
 
85
-		switch($cell['type'])
85
+		switch ($cell['type'])
86 86
 		{
87 87
 			case 'url-email':	// size: size,max-size,{2=no validation,1=rfc822 name part allowed, default only email},default if value empty
88
-				list($size,$max_size,$validation_type,$default) = explode(',',$cell['size'],4);	// 4 = allow default to contain commas
89
-				if (!$value) $value = $default;	// use default from size/options if empty
88
+				list($size, $max_size, $validation_type, $default) = explode(',', $cell['size'], 4); // 4 = allow default to contain commas
89
+				if (!$value) $value = $default; // use default from size/options if empty
90 90
 				$cell['no_lang'] = 1;
91 91
 
92 92
 				if (!$readonly)
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 					$cell['size'] = $size.','.$max_size.',';
96 96
 					if ((int)$validation_type < 2)
97 97
 					{
98
-						$cell['size'] .= $cell['needed'] ? '/^(' : '/^(|';	// if not needed allow empty, as EMAIL_PREG does not
98
+						$cell['size'] .= $cell['needed'] ? '/^(' : '/^(|'; // if not needed allow empty, as EMAIL_PREG does not
99 99
 						$cell['size'] .= self::EMAIL_PREG;
100 100
 						if ($validation_type == 1)	// allow rfc822 name part too: Ralf Becker <[email protected]>
101 101
 						{
@@ -108,76 +108,76 @@  discard block
 block discarded – undo
108 108
 					break;
109 109
 				}
110 110
 				$rfc822 = $value;
111
-				if (!(int)$size) $size = 22;	// default size for display
111
+				if (!(int)$size) $size = 22; // default size for display
112 112
 				if (is_numeric($value))
113 113
 				{
114
-					$email = $GLOBALS['egw']->accounts->id2name($value,'account_email');
115
-					$value = $GLOBALS['egw']->accounts->id2name($value,'account_fullname');
114
+					$email = $GLOBALS['egw']->accounts->id2name($value, 'account_email');
115
+					$value = $GLOBALS['egw']->accounts->id2name($value, 'account_fullname');
116 116
 					$rfc822 = $value.' <'.$email.'>';
117 117
 				}
118
-				elseif (preg_match('/^(.*) ?<(.*)>/',$value,$matches))
118
+				elseif (preg_match('/^(.*) ?<(.*)>/', $value, $matches))
119 119
 				{
120 120
 					$value = $matches[1];
121 121
 					$email = $matches[2];
122 122
 				}
123
-				elseif (($at_pos = strpos($email=$value,'@')) !== false)
123
+				elseif (($at_pos = strpos($email = $value, '@')) !== false)
124 124
 				{
125
-					if (($amp_pos = strpos(substr($value,$at_pos),'&')) !== false)
125
+					if (($amp_pos = strpos(substr($value, $at_pos), '&')) !== false)
126 126
 					{
127 127
 						//list($email,$addoptions) = explode('&',$value,2);
128
-						$email = substr($value,0,$amp_pos+$at_pos);
129
-						$addoptions = substr($value, $amp_pos+$at_pos+1);
128
+						$email = substr($value, 0, $amp_pos + $at_pos);
129
+						$addoptions = substr($value, $amp_pos + $at_pos + 1);
130 130
 						//error_log(__METHOD__.__LINE__.$email.' '.$addoptions);
131 131
 						$rfc822 = $value = $email;
132 132
 					}
133 133
 					else
134 134
 					{
135
-						if (($q_pos = strpos(substr($value,$at_pos),'?')) !== false)
135
+						if (($q_pos = strpos(substr($value, $at_pos), '?')) !== false)
136 136
 						{
137
-							$email = substr($value,0,$q_pos+$at_pos);
138
-							$addoptions = substr($value, $q_pos+$at_pos+1);
137
+							$email = substr($value, 0, $q_pos + $at_pos);
138
+							$addoptions = substr($value, $q_pos + $at_pos + 1);
139 139
 							$rfc822 = $value = $email;
140 140
 						}
141 141
 					}
142 142
 					if (strlen($value) > $size)		// shorten the name to size-2 plus '...'
143 143
 					{
144
-						$value = substr($value,0,$size-2).'...';
144
+						$value = substr($value, 0, $size - 2).'...';
145 145
 					}
146 146
 				}
147
-				$link = $this->email2link($email,$rfc822).($addoptions ? '&'.$addoptions : '');
147
+				$link = $this->email2link($email, $rfc822).($addoptions ? '&'.$addoptions : '');
148 148
 
149 149
 				$cell['type'] = 'label';
150
-				$cell['size'] = ','.$link.',,,,'.($link[0]=='f'?'700x750':'').($value != $email ? ','.$email : '');
150
+				$cell['size'] = ','.$link.',,,,'.($link[0] == 'f' ? '700x750' : '').($value != $email ? ','.$email : '');
151 151
 				break;
152 152
 
153 153
 			case 'url':		// options: [size[,max-size[,preg]]]
154
-				list($size,$max_size,$preg) = explode(',',$cell['size'],3); // 3 = allow default to contain commas
154
+				list($size, $max_size, $preg) = explode(',', $cell['size'], 3); // 3 = allow default to contain commas
155 155
 				if (!$readonly)
156 156
 				{
157 157
 					$cell['type'] = 'text';
158
-					$cell['size'] = "$size,$max_size,$preg";	// ,url"; not using html url type, as it requires a scheme
158
+					$cell['size'] = "$size,$max_size,$preg"; // ,url"; not using html url type, as it requires a scheme
159 159
 					// todo: (optional) validation
160 160
 					break;
161 161
 				}
162
-				if (!(int)$size) $size = 24;	// default size for display
162
+				if (!(int)$size) $size = 24; // default size for display
163 163
 				$cell['type'] = 'label';
164 164
 				if ($value)
165 165
 				{
166
-					$link = (strpos($value,'://') === false) ? 'http://'.$value : $value;
166
+					$link = (strpos($value, '://') === false) ? 'http://'.$value : $value;
167 167
 					$cell['size'] = ','.$link.',,,_blank';
168 168
 				}
169
-				if (substr($value,0,7) == 'http://')
169
+				if (substr($value, 0, 7) == 'http://')
170 170
 				{
171
-					$value = substr($value,7);		// cut off http:// in display
171
+					$value = substr($value, 7); // cut off http:// in display
172 172
 				}
173 173
 				if (strlen($value) > $size)		// shorten the name to size-2 plus '...'
174 174
 				{
175
-					$value = substr($value,0,$size-2).'...';
175
+					$value = substr($value, 0, $size - 2).'...';
176 176
 				}
177 177
 				break;
178 178
 
179 179
 			case 'url-phone':		// options: [size[,max-size[,preg]]]
180
-				list($size,$max_size,$preg) = explode(',',$cell['size'],3); // 3 = allow default to contain commas
180
+				list($size, $max_size, $preg) = explode(',', $cell['size'], 3); // 3 = allow default to contain commas
181 181
 				if (!$readonly)
182 182
 				{
183 183
 					$cell['type'] = 'text';
@@ -189,12 +189,12 @@  discard block
 block discarded – undo
189 189
 				if ($value)
190 190
 				{
191 191
 					$link = self::phone2link($value);
192
-					$cell['size'] = ','.$link.($GLOBALS['egw_info']['server']['call_popup']=='none' ? '' :	// 'none' = no target
192
+					$cell['size'] = ','.$link.($GLOBALS['egw_info']['server']['call_popup'] == 'none' ? '' : // 'none' = no target
193 193
 						',,,calling,'.$GLOBALS['egw_info']['server']['call_popup']);
194 194
 				}
195 195
 				break;
196 196
 		}
197
-		return True;	// extra Label Ok
197
+		return True; // extra Label Ok
198 198
 	}
199 199
 
200 200
 	/**
@@ -205,23 +205,23 @@  discard block
 block discarded – undo
205 205
 	 * @param string $rfc822 complete rfc822 addresse to use eg. for fmail
206 206
 	 * @return array/string array with get-params or mailto:$email, or '' or no mail addresse
207 207
 	 */
208
-	static function email2link($email,$rfc822='')
208
+	static function email2link($email, $rfc822 = '')
209 209
 	{
210
-		if (!$email || strpos($email,'@') === false) return '';
210
+		if (!$email || strpos($email, '@') === false) return '';
211 211
 
212 212
 		if (!$GLOBALS['egw_info']['user']['preferences']['addressbook']['force_mailto'])
213 213
 		{
214
-			if($GLOBALS['egw_info']['user']['apps']['felamimail'])
214
+			if ($GLOBALS['egw_info']['user']['apps']['felamimail'])
215 215
 			{
216 216
 				//return 'felamimail.uicompose.compose&preset[to]='.($rfc822 ? $rfc822 : $email);
217 217
 				return 'felamimail.uicompose.compose&send_to='.base64_encode($rfc822 ? $rfc822 : $email);
218 218
 			}
219
-			if($GLOBALS['egw_info']['user']['apps']['email'])
219
+			if ($GLOBALS['egw_info']['user']['apps']['email'])
220 220
 			{
221 221
 				return 'email.uicompose.compose&to='.$email;
222 222
 			}
223 223
 		}
224
-		return 'mailto:' . $email;
224
+		return 'mailto:'.$email;
225 225
 	}
226 226
 
227 227
 	/**
@@ -238,8 +238,8 @@  discard block
 block discarded – undo
238 238
 		if (is_null($call_link))
239 239
 		{
240 240
 			// for iPhone and Android: replace evtl. configured telephony integration link with tel: protocol
241
-			if (strpos($_SERVER['HTTP_USER_AGENT'],'AppleWebKit') !== false &&
242
-				(strpos($_SERVER['HTTP_USER_AGENT'],'iPhone') !== false || strpos($_SERVER['HTTP_USER_AGENT'],'Android') !== false))
241
+			if (strpos($_SERVER['HTTP_USER_AGENT'], 'AppleWebKit') !== false &&
242
+				(strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Android') !== false))
243 243
 			{
244 244
 				$call_link = 'tel:%1';
245 245
 			}
@@ -251,14 +251,14 @@  discard block
 block discarded – undo
251 251
 		if (empty($number) || empty($call_link)) return false;
252 252
 
253 253
 		static $userphone;
254
-		if (is_null($userphone) && strpos($call_link,'%t') !== false)
254
+		if (is_null($userphone) && strpos($call_link, '%t') !== false)
255 255
 		{
256 256
 			$user = $GLOBALS['egw']->contacts->read('account:'.$GLOBALS['egw_info']['user']['account_id']);
257 257
 			$userphone = is_array($user) ? ($user['tel_work'] ? $user['tel_work'] : $user['tel_home']) : false;
258 258
 		}
259
-		$number = preg_replace('/[^0-9+]+/','',str_replace(array('&#9829;','(0)'),'',$number));	// remove number formatting chars messing up the links
259
+		$number = preg_replace('/[^0-9+]+/', '', str_replace(array('&#9829;', '(0)'), '', $number)); // remove number formatting chars messing up the links
260 260
 
261
-		return str_replace(array('%1','%u','%t'),array(urlencode($number),$GLOBALS['egw_info']['user']['account_lid'],$userphone),
261
+		return str_replace(array('%1', '%u', '%t'), array(urlencode($number), $GLOBALS['egw_info']['user']['account_lid'], $userphone),
262 262
 			$call_link);
263 263
 	}
264 264
 }
Please login to merge, or discard this patch.
Braces   +35 added lines, -8 removed lines patch added patch discarded remove patch
@@ -86,7 +86,11 @@  discard block
 block discarded – undo
86 86
 		{
87 87
 			case 'url-email':	// size: size,max-size,{2=no validation,1=rfc822 name part allowed, default only email},default if value empty
88 88
 				list($size,$max_size,$validation_type,$default) = explode(',',$cell['size'],4);	// 4 = allow default to contain commas
89
-				if (!$value) $value = $default;	// use default from size/options if empty
89
+				if (!$value)
90
+				{
91
+					$value = $default;
92
+				}
93
+				// use default from size/options if empty
90 94
 				$cell['no_lang'] = 1;
91 95
 
92 96
 				if (!$readonly)
@@ -97,10 +101,13 @@  discard block
 block discarded – undo
97 101
 					{
98 102
 						$cell['size'] .= $cell['needed'] ? '/^(' : '/^(|';	// if not needed allow empty, as EMAIL_PREG does not
99 103
 						$cell['size'] .= self::EMAIL_PREG;
100
-						if ($validation_type == 1)	// allow rfc822 name part too: Ralf Becker <[email protected]>
104
+						if ($validation_type == 1)
105
+						{
106
+							// allow rfc822 name part too: Ralf Becker <[email protected]>
101 107
 						{
102 108
 							$cell['size'] .= '|[^<]+ ?<'.self::EMAIL_PREG.'>';
103 109
 						}
110
+						}
104 111
 						//$cell['size'] .= ')$/iu,email';// ,email causes browser-side validation. browser is more restrictive, so we disable browserside validation
105 112
 						$cell['size'] .= ')$/iu';
106 113
 					}
@@ -108,7 +115,11 @@  discard block
 block discarded – undo
108 115
 					break;
109 116
 				}
110 117
 				$rfc822 = $value;
111
-				if (!(int)$size) $size = 22;	// default size for display
118
+				if (!(int)$size)
119
+				{
120
+					$size = 22;
121
+				}
122
+				// default size for display
112 123
 				if (is_numeric($value))
113 124
 				{
114 125
 					$email = $GLOBALS['egw']->accounts->id2name($value,'account_email');
@@ -139,10 +150,13 @@  discard block
 block discarded – undo
139 150
 							$rfc822 = $value = $email;
140 151
 						}
141 152
 					}
142
-					if (strlen($value) > $size)		// shorten the name to size-2 plus '...'
153
+					if (strlen($value) > $size)
154
+					{
155
+						// shorten the name to size-2 plus '...'
143 156
 					{
144 157
 						$value = substr($value,0,$size-2).'...';
145 158
 					}
159
+					}
146 160
 				}
147 161
 				$link = $this->email2link($email,$rfc822).($addoptions ? '&'.$addoptions : '');
148 162
 
@@ -159,7 +173,11 @@  discard block
 block discarded – undo
159 173
 					// todo: (optional) validation
160 174
 					break;
161 175
 				}
162
-				if (!(int)$size) $size = 24;	// default size for display
176
+				if (!(int)$size)
177
+				{
178
+					$size = 24;
179
+				}
180
+				// default size for display
163 181
 				$cell['type'] = 'label';
164 182
 				if ($value)
165 183
 				{
@@ -170,10 +188,13 @@  discard block
 block discarded – undo
170 188
 				{
171 189
 					$value = substr($value,7);		// cut off http:// in display
172 190
 				}
173
-				if (strlen($value) > $size)		// shorten the name to size-2 plus '...'
191
+				if (strlen($value) > $size)
192
+				{
193
+					// shorten the name to size-2 plus '...'
174 194
 				{
175 195
 					$value = substr($value,0,$size-2).'...';
176 196
 				}
197
+				}
177 198
 				break;
178 199
 
179 200
 			case 'url-phone':		// options: [size[,max-size[,preg]]]
@@ -207,7 +228,10 @@  discard block
 block discarded – undo
207 228
 	 */
208 229
 	static function email2link($email,$rfc822='')
209 230
 	{
210
-		if (!$email || strpos($email,'@') === false) return '';
231
+		if (!$email || strpos($email,'@') === false)
232
+		{
233
+			return '';
234
+		}
211 235
 
212 236
 		if (!$GLOBALS['egw_info']['user']['preferences']['addressbook']['force_mailto'])
213 237
 		{
@@ -248,7 +272,10 @@  discard block
 block discarded – undo
248 272
 				$call_link = (string)$GLOBALS['egw_info']['server']['call_link'];
249 273
 			}
250 274
 		}
251
-		if (empty($number) || empty($call_link)) return false;
275
+		if (empty($number) || empty($call_link))
276
+		{
277
+			return false;
278
+		}
252 279
 
253 280
 		static $userphone;
254 281
 		if (is_null($userphone) && strpos($call_link,'%t') !== false)
Please login to merge, or discard this patch.
etemplate/inc/class.vfs_widget.inc.php 3 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -368,7 +368,6 @@  discard block
 block discarded – undo
368 368
 	 * @param mixed &$value
369 369
 	 * @param string $path vfs path of download
370 370
 	 * @param string $name name of widget
371
-	 * @param string $label=null label, if not set basename($path) is used
372 371
 	 * @return array
373 372
 	 */
374 373
 	static function file_widget(&$value,$path,$name,$label=null)
@@ -404,7 +403,7 @@  discard block
 block discarded – undo
404 403
 	 * If you rename a file, you have to clear the cache ($clear_after=true)!
405 404
 	 *
406 405
 	 * @param string &$path on call path without extension, if existing on return full path incl. extension
407
-	 * @param boolean $clear_after=null clear file-cache after (true) or before (false), default dont clear
406
+	 * @param boolean $clear_after clear file-cache after (true) or before (false), default dont clear
408 407
 	 * @return
409 408
 	 */
410 409
 	static function file_exists(&$path,$clear_after=null)
Please login to merge, or discard this patch.
Spacing   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	 */
44 44
 	var $public_functions = array(
45 45
 		'pre_process' => True,
46
-		'post_process' => true,		// post_process is only used for vfs-upload (all other widgets set $cell['readlonly']!)
46
+		'post_process' => true, // post_process is only used for vfs-upload (all other widgets set $cell['readlonly']!)
47 47
 	);
48 48
 	/**
49 49
 	 * availible extensions and there names for the editor
@@ -51,14 +51,14 @@  discard block
 block discarded – undo
51 51
 	 * @var array
52 52
 	 */
53 53
 	var $human_name = array(
54
-		'vfs'      => 'File name+link',	// clickable filename, with evtl. clickable path-components
55
-		'vfs-name' => 'File name',		// filename automatically urlencoded
56
-		'vfs-size' => 'File size',		// human readable filesize
57
-		'vfs-mode' => 'File mode',		// posix mode as string eg. drwxr-x---
58
-		'vfs-mime' => 'File icon',		// mime type icon or thumbnail
59
-		'vfs-uid'  => 'File owner',		// Owner of file, or 'root' if none
60
-		'vfs-gid'  => 'File group',		// Group of file, or 'root' if none
61
-		'vfs-upload' => 'VFS file',		// displays either download and delete (x) links or a file upload
54
+		'vfs'      => 'File name+link', // clickable filename, with evtl. clickable path-components
55
+		'vfs-name' => 'File name', // filename automatically urlencoded
56
+		'vfs-size' => 'File size', // human readable filesize
57
+		'vfs-mode' => 'File mode', // posix mode as string eg. drwxr-x---
58
+		'vfs-mime' => 'File icon', // mime type icon or thumbnail
59
+		'vfs-uid'  => 'File owner', // Owner of file, or 'root' if none
60
+		'vfs-gid'  => 'File group', // Group of file, or 'root' if none
61
+		'vfs-upload' => 'VFS file', // displays either download and delete (x) links or a file upload
62 62
 	);
63 63
 
64 64
 	/**
@@ -74,53 +74,53 @@  discard block
 block discarded – undo
74 74
 	 * @param object &$tmpl reference to the template we belong too
75 75
 	 * @return boolean true if extra label is allowed, false otherwise
76 76
 	 */
77
-	function pre_process($form_name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl)
77
+	function pre_process($form_name, &$value, &$cell, &$readonlys, &$extension_data, &$tmpl)
78 78
 	{
79 79
 		//echo "<p>".__METHOD__."($form_name,$value,".array2string($cell).",...)</p>\n";
80 80
 		$type = $cell['type'];
81
-		if (!in_array($type,array('vfs-name','vfs-upload'))) $cell['readonly'] = true;	// to not call post-process
81
+		if (!in_array($type, array('vfs-name', 'vfs-upload'))) $cell['readonly'] = true; // to not call post-process
82 82
 
83 83
 		// check if we have a path and not the raw value, in that case we have to do a stat first
84
-		if (in_array($type,array('vfs-size','vfs-mode','vfs-uid','vfs-gid')) && !is_numeric($value) || $type == 'vfs' && !$value)
84
+		if (in_array($type, array('vfs-size', 'vfs-mode', 'vfs-uid', 'vfs-gid')) && !is_numeric($value) || $type == 'vfs' && !$value)
85 85
 		{
86 86
 			if (!$value || !($stat = egw_vfs::stat($value)))
87 87
 			{
88
-				if ($value) $value = lang("File '%1' not found!",egw_vfs::decodePath($value));
88
+				if ($value) $value = lang("File '%1' not found!", egw_vfs::decodePath($value));
89 89
 				$cell = boetemplate::empty_cell();
90
-				return true;	// allow extra value;
90
+				return true; // allow extra value;
91 91
 			}
92 92
 		}
93 93
 		$cell['type'] = 'label';
94 94
 
95
-		switch($type)
95
+		switch ($type)
96 96
 		{
97 97
 			case 'vfs-upload':		// option: required mimetype or regular expression for mimetype to match, eg. '/^text\//i' for all text files
98
-				if (empty($value) && preg_match('/^exec.*\[([^]]+)\]$/',$form_name,$matches))	// if no value via content array, use widget name
98
+				if (empty($value) && preg_match('/^exec.*\[([^]]+)\]$/', $form_name, $matches))	// if no value via content array, use widget name
99 99
 				{
100 100
 					$value = $matches[1];
101 101
 				}
102 102
 				$extension_data = array('value' => $value, 'mimetype' => $cell['size'], 'type' => $type);
103 103
 				if ($value[0] != '/')
104 104
 				{
105
-					list($app,$id,$relpath) = explode(':',$value,3);
105
+					list($app, $id, $relpath) = explode(':', $value, 3);
106 106
 					if (empty($id))
107 107
 					{
108
-						static $tmppath = array();	// static var, so all vfs-uploads get created in the same temporary dir
108
+						static $tmppath = array(); // static var, so all vfs-uploads get created in the same temporary dir
109 109
 						if (!isset($tmppath[$app])) $tmppath[$app] = '/home/'.$GLOBALS['egw_info']['user']['account_lid'].'/.'.$app.'_'.md5(time().session_id());
110 110
 						$value = $tmppath[$app];
111
-						unset($cell['onchange']);	// no onchange, if we have to use a temporary dir
111
+						unset($cell['onchange']); // no onchange, if we have to use a temporary dir
112 112
 					}
113 113
 					else
114 114
 					{
115
-						$value = egw_link::vfs_path($app,$id,'',true);
115
+						$value = egw_link::vfs_path($app, $id, '', true);
116 116
 					}
117 117
 					if (!empty($relpath)) $value .= '/'.$relpath;
118 118
 				}
119 119
 				$path = $extension_data['path'] = $value;
120
-				if (substr($path,-1) != '/' && self::file_exists($path) && !egw_vfs::is_dir($path))	// display download link and delete icon
120
+				if (substr($path, -1) != '/' && self::file_exists($path) && !egw_vfs::is_dir($path))	// display download link and delete icon
121 121
 				{
122 122
 					$extension_data['path'] = $path;
123
-					$cell = $this->file_widget($value,$path,$cell['name'],$cell['label']);
123
+					$cell = $this->file_widget($value, $path, $cell['name'], $cell['label']);
124 124
 				}
125 125
 				else	// file does NOT exists --> display file upload
126 126
 				{
@@ -136,26 +136,26 @@  discard block
 block discarded – undo
136 136
 						{
137 137
 							$type = $cell['size'];
138 138
 						}
139
-						$cell['help'] = lang('Allowed file type: %1',$type);
139
+						$cell['help'] = lang('Allowed file type: %1', $type);
140 140
 					}
141 141
 				}
142 142
 				// check if directory (trailing slash) is given --> upload of multiple files
143
-				if (substr($path,-1) == '/' && egw_vfs::file_exists($path) && ($files = egw_vfs::scandir($path)))
143
+				if (substr($path, -1) == '/' && egw_vfs::file_exists($path) && ($files = egw_vfs::scandir($path)))
144 144
 				{
145 145
 					//echo $path; _debug_array($files);
146 146
 					$upload = $cell;
147
-					$cell = boetemplate::empty_cell('vbox','',array('size' => ',,0,0'));
147
+					$cell = boetemplate::empty_cell('vbox', '', array('size' => ',,0,0'));
148 148
 					$extension_data['files'] = $files;
149 149
 					$value = array();
150
-					foreach($files as $file)
150
+					foreach ($files as $file)
151 151
 					{
152 152
 						$file = $path.$file;
153 153
 						$basename = basename($file);
154 154
 						unset($widget);
155
-						$widget = $this->file_widget($value[$basename],$file,$upload['name']."[$basename]");
156
-						boetemplate::add_child($cell,$widget);
155
+						$widget = $this->file_widget($value[$basename], $file, $upload['name']."[$basename]");
156
+						boetemplate::add_child($cell, $widget);
157 157
 					}
158
-					boetemplate::add_child($cell,$upload);
158
+					boetemplate::add_child($cell, $upload);
159 159
 				}
160 160
 				break;
161 161
 
@@ -167,23 +167,23 @@  discard block
 block discarded – undo
167 167
 
168 168
 			case 'vfs-mode':
169 169
 				$value = egw_vfs::int2mode(is_numeric($value) ? $value : $stat['mode']);
170
-				list($span,$class) = explode(',',$cell['span'],2);
171
-				$class .= ($class ? ' ' : '') . 'vfsMode';
170
+				list($span, $class) = explode(',', $cell['span'], 2);
171
+				$class .= ($class ? ' ' : '').'vfsMode';
172 172
 				$cell['span'] = $span.','.$class;
173 173
 				$cell['no_lang'] = true;
174 174
 				break;
175 175
 
176 176
 			case 'vfs-uid':
177 177
 			case 'vfs-gid':
178
-				$uid = !is_numeric($value) ? $stat[$type=='vfs-uid'?'uid':'gid'] : $value;
179
-				$value = !$uid ? 'root' : $GLOBALS['egw']->accounts->id2name($type=='vfs-uid'?$uid:-$uid);	// our internal gid's are negative!
178
+				$uid = !is_numeric($value) ? $stat[$type == 'vfs-uid' ? 'uid' : 'gid'] : $value;
179
+				$value = !$uid ? 'root' : $GLOBALS['egw']->accounts->id2name($type == 'vfs-uid' ? $uid : -$uid); // our internal gid's are negative!
180 180
 				break;
181 181
 
182 182
 			case 'vfs':
183 183
 				if (is_array($value))
184 184
 				{
185 185
 					$name = $value['name'];
186
-					$path = substr($value['path'],0,-strlen($name)-1);
186
+					$path = substr($value['path'], 0, -strlen($name) - 1);
187 187
 					$mime = $value['mime'];
188 188
 				}
189 189
 				else
@@ -195,27 +195,27 @@  discard block
 block discarded – undo
195 195
 				}
196 196
 				if (($cell_name = $cell['name']) == '$row')
197 197
 				{
198
-					$arr = explode('][',substr($form_name,0,-1));
198
+					$arr = explode('][', substr($form_name, 0, -1));
199 199
 					$cell_name = array_pop($arr);
200 200
 				}
201 201
 				$cell['name'] = '';
202 202
 				$cell['type'] = 'hbox';
203 203
 				$cell['size'] = '0,,0,0';
204
-				foreach($name != '/' ? explode('/',$name) : array('') as $n => $component)
204
+				foreach ($name != '/' ? explode('/', $name) : array('') as $n => $component)
205 205
 				{
206 206
 					if ($n > (int)($path === '/'))
207 207
 					{
208
-						$sep = soetemplate::empty_cell('label','',array('label' => '/'));
209
-						soetemplate::add_child($cell,$sep);
208
+						$sep = soetemplate::empty_cell('label', '', array('label' => '/'));
209
+						soetemplate::add_child($cell, $sep);
210 210
 						unset($sep);
211 211
 					}
212 212
 					$value['c'.$n] = $component !== '' ? egw_vfs::decodePath($component) : '/';
213 213
 					$path .= ($path != '/' ? '/' : '').$component;
214 214
 					// replace id's in /apps again with human readable titles
215
-					$path_parts = explode('/',$path);
215
+					$path_parts = explode('/', $path);
216 216
 					if ($path_parts[1] == 'apps')
217 217
 					{
218
-						switch(count($path_parts))
218
+						switch (count($path_parts))
219 219
 						{
220 220
 							case 2:
221 221
 								$value['c'.$n] = lang('Applications');
@@ -224,14 +224,14 @@  discard block
 block discarded – undo
224 224
 								$value['c'.$n] = lang($path_parts[2]);
225 225
 								break;
226 226
 							case 4:
227
-								if (is_numeric($value['c'.$n])) $value['c'.$n] .= egw_link::title($path_parts[2],$path_parts[3]);
227
+								if (is_numeric($value['c'.$n])) $value['c'.$n] .= egw_link::title($path_parts[2], $path_parts[3]);
228 228
 								break;
229 229
 						}
230 230
 					}
231 231
 					$popup = null;
232 232
 					if (egw_vfs::is_readable($path))	// show link only if we have access to the file or dir
233 233
 					{
234
-						if ($n < count($comps)-1 || $mime == egw_vfs::DIR_MIME_TYPE || egw_vfs::is_dir($path))
234
+						if ($n < count($comps) - 1 || $mime == egw_vfs::DIR_MIME_TYPE || egw_vfs::is_dir($path))
235 235
 						{
236 236
 							$value['l'.$n] = egw_link::mime_open($path, egw_vfs::DIR_MIME_TYPE, $popup);
237 237
 							$target = '';
@@ -245,36 +245,36 @@  discard block
 block discarded – undo
245 245
 
246 246
 					if ($cell['onclick'])
247 247
 					{
248
-						$comp = boetemplate::empty_cell('button',$cell_name.'[c'.$n.']',array(
248
+						$comp = boetemplate::empty_cell('button', $cell_name.'[c'.$n.']', array(
249 249
 							'size'    => '1',
250 250
 							'no_lang' => true,
251 251
 							'span'    => ',vfsFilename',
252 252
 							'label'   => $value['c'.$n],
253
-							'onclick' => str_replace('$path',"'".addslashes($path)."'",$cell['onclick']),
253
+							'onclick' => str_replace('$path', "'".addslashes($path)."'", $cell['onclick']),
254 254
 						));
255 255
 					}
256 256
 					else
257 257
 					{
258
-						$comp = boetemplate::empty_cell('label',$cell_name.'[c'.$n.']',array(
258
+						$comp = boetemplate::empty_cell('label', $cell_name.'[c'.$n.']', array(
259 259
 							'size'    => ',@'.$cell_name.'[l'.$n.'],,,'.$target.','.$popup,
260 260
 							'no_lang' => true,
261 261
 							'span'    => ',vfsFilename',
262 262
 						));
263 263
 					}
264
-					boetemplate::add_child($cell,$comp);
264
+					boetemplate::add_child($cell, $comp);
265 265
 					unset($comp);
266 266
 				}
267
-				unset($cell['onclick']);	// otherwise it's handled by the grid too
267
+				unset($cell['onclick']); // otherwise it's handled by the grid too
268 268
 				//_debug_array($comps); _debug_array($cell); _debug_array($value);
269 269
 				break;
270 270
 
271 271
 			case 'vfs-name':	// size: [length][,maxLength[,allowPath]]
272 272
 				$cell['type'] = 'text';
273
-				list($length,$maxLength,$allowPath) = $options = explode(',',$cell['size']);
274
-				$preg = $allowPath ? '' : '/[^\\/]/';	// no slash '/' allowed, if not allowPath set
273
+				list($length, $maxLength, $allowPath) = $options = explode(',', $cell['size']);
274
+				$preg = $allowPath ? '' : '/[^\\/]/'; // no slash '/' allowed, if not allowPath set
275 275
 				$cell['size'] = "$length,$maxLength,$preg";
276 276
 				$value = egw_vfs::decodePath($value);
277
-				$extension_data = array('type' => $type,'allowPath' => $allowPath);
277
+				$extension_data = array('type' => $type, 'allowPath' => $allowPath);
278 278
 				break;
279 279
 
280 280
 			case 'vfs-mime':  // size: [thsize] (thumbnail size)
@@ -292,9 +292,9 @@  discard block
 block discarded – undo
292 292
 				}
293 293
 				if (!is_array($value))
294 294
 				{
295
-					if ($value[0] == '/' || count(explode('/',$value)) != 2)
295
+					if ($value[0] == '/' || count(explode('/', $value)) != 2)
296 296
 					{
297
-						$mime = egw_vfs::mime_content_type($path=$value);
297
+						$mime = egw_vfs::mime_content_type($path = $value);
298 298
 					}
299 299
 					else
300 300
 					{
@@ -310,24 +310,24 @@  discard block
 block discarded – undo
310 310
 				$cell['type'] = 'image';
311 311
 				$cell['label'] = mime_magic::mime2label($mime);
312 312
 
313
-				list($mime_main,$mime_sub) = explode('/',$mime);
313
+				list($mime_main, $mime_sub) = explode('/', $mime);
314 314
 				if ($mime_main == 'egw' || isset($GLOBALS['egw_info']['apps'][$mime_main]))
315 315
 				{
316
-					$value = $mime_main == 'egw' ? $mime_sub.'/navbar' : $mime;	// egw-applications for link-widget
316
+					$value = $mime_main == 'egw' ? $mime_sub.'/navbar' : $mime; // egw-applications for link-widget
317 317
 					$cell['label'] = lang($mime_main == 'egw' ? $mime_sub : $mime_main);
318
-					list($span,$class) = explode(',',$cell['span'],2);
319
-					$class .= ($class ? ' ' : '') . 'vfsMimeIcon';
318
+					list($span, $class) = explode(',', $cell['span'], 2);
319
+					$class .= ($class ? ' ' : '').'vfsMimeIcon';
320 320
 					$cell['span'] = $span.','.$class;
321 321
 				}
322
-				elseif($path && $mime_main == 'image' && in_array($mime_sub,array('png','jpeg','jpg','gif','bmp')) &&
322
+				elseif ($path && $mime_main == 'image' && in_array($mime_sub, array('png', 'jpeg', 'jpg', 'gif', 'bmp')) &&
323 323
 					(string)$GLOBALS['egw_info']['server']['link_list_thumbnail'] != '0' &&
324 324
 					(string)$GLOBALS['egw_info']['user']['preferences']['common']['link_list_thumbnail'] != '0' &&
325 325
 					// check the size of the image, as too big images get no icon, but a PHP Fatal error:  Allowed memory size exhausted
326 326
 					(!is_array($value) && ($stat = egw_vfs::stat($path)) ? $stat['size'] : $value['size']) < 1600000)
327 327
 				{
328
-					if (substr($path,0,6) == '/apps/')
328
+					if (substr($path, 0, 6) == '/apps/')
329 329
 					{
330
-						$path = egw_vfs::parse_url(egw_vfs::resolve_url_symlinks($path),PHP_URL_PATH);
330
+						$path = egw_vfs::parse_url(egw_vfs::resolve_url_symlinks($path), PHP_URL_PATH);
331 331
 					}
332 332
 
333 333
 					//Assemble the thumbnail parameters
@@ -345,11 +345,11 @@  discard block
 block discarded – undo
345 345
 					$value = egw_vfs::mime_icon($mime);
346 346
 				}
347 347
 				// mark symlinks (check if method exists, to allow etemplate to run on 1.6 API!)
348
-				if (method_exists('egw_vfs','is_link') && egw_vfs::is_link($path))
348
+				if (method_exists('egw_vfs', 'is_link') && egw_vfs::is_link($path))
349 349
 				{
350 350
 					$broken = !egw_vfs::stat($path);
351
-					list($span,$class) = explode(',',$cell['span'],2);
352
-					$class .= ($class ? ' ' : '') . ($broken ? 'vfsIsBrokenLink' : 'vfsIsLink');
351
+					list($span, $class) = explode(',', $cell['span'], 2);
352
+					$class .= ($class ? ' ' : '').($broken ? 'vfsIsBrokenLink' : 'vfsIsLink');
353 353
 					$cell['span'] = $span.','.$class;
354 354
 					$cell['label'] = ($broken ? lang('Broken link') : lang('Link')).': '.egw_vfs::decodePath(egw_vfs::readlink($path)).
355 355
 						(!$broken ? ' ('.$cell['label'].')' : '');
@@ -371,25 +371,25 @@  discard block
 block discarded – undo
371 371
 	 * @param string $label=null label, if not set basename($path) is used
372 372
 	 * @return array
373 373
 	 */
374
-	static function file_widget(&$value,$path,$name,$label=null)
374
+	static function file_widget(&$value, $path, $name, $label = null)
375 375
 	{
376
-		$value = empty($label) ? egw_vfs::decodePath(egw_vfs::basename($path)) : lang($label);	// display (translated) Label or filename (if label empty)
376
+		$value = empty($label) ? egw_vfs::decodePath(egw_vfs::basename($path)) : lang($label); // display (translated) Label or filename (if label empty)
377 377
 
378
-		$vfs_link = boetemplate::empty_cell('label',$name,array(
378
+		$vfs_link = boetemplate::empty_cell('label', $name, array(
379 379
 			'size' => ','.egw_vfs::download_url($path).',,,_blank,,'.$path,
380 380
 		));
381 381
 		// if dir is writable, add delete link
382 382
 		if (egw_vfs::is_writable(egw_vfs::dirname($path)))
383 383
 		{
384
-			$cell = boetemplate::empty_cell('hbox','',array('size' => ',,0,0'));
385
-			boetemplate::add_child($cell,$vfs_link);
386
-			$delete_icon = boetemplate::empty_cell('button',$path,array(
384
+			$cell = boetemplate::empty_cell('hbox', '', array('size' => ',,0,0'));
385
+			boetemplate::add_child($cell, $vfs_link);
386
+			$delete_icon = boetemplate::empty_cell('button', $path, array(
387 387
 				'label' => 'delete',
388
-				'size'  => 'delete',	// icon
388
+				'size'  => 'delete', // icon
389 389
 				'onclick' => "return confirm('Delete this file');",
390 390
 				'span' => ',leftPad5',
391 391
 			));
392
-			boetemplate::add_child($cell,$delete_icon);
392
+			boetemplate::add_child($cell, $delete_icon);
393 393
 		}
394 394
 		else
395 395
 		{
@@ -407,9 +407,9 @@  discard block
 block discarded – undo
407 407
 	 * @param boolean $clear_after=null clear file-cache after (true) or before (false), default dont clear
408 408
 	 * @return
409 409
 	 */
410
-	static function file_exists(&$path,$clear_after=null)
410
+	static function file_exists(&$path, $clear_after = null)
411 411
 	{
412
-		static $files = array();	// static var, to scan each directory only once
412
+		static $files = array(); // static var, to scan each directory only once
413 413
 		$dir = egw_vfs::dirname($path);
414 414
 		if ($clear_after === false) unset($files[$dir]);
415 415
 		if (!isset($files[$dir])) $files[$dir] = egw_vfs::file_exists($dir) ? egw_vfs::scandir($dir) : array();
@@ -417,9 +417,9 @@  discard block
 block discarded – undo
417 417
 		$basename = egw_vfs::basename($path);
418 418
 		$basename_len = strlen($basename);
419 419
 		$found = false;
420
-		foreach($files[$dir] as $file)
420
+		foreach ($files[$dir] as $file)
421 421
 		{
422
-			if (substr($file,0,$basename_len) == $basename)
422
+			if (substr($file, 0, $basename_len) == $basename)
423 423
 			{
424 424
 				$path = $dir.'/'.$file;
425 425
 				$found = true;
@@ -447,21 +447,21 @@  discard block
 block discarded – undo
447 447
 	 * @param mixed &value_in the posted values (already striped of magic-quotes)
448 448
 	 * @return boolean true if $value has valid content, on false no content will be returned!
449 449
 	 */
450
-	function post_process($name,&$value,&$extension_data,&$loop,&$tmpl,$value_in)
450
+	function post_process($name, &$value, &$extension_data, &$loop, &$tmpl, $value_in)
451 451
 	{
452 452
 		//error_log(__METHOD__."('$name',".array2string($value).','.array2string($extension_data).",$loop,,".array2string($value_in).')');
453 453
 		//echo '<p>'.__METHOD__."('$name',".array2string($value).','.array2string($extension_data).",$loop,,".array2string($value_in).")</p>\n";
454 454
 
455 455
 		if (!$extension_data) return false;
456 456
 
457
-		switch($extension_data['type'])
457
+		switch ($extension_data['type'])
458 458
 		{
459 459
 			case 'vfs-name':
460 460
 				$value = $extension_data['allowPath'] ? egw_vfs::encodePath($value_in) : egw_vfs::encodePathComponent($value_in);
461 461
 				return true;
462 462
 
463 463
 			case 'vfs-upload':
464
-				break;	// handeled below
464
+				break; // handeled below
465 465
 
466 466
 			default:
467 467
 				return false;
@@ -469,18 +469,18 @@  discard block
 block discarded – undo
469 469
 		// from here on vfs-upload only!
470 470
 
471 471
 		// check if delete icon clicked
472
-		if ($_POST['submit_button'] == ($fname = str_replace($extension_data['value'],$extension_data['path'],$name)) ||
473
-			substr($extension_data['path'],-1) == '/' && substr($_POST['submit_button'],0,strlen($fname)-1) == substr($fname,0,-1))
472
+		if ($_POST['submit_button'] == ($fname = str_replace($extension_data['value'], $extension_data['path'], $name)) ||
473
+			substr($extension_data['path'], -1) == '/' && substr($_POST['submit_button'], 0, strlen($fname) - 1) == substr($fname, 0, -1))
474 474
 		{
475
-			if (substr($extension_data['path'],-1) == '/')	// multiple files?
475
+			if (substr($extension_data['path'], -1) == '/')	// multiple files?
476 476
 			{
477
-				foreach($extension_data['files'] as $file)	// check of each single file, to not allow deleting of arbitrary files
477
+				foreach ($extension_data['files'] as $file)	// check of each single file, to not allow deleting of arbitrary files
478 478
 				{
479
-					if ($_POST['submit_button'] == substr($fname,0,-1).$file.']')
479
+					if ($_POST['submit_button'] == substr($fname, 0, -1).$file.']')
480 480
 					{
481 481
 						if (!egw_vfs::unlink($extension_data['path'].$file))
482 482
 						{
483
-							etemplate::set_validation_error($name,lang('Error deleting %1!',egw_vfs::decodePath($extension_data['path'].$file)));
483
+							etemplate::set_validation_error($name, lang('Error deleting %1!', egw_vfs::decodePath($extension_data['path'].$file)));
484 484
 						}
485 485
 						break;
486 486
 					}
@@ -488,24 +488,24 @@  discard block
 block discarded – undo
488 488
 			}
489 489
 			elseif (!egw_vfs::unlink($extension_data['path']))
490 490
 			{
491
-				etemplate::set_validation_error($name,lang('Error deleting %1!',egw_vfs::decodePath($extension_data['path'])));
491
+				etemplate::set_validation_error($name, lang('Error deleting %1!', egw_vfs::decodePath($extension_data['path'])));
492 492
 			}
493 493
 			$loop = true;
494 494
 			return false;
495 495
 		}
496 496
 
497 497
 		// handle file upload
498
-		$name = preg_replace('/^exec\[([^]]+)\](.*)$/','\\1\\2',$name);	// remove exec prefix
498
+		$name = preg_replace('/^exec\[([^]]+)\](.*)$/', '\\1\\2', $name); // remove exec prefix
499 499
 
500
-		if (!is_array($_FILES['exec']) || !($filename = boetemplate::get_array($_FILES['exec']['name'],$name)))
500
+		if (!is_array($_FILES['exec']) || !($filename = boetemplate::get_array($_FILES['exec']['name'], $name)))
501 501
 		{
502
-			return false;	// no file attached
502
+			return false; // no file attached
503 503
 		}
504
-		$tmp_name = boetemplate::get_array($_FILES['exec']['tmp_name'],$name);
505
-		$error = boetemplate::get_array($_FILES['exec']['error'],$name);
504
+		$tmp_name = boetemplate::get_array($_FILES['exec']['tmp_name'], $name);
505
+		$error = boetemplate::get_array($_FILES['exec']['error'], $name);
506 506
 		if ($error)
507 507
 		{
508
-			etemplate::set_validation_error($name,lang('Error uploading file!')."\n".
508
+			etemplate::set_validation_error($name, lang('Error uploading file!')."\n".
509 509
 				etemplate::max_upload_size_message());
510 510
 			$loop = true;
511 511
 			return false;
@@ -517,19 +517,19 @@  discard block
 block discarded – undo
517 517
 		// check if type matches required mime-type, if specified
518 518
 		if (!empty($extension_data['mimetype']))
519 519
 		{
520
-			$type = boetemplate::get_array($_FILES['exec']['type'],$name);
520
+			$type = boetemplate::get_array($_FILES['exec']['type'], $name);
521 521
 			$is_preg = $extension_data['mimetype'][0] == '/';
522
-			if (!$is_preg && strcasecmp($extension_data['mimetype'],$type) || $is_preg && !preg_match($extension_data['mimetype'],$type))
522
+			if (!$is_preg && strcasecmp($extension_data['mimetype'], $type) || $is_preg && !preg_match($extension_data['mimetype'], $type))
523 523
 			{
524
-				etemplate::set_validation_error($name,lang('File is of wrong type (%1 != %2)!',$type,$extension_data['mimetype']));
524
+				etemplate::set_validation_error($name, lang('File is of wrong type (%1 != %2)!', $type, $extension_data['mimetype']));
525 525
 				return false;
526 526
 			}
527 527
 		}
528 528
 		$path = $extension_data['path'];
529
-		if (substr($path,-1) != '/')
529
+		if (substr($path, -1) != '/')
530 530
 		{
531 531
 			// add extension to path
532
-			$parts = explode('.',$filename);
532
+			$parts = explode('.', $filename);
533 533
 			if (($extension = array_pop($parts)) && mime_magic::ext2mime($extension))	// really an extension --> add it to path
534 534
 			{
535 535
 				$path .= '.'.$extension;
@@ -539,17 +539,17 @@  discard block
 block discarded – undo
539 539
 		{
540 540
 			$path .= egw_vfs::encodePathComponent($filename);
541 541
 		}
542
-		if (!egw_vfs::file_exists($dir = egw_vfs::dirname($path)) && !egw_vfs::mkdir($dir,null,STREAM_MKDIR_RECURSIVE))
542
+		if (!egw_vfs::file_exists($dir = egw_vfs::dirname($path)) && !egw_vfs::mkdir($dir, null, STREAM_MKDIR_RECURSIVE))
543 543
 		{
544
-			etemplate::set_validation_error($name,lang('Error create parent directory %1!',egw_vfs::decodePath($dir)));
544
+			etemplate::set_validation_error($name, lang('Error create parent directory %1!', egw_vfs::decodePath($dir)));
545 545
 			return false;
546 546
 		}
547
-		if (!copy($tmp_name,egw_vfs::PREFIX.$path))
547
+		if (!copy($tmp_name, egw_vfs::PREFIX.$path))
548 548
 		{
549
-			etemplate::set_validation_error($name,lang('Error copying uploaded file to vfs!'));
549
+			etemplate::set_validation_error($name, lang('Error copying uploaded file to vfs!'));
550 550
 			return false;
551 551
 		}
552
-		$value = $path;	// return path of file, important if only a temporary location is used
552
+		$value = $path; // return path of file, important if only a temporary location is used
553 553
 
554 554
 		return true;
555 555
 	}
Please login to merge, or discard this patch.
Braces   +61 added lines, -15 removed lines patch added patch discarded remove patch
@@ -78,14 +78,21 @@  discard block
 block discarded – undo
78 78
 	{
79 79
 		//echo "<p>".__METHOD__."($form_name,$value,".array2string($cell).",...)</p>\n";
80 80
 		$type = $cell['type'];
81
-		if (!in_array($type,array('vfs-name','vfs-upload'))) $cell['readonly'] = true;	// to not call post-process
81
+		if (!in_array($type,array('vfs-name','vfs-upload')))
82
+		{
83
+			$cell['readonly'] = true;
84
+		}
85
+		// to not call post-process
82 86
 
83 87
 		// check if we have a path and not the raw value, in that case we have to do a stat first
84 88
 		if (in_array($type,array('vfs-size','vfs-mode','vfs-uid','vfs-gid')) && !is_numeric($value) || $type == 'vfs' && !$value)
85 89
 		{
86 90
 			if (!$value || !($stat = egw_vfs::stat($value)))
87 91
 			{
88
-				if ($value) $value = lang("File '%1' not found!",egw_vfs::decodePath($value));
92
+				if ($value)
93
+				{
94
+					$value = lang("File '%1' not found!",egw_vfs::decodePath($value));
95
+				}
89 96
 				$cell = boetemplate::empty_cell();
90 97
 				return true;	// allow extra value;
91 98
 			}
@@ -95,10 +102,13 @@  discard block
 block discarded – undo
95 102
 		switch($type)
96 103
 		{
97 104
 			case 'vfs-upload':		// option: required mimetype or regular expression for mimetype to match, eg. '/^text\//i' for all text files
98
-				if (empty($value) && preg_match('/^exec.*\[([^]]+)\]$/',$form_name,$matches))	// if no value via content array, use widget name
105
+				if (empty($value) && preg_match('/^exec.*\[([^]]+)\]$/',$form_name,$matches))
106
+				{
107
+					// if no value via content array, use widget name
99 108
 				{
100 109
 					$value = $matches[1];
101 110
 				}
111
+				}
102 112
 				$extension_data = array('value' => $value, 'mimetype' => $cell['size'], 'type' => $type);
103 113
 				if ($value[0] != '/')
104 114
 				{
@@ -106,7 +116,10 @@  discard block
 block discarded – undo
106 116
 					if (empty($id))
107 117
 					{
108 118
 						static $tmppath = array();	// static var, so all vfs-uploads get created in the same temporary dir
109
-						if (!isset($tmppath[$app])) $tmppath[$app] = '/home/'.$GLOBALS['egw_info']['user']['account_lid'].'/.'.$app.'_'.md5(time().session_id());
119
+						if (!isset($tmppath[$app]))
120
+						{
121
+							$tmppath[$app] = '/home/'.$GLOBALS['egw_info']['user']['account_lid'].'/.'.$app.'_'.md5(time().session_id());
122
+						}
110 123
 						$value = $tmppath[$app];
111 124
 						unset($cell['onchange']);	// no onchange, if we have to use a temporary dir
112 125
 					}
@@ -114,12 +127,18 @@  discard block
 block discarded – undo
114 127
 					{
115 128
 						$value = egw_link::vfs_path($app,$id,'',true);
116 129
 					}
117
-					if (!empty($relpath)) $value .= '/'.$relpath;
130
+					if (!empty($relpath))
131
+					{
132
+						$value .= '/'.$relpath;
133
+					}
118 134
 				}
119 135
 				$path = $extension_data['path'] = $value;
120
-				if (substr($path,-1) != '/' && self::file_exists($path) && !egw_vfs::is_dir($path))	// display download link and delete icon
136
+				if (substr($path,-1) != '/' && self::file_exists($path) && !egw_vfs::is_dir($path))
137
+				{
138
+					// display download link and delete icon
121 139
 				{
122 140
 					$extension_data['path'] = $path;
141
+				}
123 142
 					$cell = $this->file_widget($value,$path,$cell['name'],$cell['label']);
124 143
 				}
125 144
 				else	// file does NOT exists --> display file upload
@@ -161,7 +180,10 @@  discard block
 block discarded – undo
161 180
 
162 181
 			case 'vfs-size':	// option: add size in bytes in brackets
163 182
 				$value = egw_vfs::hsize($size = is_numeric($value) ? $value : $stat['size']);
164
-				if ($cell['size']) $value .= ' ('.$size.')';
183
+				if ($cell['size'])
184
+				{
185
+					$value .= ' ('.$size.')';
186
+				}
165 187
 				$cell['type'] = 'label';
166 188
 				break;
167 189
 
@@ -224,16 +246,22 @@  discard block
 block discarded – undo
224 246
 								$value['c'.$n] = lang($path_parts[2]);
225 247
 								break;
226 248
 							case 4:
227
-								if (is_numeric($value['c'.$n])) $value['c'.$n] .= egw_link::title($path_parts[2],$path_parts[3]);
249
+								if (is_numeric($value['c'.$n]))
250
+								{
251
+									$value['c'.$n] .= egw_link::title($path_parts[2],$path_parts[3]);
252
+								}
228 253
 								break;
229 254
 						}
230 255
 					}
231 256
 					$popup = null;
232
-					if (egw_vfs::is_readable($path))	// show link only if we have access to the file or dir
257
+					if (egw_vfs::is_readable($path))
258
+					{
259
+						// show link only if we have access to the file or dir
233 260
 					{
234 261
 						if ($n < count($comps)-1 || $mime == egw_vfs::DIR_MIME_TYPE || egw_vfs::is_dir($path))
235 262
 						{
236 263
 							$value['l'.$n] = egw_link::mime_open($path, egw_vfs::DIR_MIME_TYPE, $popup);
264
+					}
237 265
 							$target = '';
238 266
 						}
239 267
 						else
@@ -411,8 +439,14 @@  discard block
 block discarded – undo
411 439
 	{
412 440
 		static $files = array();	// static var, to scan each directory only once
413 441
 		$dir = egw_vfs::dirname($path);
414
-		if ($clear_after === false) unset($files[$dir]);
415
-		if (!isset($files[$dir])) $files[$dir] = egw_vfs::file_exists($dir) ? egw_vfs::scandir($dir) : array();
442
+		if ($clear_after === false)
443
+		{
444
+			unset($files[$dir]);
445
+		}
446
+		if (!isset($files[$dir]))
447
+		{
448
+			$files[$dir] = egw_vfs::file_exists($dir) ? egw_vfs::scandir($dir) : array();
449
+		}
416 450
 
417 451
 		$basename = egw_vfs::basename($path);
418 452
 		$basename_len = strlen($basename);
@@ -425,7 +459,10 @@  discard block
 block discarded – undo
425 459
 				$found = true;
426 460
 			}
427 461
 		}
428
-		if ($clear_after === true) unset($files[$dir]);
462
+		if ($clear_after === true)
463
+		{
464
+			unset($files[$dir]);
465
+		}
429 466
 		//echo "<p>".__METHOD__."($path) returning ".array2string($found)."</p>\n";
430 467
 		return $found;
431 468
 	}
@@ -452,7 +489,10 @@  discard block
 block discarded – undo
452 489
 		//error_log(__METHOD__."('$name',".array2string($value).','.array2string($extension_data).",$loop,,".array2string($value_in).')');
453 490
 		//echo '<p>'.__METHOD__."('$name',".array2string($value).','.array2string($extension_data).",$loop,,".array2string($value_in).")</p>\n";
454 491
 
455
-		if (!$extension_data) return false;
492
+		if (!$extension_data)
493
+		{
494
+			return false;
495
+		}
456 496
 
457 497
 		switch($extension_data['type'])
458 498
 		{
@@ -472,7 +512,9 @@  discard block
 block discarded – undo
472 512
 		if ($_POST['submit_button'] == ($fname = str_replace($extension_data['value'],$extension_data['path'],$name)) ||
473 513
 			substr($extension_data['path'],-1) == '/' && substr($_POST['submit_button'],0,strlen($fname)-1) == substr($fname,0,-1))
474 514
 		{
475
-			if (substr($extension_data['path'],-1) == '/')	// multiple files?
515
+			if (substr($extension_data['path'],-1) == '/')
516
+			{
517
+				// multiple files?
476 518
 			{
477 519
 				foreach($extension_data['files'] as $file)	// check of each single file, to not allow deleting of arbitrary files
478 520
 				{
@@ -481,6 +523,7 @@  discard block
 block discarded – undo
481 523
 						if (!egw_vfs::unlink($extension_data['path'].$file))
482 524
 						{
483 525
 							etemplate::set_validation_error($name,lang('Error deleting %1!',egw_vfs::decodePath($extension_data['path'].$file)));
526
+			}
484 527
 						}
485 528
 						break;
486 529
 					}
@@ -530,10 +573,13 @@  discard block
 block discarded – undo
530 573
 		{
531 574
 			// add extension to path
532 575
 			$parts = explode('.',$filename);
533
-			if (($extension = array_pop($parts)) && mime_magic::ext2mime($extension))	// really an extension --> add it to path
576
+			if (($extension = array_pop($parts)) && mime_magic::ext2mime($extension))
577
+			{
578
+				// really an extension --> add it to path
534 579
 			{
535 580
 				$path .= '.'.$extension;
536 581
 			}
582
+			}
537 583
 		}
538 584
 		else	// multiple upload with dir given (trailing slash)
539 585
 		{
Please login to merge, or discard this patch.
etemplate/inc/class.xmltool.inc.php 4 patches
Doc Comments   +10 added lines patch added patch discarded remove patch
@@ -158,6 +158,9 @@  discard block
 block discarded – undo
158 158
 			return $this->attributes;
159 159
 		}
160 160
 		
161
+		/**
162
+		 * @param string $comment
163
+		 */
161 164
 		function add_comment ($comment)
162 165
 		{
163 166
 			$this->comments[] = $comment;
@@ -382,6 +385,10 @@  discard block
 block discarded – undo
382 385
 		}
383 386
 
384 387
 		
388
+		/**
389
+		 * @param integer $i
390
+		 * @param xmltool $parent_node
391
+		 */
385 392
 		function import_xml_children($data, &$i, $parent_node)
386 393
 		{
387 394
 			while (++$i < count($data))
@@ -594,6 +601,9 @@  discard block
 block discarded – undo
594 601
 			$this->set_version($version);
595 602
 		}
596 603
 
604
+		/**
605
+		 * @param xmlnode $root_node
606
+		 */
597 607
 		function add_root($root_node)
598 608
 		{
599 609
 			return $this->add_node($root_node);
Please login to merge, or discard this patch.
Spacing   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -12,8 +12,8 @@  discard block
 block discarded – undo
12 12
 
13 13
 	function var2xml($name, $data)
14 14
 	{
15
-		$doc = new xmltool('root','','');
16
-		return $doc->import_var($name,$data,True,True);
15
+		$doc = new xmltool('root', '', '');
16
+		return $doc->import_var($name, $data, True, True);
17 17
 	}
18 18
 
19 19
 	class xmltool
@@ -32,13 +32,13 @@  discard block
 block discarded – undo
32 32
 		var $indentstring = "\t";
33 33
 		
34 34
 		/* start the class as either a root or a node */
35
-		function xmltool ($node_type = 'root', $name='',$indentstring="\t")
35
+		function xmltool($node_type = 'root', $name = '', $indentstring = "\t")
36 36
 		{
37 37
 			$this->node_type = $node_type;
38 38
 			$this->indentstring = $indentstring;
39 39
 			if ($this->node_type == 'node')
40 40
 			{
41
-				if($name != '')
41
+				if ($name != '')
42 42
 				{
43 43
 					$this->name = $name;
44 44
 				}
@@ -50,13 +50,13 @@  discard block
 block discarded – undo
50 50
 			}
51 51
 		}
52 52
 		
53
-		function set_version ($version = '1.0')
53
+		function set_version($version = '1.0')
54 54
 		{
55 55
 			$this->xmlversion = $version;
56 56
 			return True;
57 57
 		}
58 58
 
59
-		function set_doctype ($name, $uri = '')
59
+		function set_doctype($name, $uri = '')
60 60
 		{
61 61
 			if ($this->node_type == 'root')
62 62
 			{
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 			}
70 70
 		}
71 71
 
72
-		function add_node ($node_object, $name = '')
72
+		function add_node($node_object, $name = '')
73 73
 		{
74 74
 			switch ($this->node_type)
75 75
 			{
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 					}
85 85
 					break;
86 86
 				case 'node':
87
-					if(!is_array($this->data))
87
+					if (!is_array($this->data))
88 88
 					{
89 89
 						$this->data = Array();
90 90
 						$this->data_type = 'node';
@@ -109,9 +109,9 @@  discard block
 block discarded – undo
109 109
 			}
110 110
 		}
111 111
 
112
-		function get_node ($name = '')	// what is that function doing: NOTHING !!!
112
+		function get_node($name = '')	// what is that function doing: NOTHING !!!
113 113
 		{
114
-			switch	($this->data_type)
114
+			switch ($this->data_type)
115 115
 			{
116 116
 				case 'root':
117 117
 					break;
@@ -123,16 +123,16 @@  discard block
 block discarded – undo
123 123
 		
124 124
 		}
125 125
 
126
-		function set_value ($string)
126
+		function set_value($string)
127 127
 		{
128 128
 			$this->data = $string;
129 129
 			$this->data_type = 'value';
130 130
 			return True;
131 131
 		}
132 132
 		
133
-		function get_value ()
133
+		function get_value()
134 134
 		{
135
-			if($this->data_type == 'value')
135
+			if ($this->data_type == 'value')
136 136
 			{
137 137
 				return $this->data;
138 138
 			}
@@ -142,32 +142,32 @@  discard block
 block discarded – undo
142 142
 			}
143 143
 		}
144 144
 
145
-		function set_attribute ($name, $value = '')
145
+		function set_attribute($name, $value = '')
146 146
 		{
147 147
 			$this->attributes[$name] = $value;
148 148
 			return True;
149 149
 		}
150 150
 
151
-		function get_attribute ($name)
151
+		function get_attribute($name)
152 152
 		{
153 153
 			return $this->attributes[$name];
154 154
 		}
155 155
 
156
-		function get_attributes ()
156
+		function get_attributes()
157 157
 		{
158 158
 			return $this->attributes;
159 159
 		}
160 160
 		
161
-		function add_comment ($comment)
161
+		function add_comment($comment)
162 162
 		{
163 163
 			$this->comments[] = $comment;
164 164
 			return True;
165 165
 		}
166 166
 
167
-		function import_var($name, $value,$is_root=False,$export_xml=False)
167
+		function import_var($name, $value, $is_root = False, $export_xml = False)
168 168
 		{
169 169
 			//echo "<p>import_var: this->indentstring='$this->indentstring'</p>\n";
170
-			$node = new xmltool('node',$name,$this->indentstring);
170
+			$node = new xmltool('node', $name, $this->indentstring);
171 171
 			switch (gettype($value))
172 172
 			{
173 173
 				case 'string':
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 					$node->set_value($value);
178 178
 					break;
179 179
 				case 'boolean':
180
-					if($value == True)
180
+					if ($value == True)
181 181
 					{
182 182
 						$node->set_value('1');
183 183
 					}
@@ -188,11 +188,11 @@  discard block
 block discarded – undo
188 188
 					break;
189 189
 				case 'array':
190 190
 					$new_index = False;
191
-					while (list ($idxkey, $idxval) = each ($value))
191
+					while (list ($idxkey, $idxval) = each($value))
192 192
 					{
193
-						if(is_array($idxval))
193
+						if (is_array($idxval))
194 194
 						{
195
-							while (list ($k, $i) = each ($idxval))
195
+							while (list ($k, $i) = each($idxval))
196 196
 							{
197 197
 								if (is_int($k))
198 198
 								{
@@ -202,9 +202,9 @@  discard block
 block discarded – undo
202 202
 						}
203 203
 					}
204 204
 					reset($value);	
205
-					while (list ($key, $val) = each ($value))
205
+					while (list ($key, $val) = each($value))
206 206
 					{
207
-						if($new_index)
207
+						if ($new_index)
208 208
 						{
209 209
 							$keyname = $name;
210 210
 							$nextkey = $key;
@@ -220,13 +220,13 @@  discard block
 block discarded – undo
220 220
 							case 'integer':
221 221
 							case 'double':
222 222
 							case 'NULL':
223
-								$subnode = new xmltool('node', $nextkey,$this->indentstring);
223
+								$subnode = new xmltool('node', $nextkey, $this->indentstring);
224 224
 								$subnode->set_value($val);
225 225
 								$node->add_node($subnode);							
226 226
 								break;
227 227
 							case 'boolean':
228
-								$subnode = new xmltool('node', $nextkey,$this->indentstring);
229
-								if($val == True)
228
+								$subnode = new xmltool('node', $nextkey, $this->indentstring);
229
+								if ($val == True)
230 230
 								{
231 231
 									$subnode->set_value('1');
232 232
 								}
@@ -237,9 +237,9 @@  discard block
 block discarded – undo
237 237
 								$node->add_node($subnode);							
238 238
 								break;
239 239
 							case 'array':
240
-								if($new_index)
240
+								if ($new_index)
241 241
 								{
242
-									while (list ($subkey, $subval) = each ($val))
242
+									while (list ($subkey, $subval) = each($val))
243 243
 									{
244 244
 										$node->add_node($this->import_var($nextkey, $subval));
245 245
 									}
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 								}
252 252
 								break;
253 253
 							case 'object':
254
-								$subnode = new xmltool('node', $nextkey,$this->indentstring);
254
+								$subnode = new xmltool('node', $nextkey, $this->indentstring);
255 255
 								$subnode->set_value('PHP_SERIALIZED_OBJECT&:'.serialize($val));
256 256
 								$node->add_node($subnode);							
257 257
 								break;
@@ -275,10 +275,10 @@  discard block
 block discarded – undo
275 275
 					exit;
276 276
 			}
277 277
 	
278
-			if($is_root)
278
+			if ($is_root)
279 279
 			{
280 280
 				$this->add_node($node);
281
-				if($export_xml)
281
+				if ($export_xml)
282 282
 				{
283 283
 					$xml = $this->export_xml();
284 284
 					return $xml;
@@ -297,17 +297,17 @@  discard block
 block discarded – undo
297 297
 
298 298
 		function export_var()
299 299
 		{
300
-			if($this->node_type == 'root')
300
+			if ($this->node_type == 'root')
301 301
 			{
302 302
 				return $this->data->export_var();
303 303
 			}
304 304
 
305
-			if($this->data_type != 'node')
305
+			if ($this->data_type != 'node')
306 306
 			{	
307
-				$found_at = strpos($this->data,'PHP_SERIALIZED_OBJECT&:');
308
-				if($found_at !== False)
307
+				$found_at = strpos($this->data, 'PHP_SERIALIZED_OBJECT&:');
308
+				if ($found_at !== False)
309 309
 				{
310
-					return unserialize(str_replace ('PHP_SERIALIZED_OBJECT&:', '', $this->data));
310
+					return unserialize(str_replace('PHP_SERIALIZED_OBJECT&:', '', $this->data));
311 311
 				}
312 312
 				return $this->data;
313 313
 			}
@@ -315,9 +315,9 @@  discard block
 block discarded – undo
315 315
 			{
316 316
 				$new_index = False;
317 317
 				reset($this->data);
318
-				while(list($key,$val) = each($this->data))
318
+				while (list($key, $val) = each($this->data))
319 319
 				{
320
-					if(!isset($found_keys[$val->name]))
320
+					if (!isset($found_keys[$val->name]))
321 321
 					{
322 322
 						$found_keys[$val->name] = True;
323 323
 					}
@@ -327,10 +327,10 @@  discard block
 block discarded – undo
327 327
 					}
328 328
 				}
329 329
 
330
-				if($new_index)
330
+				if ($new_index)
331 331
 				{
332 332
 					reset($this->data);
333
-					while(list($key,$val) = each($this->data))
333
+					while (list($key, $val) = each($this->data))
334 334
 					{
335 335
 
336 336
 						$return_array[$val->name][] = $val->export_var();
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 				else
340 340
 				{
341 341
 					reset($this->data);
342
-					while(list($key,$val) = each($this->data))
342
+					while (list($key, $val) = each($this->data))
343 343
 					{
344 344
 						$return_array[$val->name] = $val->export_var();
345 345
 					}
@@ -350,19 +350,19 @@  discard block
 block discarded – undo
350 350
 
351 351
 		function export_struct()
352 352
 		{
353
-			if($this->node_type == 'root')
353
+			if ($this->node_type == 'root')
354 354
 			{
355 355
 				return $this->data->export_struct();
356 356
 			}
357 357
 
358 358
 			$retval['tag'] = $this->name;
359 359
 			$retval['attributes'] = $this->attributes;
360
-			if($this->data_type != 'node')
360
+			if ($this->data_type != 'node')
361 361
 			{	
362
-				$found_at = strpos($this->data,'PHP_SERIALIZED_OBJECT&:');
363
-				if($found_at !== False)
362
+				$found_at = strpos($this->data, 'PHP_SERIALIZED_OBJECT&:');
363
+				if ($found_at !== False)
364 364
 				{
365
-					$retval['value'] = unserialize(str_replace ('PHP_SERIALIZED_OBJECT&:', '', $this->data));
365
+					$retval['value'] = unserialize(str_replace('PHP_SERIALIZED_OBJECT&:', '', $this->data));
366 366
 				}
367 367
 				else
368 368
 				{
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 			else
374 374
 			{
375 375
 				reset($this->data);
376
-				while(list($key,$val) = each($this->data))
376
+				while (list($key, $val) = each($this->data))
377 377
 				{
378 378
 					$retval['children'][] = $val->export_struct();
379 379
 				}				
@@ -390,24 +390,24 @@  discard block
 block discarded – undo
390 390
 				{
391 391
 					case 'cdata':
392 392
 					case 'complete':
393
-						$node = new xmltool('node',$data[$i]['tag'],$this->indentstring);
394
-						if(is_array($data[$i]['attributes']) && count($data[$i]['attributes']) > 0)
393
+						$node = new xmltool('node', $data[$i]['tag'], $this->indentstring);
394
+						if (is_array($data[$i]['attributes']) && count($data[$i]['attributes']) > 0)
395 395
 						{
396
-							while(list($k,$v)=each($data[$i]['attributes']))
396
+							while (list($k, $v) = each($data[$i]['attributes']))
397 397
 							{
398
-								$node->set_attribute($k,$v);
398
+								$node->set_attribute($k, $v);
399 399
 							}
400 400
 						}
401 401
 						$node->set_value($data[$i]['value']);
402 402
 						$parent_node->add_node($node);
403 403
 						break;
404 404
 					case 'open':
405
-						$node = new xmltool('node',$data[$i]['tag'],$this->indentstring);
406
-						if(is_array($data[$i]['attributes']) && count($data[$i]['attributes']) > 0)
405
+						$node = new xmltool('node', $data[$i]['tag'], $this->indentstring);
406
+						if (is_array($data[$i]['attributes']) && count($data[$i]['attributes']) > 0)
407 407
 						{
408
-							while(list($k,$v)=each($data[$i]['attributes']))
408
+							while (list($k, $v) = each($data[$i]['attributes']))
409 409
 							{
410
-								$node->set_attribute($k,$v);
410
+								$node->set_attribute($k, $v);
411 411
 							}
412 412
 						}
413 413
 						
@@ -424,14 +424,14 @@  discard block
 block discarded – undo
424 424
 		{
425 425
 			$parser = xml_parser_create();
426 426
 			xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
427
-			xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE,   1);
427
+			xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
428 428
 			xml_parse_into_struct($parser, $xmldata, $vals, $index);
429 429
 			xml_parser_free($parser);
430 430
 			unset($index);	
431
-			$node = new xmltool('node',$vals[0]['tag'],$this->indentstring);
432
-			if(isset($vals[0]['attributes']))
431
+			$node = new xmltool('node', $vals[0]['tag'], $this->indentstring);
432
+			if (isset($vals[0]['attributes']))
433 433
 			{
434
-				while(list($key,$value) = each($vals[0]['attributes']))
434
+				while (list($key, $value) = each($vals[0]['attributes']))
435 435
 				{
436 436
 					$node->set_attribute($key, $value);
437 437
 				}
@@ -458,20 +458,20 @@  discard block
 block discarded – undo
458 458
 			if ($this->node_type == 'root')
459 459
 			{
460 460
 				$result = '<?xml version="'.$this->xmlversion.'"?>'."\n";
461
-				if(count($this->doctype) == 1)
461
+				if (count($this->doctype) == 1)
462 462
 				{
463
-					list($doctype_name,$doctype_uri) = each($this->doctype);
463
+					list($doctype_name, $doctype_uri) = each($this->doctype);
464 464
 					$result .= '<!DOCTYPE '.$doctype_name.' SYSTEM "'.$doctype_uri.'">'."\n";
465 465
 				}
466
-				if(count($this->comments) > 0 )
466
+				if (count($this->comments) > 0)
467 467
 				{
468 468
 					//reset($this->comments);
469
-					while(list($key,$val) = each ($this->comments))
469
+					while (list($key, $val) = each($this->comments))
470 470
 					{
471 471
 						$result .= "<!-- $val -->\n";
472 472
 					}
473 473
 				}
474
-				if(is_object($this->data))
474
+				if (is_object($this->data))
475 475
 				{
476 476
 					$indent = 0;
477 477
 					$result .= $this->data->export_xml($indent);
@@ -486,12 +486,12 @@  discard block
 block discarded – undo
486 486
 				}
487 487
 
488 488
 				$result = $indentstring.'<'.$this->name;
489
-				if(count($this->attributes) > 0 )
489
+				if (count($this->attributes) > 0)
490 490
 				{
491 491
 					reset($this->attributes);
492
-					while(list($key,$val) = each ($this->attributes))
492
+					while (list($key, $val) = each($this->attributes))
493 493
 					{
494
-						if (!is_array($val)) $result .= ' '.$key.'="'.htmlspecialchars($val,ENT_COMPAT,'utf-8').'"';
494
+						if (!is_array($val)) $result .= ' '.$key.'="'.htmlspecialchars($val, ENT_COMPAT, 'utf-8').'"';
495 495
 					}
496 496
 				}
497 497
 
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
 					switch ($this->data_type)
508 508
 					{
509 509
 						case 'value':
510
-							if(is_array($this->data))
510
+							if (is_array($this->data))
511 511
 							{
512 512
 								$type_error = True;
513 513
 								break;
@@ -518,37 +518,37 @@  discard block
 block discarded – undo
518 518
 								$result .= '<![CDATA['.$this->data.']]>';
519 519
 								$endtag_indent = '';		
520 520
 							}
521
-							else*/if(strlen($this->data) > 30 && !empty($this->indentstring))
521
+							else*/if (strlen($this->data) > 30 && !empty($this->indentstring))
522 522
 							{
523
-								$result .= "\n".$indentstring.$this->indentstring.htmlspecialchars($this->data,ENT_COMPAT,'utf-8')."\n";
523
+								$result .= "\n".$indentstring.$this->indentstring.htmlspecialchars($this->data, ENT_COMPAT, 'utf-8')."\n";
524 524
 								$endtag_indent = $indentstring;
525 525
 							}
526 526
 							else
527 527
 							{
528
-								$result .= htmlspecialchars($this->data,ENT_COMPAT,'utf-8');
528
+								$result .= htmlspecialchars($this->data, ENT_COMPAT, 'utf-8');
529 529
 								$endtag_indent = '';
530 530
 							}
531 531
 							break;
532 532
 						case 'node':
533 533
 							$result .= "\n";
534
-							if(!is_array($this->data))
534
+							if (!is_array($this->data))
535 535
 							{
536 536
 								$type_error = True;
537 537
 								break;
538 538
 							}
539 539
 				
540
-							$subindent = $indent+1;
540
+							$subindent = $indent + 1;
541 541
 							reset($this->data);
542
-							while(list($key,$val) = each ($this->data))
542
+							while (list($key, $val) = each($this->data))
543 543
 							{
544
-								if(is_object($val))
544
+								if (is_object($val))
545 545
 								{
546 546
 									$result .= $val->export_xml($subindent);
547 547
 								}
548 548
 							}
549 549
 							break;
550 550
 						default:
551
-						if($this->data != '')
551
+						if ($this->data != '')
552 552
 						{
553 553
 							echo 'Invalid or unset data type ('.$this->data_type.'). This should not be possible if using the class as intended<br>';
554 554
 						}
@@ -560,15 +560,15 @@  discard block
 block discarded – undo
560 560
 					}
561 561
 
562 562
 					$result .= $endtag_indent.'</'.$this->name.'>';
563
-					if($indent != 0)
563
+					if ($indent != 0)
564 564
 					{
565 565
 						$result .= "\n";
566 566
 					}
567 567
 				}
568
-				if(count($this->comments) > 0 )
568
+				if (count($this->comments) > 0)
569 569
 				{
570 570
 					reset($this->comments);
571
-					while(list($key,$val) = each ($this->comments))
571
+					while (list($key, $val) = each($this->comments))
572 572
 					{
573 573
 						$result .= $endtag_indent."<!-- $val -->\n";
574 574
 					}
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
 	{
583 583
 		function xmlnode($name)
584 584
 		{
585
-			$this->xmltool('node',$name);
585
+			$this->xmltool('node', $name);
586 586
 		}
587 587
 	}
588 588
 
Please login to merge, or discard this patch.
Braces   +7 added lines, -4 removed lines patch added patch discarded remove patch
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
 			}
304 304
 
305 305
 			if($this->data_type != 'node')
306
-			{	
306
+			{
307 307
 				$found_at = strpos($this->data,'PHP_SERIALIZED_OBJECT&:');
308 308
 				if($found_at !== False)
309 309
 				{
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 			$retval['tag'] = $this->name;
359 359
 			$retval['attributes'] = $this->attributes;
360 360
 			if($this->data_type != 'node')
361
-			{	
361
+			{
362 362
 				$found_at = strpos($this->data,'PHP_SERIALIZED_OBJECT&:');
363 363
 				if($found_at !== False)
364 364
 				{
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
 			}
421 421
 		}
422 422
 		
423
-		function import_xml($xmldata) 
423
+		function import_xml($xmldata)
424 424
 		{
425 425
 			$parser = xml_parser_create();
426 426
 			xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
@@ -491,7 +491,10 @@  discard block
 block discarded – undo
491 491
 					reset($this->attributes);
492 492
 					while(list($key,$val) = each ($this->attributes))
493 493
 					{
494
-						if (!is_array($val)) $result .= ' '.$key.'="'.htmlspecialchars($val,ENT_COMPAT,'utf-8').'"';
494
+						if (!is_array($val))
495
+						{
496
+							$result .= ' '.$key.'="'.htmlspecialchars($val,ENT_COMPAT,'utf-8').'"';
497
+						}
495 498
 					}
496 499
 				}
497 500
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -20,15 +20,15 @@  discard block
 block discarded – undo
20 20
 	{
21 21
 		/* for root nodes */
22 22
 		var $xmlversion = '1.0';
23
-		var $doctype = Array();
23
+		var $doctype = array();
24 24
 		/* shared */
25 25
 		var $node_type = '';
26 26
 		var $name = '';
27 27
 		var $data_type;
28 28
 		var $data;
29 29
 		/* for nodes */
30
-		var $attributes = Array();
31
-		var $comments = Array();
30
+		var $attributes = array();
31
+		var $comments = array();
32 32
 		var $indentstring = "\t";
33 33
 		
34 34
 		/* start the class as either a root or a node */
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 				case 'node':
87 87
 					if(!is_array($this->data))
88 88
 					{
89
-						$this->data = Array();
89
+						$this->data = array();
90 90
 						$this->data_type = 'node';
91 91
 					}
92 92
 					if (is_object($node_object))
Please login to merge, or discard this patch.
etemplate/thumbnail.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -80,6 +80,7 @@
 block discarded – undo
80 80
 
81 81
 /**
82 82
  * Returns the maximum width/height of a thumbnail
83
+ * @return integer|null
83 84
  */
84 85
 function get_maxsize()
85 86
 {
Please login to merge, or discard this patch.
Spacing   +25 added lines, -26 removed lines patch added patch discarded remove patch
@@ -68,9 +68,9 @@  discard block
 block discarded – undo
68 68
 		}
69 69
 	}
70 70
 
71
-	if (!preg_match('/^[a-z0-9_-]+$/i',$app))
71
+	if (!preg_match('/^[a-z0-9_-]+$/i', $app))
72 72
 	{
73
-		die('Stop');	// just to prevent someone doing nasty things
73
+		die('Stop'); // just to prevent someone doing nasty things
74 74
 	}
75 75
 
76 76
 	return $app;
@@ -81,8 +81,7 @@  discard block
 block discarded – undo
81 81
  */
82 82
 function get_maxsize()
83 83
 {
84
-	$preset = !($GLOBALS['egw_info']['server']['link_list_thumbnail'] > 0) ? 64 :
85
-		$GLOBALS['egw_info']['server']['link_list_thumbnail'];
84
+	$preset = !($GLOBALS['egw_info']['server']['link_list_thumbnail'] > 0) ? 64 : $GLOBALS['egw_info']['server']['link_list_thumbnail'];
86 85
 
87 86
 	// Another maximum size may be passed if thumbnails are turned on
88 87
 	if ($preset != 0 && isset($_GET['thsize']) && is_numeric($_GET['thsize']))
@@ -148,7 +147,7 @@  discard block
 block discarded – undo
148 147
 	}
149 148
 	$dst = gen_dstfile($stat && !empty($stat['url']) ? $stat['url'] : $src, $maxsize, $height, $width, $minsize);
150 149
 	$dst_dir = dirname($dst);
151
-	if(file_exists($dst_dir))
150
+	if (file_exists($dst_dir))
152 151
 	{
153 152
 		// Check whether the destination file already exists and is newer than
154 153
 		// the source file. Assume the file doesn't exist if thumbnailing is turned off.
@@ -188,7 +187,7 @@  discard block
 block discarded – undo
188 187
 		{
189 188
 			// Allow client to cache these, makes scrolling in filemanager much nicer
190 189
 			// setting maximum allow caching time of one year, if url contains (non-empty) moditication time
191
-			egw_session::cache_control(empty($_GET['mtime']) ? 300 : 31536000, true);	// true = private / browser only caching
190
+			egw_session::cache_control(empty($_GET['mtime']) ? 300 : 31536000, true); // true = private / browser only caching
192 191
 			header('Content-Type: '.$output_mime);
193 192
 			readfile($dst);
194 193
 			return true;
@@ -210,7 +209,7 @@  discard block
 block discarded – undo
210 209
  * @param int $minsize =null
211 210
  * @return string
212 211
  */
213
-function gen_dstfile($src, $maxsize, $height=null, $width=null, $minsize=null)
212
+function gen_dstfile($src, $maxsize, $height = null, $width = null, $minsize = null)
214 213
 {
215 214
 	// Use the egroupware file cache to store the thumbnails on a per instance basis
216 215
 	$cachefile = new egw_cache_files(array());
@@ -236,7 +235,7 @@  discard block
 block discarded – undo
236 235
  * TODO: As this is a general purpose function, it might probably be moved
237 236
  *   to some other php file or an "image utils" class.
238 237
  */
239
-function get_scaled_image_size($w, $h, $maxw, $maxh, $minw=0, $minh=0)
238
+function get_scaled_image_size($w, $h, $maxw, $maxh, $minw = 0, $minh = 0)
240 239
 {
241 240
 	//Scale will contain the factor by which the image has to be scaled down
242 241
 	$scale = 1.0;
@@ -297,7 +296,7 @@  discard block
 block discarded – undo
297 296
  * @param int $maxh the maximum height of the thumbnail
298 297
  * @returns boolean|resource false or a gd_image
299 298
  */
300
-function gd_image_load($file,$maxw,$maxh)
299
+function gd_image_load($file, $maxw, $maxh)
301 300
 {
302 301
 	// Get mime type
303 302
 	list($type, $image_type) = explode('/', egw_vfs::mime_content_type($file));
@@ -305,9 +304,9 @@  discard block
 block discarded – undo
305 304
 	if (!$type) list($type, $image_type) = explode('/', mime_magic::filename2mime($file));
306 305
 
307 306
 	// Call the according gd constructor depending on the file type
308
-	if($type == 'image')
307
+	if ($type == 'image')
309 308
 	{
310
-		if (in_array($image_type, array('tiff','jpeg')) && ($image = exif_thumbnail_load($file)))
309
+		if (in_array($image_type, array('tiff', 'jpeg')) && ($image = exif_thumbnail_load($file)))
311 310
 		{
312 311
 			return $image;
313 312
 		}
@@ -326,12 +325,12 @@  discard block
 block discarded – undo
326 325
 	else if ($type == 'application')
327 326
 	{
328 327
 		$thumb = false;
329
-		if(strpos($image_type,'vnd.oasis.opendocument.') === 0)
328
+		if (strpos($image_type, 'vnd.oasis.opendocument.') === 0)
330 329
 		{
331 330
 			// OpenDocuments have thumbnails inside already
332 331
 			$thumb = get_opendocument_thumbnail($file);
333 332
 		}
334
-		else if($image_type == 'pdf')
333
+		else if ($image_type == 'pdf')
335 334
 		{
336 335
 			$thumb = get_pdf_thumbnail($file);
337 336
 		}
@@ -341,7 +340,7 @@  discard block
 block discarded – undo
341 340
 			//$thumb = get_msoffice_thumbnail($file);
342 341
 		}
343 342
 		// Mark it with mime type icon
344
-		if($thumb)
343
+		if ($thumb)
345 344
 		{
346 345
 			// Need to scale first, or the mark will be wrong size
347 346
 			$scaled = get_scaled_image_size(imagesx($thumb), imagesy($thumb), $maxw, $maxh);
@@ -381,8 +380,8 @@  discard block
 block discarded – undo
381 380
 
382 381
 	// Image is already there, but we can't access them directly through VFS
383 382
 	$ext = $mimetype == 'application/vnd.oasis.opendocument.text' ? '.odt' : '.ods';
384
-	$archive = tempnam($GLOBALS['egw_info']['server']['temp_dir'], basename($file,$ext).'-');
385
-	copy($file,$archive);
383
+	$archive = tempnam($GLOBALS['egw_info']['server']['temp_dir'], basename($file, $ext).'-');
384
+	copy($file, $archive);
386 385
 
387 386
 	$thumbnail_url = 'zip://'.$archive.'#Thumbnails/thumbnail.png';
388 387
 	$image = imagecreatefromstring(file_get_contents($thumbnail_url));
@@ -436,7 +435,7 @@  discard block
 block discarded – undo
436 435
  */
437 436
 function get_pdf_thumbnail($file)
438 437
 {
439
-	if(!pdf_thumbnails_available()) return false;
438
+	if (!pdf_thumbnails_available()) return false;
440 439
 
441 440
 	// switch off max_excution_time, as some thumbnails take longer and
442 441
 	// will be startet over and over again, if they dont finish
@@ -465,7 +464,7 @@  discard block
 block discarded – undo
465 464
 	$target_height = imagesy($target_image);
466 465
 
467 466
 	// Find mime image, if no tag image set
468
-	if(!$tag_image && $mime)
467
+	if (!$tag_image && $mime)
469 468
 	{
470 469
 		list($app, $icon) = explode('/', egw_vfs::mime_icon($mime), 2);
471 470
 		list(, $path) = explode($GLOBALS['egw_info']['server']['webserver_url'],
@@ -476,16 +475,16 @@  discard block
 block discarded – undo
476 475
 
477 476
 	// Find correct size - max 1/3 target
478 477
 	$tag_size = get_scaled_image_size(imagesx($tag_image), imagesy($tag_image), $target_width / 3, $target_height / 3);
479
-	if(!$tag_size) return;
480
-	list($tag_width,$tag_height) = $tag_size;
478
+	if (!$tag_size) return;
479
+	list($tag_width, $tag_height) = $tag_size;
481 480
 
482 481
 	// Put it in
483
-	if($mime)
482
+	if ($mime)
484 483
 	{
485
-		imagecopyresampled($target_image,$tag_image,
484
+		imagecopyresampled($target_image, $tag_image,
486 485
 			$target_width - $tag_width,
487 486
 			$target_height - $tag_height,
488
-			0,0,
487
+			0, 0,
489 488
 			$tag_width,
490 489
 			$tag_height,
491 490
 			imagesx($tag_image),
@@ -539,7 +538,7 @@  discard block
 block discarded – undo
539 538
 function gd_image_thumbnail($file, $maxw, $maxh, $minw, $minh)
540 539
 {
541 540
 	//Load the image
542
-	if (($img_src = gd_image_load($file,$maxw,$maxh)) !== false)
541
+	if (($img_src = gd_image_load($file, $maxw, $maxh)) !== false)
543 542
 	{
544 543
 		//Get the constraints of the image
545 544
 		$w = imagesx($img_src);
@@ -569,14 +568,14 @@  discard block
 block discarded – undo
569 568
 */
570 569
 function gdVersion($user_ver = 0)
571 570
 {
572
-	if (! extension_loaded('gd')) { return; }
571
+	if (!extension_loaded('gd')) { return; }
573 572
 	static $gd_ver = 0;
574 573
 
575 574
 	// Just accept the specified setting if it's 1.
576 575
 	if ($user_ver == 1) { $gd_ver = 1; return 1; }
577 576
 
578 577
 	// Use the static variable if function was called previously.
579
-	if ($user_ver !=2 && $gd_ver > 0 ) { return $gd_ver; }
578
+	if ($user_ver != 2 && $gd_ver > 0) { return $gd_ver; }
580 579
 
581 580
 	// Use the gd_info() function if possible.
582 581
 	if (function_exists('gd_info')) {
Please login to merge, or discard this patch.
Braces   +38 added lines, -12 removed lines patch added patch discarded remove patch
@@ -242,10 +242,13 @@  discard block
 block discarded – undo
242 242
 	$scale = 1.0;
243 243
 
244 244
 	//Select the constraining dimension
245
-	if ($w > $h) // landscape image: constraining factor $minh or $maxw
245
+	if ($w > $h)
246
+	{
247
+		// landscape image: constraining factor $minh or $maxw
246 248
 	{
247 249
 		$scale = $minh ? $minh / $h : $maxw / $w;
248 250
 	}
251
+	}
249 252
 	else // portrail image: constraining factor $minw or $maxh
250 253
 	{
251 254
 		$scale = $minw ? $minw / $w : $maxh / $h;
@@ -302,7 +305,10 @@  discard block
 block discarded – undo
302 305
 	// Get mime type
303 306
 	list($type, $image_type) = explode('/', egw_vfs::mime_content_type($file));
304 307
 	// if $file is not from vfs, use mime_magic::filename2mime to get mime-type from extension
305
-	if (!$type) list($type, $image_type) = explode('/', mime_magic::filename2mime($file));
308
+	if (!$type)
309
+	{
310
+		list($type, $image_type) = explode('/', mime_magic::filename2mime($file));
311
+	}
306 312
 
307 313
 	// Call the according gd constructor depending on the file type
308 314
 	if($type == 'image')
@@ -436,7 +442,10 @@  discard block
 block discarded – undo
436 442
  */
437 443
 function get_pdf_thumbnail($file)
438 444
 {
439
-	if(!pdf_thumbnails_available()) return false;
445
+	if(!pdf_thumbnails_available())
446
+	{
447
+		return false;
448
+	}
440 449
 
441 450
 	// switch off max_excution_time, as some thumbnails take longer and
442 451
 	// will be startet over and over again, if they dont finish
@@ -476,7 +485,10 @@  discard block
 block discarded – undo
476 485
 
477 486
 	// Find correct size - max 1/3 target
478 487
 	$tag_size = get_scaled_image_size(imagesx($tag_image), imagesy($tag_image), $target_width / 3, $target_height / 3);
479
-	if(!$tag_size) return;
488
+	if(!$tag_size)
489
+	{
490
+		return;
491
+	}
480 492
 	list($tag_width,$tag_height) = $tag_size;
481 493
 
482 494
 	// Put it in
@@ -569,17 +581,24 @@  discard block
 block discarded – undo
569 581
 */
570 582
 function gdVersion($user_ver = 0)
571 583
 {
572
-	if (! extension_loaded('gd')) { return; }
584
+	if (! extension_loaded('gd'))
585
+	{
586
+return; }
573 587
 	static $gd_ver = 0;
574 588
 
575 589
 	// Just accept the specified setting if it's 1.
576
-	if ($user_ver == 1) { $gd_ver = 1; return 1; }
590
+	if ($user_ver == 1)
591
+	{
592
+$gd_ver = 1; return 1; }
577 593
 
578 594
 	// Use the static variable if function was called previously.
579
-	if ($user_ver !=2 && $gd_ver > 0 ) { return $gd_ver; }
595
+	if ($user_ver !=2 && $gd_ver > 0 )
596
+	{
597
+return $gd_ver; }
580 598
 
581 599
 	// Use the gd_info() function if possible.
582
-	if (function_exists('gd_info')) {
600
+	if (function_exists('gd_info'))
601
+	{
583 602
 		$ver_info = gd_info();
584 603
 		$match = null;
585 604
 		preg_match('/\d/', $ver_info['GD Version'], $match);
@@ -588,11 +607,15 @@  discard block
 block discarded – undo
588 607
 	}
589 608
 
590 609
 	// If phpinfo() is disabled use a specified / fail-safe choice...
591
-	if (preg_match('/phpinfo/', ini_get('disable_functions'))) {
592
-		if ($user_ver == 2) {
610
+	if (preg_match('/phpinfo/', ini_get('disable_functions')))
611
+	{
612
+		if ($user_ver == 2)
613
+		{
593 614
 			$gd_ver = 2;
594 615
 			return 2;
595
-		} else {
616
+		}
617
+		else
618
+		{
596 619
 			$gd_ver = 1;
597 620
 			return 1;
598 621
 		}
@@ -601,6 +624,9 @@  discard block
 block discarded – undo
601 624
 	ob_start();
602 625
 	phpinfo(8);
603 626
 	$info = stristr(ob_get_clean(), 'gd version');
604
-	if (preg_match('/\d/', $info, $match)) $gd_ver = $match[0];
627
+	if (preg_match('/\d/', $info, $match))
628
+	{
629
+		$gd_ver = $match[0];
630
+	}
605 631
 	return $match[0];
606 632
 }
Please login to merge, or discard this patch.
home/inc/class.home_ui.inc.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -150,7 +150,7 @@
 block discarded – undo
150 150
 	 * Get a list of the user's portlets, and their associated values & settings, for display
151 151
 	 *
152 152
 	 * Actual portlet content is provided by each portlet.
153
-	 * @param template etemplate so attributes can be set
153
+	 * @param template etemplate_new so attributes can be set
154 154
 	 */
155 155
 	protected function get_user_portlets(etemplate_new &$template)
156 156
 	{
Please login to merge, or discard this patch.
Spacing   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -45,21 +45,21 @@  discard block
 block discarded – undo
45 45
 		$content = array(
46 46
 			'portlets' => $this->get_user_portlets($template)
47 47
 		);
48
-		$template->setElementAttribute('home.index','actions',$this->get_actions());
48
+		$template->setElementAttribute('home.index', 'actions', $this->get_actions());
49 49
 
50 50
 		$GLOBALS['egw_info']['flags']['app_header'] = lang('home');
51 51
 		$GLOBALS['egw_info']['flags']['currentapp'] = 'home';
52 52
 
53 53
 		// Main screen message
54 54
 		translation::add_app('mainscreen');
55
-		$greeting = translation::translate('mainscreen_message',false,'');
55
+		$greeting = translation::translate('mainscreen_message', false, '');
56 56
 
57
-		if($greeting == 'mainscreen_message'|| empty($greeting))
57
+		if ($greeting == 'mainscreen_message' || empty($greeting))
58 58
 		{
59
-			translation::add_app('mainscreen','en');    // trying the en one
60
-			$greeting = translation::translate('mainscreen_message',false,'');
59
+			translation::add_app('mainscreen', 'en'); // trying the en one
60
+			$greeting = translation::translate('mainscreen_message', false, '');
61 61
 		}
62
-		if(!($greeting == 'mainscreen_message'|| empty($greeting)))
62
+		if (!($greeting == 'mainscreen_message' || empty($greeting)))
63 63
 		{
64 64
 			$content['mainscreen_message'] = $greeting;
65 65
 		}
@@ -67,11 +67,11 @@  discard block
 block discarded – undo
67 67
 		$template->exec('home.home_ui.index', $content);
68 68
 
69 69
 		// Now run the portlets themselves
70
-		foreach($content['portlets'] as $portlet => $p_data)
70
+		foreach ($content['portlets'] as $portlet => $p_data)
71 71
 		{
72 72
 			$id = $p_data['id'];
73 73
 
74
-			if(!$id) continue;
74
+			if (!$id) continue;
75 75
 			$portlet = $this->get_portlet($id, $p_data, $content, $attrs, true);
76 76
 		}
77 77
 
@@ -89,15 +89,15 @@  discard block
 block discarded – undo
89 89
 		$add_portlets = $portlets;
90 90
 		$change_for_add = function(&$add_portlets) use (&$change_for_add)
91 91
 		{
92
-			foreach($add_portlets as $id => &$add)
92
+			foreach ($add_portlets as $id => &$add)
93 93
 			{
94
-				if(is_array($add['children']))
94
+				if (is_array($add['children']))
95 95
 				{
96 96
 					$change_for_add($add['children']);
97 97
 				}
98
-				if($id && !$add['children'])
98
+				if ($id && !$add['children'])
99 99
 				{
100
-					$add['id'] = 'add_' . $id;
100
+					$add['id'] = 'add_'.$id;
101 101
 					$add['class'] = 'add_'.$id;
102 102
 				}
103 103
 			}
@@ -116,10 +116,10 @@  discard block
 block discarded – undo
116 116
 
117 117
 		// Add all known portlets as drop actions too.  If there are multiple matches, there will be a menu
118 118
 		$drop_execute = 'javaScript:app.home.add_from_drop';
119
-		foreach($portlets as $app => &$children)
119
+		foreach ($portlets as $app => &$children)
120 120
 		{
121 121
 			// Home portlets - uses link system, so all apps that support that are accepted
122
-			if(!$children['children'])
122
+			if (!$children['children'])
123 123
 			{
124 124
 				$children['class'] = $app;
125 125
 				$children['onExecute'] = $drop_execute;
@@ -128,11 +128,11 @@  discard block
 block discarded – undo
128 128
 			}
129 129
 			else
130 130
 			{
131
-				foreach($children['children'] as $portlet => $app_portlet)
131
+				foreach ($children['children'] as $portlet => $app_portlet)
132 132
 				{
133
-					if(!is_array($app_portlet)) continue;
133
+					if (!is_array($app_portlet)) continue;
134 134
 					$app_portlet['class'] = $portlet;
135
-					$app_portlet['id'] = 'drop_' . $app_portlet['id'];
135
+					$app_portlet['id'] = 'drop_'.$app_portlet['id'];
136 136
 					$app_portlet['onExecute'] = $drop_execute;
137 137
 					$app_portlet['acceptedTypes'] = $app;
138 138
 					$app_portlet['type'] = 'drop';
@@ -152,13 +152,13 @@  discard block
 block discarded – undo
152 152
 	 * Actual portlet content is provided by each portlet.
153 153
 	 * @param template etemplate so attributes can be set
154 154
 	 */
155
-	protected function get_user_portlets(etemplate_new &$template)
155
+	protected function get_user_portlets(etemplate_new&$template)
156 156
 	{
157 157
 		$portlets = array();
158 158
 
159
-		foreach((array)$GLOBALS['egw_info']['user']['preferences']['home']as $id => $context)
159
+		foreach ((array)$GLOBALS['egw_info']['user']['preferences']['home']as $id => $context)
160 160
 		{
161
-			if(strpos($id,'portlet_') !== 0 || // Not a portlet
161
+			if (strpos($id, 'portlet_') !== 0 || // Not a portlet
162 162
 				in_array($id, array_keys($GLOBALS['egw_info']['user']['apps'])) || // Some other app put it's pref in here
163 163
 				!is_array($context) // Not a valid portlet (probably user deleted a default)
164 164
 			) continue;
@@ -174,12 +174,12 @@  discard block
 block discarded – undo
174 174
 			// Get settings
175 175
 			// Exclude common attributes changed through UI and settings lacking a type
176 176
 			$settings = $portlet->get_properties();
177
-			foreach($settings as $key => $setting)
177
+			foreach ($settings as $key => $setting)
178 178
 			{
179
-				if(is_array($setting) && !array_key_exists('type',$setting)) unset($settings[$key]);
179
+				if (is_array($setting) && !array_key_exists('type', $setting)) unset($settings[$key]);
180 180
 			}
181 181
 			$settings += $context;
182
-			foreach(home_portlet::$common_attributes as $attr)
182
+			foreach (home_portlet::$common_attributes as $attr)
183 183
 			{
184 184
 				unset($settings[$attr]);
185 185
 			}
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 			// Add in default for admins
193 193
 			self::create_default_actions($actions, $id);
194 194
 
195
-			$template->setElementAttribute("portlets[" . count($portlets) . "[$id]", 'actions', $actions);
195
+			$template->setElementAttribute("portlets[".count($portlets)."[$id]", 'actions', $actions);
196 196
 
197 197
 			$portlets[] = $portlet_content;
198 198
 		}
@@ -216,11 +216,11 @@  discard block
 block discarded – undo
216 216
 	 */
217 217
 	protected function get_portlet($id, &$context, &$content, &$attributes, $full_exec = false)
218 218
 	{
219
-		if(!$context['class']) $context['class'] = 'home_link_portlet';
219
+		if (!$context['class']) $context['class'] = 'home_link_portlet';
220 220
 
221 221
 		// This should be set already, but just in case the execution path
222 222
 		// is different from normal...
223
-		if(egw_json_response::isJSONResponse())
223
+		if (egw_json_response::isJSONResponse())
224 224
 		{
225 225
 			$GLOBALS['egw']->framework->response = egw_json_response::get();
226 226
 		}
@@ -235,12 +235,12 @@  discard block
 block discarded – undo
235 235
 
236 236
 		// Exclude common attributes changed through UI and settings lacking a type
237 237
 		$settings = $portlet->get_properties();
238
-		foreach($settings as $key => $setting)
238
+		foreach ($settings as $key => $setting)
239 239
 		{
240
-			if(is_array($setting) && !array_key_exists('type',$setting)) unset($settings[$key]);
240
+			if (is_array($setting) && !array_key_exists('type', $setting)) unset($settings[$key]);
241 241
 		}
242 242
 		$settings += $context;
243
-		foreach(home_portlet::$common_attributes as $attr)
243
+		foreach (home_portlet::$common_attributes as $attr)
244 244
 		{
245 245
 			unset($settings[$attr]);
246 246
 		}
@@ -255,31 +255,31 @@  discard block
 block discarded – undo
255 255
 		self::create_default_actions($attributes['actions'], $id);
256 256
 
257 257
 		// Set any provided common attributes (size, etc)
258
-		foreach(home_portlet::$common_attributes as $name)
258
+		foreach (home_portlet::$common_attributes as $name)
259 259
 		{
260
-			if(array_key_exists($name, $context))
260
+			if (array_key_exists($name, $context))
261 261
 			{
262 262
 				$attributes[$name] = $context[$name];
263 263
 			}
264 264
 		}
265
-		foreach($attributes as $attr => $value)
265
+		foreach ($attributes as $attr => $value)
266 266
 		{
267 267
 			$etemplate->setElementAttribute($id, $attr, $value);
268 268
 		}
269 269
 
270 270
 		// Make sure custom javascript is loaded
271 271
 		$appname = $context['appname'];
272
-		if(!$appname)
272
+		if (!$appname)
273 273
 		{
274
-			list($app) = explode('_',$classname);
275
-			if($GLOBALS['egw_info']['apps'][$app])
274
+			list($app) = explode('_', $classname);
275
+			if ($GLOBALS['egw_info']['apps'][$app])
276 276
 			{
277 277
 				$appname = $app;
278 278
 			}
279 279
 		}
280 280
 		egw_framework::validate_file('', $classname, $appname ? $appname : 'home');
281 281
 
282
-		if($full_exec)
282
+		if ($full_exec)
283 283
 		{
284 284
 			$content = $portlet->exec($id, $etemplate, $full_exec ? 2 : -1);
285 285
 		}
@@ -296,23 +296,23 @@  discard block
 block discarded – undo
296 296
 	protected function get_legacy_portlets(&$content, &$attributes)
297 297
 	{
298 298
 		$sorted_apps = array_keys($GLOBALS['egw_info']['user']['apps']);
299
-		$portal_oldvarnames = array('mainscreen_showevents', 'homeShowEvents','homeShowLatest','mainscreen_showmail','mainscreen_showbirthdays','mainscreen_show_new_updated', 'homepage_display');
299
+		$portal_oldvarnames = array('mainscreen_showevents', 'homeShowEvents', 'homeShowLatest', 'mainscreen_showmail', 'mainscreen_showbirthdays', 'mainscreen_show_new_updated', 'homepage_display');
300 300
 
301
-		foreach($sorted_apps as $appname)
301
+		foreach ($sorted_apps as $appname)
302 302
 		{
303 303
 			// If there's already [new] settings, or no preference, skip it
304
-			if($content[$appname]) continue;
304
+			if ($content[$appname]) continue;
305 305
 			$no_pref = true;
306
-			foreach($portal_oldvarnames as $varcheck)
306
+			foreach ($portal_oldvarnames as $varcheck)
307 307
 			{
308 308
 				$thisd = $GLOBALS['egw_info']['user']['preferences'][$appname][$varcheck];
309
-				if($thisd)
309
+				if ($thisd)
310 310
 				{
311 311
 					$no_pref = false;
312 312
 					break;
313 313
 				}
314 314
 			}
315
-			if($no_pref || !$GLOBALS['egw']->hooks->hook_exists('home', $appname))
315
+			if ($no_pref || !$GLOBALS['egw']->hooks->hook_exists('home', $appname))
316 316
 			{
317 317
 				continue;
318 318
 			}
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 			$_content = '';
324 324
 			$_attributes = array();
325 325
 			$this->get_portlet($appname, $context, $_content, $_attributes);
326
-			if(trim($_content))
326
+			if (trim($_content))
327 327
 			{
328 328
 				$content[$appname] = $_content;
329 329
 				$attributes[$appname] = $_attributes;
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 
343 343
 			// Ignore some problem files and base classes that shouldn't be options
344 344
 			$ignore = array(
345
-				'.','..',
345
+				'.', '..',
346 346
 				'class.home_portlet.inc.php',
347 347
 				'class.home_legacy_portlet.inc.php',
348 348
 				'class.home_favorite_portlet.inc.php',
@@ -350,18 +350,18 @@  discard block
 block discarded – undo
350 350
 				'class.home_weather_portlet.inc.php'
351 351
 			);
352 352
 			// Look through all known classes for portlets - for now, they need 'portlet' in the file name
353
-			foreach(array_keys($GLOBALS['egw_info']['apps']) as $appname)
353
+			foreach (array_keys($GLOBALS['egw_info']['apps']) as $appname)
354 354
 			{
355
-				if(in_array($appname, array('phpgwapi', 'felamimail'))) continue;
356
-				$files = (array)@scandir(EGW_SERVER_ROOT . '/'.$appname .'/inc/');
357
-				if(!$files) continue;
355
+				if (in_array($appname, array('phpgwapi', 'felamimail'))) continue;
356
+				$files = (array)@scandir(EGW_SERVER_ROOT.'/'.$appname.'/inc/');
357
+				if (!$files) continue;
358 358
 
359
-				foreach($files as $entry)
359
+				foreach ($files as $entry)
360 360
 				{
361
-					if (!in_array($entry, $ignore) && substr($entry,-8) == '.inc.php' && strpos($entry,'portlet'))
361
+					if (!in_array($entry, $ignore) && substr($entry, -8) == '.inc.php' && strpos($entry, 'portlet'))
362 362
 					{
363 363
 						list(,$classname) = explode('.', $entry);
364
-						if(class_exists($classname) &&
364
+						if (class_exists($classname) &&
365 365
 							in_array('home_portlet', class_parents($classname, false)))
366 366
 						{
367 367
 							$classes[$appname][] = $classname;
@@ -373,19 +373,19 @@  discard block
 block discarded – undo
373 373
 					}
374 374
 				}
375 375
 
376
-				if(!$classes[$appname]) continue;
376
+				if (!$classes[$appname]) continue;
377 377
 
378 378
 				// Build 'Add' actions for each discovered portlet.
379 379
 				// Portlets from other apps go in sub-actions
380
-				$add_to =& $list;
381
-				if($classes[$appname] && $appname != 'home')
380
+				$add_to = & $list;
381
+				if ($classes[$appname] && $appname != 'home')
382 382
 				{
383 383
 					$list[$appname] = array(
384 384
 						'caption' => lang($appname),
385 385
 					);
386
-					$add_to =& $list[$appname]['children'];
386
+					$add_to = & $list[$appname]['children'];
387 387
 				}
388
-				foreach($classes[$appname] as $portlet)
388
+				foreach ($classes[$appname] as $portlet)
389 389
 				{
390 390
 					$instance = new $portlet();
391 391
 					$desc = $instance->get_description();
@@ -405,10 +405,10 @@  discard block
 block discarded – undo
405 405
 		}, array(), 60);
406 406
 
407 407
 		// Filter list by current user's permissions
408
-		foreach($list as $appname => $children)
408
+		foreach ($list as $appname => $children)
409 409
 		{
410
-			if(in_array($appname, array_keys($GLOBALS['egw_info']['apps']))) {
411
-				if(!in_array($appname, array_keys($GLOBALS['egw_info']['user']['apps'])))
410
+			if (in_array($appname, array_keys($GLOBALS['egw_info']['apps']))) {
411
+				if (!in_array($appname, array_keys($GLOBALS['egw_info']['user']['apps'])))
412 412
 				{
413 413
 					unset($list[$appname]);
414 414
 				}
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 	 */
426 426
 	protected static function create_default_actions(&$actions, $portlet_id = null)
427 427
 	{
428
-		if($GLOBALS['egw_info']['user']['apps']['admin'])
428
+		if ($GLOBALS['egw_info']['user']['apps']['admin'])
429 429
 		{
430 430
 			$actions['add_default'] = array(
431 431
 				'type'		=> 'popup',
@@ -435,25 +435,25 @@  discard block
 block discarded – undo
435 435
 				'icon'		=> 'preference'
436 436
 			);
437 437
 			// Customize for the given portlet
438
-			if($portlet_id !== null)
438
+			if ($portlet_id !== null)
439 439
 			{
440
-				foreach(array('forced','group','default') as $location)
440
+				foreach (array('forced', 'group', 'default') as $location)
441 441
 				{
442 442
 					$loc = $GLOBALS['egw']->preferences->$location;
443 443
 
444
-					if($loc['home'][$portlet_id])
444
+					if ($loc['home'][$portlet_id])
445 445
 					{
446 446
 						// If it's forced, no point in setting default
447
-						if($location == 'forced')
447
+						if ($location == 'forced')
448 448
 						{
449 449
 							unset($actions['add_default']);
450 450
 						}
451 451
 						// If it's a group, we'd like to know which
452
-						if($location == 'group')
452
+						if ($location == 'group')
453 453
 						{
454 454
 							$options = array('account_type' => $type);
455
-							$groups = accounts::link_query('',$options);
456
-							foreach($groups as $gid => $name)
455
+							$groups = accounts::link_query('', $options);
456
+							foreach ($groups as $gid => $name)
457 457
 							{
458 458
 								$prefs = new preferences($gid);
459 459
 								$prefs->read_repository();
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 						}
467 467
 						$actions['remove_default_'.$location] = array(
468 468
 							'type'		=> 'popup',
469
-							'caption'	=> lang('Remove default %1',is_numeric($location) ? accounts::id2name($location) : $location),
469
+							'caption'	=> lang('Remove default %1', is_numeric($location) ? accounts::id2name($location) : $location),
470 470
 							'onExecute'	=> 'javaScript:app.home.set_default',
471 471
 							'group'		=> 'Admins',
472 472
 							'portlet_group' => $location
@@ -477,14 +477,14 @@  discard block
 block discarded – undo
477 477
 		}
478 478
 
479 479
 		// Change action for forced
480
-		if($portlet_id && $GLOBALS['egw']->preferences->forced['home'][$portlet_id])
480
+		if ($portlet_id && $GLOBALS['egw']->preferences->forced['home'][$portlet_id])
481 481
 		{
482 482
 			// No one can remove it
483 483
 			$actions['remove_portlet']['enabled'] = false;
484
-			$actions['remove_portlet']['caption'] .= ' ('.lang('Forced') .')';
484
+			$actions['remove_portlet']['caption'] .= ' ('.lang('Forced').')';
485 485
 
486 486
 			// Non-admins can't edit it
487
-			if($actions['edit_settings'] && !$GLOBALS['egw_info']['user']['apps']['admin'])
487
+			if ($actions['edit_settings'] && !$GLOBALS['egw_info']['user']['apps']['admin'])
488 488
 			{
489 489
 				$actions['edit_settings']['enabled'] = false;
490 490
 				$actions['edit_settings']['visible'] = false;
@@ -503,14 +503,14 @@  discard block
 block discarded – undo
503 503
 	public function ajax_set_properties($portlet_id, $attributes, $values, $group = false)
504 504
 	{
505 505
 		//error_log(__METHOD__ . "($portlet_id, " .array2string($attributes).','.array2string($values).",$group)");
506
-		if(!$attributes)
506
+		if (!$attributes)
507 507
 		{
508 508
 			$attributes = array();
509 509
 		}
510 510
 
511
-		if(!$GLOBALS['egw_info']['user']['apps']['admin'])
511
+		if (!$GLOBALS['egw_info']['user']['apps']['admin'])
512 512
 		{
513
-			if($group == 'forced')
513
+			if ($group == 'forced')
514 514
 			{
515 515
 				// Quietly reject
516 516
 				return;
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
 			// Not an admin, can only override.
519 519
 			$group = false;
520 520
 		}
521
-		if($group && $GLOBALS['egw_info']['user']['apps']['admin'])
521
+		if ($group && $GLOBALS['egw_info']['user']['apps']['admin'])
522 522
 		{
523 523
 			$prefs = new preferences(is_numeric($group) ? $group : $GLOBALS['egw_info']['user']['account_id']);
524 524
 		}
@@ -532,23 +532,23 @@  discard block
 block discarded – undo
532 532
 
533 533
 		$response = egw_json_response::get();
534 534
 
535
-		if($values =='~reload~')
535
+		if ($values == '~reload~')
536 536
 		{
537 537
 			$full_exec = true;
538 538
 			$values = array();
539 539
 		}
540
-		if($values == '~remove~')
540
+		if ($values == '~remove~')
541 541
 		{
542 542
 			// Already removed client side, needs to be removed permanently
543
-			$default = $prefs->default_prefs('home',$portlet_id) || $prefs->group['home'][$portlet_id];
543
+			$default = $prefs->default_prefs('home', $portlet_id) || $prefs->group['home'][$portlet_id];
544 544
 
545
-			if($default)
545
+			if ($default)
546 546
 			{
547 547
 				// Can't delete forced - not a UI option though
548
-				if(!$GLOBALS['egw']->preferences->forced['home'][$portlet_id])
548
+				if (!$GLOBALS['egw']->preferences->forced['home'][$portlet_id])
549 549
 				{
550 550
 					// Set a flag to override default instead of just delete
551
-					$GLOBALS['egw']->preferences->add('home',$portlet_id, 'deleted');
551
+					$GLOBALS['egw']->preferences->add('home', $portlet_id, 'deleted');
552 552
 					$GLOBALS['egw']->preferences->save_repository();
553 553
 				}
554 554
 			}
@@ -565,19 +565,19 @@  discard block
 block discarded – undo
565 565
 			// Remove some constant stuff that winds up here
566 566
 			unset($values['edit_template']);
567 567
 			unset($values['readonly']);
568
-			unset($values['disabled']);unset($values['no_lang']);
568
+			unset($values['disabled']); unset($values['no_lang']);
569 569
 			unset($values['actions']);
570 570
 			unset($values['statustext']);
571
-			unset($values['type']);unset($values['label']);unset($values['status']);
572
-			unset($values['value']);unset($values['align']);
571
+			unset($values['type']); unset($values['label']); unset($values['status']);
572
+			unset($values['value']); unset($values['align']);
573 573
 
574 574
 			// Get portlet settings, and merge new with old
575 575
 			$context = array_merge((array)$portlets[$portlet_id], $values);
576 576
 			$context['group'] = $group;
577 577
 
578 578
 			// Handle add IDs
579
-			$classname =& $context['class'];
580
-			if(strpos($classname,'add_') == 0 && !class_exists($classname))
579
+			$classname = & $context['class'];
580
+			if (strpos($classname, 'add_') == 0 && !class_exists($classname))
581 581
 			{
582 582
 				$add = true;
583 583
 				$classname = substr($classname, 4);
@@ -585,13 +585,13 @@  discard block
 block discarded – undo
585 585
 			$portlet = $this->get_portlet($portlet_id, $context, $content, $attributes, $full_exec);
586 586
 
587 587
 			$context['class'] = get_class($portlet);
588
-			foreach($portlet->get_properties() as $property)
588
+			foreach ($portlet->get_properties() as $property)
589 589
 			{
590
-				if($values[$property['name']])
590
+				if ($values[$property['name']])
591 591
 				{
592 592
 					$context[$property['name']] = $values[$property['name']];
593 593
 				}
594
-				elseif($portlets[$portlet_id][$property['name']])
594
+				elseif ($portlets[$portlet_id][$property['name']])
595 595
 				{
596 596
 					$context[$property['name']] = $portlets[$portlet_id][$property['name']];
597 597
 				}
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 			$update = array('attributes' => $attributes);
602 602
 
603 603
 			// New portlet?  Flag going straight to edit mode
604
-			if($add)
604
+			if ($add)
605 605
 			{
606 606
 				$update['edit_settings'] = true;
607 607
 			}
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
 		}
614 614
 
615 615
 		// Save updated preferences
616
-		$prefs->save_repository(True,$type);
616
+		$prefs->save_repository(True, $type);
617 617
 	}
618 618
 
619 619
 	/**
@@ -626,10 +626,10 @@  discard block
 block discarded – undo
626 626
 	public static function ajax_set_default($action, $portlet_ids, $group)
627 627
 	{
628 628
 		// Admins only
629
-		if(!$GLOBALS['egw_info']['apps']['admin']) return;
629
+		if (!$GLOBALS['egw_info']['apps']['admin']) return;
630 630
 
631 631
 		// Load the appropriate group
632
-		if($group)
632
+		if ($group)
633 633
 		{
634 634
 			$prefs = new preferences(is_numeric($group) ? $group : $GLOBALS['egw_info']['user']['account_id']);
635 635
 		}
@@ -641,30 +641,30 @@  discard block
 block discarded – undo
641 641
 
642 642
 		$type = is_numeric($group) ? "user" : $group;
643 643
 
644
-		if($action == 'add')
644
+		if ($action == 'add')
645 645
 		{
646
-			foreach($portlet_ids as $id)
646
+			foreach ($portlet_ids as $id)
647 647
 			{
648 648
 				egw_json_response::get()->call('egw.message', lang("Set default"));
649 649
 				// Current user is setting the default, copy their settings
650 650
 				$settings = $GLOBALS['egw_info']['user']['preferences']['home'][$id];
651 651
 				$settings['group'] = $group;
652
-				$prefs->add('home',$id,$settings,$type);
652
+				$prefs->add('home', $id, $settings, $type);
653 653
 
654 654
 				// Remove user's copy
655
-				$GLOBALS['egw']->preferences->delete('home',$id);
655
+				$GLOBALS['egw']->preferences->delete('home', $id);
656 656
 				$GLOBALS['egw']->preferences->save_repository(true);
657 657
 			}
658 658
 		}
659 659
 		else if ($action == "delete")
660 660
 		{
661
-			foreach($portlet_ids as $id)
661
+			foreach ($portlet_ids as $id)
662 662
 			{
663 663
 				egw_json_response::get()->call('egw.message', lang("Removed default"));
664
-				$prefs->delete('home',$id, $type);
664
+				$prefs->delete('home', $id, $type);
665 665
 			}
666 666
 		}
667
-		$prefs->save_repository(false,$type);
667
+		$prefs->save_repository(false, $type);
668 668
 
669 669
 		// Update preferences client side for consistency
670 670
 		$prefs = $GLOBALS['egw']->preferences;
@@ -717,7 +717,7 @@  discard block
 block discarded – undo
717 717
 						'state' => array(
718 718
 							'cat_id' => '0',
719 719
 							'filter' => 'default',
720
-							'owner' => 0,	// current user
720
+							'owner' => 0, // current user
721 721
 							'sortby' => 'user',
722 722
 							'planner_days' => '0',
723 723
 							'view' => 'week',
@@ -766,9 +766,9 @@  discard block
 block discarded – undo
766 766
 		{
767 767
 			unset($app_prefs['home']['portlet_setup142n']);
768 768
 		}
769
-		foreach($app_prefs as $app => $prefs)
769
+		foreach ($app_prefs as $app => $prefs)
770 770
 		{
771
-			foreach($prefs as $name => $value)
771
+			foreach ($prefs as $name => $value)
772 772
 			{
773 773
 				preferences::delete_preference($app, $name, 'default');
774 774
 				$preferences->add($app, $name, $value, 'default');
@@ -789,10 +789,10 @@  discard block
 block discarded – undo
789 789
 	 */
790 790
 	public static function setup_default_home()
791 791
 	{
792
-		switch($GLOBALS['egw_info']['server'][self::HOME_VERSION])
792
+		switch ($GLOBALS['egw_info']['server'][self::HOME_VERSION])
793 793
 		{
794 794
 			case self::CURRENT_HOME_VERSION:
795
-				return;	// already up to date --> nothing to do
795
+				return; // already up to date --> nothing to do
796 796
 
797 797
 			default:
798 798
 				call_user_func(array(__CLASS__, 'setup_default_home_'.str_replace('.', '_', self::CURRENT_HOME_VERSION)));
Please login to merge, or discard this patch.
Braces   +52 added lines, -14 removed lines patch added patch discarded remove patch
@@ -71,7 +71,10 @@  discard block
 block discarded – undo
71 71
 		{
72 72
 			$id = $p_data['id'];
73 73
 
74
-			if(!$id) continue;
74
+			if(!$id)
75
+			{
76
+				continue;
77
+			}
75 78
 			$portlet = $this->get_portlet($id, $p_data, $content, $attrs, true);
76 79
 		}
77 80
 
@@ -130,7 +133,10 @@  discard block
 block discarded – undo
130 133
 			{
131 134
 				foreach($children['children'] as $portlet => $app_portlet)
132 135
 				{
133
-					if(!is_array($app_portlet)) continue;
136
+					if(!is_array($app_portlet))
137
+					{
138
+						continue;
139
+					}
134 140
 					$app_portlet['class'] = $portlet;
135 141
 					$app_portlet['id'] = 'drop_' . $app_portlet['id'];
136 142
 					$app_portlet['onExecute'] = $drop_execute;
@@ -161,7 +167,10 @@  discard block
 block discarded – undo
161 167
 			if(strpos($id,'portlet_') !== 0 || // Not a portlet
162 168
 				in_array($id, array_keys($GLOBALS['egw_info']['user']['apps'])) || // Some other app put it's pref in here
163 169
 				!is_array($context) // Not a valid portlet (probably user deleted a default)
164
-			) continue;
170
+			)
171
+			{
172
+				continue;
173
+			}
165 174
 
166 175
 			$classname = $context['class'];
167 176
 			$portlet = new $classname($context);
@@ -176,7 +185,10 @@  discard block
 block discarded – undo
176 185
 			$settings = $portlet->get_properties();
177 186
 			foreach($settings as $key => $setting)
178 187
 			{
179
-				if(is_array($setting) && !array_key_exists('type',$setting)) unset($settings[$key]);
188
+				if(is_array($setting) && !array_key_exists('type',$setting))
189
+				{
190
+					unset($settings[$key]);
191
+				}
180 192
 			}
181 193
 			$settings += $context;
182 194
 			foreach(home_portlet::$common_attributes as $attr)
@@ -216,7 +228,10 @@  discard block
 block discarded – undo
216 228
 	 */
217 229
 	protected function get_portlet($id, &$context, &$content, &$attributes, $full_exec = false)
218 230
 	{
219
-		if(!$context['class']) $context['class'] = 'home_link_portlet';
231
+		if(!$context['class'])
232
+		{
233
+			$context['class'] = 'home_link_portlet';
234
+		}
220 235
 
221 236
 		// This should be set already, but just in case the execution path
222 237
 		// is different from normal...
@@ -237,7 +252,10 @@  discard block
 block discarded – undo
237 252
 		$settings = $portlet->get_properties();
238 253
 		foreach($settings as $key => $setting)
239 254
 		{
240
-			if(is_array($setting) && !array_key_exists('type',$setting)) unset($settings[$key]);
255
+			if(is_array($setting) && !array_key_exists('type',$setting))
256
+			{
257
+				unset($settings[$key]);
258
+			}
241 259
 		}
242 260
 		$settings += $context;
243 261
 		foreach(home_portlet::$common_attributes as $attr)
@@ -301,7 +319,10 @@  discard block
 block discarded – undo
301 319
 		foreach($sorted_apps as $appname)
302 320
 		{
303 321
 			// If there's already [new] settings, or no preference, skip it
304
-			if($content[$appname]) continue;
322
+			if($content[$appname])
323
+			{
324
+				continue;
325
+			}
305 326
 			$no_pref = true;
306 327
 			foreach($portal_oldvarnames as $varcheck)
307 328
 			{
@@ -336,7 +357,8 @@  discard block
 block discarded – undo
336 357
 	 */
337 358
 	protected function get_portlet_list()
338 359
 	{
339
-		$list = egw_cache::getTree('home', 'portlet_classes', function() {
360
+		$list = egw_cache::getTree('home', 'portlet_classes', function()
361
+		{
340 362
 			$list = array();
341 363
 			$classes = array();
342 364
 
@@ -352,9 +374,15 @@  discard block
 block discarded – undo
352 374
 			// Look through all known classes for portlets - for now, they need 'portlet' in the file name
353 375
 			foreach(array_keys($GLOBALS['egw_info']['apps']) as $appname)
354 376
 			{
355
-				if(in_array($appname, array('phpgwapi', 'felamimail'))) continue;
377
+				if(in_array($appname, array('phpgwapi', 'felamimail')))
378
+				{
379
+					continue;
380
+				}
356 381
 				$files = (array)@scandir(EGW_SERVER_ROOT . '/'.$appname .'/inc/');
357
-				if(!$files) continue;
382
+				if(!$files)
383
+				{
384
+					continue;
385
+				}
358 386
 
359 387
 				foreach($files as $entry)
360 388
 				{
@@ -373,7 +401,10 @@  discard block
 block discarded – undo
373 401
 					}
374 402
 				}
375 403
 
376
-				if(!$classes[$appname]) continue;
404
+				if(!$classes[$appname])
405
+				{
406
+					continue;
407
+				}
377 408
 
378 409
 				// Build 'Add' actions for each discovered portlet.
379 410
 				// Portlets from other apps go in sub-actions
@@ -407,7 +438,8 @@  discard block
 block discarded – undo
407 438
 		// Filter list by current user's permissions
408 439
 		foreach($list as $appname => $children)
409 440
 		{
410
-			if(in_array($appname, array_keys($GLOBALS['egw_info']['apps']))) {
441
+			if(in_array($appname, array_keys($GLOBALS['egw_info']['apps'])))
442
+			{
411 443
 				if(!in_array($appname, array_keys($GLOBALS['egw_info']['user']['apps'])))
412 444
 				{
413 445
 					unset($list[$appname]);
@@ -626,7 +658,10 @@  discard block
 block discarded – undo
626 658
 	public static function ajax_set_default($action, $portlet_ids, $group)
627 659
 	{
628 660
 		// Admins only
629
-		if(!$GLOBALS['egw_info']['apps']['admin']) return;
661
+		if(!$GLOBALS['egw_info']['apps']['admin'])
662
+		{
663
+			return;
664
+		}
630 665
 
631 666
 		// Load the appropriate group
632 667
 		if($group)
@@ -689,7 +724,10 @@  discard block
 block discarded – undo
689 724
 		$preferences = $GLOBALS['egw']->preferences;
690 725
 		$preferences->read_repository();
691 726
 		$lang = $preferences->default['common']['lang'];
692
-		if (empty($lang)) $lang = 'en';
727
+		if (empty($lang))
728
+		{
729
+			$lang = 'en';
730
+		}
693 731
 
694 732
 		translation::add_app('calendar', $lang);
695 733
 		$weekview = lang('Weekview');
Please login to merge, or discard this patch.
infolog/inc/class.infolog_activesync.inc.php 4 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 *
70 70
 	 * Currently we only return an own infolog
71 71
 	 *
72
-	 * @param int $account=null account_id of addressbook or null to get array of all addressbooks
72
+	 * @param int $account account_id of addressbook or null to get array of all addressbooks
73 73
 	 * @return string|array folder name of array with int account_id => folder name pairs
74 74
 	 */
75 75
 	private function get_folders($account=null)
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 	 * will work OK apart from that.
184 184
 	 *
185 185
 	 * @param string $id folder id
186
-	 * @param int $cutoffdate=null
186
+	 * @param int $cutoffdate
187 187
 	 * @return array
188 188
   	 */
189 189
 	function GetMessageList($id, $cutoffdate=NULL)
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	 * @param string $id
221 221
 	 * @param int $truncsize
222 222
 	 * @param int $bodypreference
223
-	 * @param bool $mimesupport
223
+	 * @param integer $mimesupport
224 224
 	 * @return $messageobject|boolean false on error
225 225
 	 */
226 226
 	public function GetMessage($folderid, $id, $truncsize, $bodypreference=false, $optionbodypreference=false, $mimesupport = 0)
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -177,7 +177,7 @@
 block discarded – undo
177 177
 	 * @param int $cutoffdate =null
178 178
 	 * @param array $not_uids =null uids NOT to return for meeting requests
179 179
 	 * @return array
180
-  	 */
180
+	 */
181 181
 	function GetMessageList($id, $cutoffdate=NULL, array $not_uids=null)
182 182
 	{
183 183
 		if (!isset($this->calendar)) $this->calendar = new calendar_boupdate();
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -34,12 +34,12 @@  discard block
 block discarded – undo
34 34
 	 */
35 35
 	static public $mapping = array(
36 36
 		'body'	=> 'info_des',
37
-		'categories' => 'info_cat',	// infolog supports only a single category
38
-		'complete' => 'info_status', 	// 0 or 1 <--> 'done', ....
37
+		'categories' => 'info_cat', // infolog supports only a single category
38
+		'complete' => 'info_status', // 0 or 1 <--> 'done', ....
39 39
 		'datecompleted' => 'info_datecompleted',
40 40
 		'duedate' => 'info_enddate',
41
-		'importance' => 'info_priority',	// 0=Low, 1=Normal, 2=High (EGW additional 3=Urgent)
42
-		'sensitivity' => 'info_access',	// 0=Normal, 1=Personal, 2=Private, 3=Confiential <--> 'public', 'private'
41
+		'importance' => 'info_priority', // 0=Low, 1=Normal, 2=High (EGW additional 3=Urgent)
42
+		'sensitivity' => 'info_access', // 0=Normal, 1=Personal, 2=Private, 3=Confiential <--> 'public', 'private'
43 43
 		'startdate' => 'info_startdate',
44 44
 		'subject' => 'info_subject',
45 45
 		//'recurrence' => EGroupware InfoLog does NOT support recuring tasks
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	 * @param int $account=null account_id of addressbook or null to get array of all addressbooks
73 73
 	 * @return string|array folder name of array with int account_id => folder name pairs
74 74
 	 */
75
-	private function get_folders($account=null)
75
+	private function get_folders($account = null)
76 76
 	{
77 77
 		$folders = array(
78 78
 			$GLOBALS['egw_info']['user']['account_id'] => lang('InfoLog'),
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 		foreach ($this->get_folders() as $account => $label)
93 93
 		{
94 94
 			$folderlist[] = array(
95
-				'id'	=>	$this->backend->createID('infolog',$account),
95
+				'id'	=>	$this->backend->createID('infolog', $account),
96 96
 				'mod'	=>	$label,
97 97
 				'parent'=>	'0',
98 98
 			);
@@ -186,11 +186,11 @@  discard block
 block discarded – undo
186 186
 	 * @param int $cutoffdate=null
187 187
 	 * @return array
188 188
   	 */
189
-	function GetMessageList($id, $cutoffdate=NULL)
189
+	function GetMessageList($id, $cutoffdate = NULL)
190 190
 	{
191 191
 		if (!isset($this->infolog)) $this->infolog = new infolog_bo();
192 192
 
193
-		$this->backend->splitID($id,$type,$user);
193
+		$this->backend->splitID($id, $type, $user);
194 194
 		if (!($infolog_types = $GLOBALS['egw_info']['user']['preferences']['activesync']['infolog-types']))
195 195
 		{
196 196
 			$infolog_types = 'task';
@@ -202,9 +202,9 @@  discard block
 block discarded – undo
202 202
 		);
203 203
 
204 204
 		$messagelist = array();
205
-		if (($infologs =& $this->infolog->search($filter)))
205
+		if (($infologs = & $this->infolog->search($filter)))
206 206
 		{
207
-			foreach($infologs as $infolog)
207
+			foreach ($infologs as $infolog)
208 208
 			{
209 209
 				$messagelist[] = $this->StatMessage($id, $infolog);
210 210
 			}
@@ -223,11 +223,11 @@  discard block
 block discarded – undo
223 223
 	 * @param bool $mimesupport
224 224
 	 * @return $messageobject|boolean false on error
225 225
 	 */
226
-	public function GetMessage($folderid, $id, $truncsize, $bodypreference=false, $optionbodypreference=false, $mimesupport = 0)
226
+	public function GetMessage($folderid, $id, $truncsize, $bodypreference = false, $optionbodypreference = false, $mimesupport = 0)
227 227
 	{
228 228
 		if (!isset($this->infolog)) $this->infolog = new infolog_bo();
229 229
 
230
-		debugLog (__METHOD__."('$folderid', $id, truncsize=$truncsize, bodyprefence=$bodypreference, mimesupport=$mimesupport)");
230
+		debugLog(__METHOD__."('$folderid', $id, truncsize=$truncsize, bodyprefence=$bodypreference, mimesupport=$mimesupport)");
231 231
 		$this->backend->splitID($folderid, $type, $account);
232 232
 		if ($type != 'infolog' || !($infolog = $this->infolog->read($id, true, 'server')))
233 233
 		{
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 			return false;
236 236
 		}
237 237
 		$message = new SyncTask();
238
-		foreach(self::$mapping as $key => $attr)
238
+		foreach (self::$mapping as $key => $attr)
239 239
 		{
240 240
 			switch ($attr)
241 241
 			{
@@ -248,11 +248,11 @@  discard block
 block discarded – undo
248 248
 					}
249 249
 					else
250 250
 					{
251
-						if (strlen ($infolog[$attr]) > 0)
251
+						if (strlen($infolog[$attr]) > 0)
252 252
 						{
253 253
 							debugLog("airsyncbasebody!");
254 254
 							$message->airsyncbasebody = new SyncAirSyncBaseBody();
255
-							$message->airsyncbasenativebodytype=1;
255
+							$message->airsyncbasenativebodytype = 1;
256 256
 							$this->backend->note2messagenote($infolog[$attr], $bodypreference, $message->airsyncbasebody);
257 257
 						}
258 258
 					}
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 
262 262
 				case 'info_cat':
263 263
 					$message->$key = array();
264
-					foreach($infolog[$attr] ? explode(',',$infolog[$attr]) : array() as $cat_id)
264
+					foreach ($infolog[$attr] ? explode(',', $infolog[$attr]) : array() as $cat_id)
265 265
 					{
266 266
 						$message->categories[] = categories::id2name($cat_id);
267 267
 					}
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 					break;
277 277
 
278 278
 				case 'info_priority':
279
-					if ($infolog[$attr] > 2) $infolog[$attr] = 2;	// AS does not know 3=Urgent (only 0=Low, 1=Normal, 2=High)
279
+					if ($infolog[$attr] > 2) $infolog[$attr] = 2; // AS does not know 3=Urgent (only 0=Low, 1=Normal, 2=High)
280 280
 					// fall through
281 281
 				default:
282 282
 					if (!empty($infolog[$attr])) $message->$key = $infolog[$attr];
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 					case 'info_cat':
396 396
 						if (is_array($message->$key))
397 397
 						{
398
-							$infolog[$attr] = implode(',', array_filter($this->infolog->find_or_add_categories($message->$key, $id),'strlen'));
398
+							$infolog[$attr] = implode(',', array_filter($this->infolog->find_or_add_categories($message->$key, $id), 'strlen'));
399 399
 						}
400 400
 						break;
401 401
 
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 						break;
413 413
 
414 414
 					case 'info_priority':	// AS does not know 3=Urgent (only 0=Low, 1=Normal, 2=High)
415
-						if ($infolog[$attr] == 3 && $message->$key == 2) break;	// --> do NOT change Urgent, if AS reports High
415
+						if ($infolog[$attr] == 3 && $message->$key == 2) break; // --> do NOT change Urgent, if AS reports High
416 416
 						// fall through
417 417
 					default:
418 418
 						$infolog[$attr] = $message->$key;
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
 			'info_type' => explode(',', $infolog_types),
528 528
 		));
529 529
 
530
-		$changes = array();	// no change
530
+		$changes = array(); // no change
531 531
 		$syncstate_was = $syncstate;
532 532
 
533 533
 		if ($ctag !== $syncstate)
Please login to merge, or discard this patch.
Braces   +70 added lines, -17 removed lines patch added patch discarded remove patch
@@ -188,7 +188,10 @@  discard block
 block discarded – undo
188 188
   	 */
189 189
 	function GetMessageList($id, $cutoffdate=NULL)
190 190
 	{
191
-		if (!isset($this->infolog)) $this->infolog = new infolog_bo();
191
+		if (!isset($this->infolog))
192
+		{
193
+			$this->infolog = new infolog_bo();
194
+		}
192 195
 
193 196
 		$this->backend->splitID($id,$type,$user);
194 197
 		if (!($infolog_types = $GLOBALS['egw_info']['user']['preferences']['activesync']['infolog-types']))
@@ -225,7 +228,10 @@  discard block
 block discarded – undo
225 228
 	 */
226 229
 	public function GetMessage($folderid, $id, $truncsize, $bodypreference=false, $optionbodypreference=false, $mimesupport = 0)
227 230
 	{
228
-		if (!isset($this->infolog)) $this->infolog = new infolog_bo();
231
+		if (!isset($this->infolog))
232
+		{
233
+			$this->infolog = new infolog_bo();
234
+		}
229 235
 
230 236
 		debugLog (__METHOD__."('$folderid', $id, truncsize=$truncsize, bodyprefence=$bodypreference, mimesupport=$mimesupport)");
231 237
 		$this->backend->splitID($folderid, $type, $account);
@@ -276,10 +282,17 @@  discard block
 block discarded – undo
276 282
 					break;
277 283
 
278 284
 				case 'info_priority':
279
-					if ($infolog[$attr] > 2) $infolog[$attr] = 2;	// AS does not know 3=Urgent (only 0=Low, 1=Normal, 2=High)
285
+					if ($infolog[$attr] > 2)
286
+					{
287
+						$infolog[$attr] = 2;
288
+					}
289
+					// AS does not know 3=Urgent (only 0=Low, 1=Normal, 2=High)
280 290
 					// fall through
281 291
 				default:
282
-					if (!empty($infolog[$attr])) $message->$key = $infolog[$attr];
292
+					if (!empty($infolog[$attr]))
293
+					{
294
+						$message->$key = $infolog[$attr];
295
+					}
283 296
 			}
284 297
 		}
285 298
 		//debugLog(__METHOD__."(folder='$folderid',$id,...) returning ".array2string($message));
@@ -300,9 +313,15 @@  discard block
 block discarded – undo
300 313
 	 */
301 314
 	public function StatMessage($folderid, $infolog)
302 315
 	{
303
-		if (!isset($this->infolog)) $this->infolog = new infolog_bo();
316
+		if (!isset($this->infolog))
317
+		{
318
+			$this->infolog = new infolog_bo();
319
+		}
304 320
 
305
-		if (!is_array($infolog)) $infolog = $this->infolog->read($infolog, true, 'server');
321
+		if (!is_array($infolog))
322
+		{
323
+			$infolog = $this->infolog->read($infolog, true, 'server');
324
+		}
306 325
 
307 326
 		if (!$infolog)
308 327
 		{
@@ -370,20 +389,29 @@  discard block
 block discarded – undo
370 389
 	 */
371 390
 	public function ChangeMessage($folderid, $id, $message)
372 391
 	{
373
-		if (!isset($this->infolog)) $this->infolog = new infolog_bo();
392
+		if (!isset($this->infolog))
393
+		{
394
+			$this->infolog = new infolog_bo();
395
+		}
374 396
 
375 397
 		$this->backend->splitID($folderid, $type, $account);
376 398
 		//debugLog(__METHOD__. " Id " .$id. " Account ". $account . " FolderID " . $folderid);
377
-		if ($type != 'infolog') // || !($infolog = $this->addressbook->read($id)))
399
+		if ($type != 'infolog')
400
+		{
401
+			// || !($infolog = $this->addressbook->read($id)))
378 402
 		{
379 403
 			debugLog(__METHOD__." Folder wrong or infolog not existing");
404
+		}
380 405
 			return false;
381 406
 		}
382 407
 		$infolog = array();
383 408
 		if (empty($id) && $this->infolog->check_access(0, EGW_ACL_EDIT, $account) ||
384 409
 			($infolog = $this->infolog->read($id)) && $this->infolog->check_access($infolog, EGW_ACL_EDIT))
385 410
 		{
386
-			if (!$infolog) $infolog = array();
411
+			if (!$infolog)
412
+			{
413
+				$infolog = array();
414
+			}
387 415
 			foreach (self::$mapping as $key => $attr)
388 416
 			{
389 417
 				switch ($attr)
@@ -407,12 +435,19 @@  discard block
 block discarded – undo
407 435
 						if ((in_array($infolog[$attr], self::$done_status) !== (boolean)$message->$key) || !isset($infolog[$attr]))
408 436
 						{
409 437
 							$infolog[$attr] = $message->$key ? 'done' : 'not-started';
410
-							if (!(boolean)$message->$key) $infolog['info_percent'] = 0;
438
+							if (!(boolean)$message->$key)
439
+							{
440
+								$infolog['info_percent'] = 0;
441
+							}
411 442
 						}
412 443
 						break;
413 444
 
414 445
 					case 'info_priority':	// AS does not know 3=Urgent (only 0=Low, 1=Normal, 2=High)
415
-						if ($infolog[$attr] == 3 && $message->$key == 2) break;	// --> do NOT change Urgent, if AS reports High
446
+						if ($infolog[$attr] == 3 && $message->$key == 2)
447
+						{
448
+							break;
449
+						}
450
+						// --> do NOT change Urgent, if AS reports High
416 451
 						// fall through
417 452
 					default:
418 453
 						$infolog[$attr] = $message->$key;
@@ -420,7 +455,10 @@  discard block
 block discarded – undo
420 455
 				}
421 456
 			}
422 457
 			// $infolog['info_owner'] = $account;
423
-			if (!empty($id)) $infolog['info_id'] = $id;
458
+			if (!empty($id))
459
+			{
460
+				$infolog['info_id'] = $id;
461
+			}
424 462
 			$newid = $this->infolog->write($infolog);
425 463
 			debugLog(__METHOD__."($folderid,$id) infolog(".array2string($infolog).") returning ".array2string($newid));
426 464
 			return $this->StatMessage($folderid, $newid);
@@ -465,7 +503,10 @@  discard block
 block discarded – undo
465 503
 	 */
466 504
 	public function DeleteMessage($folderid, $id)
467 505
 	{
468
-		if (!isset($this->infolog)) $this->infolog = new infolog_bo();
506
+		if (!isset($this->infolog))
507
+		{
508
+			$this->infolog = new infolog_bo();
509
+		}
469 510
 
470 511
 		$ret = $this->infolog->delete($id);
471 512
 		debugLog(__METHOD__."('$folderid', $id) delete($id) returned ".array2string($ret));
@@ -513,9 +554,15 @@  discard block
 block discarded – undo
513 554
 	{
514 555
 		$this->backend->splitID($folderid, $type, $owner);
515 556
 
516
-		if ($type != 'infolog') return false;
557
+		if ($type != 'infolog')
558
+		{
559
+			return false;
560
+		}
517 561
 
518
-		if (!isset($this->infolog)) $this->infolog = new infolog_bo();
562
+		if (!isset($this->infolog))
563
+		{
564
+			$this->infolog = new infolog_bo();
565
+		}
519 566
 
520 567
 		if (!($infolog_types = $GLOBALS['egw_info']['user']['preferences']['activesync']['infolog-types']))
521 568
 		{
@@ -547,8 +594,14 @@  discard block
 block discarded – undo
547 594
 	 */
548 595
 	function settings($hook_data)
549 596
 	{
550
-		if (!$hook_data['setup']) translation::add_app('infolog');
551
-		if (!isset($this->infolog)) $this->infolog = new infolog_bo();
597
+		if (!$hook_data['setup'])
598
+		{
599
+			translation::add_app('infolog');
600
+		}
601
+		if (!isset($this->infolog))
602
+		{
603
+			$this->infolog = new infolog_bo();
604
+		}
552 605
 
553 606
 		if (!($types = $this->infolog->enums['type']))
554 607
 		{
Please login to merge, or discard this patch.