@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * @param string $cname |
27 | 27 | * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' |
28 | 28 | */ |
29 | - public function beforeSendToClient($cname, array $expand=null) |
|
29 | + public function beforeSendToClient($cname, array $expand = null) |
|
30 | 30 | { |
31 | 31 | $matches = null; |
32 | 32 | if ($cname == '$row') // happens eg. with custom-fields: $cname='$row', this->id='#something' |
@@ -55,13 +55,13 @@ discard block |
||
55 | 55 | |
56 | 56 | // Make sure s, etc. are properly encoded when sent, and not double-encoded |
57 | 57 | $options = (isset(self::$request->sel_options[$form_name]) ? $form_name : $this->id); |
58 | - if(is_array(self::$request->sel_options[$options])) |
|
58 | + if (is_array(self::$request->sel_options[$options])) |
|
59 | 59 | { |
60 | 60 | |
61 | 61 | // Fix any custom options from application |
62 | - self::fix_encoded_options(self::$request->sel_options[$options],true); |
|
62 | + self::fix_encoded_options(self::$request->sel_options[$options], true); |
|
63 | 63 | |
64 | - if(!self::$request->sel_options[$options]) |
|
64 | + if (!self::$request->sel_options[$options]) |
|
65 | 65 | { |
66 | 66 | unset(self::$request->sel_options[$options]); |
67 | 67 | } |
@@ -29,10 +29,13 @@ |
||
29 | 29 | public function beforeSendToClient($cname, array $expand=null) |
30 | 30 | { |
31 | 31 | $matches = null; |
32 | - if ($cname == '$row') // happens eg. with custom-fields: $cname='$row', this->id='#something' |
|
32 | + if ($cname == '$row') |
|
33 | + { |
|
34 | + // happens eg. with custom-fields: $cname='$row', this->id='#something' |
|
33 | 35 | { |
34 | 36 | $form_name = $this->id; |
35 | 37 | } |
38 | + } |
|
36 | 39 | // happens with fields in nm-header: $cname='nm', this->id='${row}[something]' or '{$row}[something]' |
37 | 40 | elseif (preg_match('/(\${row}|{\$row})\[([^]]+)\]$/', $this->id, $matches)) |
38 | 41 | { |
@@ -26,7 +26,7 @@ |
||
26 | 26 | * @param string|XMLReader $xml |
27 | 27 | * @param boolean $cloned =true true: object does NOT need to be cloned, false: to set attribute, set them in cloned object |
28 | 28 | */ |
29 | - public function set_attrs($xml, $cloned=true) |
|
29 | + public function set_attrs($xml, $cloned = true) |
|
30 | 30 | { |
31 | 31 | parent::set_attrs($xml, $cloned); |
32 | 32 |
@@ -29,18 +29,18 @@ discard block |
||
29 | 29 | * @param string $cname |
30 | 30 | * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' |
31 | 31 | */ |
32 | - public function beforeSendToClient($cname, array $expand=null) |
|
32 | + public function beforeSendToClient($cname, array $expand = null) |
|
33 | 33 | { |
34 | - switch($this->attrs['type']) |
|
34 | + switch ($this->attrs['type']) |
|
35 | 35 | { |
36 | 36 | case "link-entry": |
37 | 37 | self::$transformation['type'] = $this->attrs['type'] = 'nextmatch-entryheader'; |
38 | 38 | break; |
39 | 39 | default: |
40 | - list($type) = explode('-',$this->attrs['type']); |
|
41 | - if($type == 'select') |
|
40 | + list($type) = explode('-', $this->attrs['type']); |
|
41 | + if ($type == 'select') |
|
42 | 42 | { |
43 | - if(in_array($this->attrs['type'], Widget\Select::$cached_types)) |
|
43 | + if (in_array($this->attrs['type'], Widget\Select::$cached_types)) |
|
44 | 44 | { |
45 | 45 | $widget_type = $this->attrs['type']; |
46 | 46 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $this->setElementAttribute($form_name, 'options', trim($this->attrs['widget_options']) != '' ? $this->attrs['widget_options'] : ''); |
54 | 54 | |
55 | 55 | $this->setElementAttribute($form_name, 'type', $this->attrs['type']); |
56 | - if($widget_type) |
|
56 | + if ($widget_type) |
|
57 | 57 | { |
58 | 58 | $this->setElementAttribute($form_name, 'widget_type', $widget_type); |
59 | 59 | } |
@@ -69,11 +69,11 @@ discard block |
||
69 | 69 | * @param array $content |
70 | 70 | * @param array &$validated=array() validated content |
71 | 71 | */ |
72 | - public function validate($cname, array $expand, array $content, &$validated=array()) |
|
72 | + public function validate($cname, array $expand, array $content, &$validated = array()) |
|
73 | 73 | { |
74 | 74 | $value = $value_in = self::get_array($content, $form_name); |
75 | 75 | |
76 | - $valid =& self::get_array($validated, $form_name, true); |
|
76 | + $valid = & self::get_array($validated, $form_name, true); |
|
77 | 77 | // returning null instead of array(), as array() will be overwritten by etemplate_new::complete_array_merge() |
78 | 78 | // with preserved old content and therefore user can not empty a taglist |
79 | 79 | $valid = $value ? $value : null; |
@@ -238,10 +238,10 @@ |
||
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
241 | - * Delete a directory RECURSIVELY |
|
242 | - * @param string $dir - directory path |
|
243 | - * @link http://php.net/manual/en/function.rmdir.php |
|
244 | - */ |
|
241 | + * Delete a directory RECURSIVELY |
|
242 | + * @param string $dir - directory path |
|
243 | + * @link http://php.net/manual/en/function.rmdir.php |
|
244 | + */ |
|
245 | 245 | private static function rrmdir($dir) |
246 | 246 | { |
247 | 247 | if (is_dir($dir)) |
@@ -116,7 +116,7 @@ |
||
116 | 116 | /** |
117 | 117 | * Process one uploaded file. There should only be one per request... |
118 | 118 | */ |
119 | - protected static function process_uploaded_file($field, Array &$file, $mime, Array &$file_data) |
|
119 | + protected static function process_uploaded_file($field, array &$file, $mime, array &$file_data) |
|
120 | 120 | { |
121 | 121 | unset($field); // not used |
122 | 122 |
@@ -42,7 +42,10 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public function __construct($xml='') |
44 | 44 | { |
45 | - if($xml) parent::__construct($xml); |
|
45 | + if($xml) |
|
46 | + { |
|
47 | + parent::__construct($xml); |
|
48 | + } |
|
46 | 49 | |
47 | 50 | // Legacy multiple - id ends in [] |
48 | 51 | if(substr($this->id,-2) == '[]') |
@@ -102,7 +105,8 @@ discard block |
||
102 | 105 | $file_list = array(); |
103 | 106 | foreach($files as $f_field => $values) |
104 | 107 | { |
105 | - foreach($values as $key => $f_value) { |
|
108 | + foreach($values as $key => $f_value) |
|
109 | + { |
|
106 | 110 | $file_list[$key][$f_field] = $f_value; |
107 | 111 | } |
108 | 112 | } |
@@ -120,7 +124,10 @@ discard block |
||
120 | 124 | if ($widget) |
121 | 125 | { |
122 | 126 | $callback = $widget->attrs['callback']; |
123 | - if(!$callback) $callback = $template->getElementAttribute($field, 'callback'); |
|
127 | + if(!$callback) |
|
128 | + { |
|
129 | + $callback = $template->getElementAttribute($field, 'callback'); |
|
130 | + } |
|
124 | 131 | if($callback) |
125 | 132 | { |
126 | 133 | ExecMethod2($callback, $_FILES[$field], $widget_id, self::$request, $response); |
@@ -146,7 +153,8 @@ discard block |
||
146 | 153 | $file['type'] = $_POST['resumableType']; |
147 | 154 | } |
148 | 155 | |
149 | - if ($file['error'] == UPLOAD_ERR_OK && trim($file['name']) != '' && $file['size'] > 0 && is_uploaded_file($file['tmp_name'])) { |
|
156 | + if ($file['error'] == UPLOAD_ERR_OK && trim($file['name']) != '' && $file['size'] > 0 && is_uploaded_file($file['tmp_name'])) |
|
157 | + { |
|
150 | 158 | // Don't trust what the browser tells us for mime |
151 | 159 | if(function_exists('mime_content_type')) |
152 | 160 | { |
@@ -189,7 +197,8 @@ discard block |
||
189 | 197 | $new_file = self::createFileFromChunks($temp_dir, str_replace('/','_',$_POST['resumableFilename']), |
190 | 198 | $_POST['resumableChunkSize'], $_POST['resumableTotalSize']); |
191 | 199 | } |
192 | - if( $new_file) { |
|
200 | + if( $new_file) |
|
201 | + { |
|
193 | 202 | $file['tmp_name'] = $new_file; |
194 | 203 | |
195 | 204 | // Data to send back to client |
@@ -214,19 +223,23 @@ discard block |
||
214 | 223 | * @param string $chunkSize - each chunk size (in bytes) |
215 | 224 | * @param string $totalSize - original file size (in bytes) |
216 | 225 | */ |
217 | - private static function createFileFromChunks($temp_dir, $fileName, $chunkSize, $totalSize) { |
|
226 | + private static function createFileFromChunks($temp_dir, $fileName, $chunkSize, $totalSize) |
|
227 | + { |
|
218 | 228 | |
219 | 229 | // count all the parts of this file |
220 | 230 | $total_files = 0; |
221 | - foreach(scandir($temp_dir) as $file) { |
|
222 | - if (stripos($file, $fileName) !== false) { |
|
231 | + foreach(scandir($temp_dir) as $file) |
|
232 | + { |
|
233 | + if (stripos($file, $fileName) !== false) |
|
234 | + { |
|
223 | 235 | $total_files++; |
224 | 236 | } |
225 | 237 | } |
226 | 238 | |
227 | 239 | // check that all the parts are present |
228 | 240 | // the size of the last part is between chunkSize and 2*$chunkSize |
229 | - if ($total_files * $chunkSize >= ($totalSize - $chunkSize + 1)) { |
|
241 | + if ($total_files * $chunkSize >= ($totalSize - $chunkSize + 1)) |
|
242 | + { |
|
230 | 243 | if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir'])) |
231 | 244 | { |
232 | 245 | $new_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'egw_'); |
@@ -237,21 +250,28 @@ discard block |
||
237 | 250 | } |
238 | 251 | |
239 | 252 | // create the final destination file |
240 | - if (($fp = fopen($new_file, 'w')) !== false) { |
|
241 | - for ($i=1; $i<=$total_files; $i++) { |
|
253 | + if (($fp = fopen($new_file, 'w')) !== false) |
|
254 | + { |
|
255 | + for ($i=1; $i<=$total_files; $i++) |
|
256 | + { |
|
242 | 257 | fwrite($fp, file_get_contents($temp_dir.'/'.$fileName.'.part'.$i)); |
243 | 258 | } |
244 | 259 | fclose($fp); |
245 | - } else { |
|
260 | + } |
|
261 | + else |
|
262 | + { |
|
246 | 263 | _log('cannot create the destination file'); |
247 | 264 | return false; |
248 | 265 | } |
249 | 266 | |
250 | 267 | // rename the temporary directory (to avoid access from other |
251 | 268 | // concurrent chunks uploads) and than delete it |
252 | - if (rename($temp_dir, $temp_dir.'_UNUSED')) { |
|
269 | + if (rename($temp_dir, $temp_dir.'_UNUSED')) |
|
270 | + { |
|
253 | 271 | self::rrmdir($temp_dir.'_UNUSED'); |
254 | - } else { |
|
272 | + } |
|
273 | + else |
|
274 | + { |
|
255 | 275 | self::rrmdir($temp_dir); |
256 | 276 | } |
257 | 277 | |
@@ -306,14 +326,23 @@ discard block |
||
306 | 326 | $value = $value_in = self::get_array($content, $form_name); |
307 | 327 | $valid =& self::get_array($validated, $form_name, true); |
308 | 328 | |
309 | - if(!is_array($value)) $value = array(); |
|
329 | + if(!is_array($value)) |
|
330 | + { |
|
331 | + $value = array(); |
|
332 | + } |
|
310 | 333 | |
311 | 334 | // Incoming values indexed by temp name |
312 | - if($value[0]) $value = $value[0]; |
|
335 | + if($value[0]) |
|
336 | + { |
|
337 | + $value = $value[0]; |
|
338 | + } |
|
313 | 339 | |
314 | 340 | foreach($value as $tmp => $file) |
315 | 341 | { |
316 | - if(!$file) continue; |
|
342 | + if(!$file) |
|
343 | + { |
|
344 | + continue; |
|
345 | + } |
|
317 | 346 | if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir'])) |
318 | 347 | { |
319 | 348 | $path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.$tmp; |
@@ -333,7 +362,10 @@ discard block |
||
333 | 362 | ); |
334 | 363 | } |
335 | 364 | |
336 | - if($valid && !$this->attrs['multiple']) $valid = $valid[0]; |
|
365 | + if($valid && !$this->attrs['multiple']) |
|
366 | + { |
|
367 | + $valid = $valid[0]; |
|
368 | + } |
|
337 | 369 | } |
338 | 370 | } |
339 | 371 | } |
@@ -40,12 +40,12 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @param string $xml |
42 | 42 | */ |
43 | - public function __construct($xml='') |
|
43 | + public function __construct($xml = '') |
|
44 | 44 | { |
45 | - if($xml) parent::__construct($xml); |
|
45 | + if ($xml) parent::__construct($xml); |
|
46 | 46 | |
47 | 47 | // Legacy multiple - id ends in [] |
48 | - if(substr($this->id,-2) == '[]') |
|
48 | + if (substr($this->id, -2) == '[]') |
|
49 | 49 | { |
50 | 50 | $this->setElementAttribute($this->id, 'multiple', true); |
51 | 51 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | $response = Api\Json\Response::get(); |
67 | 67 | $request_id = str_replace(' ', '+', rawurldecode($_REQUEST['request_id'])); |
68 | 68 | $widget_id = $_REQUEST['widget_id']; |
69 | - if(!self::$request = Etemplate\Request::read($request_id)) |
|
69 | + if (!self::$request = Etemplate\Request::read($request_id)) |
|
70 | 70 | { |
71 | 71 | $response->error("Could not read session"); |
72 | 72 | return; |
@@ -91,22 +91,22 @@ discard block |
||
91 | 91 | { |
92 | 92 | $widget = $template->getElementById($matches[1].':$cont[id]:'.$matches[3]); |
93 | 93 | } |
94 | - if($widget && $widget->attrs['mime']) |
|
94 | + if ($widget && $widget->attrs['mime']) |
|
95 | 95 | { |
96 | 96 | $mime = $widget->attrs['mime']; |
97 | 97 | } |
98 | 98 | |
99 | 99 | // Check for legacy [] in id to indicate multiple - it changes format |
100 | - if(is_array($files['name'])) |
|
100 | + if (is_array($files['name'])) |
|
101 | 101 | { |
102 | 102 | $file_list = array(); |
103 | - foreach($files as $f_field => $values) |
|
103 | + foreach ($files as $f_field => $values) |
|
104 | 104 | { |
105 | - foreach($values as $key => $f_value) { |
|
105 | + foreach ($values as $key => $f_value) { |
|
106 | 106 | $file_list[$key][$f_field] = $f_value; |
107 | 107 | } |
108 | 108 | } |
109 | - foreach($file_list as $file) |
|
109 | + foreach ($file_list as $file) |
|
110 | 110 | { |
111 | 111 | static::process_uploaded_file($field, $file, $mime, $file_data); |
112 | 112 | } |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | if ($widget) |
121 | 121 | { |
122 | 122 | $callback = $widget->attrs['callback']; |
123 | - if(!$callback) $callback = $template->getElementAttribute($field, 'callback'); |
|
124 | - if($callback) |
|
123 | + if (!$callback) $callback = $template->getElementAttribute($field, 'callback'); |
|
124 | + if ($callback) |
|
125 | 125 | { |
126 | 126 | ExecMethod2($callback, $_FILES[$field], $widget_id, self::$request, $response); |
127 | 127 | } |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | */ |
138 | 138 | protected static function process_uploaded_file($field, Array &$file, $mime, Array &$file_data) |
139 | 139 | { |
140 | - unset($field); // not used |
|
140 | + unset($field); // not used |
|
141 | 141 | |
142 | 142 | // Chunks get mangled a little |
143 | - if($file['name'] == 'blob') |
|
143 | + if ($file['name'] == 'blob') |
|
144 | 144 | { |
145 | 145 | $file['name'] = $_POST['resumableFilename']; |
146 | 146 | $file['type'] = $_POST['resumableType']; |
@@ -148,19 +148,19 @@ discard block |
||
148 | 148 | |
149 | 149 | if ($file['error'] == UPLOAD_ERR_OK && trim($file['name']) != '' && $file['size'] > 0 && is_uploaded_file($file['tmp_name'])) { |
150 | 150 | // Don't trust what the browser tells us for mime |
151 | - if(function_exists('mime_content_type')) |
|
151 | + if (function_exists('mime_content_type')) |
|
152 | 152 | { |
153 | 153 | $file['type'] = $type = Api\MimeMagic::analyze_file($file['tmp_name']); |
154 | 154 | } |
155 | 155 | |
156 | 156 | // Mime check |
157 | - if($mime) |
|
157 | + if ($mime) |
|
158 | 158 | { |
159 | 159 | $is_preg = $mime[0] == '/'; |
160 | - if (!$is_preg && strcasecmp($mime,$type) || |
|
161 | - $is_preg && !preg_match($mime,$type)) |
|
160 | + if (!$is_preg && strcasecmp($mime, $type) || |
|
161 | + $is_preg && !preg_match($mime, $type)) |
|
162 | 162 | { |
163 | - $file_data[$file['name']] = $file['name'].':'.lang('File is of wrong type (%1 != %2)!',$type,$mime); |
|
163 | + $file_data[$file['name']] = $file['name'].':'.lang('File is of wrong type (%1 != %2)!', $type, $mime); |
|
164 | 164 | //error_log(__METHOD__.__LINE__.array2string($file_data[$file['name']])); |
165 | 165 | return false; |
166 | 166 | } |
@@ -169,8 +169,8 @@ discard block |
||
169 | 169 | // Resumable / chunked uploads |
170 | 170 | // init the destination file (format <filename.ext>.part<#chunk> |
171 | 171 | // the file is stored in a temporary directory |
172 | - $temp_dir = $GLOBALS['egw_info']['server']['temp_dir'].'/'.str_replace('/','_',$_POST['resumableIdentifier']); |
|
173 | - $dest_file = $temp_dir.'/'.str_replace('/','_',$_POST['resumableFilename']).'.part'.(int)$_POST['resumableChunkNumber']; |
|
172 | + $temp_dir = $GLOBALS['egw_info']['server']['temp_dir'].'/'.str_replace('/', '_', $_POST['resumableIdentifier']); |
|
173 | + $dest_file = $temp_dir.'/'.str_replace('/', '_', $_POST['resumableFilename']).'.part'.(int)$_POST['resumableChunkNumber']; |
|
174 | 174 | |
175 | 175 | // create the temporary directory |
176 | 176 | if (!is_dir($temp_dir)) |
@@ -186,10 +186,10 @@ discard block |
||
186 | 186 | else |
187 | 187 | { |
188 | 188 | // check if all the parts present, and create the final destination file |
189 | - $new_file = self::createFileFromChunks($temp_dir, str_replace('/','_',$_POST['resumableFilename']), |
|
189 | + $new_file = self::createFileFromChunks($temp_dir, str_replace('/', '_', $_POST['resumableFilename']), |
|
190 | 190 | $_POST['resumableChunkSize'], $_POST['resumableTotalSize']); |
191 | 191 | } |
192 | - if( $new_file) { |
|
192 | + if ($new_file) { |
|
193 | 193 | $file['tmp_name'] = $new_file; |
194 | 194 | |
195 | 195 | // Data to send back to client |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | |
219 | 219 | // count all the parts of this file |
220 | 220 | $total_files = 0; |
221 | - foreach(scandir($temp_dir) as $file) { |
|
221 | + foreach (scandir($temp_dir) as $file) { |
|
222 | 222 | if (stripos($file, $fileName) !== false) { |
223 | 223 | $total_files++; |
224 | 224 | } |
@@ -226,10 +226,10 @@ discard block |
||
226 | 226 | |
227 | 227 | // check that all the parts are present |
228 | 228 | // the size of the last part is between chunkSize and 2*$chunkSize |
229 | - if ($total_files * $chunkSize >= ($totalSize - $chunkSize + 1)) { |
|
229 | + if ($total_files * $chunkSize >= ($totalSize - $chunkSize + 1)) { |
|
230 | 230 | if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir'])) |
231 | 231 | { |
232 | - $new_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'egw_'); |
|
232 | + $new_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'], 'egw_'); |
|
233 | 233 | } |
234 | 234 | else |
235 | 235 | { |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | |
239 | 239 | // create the final destination file |
240 | 240 | if (($fp = fopen($new_file, 'w')) !== false) { |
241 | - for ($i=1; $i<=$total_files; $i++) { |
|
241 | + for ($i = 1; $i <= $total_files; $i++) { |
|
242 | 242 | fwrite($fp, file_get_contents($temp_dir.'/'.$fileName.'.part'.$i)); |
243 | 243 | } |
244 | 244 | fclose($fp); |
@@ -274,13 +274,13 @@ discard block |
||
274 | 274 | { |
275 | 275 | if ($object != "." && $object != "..") |
276 | 276 | { |
277 | - if (filetype($dir . "/" . $object) == "dir") |
|
277 | + if (filetype($dir."/".$object) == "dir") |
|
278 | 278 | { |
279 | - self::rrmdir($dir . "/" . $object); |
|
279 | + self::rrmdir($dir."/".$object); |
|
280 | 280 | } |
281 | 281 | else |
282 | 282 | { |
283 | - unlink($dir . "/" . $object); |
|
283 | + unlink($dir."/".$object); |
|
284 | 284 | } |
285 | 285 | } |
286 | 286 | } |
@@ -297,23 +297,23 @@ discard block |
||
297 | 297 | * @param array $content |
298 | 298 | * @param array &$validated=array() validated content |
299 | 299 | */ |
300 | - public function validate($cname, array $expand, array $content, &$validated=array()) |
|
300 | + public function validate($cname, array $expand, array $content, &$validated = array()) |
|
301 | 301 | { |
302 | 302 | $form_name = self::form_name($cname, $this->id, $expand); |
303 | 303 | |
304 | 304 | if (!$this->is_readonly($cname, $form_name)) |
305 | 305 | { |
306 | 306 | $value = $value_in = self::get_array($content, $form_name); |
307 | - $valid =& self::get_array($validated, $form_name, true); |
|
307 | + $valid = & self::get_array($validated, $form_name, true); |
|
308 | 308 | |
309 | - if(!is_array($value)) $value = array(); |
|
309 | + if (!is_array($value)) $value = array(); |
|
310 | 310 | |
311 | 311 | // Incoming values indexed by temp name |
312 | - if($value[0]) $value = $value[0]; |
|
312 | + if ($value[0]) $value = $value[0]; |
|
313 | 313 | |
314 | - foreach($value as $tmp => $file) |
|
314 | + foreach ($value as $tmp => $file) |
|
315 | 315 | { |
316 | - if(!$file) continue; |
|
316 | + if (!$file) continue; |
|
317 | 317 | if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir'])) |
318 | 318 | { |
319 | 319 | $path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.$tmp; |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | ); |
334 | 334 | } |
335 | 335 | |
336 | - if($valid && !$this->attrs['multiple']) $valid = $valid[0]; |
|
336 | + if ($valid && !$this->attrs['multiple']) $valid = $valid[0]; |
|
337 | 337 | } |
338 | 338 | } |
339 | 339 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @param array &$validated=array() validated content |
45 | 45 | * @return boolean true if no validation error, false otherwise |
46 | 46 | */ |
47 | - public function validate($cname, array $expand, array $content, &$validated=array()) |
|
47 | + public function validate($cname, array $expand, array $content, &$validated = array()) |
|
48 | 48 | { |
49 | 49 | $form_name = self::form_name($cname, $this->id, $expand); |
50 | 50 | //error_log(__METHOD__."('$cname', ".array2string($expand).", ...) $this: get_array(\$content, '$form_name')=".array2string(self::get_array($content, $form_name))); |
@@ -53,18 +53,18 @@ discard block |
||
53 | 53 | { |
54 | 54 | $value = self::get_array($content, $form_name); |
55 | 55 | |
56 | - if( |
|
56 | + if ( |
|
57 | 57 | // Handle case of not existing $row_cont[id], eg: create[] |
58 | 58 | is_array($value) && count($value) == 1 || |
59 | 59 | // check === true, as get_array() ignores a "[]" postfix and returns array() eg. for a not existing $row_cont[id] in "delete[$row_cont[id]]" |
60 | 60 | $value == true |
61 | 61 | ) |
62 | 62 | { |
63 | - $valid =& self::get_array($validated, $form_name, true); |
|
63 | + $valid = & self::get_array($validated, $form_name, true); |
|
64 | 64 | if (true) $valid = is_array($value) ? $value : 'pressed'; |
65 | 65 | |
66 | 66 | // recorded pressed button globally, was in the template object before, put now as static on this object |
67 | - if ($this->type == 'cancel' || $form_name == 'cancel' || substr($form_name,-10) == '[cancel]') |
|
67 | + if ($this->type == 'cancel' || $form_name == 'cancel' || substr($form_name, -10) == '[cancel]') |
|
68 | 68 | { |
69 | 69 | self::$canceled = true; |
70 | 70 | } |
@@ -76,4 +76,4 @@ discard block |
||
76 | 76 | } |
77 | 77 | } |
78 | 78 | } |
79 | -Etemplate\Widget::registerWidget(__NAMESPACE__.'\\Button', array('button','buttononly')); |
|
79 | +Etemplate\Widget::registerWidget(__NAMESPACE__.'\\Button', array('button', 'buttononly')); |
@@ -42,7 +42,7 @@ |
||
42 | 42 | * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' |
43 | 43 | * @param array $content |
44 | 44 | * @param array &$validated=array() validated content |
45 | - * @return boolean true if no validation error, false otherwise |
|
45 | + * @return boolean|null true if no validation error, false otherwise |
|
46 | 46 | */ |
47 | 47 | public function validate($cname, array $expand, array $content, &$validated=array()) |
48 | 48 | { |
@@ -58,10 +58,12 @@ |
||
58 | 58 | is_array($value) && count($value) == 1 || |
59 | 59 | // check === true, as get_array() ignores a "[]" postfix and returns array() eg. for a not existing $row_cont[id] in "delete[$row_cont[id]]" |
60 | 60 | $value == true |
61 | - ) |
|
62 | - { |
|
61 | + ) { |
|
63 | 62 | $valid =& self::get_array($validated, $form_name, true); |
64 | - if (true) $valid = is_array($value) ? $value : 'pressed'; |
|
63 | + if (true) |
|
64 | + { |
|
65 | + $valid = is_array($value) ? $value : 'pressed'; |
|
66 | + } |
|
65 | 67 | |
66 | 68 | // recorded pressed button globally, was in the template object before, put now as static on this object |
67 | 69 | if ($this->type == 'cancel' || $form_name == 'cancel' || substr($form_name,-10) == '[cancel]') |
@@ -65,11 +65,11 @@ discard block |
||
65 | 65 | * @param boolean $respect_disabled =false false (default): ignore disabled, true: method is NOT run for disabled widgets AND their children |
66 | 66 | * @param array $columns_disabled=array() disabled columns |
67 | 67 | */ |
68 | - public function run($method_name, $params=array(''), $respect_disabled=false, &$columns_disabled=array()) |
|
68 | + public function run($method_name, $params = array(''), $respect_disabled = false, &$columns_disabled = array()) |
|
69 | 69 | { |
70 | 70 | // maintain $expand array name-expansion |
71 | - $cname =& $params[0]; |
|
72 | - $expand =& $params[1]; |
|
71 | + $cname = & $params[0]; |
|
72 | + $expand = & $params[1]; |
|
73 | 73 | $old_cname = $params[0]; |
74 | 74 | $old_expand = $params[1]; |
75 | 75 | |
@@ -85,13 +85,13 @@ discard block |
||
85 | 85 | //error_log(__METHOD__."('$method_name', ".array2string($params).', '.array2string($respect_disabled).") $this disabled='{$this->attrs['disabled']}'=".array2string($disabled).": NOT running"); |
86 | 86 | $params[0] = $old_cname; |
87 | 87 | $params[1] = $old_expand; |
88 | - return false; // return |
|
88 | + return false; // return |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | if ($this->id) $cname = self::form_name($cname, $this->id, $expand); |
92 | 92 | if ($expand['cname'] !== $cname && $cname) |
93 | 93 | { |
94 | - $expand['cont'] =& self::get_array(self::$request->content, $cname); |
|
94 | + $expand['cont'] = & self::get_array(self::$request->content, $cname); |
|
95 | 95 | $expand['cname'] = $cname; |
96 | 96 | } |
97 | 97 | |
@@ -101,10 +101,10 @@ discard block |
||
101 | 101 | } |
102 | 102 | //foreach($this->children as $n => $child) |
103 | 103 | $repeat_child = null; |
104 | - for($n = 0; ; ++$n) |
|
104 | + for ($n = 0; ; ++$n) |
|
105 | 105 | { |
106 | 106 | // maintain $expand array name-expansion |
107 | - switch($this->type) |
|
107 | + switch ($this->type) |
|
108 | 108 | { |
109 | 109 | case 'rows': |
110 | 110 | $expand['row'] = $n; |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | if (isset($this->children[$n])) |
117 | 117 | { |
118 | 118 | $child = $this->children[$n]; |
119 | - if($this->type == 'rows' || $this->type == 'columns') |
|
119 | + if ($this->type == 'rows' || $this->type == 'columns') |
|
120 | 120 | { |
121 | 121 | /* |
122 | 122 | * We store a clone of the repeated child, because at the end |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | if (in_array($n, $columns_disabled)) |
144 | 144 | { |
145 | 145 | //error_log(__METHOD__."('$method_name', ".array2string($params).', '.array2string($respect_disabled).") $this column $n is disabled: NOT running"); |
146 | - continue; // do NOT run $method_name on disabled columns |
|
146 | + continue; // do NOT run $method_name on disabled columns |
|
147 | 147 | } |
148 | 148 | } |
149 | 149 | //error_log('Running ' . $method_name . ' on child ' . $n . '(' . $child . ') ['.$expand['row'] . ','.$expand['c'] . ']'); |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | |
152 | 152 | if ($this->type == 'columns' && $disabled) |
153 | 153 | { |
154 | - $columns_disabled[] = $n; // mark column as disabled |
|
154 | + $columns_disabled[] = $n; // mark column as disabled |
|
155 | 155 | } |
156 | 156 | } |
157 | 157 | if ($this->type == 'grid') |
@@ -175,34 +175,34 @@ discard block |
||
175 | 175 | private function need_autorepeat($cname, array $expand) |
176 | 176 | { |
177 | 177 | // check id's of children |
178 | - foreach($this->children as $n => $direct_child) |
|
178 | + foreach ($this->children as $n => $direct_child) |
|
179 | 179 | { |
180 | - foreach(array_merge(array($direct_child), $n ? array() : $direct_child->children) as $child) |
|
180 | + foreach (array_merge(array($direct_child), $n ? array() : $direct_child->children) as $child) |
|
181 | 181 | { |
182 | 182 | $pat = $child->id; |
183 | - while(($patstr = strstr($pat, '$'))) |
|
183 | + while (($patstr = strstr($pat, '$'))) |
|
184 | 184 | { |
185 | - $pat = substr($patstr,$patstr[1] == '{' ? 2 : 1); |
|
185 | + $pat = substr($patstr, $patstr[1] == '{' ? 2 : 1); |
|
186 | 186 | |
187 | 187 | switch ($this->type) |
188 | 188 | { |
189 | 189 | case 'column': |
190 | - $Ok = $pat[0] == 'c' && !(substr($pat,0,4) == 'cont' || substr($pat,0,2) == 'c_' || |
|
191 | - substr($pat,0,4) == 'col_'); |
|
190 | + $Ok = $pat[0] == 'c' && !(substr($pat, 0, 4) == 'cont' || substr($pat, 0, 2) == 'c_' || |
|
191 | + substr($pat, 0, 4) == 'col_'); |
|
192 | 192 | break; |
193 | 193 | case 'row': |
194 | - $Ok = $pat[0] == 'r' && !(substr($pat,0,2) == 'r_' || |
|
195 | - substr($pat,0,4) == 'row_' && substr($pat,0,8) != 'row_cont'); |
|
194 | + $Ok = $pat[0] == 'r' && !(substr($pat, 0, 2) == 'r_' || |
|
195 | + substr($pat, 0, 4) == 'row_' && substr($pat, 0, 8) != 'row_cont'); |
|
196 | 196 | //error_log(__METHOD__."() pat='$pat' --> Ok=".array2string($Ok)); |
197 | 197 | break; |
198 | 198 | default: |
199 | 199 | return false; |
200 | 200 | } |
201 | - if ($Ok && ($fname=self::form_name($cname, $child->id, $expand)) && |
|
201 | + if ($Ok && ($fname = self::form_name($cname, $child->id, $expand)) && |
|
202 | 202 | // need to break if fname ends in [] as get_array() will ignore it and returns whole array |
203 | 203 | // for an id like "run[$row_cont[appname]]" |
204 | 204 | substr($fname, -2) != '[]' && |
205 | - ($value = self::get_array(self::$request->content,$fname)) !== null) // null = not found (can be false!) |
|
205 | + ($value = self::get_array(self::$request->content, $fname)) !== null) // null = not found (can be false!) |
|
206 | 206 | { |
207 | 207 | //error_log(__METHOD__."('$cname', ) $this autorepeating row $expand[row] because of $child->id = '$fname' is ".array2string($value)); |
208 | 208 | unset($value); |
@@ -88,7 +88,10 @@ discard block |
||
88 | 88 | return false; // return |
89 | 89 | } |
90 | 90 | |
91 | - if ($this->id) $cname = self::form_name($cname, $this->id, $expand); |
|
91 | + if ($this->id) |
|
92 | + { |
|
93 | + $cname = self::form_name($cname, $this->id, $expand); |
|
94 | + } |
|
92 | 95 | if ($expand['cname'] !== $cname && $cname) |
93 | 96 | { |
94 | 97 | $expand['cont'] =& self::get_array(self::$request->content, $cname); |
@@ -202,10 +205,13 @@ discard block |
||
202 | 205 | // need to break if fname ends in [] as get_array() will ignore it and returns whole array |
203 | 206 | // for an id like "run[$row_cont[appname]]" |
204 | 207 | substr($fname, -2) != '[]' && |
205 | - ($value = self::get_array(self::$request->content,$fname)) !== null) // null = not found (can be false!) |
|
208 | + ($value = self::get_array(self::$request->content,$fname)) !== null) |
|
209 | + { |
|
210 | + // null = not found (can be false!) |
|
206 | 211 | { |
207 | 212 | //error_log(__METHOD__."('$cname', ) $this autorepeating row $expand[row] because of $child->id = '$fname' is ".array2string($value)); |
208 | 213 | unset($value); |
214 | + } |
|
209 | 215 | return true; |
210 | 216 | } |
211 | 217 | } |
@@ -38,16 +38,16 @@ discard block |
||
38 | 38 | $form_name = self::form_name($cname, $this->id); |
39 | 39 | |
40 | 40 | $config = Api\Html\CkEditorConfig::get_ckeditor_config_array($this->attrs['mode'], $this->attrs['height'], |
41 | - $this->attrs['expand_toolbar'],$this->attrs['base_href'] |
|
41 | + $this->attrs['expand_toolbar'], $this->attrs['base_href'] |
|
42 | 42 | ); |
43 | 43 | // User preferences |
44 | 44 | $font = $GLOBALS['egw_info']['user']['preferences']['common']['rte_font']; |
45 | 45 | $font_size = Api\Html\CkEditorConfig::font_size_from_prefs(); |
46 | 46 | $font_span = '<span style="width: 100%; display: inline; '. |
47 | - ($font?'font-family:'.$font.'; ':'').($font_size?'font-size:'.$font_size.'; ':''). |
|
47 | + ($font ? 'font-family:'.$font.'; ' : '').($font_size ? 'font-size:'.$font_size.'; ' : ''). |
|
48 | 48 | '">​</span>'; |
49 | 49 | if (empty($font) && empty($font_size)) $font_span = ''; |
50 | - if($font_span) |
|
50 | + if ($font_span) |
|
51 | 51 | { |
52 | 52 | $config['preference_style'] = $font_span; |
53 | 53 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @param array &$validated=array() validated content |
66 | 66 | * @return boolean true if no validation error, false otherwise |
67 | 67 | */ |
68 | - public function validate($cname, array $expand, array $content, &$validated=array()) |
|
68 | + public function validate($cname, array $expand, array $content, &$validated = array()) |
|
69 | 69 | { |
70 | 70 | $form_name = self::form_name($cname, $this->id, $expand); |
71 | 71 | |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | { |
78 | 78 | $value = Api\Html\HtmLawed::purify($value, $this->attrs['validation_rules']); |
79 | 79 | } |
80 | - $valid =& self::get_array($validated, $form_name, true); |
|
80 | + $valid = & self::get_array($validated, $form_name, true); |
|
81 | 81 | if (true) $valid = $value; |
82 | 82 | } |
83 | 83 | } |
@@ -42,7 +42,7 @@ |
||
42 | 42 | * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' |
43 | 43 | * @param array $content |
44 | 44 | * @param array &$validated=array() validated content |
45 | - * @return boolean true if no validation error, false otherwise |
|
45 | + * @return boolean|null true if no validation error, false otherwise |
|
46 | 46 | */ |
47 | 47 | public function validate($cname, array $expand, array $content, &$validated=array()) |
48 | 48 | { |
@@ -46,7 +46,10 @@ discard block |
||
46 | 46 | $font_span = '<span style="width: 100%; display: inline; '. |
47 | 47 | ($font?'font-family:'.$font.'; ':'').($font_size?'font-size:'.$font_size.'; ':''). |
48 | 48 | '">​</span>'; |
49 | - if (empty($font) && empty($font_size)) $font_span = ''; |
|
49 | + if (empty($font) && empty($font_size)) |
|
50 | + { |
|
51 | + $font_span = ''; |
|
52 | + } |
|
50 | 53 | if($font_span) |
51 | 54 | { |
52 | 55 | $config['preference_style'] = $font_span; |
@@ -78,7 +81,10 @@ discard block |
||
78 | 81 | $value = Api\Html\HtmLawed::purify($value, $this->attrs['validation_rules']); |
79 | 82 | } |
80 | 83 | $valid =& self::get_array($validated, $form_name, true); |
81 | - if (true) $valid = $value; |
|
84 | + if (true) |
|
85 | + { |
|
86 | + $valid = $value; |
|
87 | + } |
|
82 | 88 | } |
83 | 89 | } |
84 | 90 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function __construct($xml = '') |
33 | 33 | { |
34 | - if($xml) { |
|
34 | + if ($xml) { |
|
35 | 35 | parent::__construct($xml); |
36 | 36 | } |
37 | 37 | } |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * Find items that match the given parameters |
41 | 41 | * using the egw_link class |
42 | 42 | */ |
43 | - public static function ajax_item_search($app, $type, $pattern, $options=array()) |
|
43 | + public static function ajax_item_search($app, $type, $pattern, $options = array()) |
|
44 | 44 | { |
45 | 45 | $options['type'] = $type ? $type : $options['type']; |
46 | 46 | $items = Api\Link::query($app, $pattern, $options); |
@@ -31,7 +31,8 @@ |
||
31 | 31 | */ |
32 | 32 | public function __construct($xml = '') |
33 | 33 | { |
34 | - if($xml) { |
|
34 | + if($xml) |
|
35 | + { |
|
35 | 36 | parent::__construct($xml); |
36 | 37 | } |
37 | 38 | } |
@@ -33,7 +33,7 @@ |
||
33 | 33 | * while it uses select-account for owner in historylog (containing all users). |
34 | 34 | * |
35 | 35 | * @param string $cname |
36 | - */ |
|
36 | + */ |
|
37 | 37 | public function beforeSendToClient($cname) |
38 | 38 | { |
39 | 39 | $form_name = self::form_name($cname, $this->id); |
@@ -38,19 +38,19 @@ discard block |
||
38 | 38 | { |
39 | 39 | $form_name = self::form_name($cname, $this->id); |
40 | 40 | |
41 | - if(is_array(self::$request->content[$form_name]['status-widgets'])) |
|
41 | + if (is_array(self::$request->content[$form_name]['status-widgets'])) |
|
42 | 42 | { |
43 | - foreach(self::$request->content[$form_name]['status-widgets'] as $key => $type) |
|
43 | + foreach (self::$request->content[$form_name]['status-widgets'] as $key => $type) |
|
44 | 44 | { |
45 | - if(!is_array($type)) |
|
45 | + if (!is_array($type)) |
|
46 | 46 | { |
47 | - list($basetype) = explode('-',$type); |
|
47 | + list($basetype) = explode('-', $type); |
|
48 | 48 | $widget = @self::factory($basetype, '<?xml version="1.0"?><'.$type.' type="'.$type.'"/>', $key); |
49 | 49 | $widget->id = $key; |
50 | 50 | $widget->attrs['type'] = $type; |
51 | 51 | $widget->type = $type; |
52 | 52 | |
53 | - if(method_exists($widget, 'beforeSendToClient')) |
|
53 | + if (method_exists($widget, 'beforeSendToClient')) |
|
54 | 54 | { |
55 | 55 | // need to use $form_name as $cname see comment in header |
56 | 56 | $widget->beforeSendToClient($form_name, array()); |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | else |
60 | 60 | { |
61 | 61 | // need to use self::form_name($form_name, $key) as index into sel_options see comment in header |
62 | - $options =& self::get_array(self::$request->sel_options, self::form_name($form_name, $key), true); |
|
62 | + $options = & self::get_array(self::$request->sel_options, self::form_name($form_name, $key), true); |
|
63 | 63 | if (!is_array($options)) $options = array(); |
64 | 64 | $options += $type; |
65 | 65 | } |
@@ -82,11 +82,11 @@ discard block |
||
82 | 82 | * @param array &$validated=array() validated content |
83 | 83 | * @return boolean true if no validation error, false otherwise |
84 | 84 | */ |
85 | - public function validate($cname, array $expand, array $content, &$validated=array()) |
|
85 | + public function validate($cname, array $expand, array $content, &$validated = array()) |
|
86 | 86 | { |
87 | 87 | $form_name = self::form_name($cname, $this->id, $expand); |
88 | 88 | $value = self::get_array($content, $form_name); |
89 | - $valid =& self::get_array($validated, $form_name, true); |
|
89 | + $valid = & self::get_array($validated, $form_name, true); |
|
90 | 90 | if (true) $valid = $value; |
91 | 91 | return true; |
92 | 92 | } |
@@ -60,7 +60,10 @@ discard block |
||
60 | 60 | { |
61 | 61 | // need to use self::form_name($form_name, $key) as index into sel_options see comment in header |
62 | 62 | $options =& self::get_array(self::$request->sel_options, self::form_name($form_name, $key), true); |
63 | - if (!is_array($options)) $options = array(); |
|
63 | + if (!is_array($options)) |
|
64 | + { |
|
65 | + $options = array(); |
|
66 | + } |
|
64 | 67 | $options += $type; |
65 | 68 | } |
66 | 69 | |
@@ -87,7 +90,10 @@ discard block |
||
87 | 90 | $form_name = self::form_name($cname, $this->id, $expand); |
88 | 91 | $value = self::get_array($content, $form_name); |
89 | 92 | $valid =& self::get_array($validated, $form_name, true); |
90 | - if (true) $valid = $value; |
|
93 | + if (true) |
|
94 | + { |
|
95 | + $valid = $value; |
|
96 | + } |
|
91 | 97 | return true; |
92 | 98 | } |
93 | 99 | } |