@@ -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)) |
@@ -27,12 +27,12 @@ discard block |
||
27 | 27 | * |
28 | 28 | * @param string $xml |
29 | 29 | */ |
30 | - public function __construct($xml='') |
|
30 | + public function __construct($xml = '') |
|
31 | 31 | { |
32 | - if($xml) parent::__construct($xml); |
|
32 | + if ($xml) parent::__construct($xml); |
|
33 | 33 | |
34 | 34 | // Legacy multiple - id ends in [] |
35 | - if(substr($this->id,-2) == '[]') |
|
35 | + if (substr($this->id, -2) == '[]') |
|
36 | 36 | { |
37 | 37 | $this->setElementAttribute($this->id, 'multiple', true); |
38 | 38 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | $response = Api\Json\Response::get(); |
53 | 53 | $request_id = str_replace(' ', '+', rawurldecode($_REQUEST['request_id'])); |
54 | 54 | $widget_id = $_REQUEST['widget_id']; |
55 | - if(!self::$request = Etemplate\Request::read($request_id)) { |
|
55 | + if (!self::$request = Etemplate\Request::read($request_id)) { |
|
56 | 56 | $response->error("Could not read session"); |
57 | 57 | return; |
58 | 58 | } |
@@ -70,20 +70,20 @@ discard block |
||
70 | 70 | foreach ($_FILES as $field => &$files) |
71 | 71 | { |
72 | 72 | $widget = $template->getElementById($widget_id ? $widget_id : $field); |
73 | - if($widget && $widget->attrs['mime']) { |
|
73 | + if ($widget && $widget->attrs['mime']) { |
|
74 | 74 | $mime = $widget->attrs['mime']; |
75 | 75 | } |
76 | 76 | |
77 | 77 | // Check for legacy [] in id to indicate multiple - it changes format |
78 | - if(is_array($files['name'])) { |
|
78 | + if (is_array($files['name'])) { |
|
79 | 79 | $file_list = array(); |
80 | - foreach($files as $f_field => $values) |
|
80 | + foreach ($files as $f_field => $values) |
|
81 | 81 | { |
82 | - foreach($values as $key => $f_value) { |
|
82 | + foreach ($values as $key => $f_value) { |
|
83 | 83 | $file_list[$key][$f_field] = $f_value; |
84 | 84 | } |
85 | 85 | } |
86 | - foreach($file_list as $file) |
|
86 | + foreach ($file_list as $file) |
|
87 | 87 | { |
88 | 88 | self::process_uploaded_file($field, $file, $mime, $file_data); |
89 | 89 | } |
@@ -99,13 +99,13 @@ discard block |
||
99 | 99 | $response->data($file_data); |
100 | 100 | |
101 | 101 | // Check for a callback, call it if there is one |
102 | - foreach($_FILES as $field => $file) |
|
102 | + foreach ($_FILES as $field => $file) |
|
103 | 103 | { |
104 | - if(($element = $template->getElementById($field))) |
|
104 | + if (($element = $template->getElementById($field))) |
|
105 | 105 | { |
106 | 106 | $callback = $element->attrs['callback']; |
107 | - if(!$callback) $callback = $template->getElementAttribute($field, 'callback'); |
|
108 | - if($callback) |
|
107 | + if (!$callback) $callback = $template->getElementAttribute($field, 'callback'); |
|
108 | + if ($callback) |
|
109 | 109 | { |
110 | 110 | ExecMethod($callback, $_FILES[$field]); |
111 | 111 | } |
@@ -118,10 +118,10 @@ discard block |
||
118 | 118 | */ |
119 | 119 | protected static function process_uploaded_file($field, Array &$file, $mime, Array &$file_data) |
120 | 120 | { |
121 | - unset($field); // not used |
|
121 | + unset($field); // not used |
|
122 | 122 | |
123 | 123 | // Chunks get mangled a little |
124 | - if($file['name'] == 'blob') |
|
124 | + if ($file['name'] == 'blob') |
|
125 | 125 | { |
126 | 126 | $file['name'] = $_POST['resumableFilename']; |
127 | 127 | $file['type'] = $_POST['resumableType']; |
@@ -129,14 +129,14 @@ discard block |
||
129 | 129 | |
130 | 130 | if ($file['error'] == UPLOAD_ERR_OK && trim($file['name']) != '' && $file['size'] > 0 && is_uploaded_file($file['tmp_name'])) { |
131 | 131 | // Mime check |
132 | - if($mime) |
|
132 | + if ($mime) |
|
133 | 133 | { |
134 | 134 | $type = $file['type']; |
135 | 135 | $is_preg = $mime[0] == '/'; |
136 | - if (!$is_preg && strcasecmp($mime,$type) || |
|
137 | - $is_preg && !preg_match($mime,$type)) |
|
136 | + if (!$is_preg && strcasecmp($mime, $type) || |
|
137 | + $is_preg && !preg_match($mime, $type)) |
|
138 | 138 | { |
139 | - $file_data[$file['name']] = $file['name'].':'.lang('File is of wrong type (%1 != %2)!',$type,$mime); |
|
139 | + $file_data[$file['name']] = $file['name'].':'.lang('File is of wrong type (%1 != %2)!', $type, $mime); |
|
140 | 140 | //error_log(__METHOD__.__LINE__.array2string($file_data[$file['name']])); |
141 | 141 | return false; |
142 | 142 | } |
@@ -145,8 +145,8 @@ discard block |
||
145 | 145 | // Resumable / chunked uploads |
146 | 146 | // init the destination file (format <filename.ext>.part<#chunk> |
147 | 147 | // the file is stored in a temporary directory |
148 | - $temp_dir = $GLOBALS['egw_info']['server']['temp_dir'].'/'.str_replace('/','_',$_POST['resumableIdentifier']); |
|
149 | - $dest_file = $temp_dir.'/'.str_replace('/','_',$_POST['resumableFilename']).'.part'.(int)$_POST['resumableChunkNumber']; |
|
148 | + $temp_dir = $GLOBALS['egw_info']['server']['temp_dir'].'/'.str_replace('/', '_', $_POST['resumableIdentifier']); |
|
149 | + $dest_file = $temp_dir.'/'.str_replace('/', '_', $_POST['resumableFilename']).'.part'.(int)$_POST['resumableChunkNumber']; |
|
150 | 150 | |
151 | 151 | // create the temporary directory |
152 | 152 | if (!is_dir($temp_dir)) |
@@ -162,10 +162,10 @@ discard block |
||
162 | 162 | else |
163 | 163 | { |
164 | 164 | // check if all the parts present, and create the final destination file |
165 | - $new_file = self::createFileFromChunks($temp_dir, str_replace('/','_',$_POST['resumableFilename']), |
|
165 | + $new_file = self::createFileFromChunks($temp_dir, str_replace('/', '_', $_POST['resumableFilename']), |
|
166 | 166 | $_POST['resumableChunkSize'], $_POST['resumableTotalSize']); |
167 | 167 | } |
168 | - if( $new_file) { |
|
168 | + if ($new_file) { |
|
169 | 169 | $file['tmp_name'] = $new_file; |
170 | 170 | |
171 | 171 | // Data to send back to client |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | |
195 | 195 | // count all the parts of this file |
196 | 196 | $total_files = 0; |
197 | - foreach(scandir($temp_dir) as $file) { |
|
197 | + foreach (scandir($temp_dir) as $file) { |
|
198 | 198 | if (stripos($file, $fileName) !== false) { |
199 | 199 | $total_files++; |
200 | 200 | } |
@@ -202,10 +202,10 @@ discard block |
||
202 | 202 | |
203 | 203 | // check that all the parts are present |
204 | 204 | // the size of the last part is between chunkSize and 2*$chunkSize |
205 | - if ($total_files * $chunkSize >= ($totalSize - $chunkSize + 1)) { |
|
205 | + if ($total_files * $chunkSize >= ($totalSize - $chunkSize + 1)) { |
|
206 | 206 | if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir'])) |
207 | 207 | { |
208 | - $new_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'egw_'); |
|
208 | + $new_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'], 'egw_'); |
|
209 | 209 | } |
210 | 210 | else |
211 | 211 | { |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | |
215 | 215 | // create the final destination file |
216 | 216 | if (($fp = fopen($new_file, 'w')) !== false) { |
217 | - for ($i=1; $i<=$total_files; $i++) { |
|
217 | + for ($i = 1; $i <= $total_files; $i++) { |
|
218 | 218 | fwrite($fp, file_get_contents($temp_dir.'/'.$fileName.'.part'.$i)); |
219 | 219 | } |
220 | 220 | fclose($fp); |
@@ -250,13 +250,13 @@ discard block |
||
250 | 250 | { |
251 | 251 | if ($object != "." && $object != "..") |
252 | 252 | { |
253 | - if (filetype($dir . "/" . $object) == "dir") |
|
253 | + if (filetype($dir."/".$object) == "dir") |
|
254 | 254 | { |
255 | - self::rrmdir($dir . "/" . $object); |
|
255 | + self::rrmdir($dir."/".$object); |
|
256 | 256 | } |
257 | 257 | else |
258 | 258 | { |
259 | - unlink($dir . "/" . $object); |
|
259 | + unlink($dir."/".$object); |
|
260 | 260 | } |
261 | 261 | } |
262 | 262 | } |
@@ -273,23 +273,23 @@ discard block |
||
273 | 273 | * @param array $content |
274 | 274 | * @param array &$validated=array() validated content |
275 | 275 | */ |
276 | - public function validate($cname, array $expand, array $content, &$validated=array()) |
|
276 | + public function validate($cname, array $expand, array $content, &$validated = array()) |
|
277 | 277 | { |
278 | 278 | $form_name = self::form_name($cname, $this->id, $expand); |
279 | 279 | |
280 | 280 | if (!$this->is_readonly($cname, $form_name)) |
281 | 281 | { |
282 | 282 | $value = $value_in = self::get_array($content, $form_name); |
283 | - $valid =& self::get_array($validated, $form_name, true); |
|
283 | + $valid = & self::get_array($validated, $form_name, true); |
|
284 | 284 | |
285 | - if(!is_array($value)) $value = array(); |
|
285 | + if (!is_array($value)) $value = array(); |
|
286 | 286 | |
287 | 287 | // Incoming values indexed by temp name |
288 | - if($value[0]) $value = $value[0]; |
|
288 | + if ($value[0]) $value = $value[0]; |
|
289 | 289 | |
290 | - foreach($value as $tmp => $file) |
|
290 | + foreach ($value as $tmp => $file) |
|
291 | 291 | { |
292 | - if(!$file) continue; |
|
292 | + if (!$file) continue; |
|
293 | 293 | if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir'])) |
294 | 294 | { |
295 | 295 | $path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.$tmp; |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | ); |
310 | 310 | } |
311 | 311 | |
312 | - if($valid && !$this->attrs['multiple']) $valid = $valid[0]; |
|
312 | + if ($valid && !$this->attrs['multiple']) $valid = $valid[0]; |
|
313 | 313 | } |
314 | 314 | } |
315 | 315 | } |
@@ -29,7 +29,10 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function __construct($xml='') |
31 | 31 | { |
32 | - if($xml) parent::__construct($xml); |
|
32 | + if($xml) |
|
33 | + { |
|
34 | + parent::__construct($xml); |
|
35 | + } |
|
33 | 36 | |
34 | 37 | // Legacy multiple - id ends in [] |
35 | 38 | if(substr($this->id,-2) == '[]') |
@@ -48,11 +51,13 @@ discard block |
||
48 | 51 | * |
49 | 52 | * @note Currently, no attempt is made to clean up files automatically. |
50 | 53 | */ |
51 | - public static function ajax_upload() { |
|
54 | + public static function ajax_upload() |
|
55 | + { |
|
52 | 56 | $response = Api\Json\Response::get(); |
53 | 57 | $request_id = str_replace(' ', '+', rawurldecode($_REQUEST['request_id'])); |
54 | 58 | $widget_id = $_REQUEST['widget_id']; |
55 | - if(!self::$request = Etemplate\Request::read($request_id)) { |
|
59 | + if(!self::$request = Etemplate\Request::read($request_id)) |
|
60 | + { |
|
56 | 61 | $response->error("Could not read session"); |
57 | 62 | return; |
58 | 63 | } |
@@ -70,16 +75,19 @@ discard block |
||
70 | 75 | foreach ($_FILES as $field => &$files) |
71 | 76 | { |
72 | 77 | $widget = $template->getElementById($widget_id ? $widget_id : $field); |
73 | - if($widget && $widget->attrs['mime']) { |
|
78 | + if($widget && $widget->attrs['mime']) |
|
79 | + { |
|
74 | 80 | $mime = $widget->attrs['mime']; |
75 | 81 | } |
76 | 82 | |
77 | 83 | // Check for legacy [] in id to indicate multiple - it changes format |
78 | - if(is_array($files['name'])) { |
|
84 | + if(is_array($files['name'])) |
|
85 | + { |
|
79 | 86 | $file_list = array(); |
80 | 87 | foreach($files as $f_field => $values) |
81 | 88 | { |
82 | - foreach($values as $key => $f_value) { |
|
89 | + foreach($values as $key => $f_value) |
|
90 | + { |
|
83 | 91 | $file_list[$key][$f_field] = $f_value; |
84 | 92 | } |
85 | 93 | } |
@@ -104,7 +112,10 @@ discard block |
||
104 | 112 | if(($element = $template->getElementById($field))) |
105 | 113 | { |
106 | 114 | $callback = $element->attrs['callback']; |
107 | - if(!$callback) $callback = $template->getElementAttribute($field, 'callback'); |
|
115 | + if(!$callback) |
|
116 | + { |
|
117 | + $callback = $template->getElementAttribute($field, 'callback'); |
|
118 | + } |
|
108 | 119 | if($callback) |
109 | 120 | { |
110 | 121 | ExecMethod($callback, $_FILES[$field]); |
@@ -127,7 +138,8 @@ discard block |
||
127 | 138 | $file['type'] = $_POST['resumableType']; |
128 | 139 | } |
129 | 140 | |
130 | - if ($file['error'] == UPLOAD_ERR_OK && trim($file['name']) != '' && $file['size'] > 0 && is_uploaded_file($file['tmp_name'])) { |
|
141 | + if ($file['error'] == UPLOAD_ERR_OK && trim($file['name']) != '' && $file['size'] > 0 && is_uploaded_file($file['tmp_name'])) |
|
142 | + { |
|
131 | 143 | // Mime check |
132 | 144 | if($mime) |
133 | 145 | { |
@@ -165,7 +177,8 @@ discard block |
||
165 | 177 | $new_file = self::createFileFromChunks($temp_dir, str_replace('/','_',$_POST['resumableFilename']), |
166 | 178 | $_POST['resumableChunkSize'], $_POST['resumableTotalSize']); |
167 | 179 | } |
168 | - if( $new_file) { |
|
180 | + if( $new_file) |
|
181 | + { |
|
169 | 182 | $file['tmp_name'] = $new_file; |
170 | 183 | |
171 | 184 | // Data to send back to client |
@@ -190,19 +203,23 @@ discard block |
||
190 | 203 | * @param string $chunkSize - each chunk size (in bytes) |
191 | 204 | * @param string $totalSize - original file size (in bytes) |
192 | 205 | */ |
193 | - private static function createFileFromChunks($temp_dir, $fileName, $chunkSize, $totalSize) { |
|
206 | + private static function createFileFromChunks($temp_dir, $fileName, $chunkSize, $totalSize) |
|
207 | + { |
|
194 | 208 | |
195 | 209 | // count all the parts of this file |
196 | 210 | $total_files = 0; |
197 | - foreach(scandir($temp_dir) as $file) { |
|
198 | - if (stripos($file, $fileName) !== false) { |
|
211 | + foreach(scandir($temp_dir) as $file) |
|
212 | + { |
|
213 | + if (stripos($file, $fileName) !== false) |
|
214 | + { |
|
199 | 215 | $total_files++; |
200 | 216 | } |
201 | 217 | } |
202 | 218 | |
203 | 219 | // check that all the parts are present |
204 | 220 | // the size of the last part is between chunkSize and 2*$chunkSize |
205 | - if ($total_files * $chunkSize >= ($totalSize - $chunkSize + 1)) { |
|
221 | + if ($total_files * $chunkSize >= ($totalSize - $chunkSize + 1)) |
|
222 | + { |
|
206 | 223 | if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir'])) |
207 | 224 | { |
208 | 225 | $new_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'],'egw_'); |
@@ -213,21 +230,28 @@ discard block |
||
213 | 230 | } |
214 | 231 | |
215 | 232 | // create the final destination file |
216 | - if (($fp = fopen($new_file, 'w')) !== false) { |
|
217 | - for ($i=1; $i<=$total_files; $i++) { |
|
233 | + if (($fp = fopen($new_file, 'w')) !== false) |
|
234 | + { |
|
235 | + for ($i=1; $i<=$total_files; $i++) |
|
236 | + { |
|
218 | 237 | fwrite($fp, file_get_contents($temp_dir.'/'.$fileName.'.part'.$i)); |
219 | 238 | } |
220 | 239 | fclose($fp); |
221 | - } else { |
|
240 | + } |
|
241 | + else |
|
242 | + { |
|
222 | 243 | _log('cannot create the destination file'); |
223 | 244 | return false; |
224 | 245 | } |
225 | 246 | |
226 | 247 | // rename the temporary directory (to avoid access from other |
227 | 248 | // concurrent chunks uploads) and than delete it |
228 | - if (rename($temp_dir, $temp_dir.'_UNUSED')) { |
|
249 | + if (rename($temp_dir, $temp_dir.'_UNUSED')) |
|
250 | + { |
|
229 | 251 | self::rrmdir($temp_dir.'_UNUSED'); |
230 | - } else { |
|
252 | + } |
|
253 | + else |
|
254 | + { |
|
231 | 255 | self::rrmdir($temp_dir); |
232 | 256 | } |
233 | 257 | |
@@ -282,14 +306,23 @@ discard block |
||
282 | 306 | $value = $value_in = self::get_array($content, $form_name); |
283 | 307 | $valid =& self::get_array($validated, $form_name, true); |
284 | 308 | |
285 | - if(!is_array($value)) $value = array(); |
|
309 | + if(!is_array($value)) |
|
310 | + { |
|
311 | + $value = array(); |
|
312 | + } |
|
286 | 313 | |
287 | 314 | // Incoming values indexed by temp name |
288 | - if($value[0]) $value = $value[0]; |
|
315 | + if($value[0]) |
|
316 | + { |
|
317 | + $value = $value[0]; |
|
318 | + } |
|
289 | 319 | |
290 | 320 | foreach($value as $tmp => $file) |
291 | 321 | { |
292 | - if(!$file) continue; |
|
322 | + if(!$file) |
|
323 | + { |
|
324 | + continue; |
|
325 | + } |
|
293 | 326 | if (is_dir($GLOBALS['egw_info']['server']['temp_dir']) && is_writable($GLOBALS['egw_info']['server']['temp_dir'])) |
294 | 327 | { |
295 | 328 | $path = $GLOBALS['egw_info']['server']['temp_dir'].'/'.$tmp; |
@@ -309,7 +342,10 @@ discard block |
||
309 | 342 | ); |
310 | 343 | } |
311 | 344 | |
312 | - if($valid && !$this->attrs['multiple']) $valid = $valid[0]; |
|
345 | + if($valid && !$this->attrs['multiple']) |
|
346 | + { |
|
347 | + $valid = $valid[0]; |
|
348 | + } |
|
313 | 349 | } |
314 | 350 | } |
315 | 351 | } |
@@ -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 |
@@ -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 | } |
@@ -29,14 +29,14 @@ |
||
29 | 29 | * @param array &$validated=array() validated content |
30 | 30 | * @return boolean true if no validation error, false otherwise |
31 | 31 | */ |
32 | - public function validate($cname, array $expand, array $content, &$validated=array()) |
|
32 | + public function validate($cname, array $expand, array $content, &$validated = array()) |
|
33 | 33 | { |
34 | 34 | $form_name = self::form_name($cname, $this->id, $expand); |
35 | 35 | |
36 | 36 | if (!$this->is_readonly($cname, $form_name)) |
37 | 37 | { |
38 | 38 | $value = self::get_array($content, $form_name); |
39 | - $valid =& self::get_array($validated, $form_name, true); |
|
39 | + $valid = & self::get_array($validated, $form_name, true); |
|
40 | 40 | if (true) $valid = $value; |
41 | 41 | } |
42 | 42 | } |
@@ -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 | { |
@@ -37,7 +37,10 @@ |
||
37 | 37 | { |
38 | 38 | $value = self::get_array($content, $form_name); |
39 | 39 | $valid =& self::get_array($validated, $form_name, true); |
40 | - if (true) $valid = $value; |
|
40 | + if (true) |
|
41 | + { |
|
42 | + $valid = $value; |
|
43 | + } |
|
41 | 44 | } |
42 | 45 | } |
43 | 46 | } |
@@ -29,21 +29,21 @@ |
||
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 | 34 | $form_name = self::form_name($cname, $this->id, $expand); |
35 | - $value =& self::get_array(self::$request->content, $form_name); |
|
35 | + $value = & self::get_array(self::$request->content, $form_name); |
|
36 | 36 | |
37 | 37 | $image = $value != '' ? $value : $this->attrs['src']; |
38 | 38 | |
39 | - if (is_string($image)) list($app,$img) = explode('/',$image,2); |
|
40 | - if (!$app || !$img || !is_dir(EGW_SERVER_ROOT.'/'.$app) || strpos($img,'/')!==false) |
|
39 | + if (is_string($image)) list($app, $img) = explode('/', $image, 2); |
|
40 | + if (!$app || !$img || !is_dir(EGW_SERVER_ROOT.'/'.$app) || strpos($img, '/') !== false) |
|
41 | 41 | { |
42 | 42 | $img = $image; |
43 | - list($app) = explode('.',$form_name); |
|
43 | + list($app) = explode('.', $form_name); |
|
44 | 44 | } |
45 | 45 | $src = Api\Image::find($app, $img); |
46 | - if(!$this->id) |
|
46 | + if (!$this->id) |
|
47 | 47 | { |
48 | 48 | // self::setElementAttribute($this->attrs['src'], 'id', $this->attrs['src']); |
49 | 49 | } |
@@ -36,7 +36,10 @@ |
||
36 | 36 | |
37 | 37 | $image = $value != '' ? $value : $this->attrs['src']; |
38 | 38 | |
39 | - if (is_string($image)) list($app,$img) = explode('/',$image,2); |
|
39 | + if (is_string($image)) |
|
40 | + { |
|
41 | + list($app,$img) = explode('/',$image,2); |
|
42 | + } |
|
40 | 43 | if (!$app || !$img || !is_dir(EGW_SERVER_ROOT.'/'.$app) || strpos($img,'/')!==false) |
41 | 44 | { |
42 | 45 | $img = $image; |
@@ -32,7 +32,7 @@ |
||
32 | 32 | { |
33 | 33 | $GLOBALS['egw_info']['flags']['currentapp'] = 'etemplate'; |
34 | 34 | $GLOBALS['egw_info']['flags']['app_header'] = 'et2 Widgets'; |
35 | - //'js_link_registry' => True, |
|
35 | + //'js_link_registry' => True, |
|
36 | 36 | |
37 | 37 | // Widget browser code |
38 | 38 | Api\Framework::includeJS('/api/js/etemplate/widget_browser.js'); |
@@ -46,7 +46,7 @@ |
||
46 | 46 | |
47 | 47 | Api\Framework::includeCSS('/api/templates/default/etemplate2.css'); |
48 | 48 | |
49 | - Api\Framework::includeCSS('api','widget_browser',false); |
|
49 | + Api\Framework::includeCSS('api', 'widget_browser', false); |
|
50 | 50 | |
51 | 51 | // load translations |
52 | 52 | Api\Translation::add_app('etemplate'); |