@@ -150,7 +150,10 @@ discard block |
||
150 | 150 | */ |
151 | 151 | protected function action($attr, $action, array &$attrs) |
152 | 152 | { |
153 | - if (self::DEBUG) error_log(__METHOD__."('$attr', ".array2string($action).')'); |
|
153 | + if (self::DEBUG) |
|
154 | + { |
|
155 | + error_log(__METHOD__."('$attr', ".array2string($action).')'); |
|
156 | + } |
|
154 | 157 | // action is an assignment |
155 | 158 | if (is_scalar($action) || is_null($action)) |
156 | 159 | { |
@@ -160,7 +163,10 @@ discard block |
||
160 | 163 | $replace = array(); |
161 | 164 | foreach($attrs as $a => $v) |
162 | 165 | { |
163 | - if (is_scalar($v) || is_null($v)) $replace['@'.$a] = $v; |
|
166 | + if (is_scalar($v) || is_null($v)) |
|
167 | + { |
|
168 | + $replace['@'.$a] = $v; |
|
169 | + } |
|
164 | 170 | } |
165 | 171 | $action = strtr($action, $replace); |
166 | 172 | // now replace with non-scalar value, eg. if values is an array: "@value", "@value[key] or "@value[@key]" |
@@ -170,7 +176,10 @@ discard block |
||
170 | 176 | } |
171 | 177 | } |
172 | 178 | $attrs[$attr] = $action; |
173 | - if (self::DEBUG) error_log(__METHOD__."('$attr', ".array2string($action).") attrs['$attr'] = ".array2string($action).', attrs='.array2string($attrs)); |
|
179 | + if (self::DEBUG) |
|
180 | + { |
|
181 | + error_log(__METHOD__."('$attr', ".array2string($action).") attrs['$attr'] = ".array2string($action).', attrs='.array2string($attrs)); |
|
182 | + } |
|
174 | 183 | } |
175 | 184 | // action is a serverside callback |
176 | 185 | elseif(is_array($action) && isset($action['__callback__'])) |
@@ -218,7 +227,10 @@ discard block |
||
218 | 227 | $attrs[$attr] = $actions; |
219 | 228 | $actions = array($attr => $actions); |
220 | 229 | } |
221 | - if (self::DEBUG) error_log(__METHOD__."(attr='$attr', action=".array2string($action).") attrs['$attr']=='{$attrs[$attr]}' --> running actions"); |
|
230 | + if (self::DEBUG) |
|
231 | + { |
|
232 | + error_log(__METHOD__."(attr='$attr', action=".array2string($action).") attrs['$attr']=='{$attrs[$attr]}' --> running actions"); |
|
233 | + } |
|
222 | 234 | foreach($actions as $attr => $action) |
223 | 235 | { |
224 | 236 | $this->action($attr, $action, $attrs); |
@@ -148,9 +148,15 @@ discard block |
||
148 | 148 | */ |
149 | 149 | public function get_contact($value, array $attrs) |
150 | 150 | { |
151 | - if (is_array($value) && !(array_key_exists('app',$value) && array_key_exists('id', $value))) return $value; |
|
151 | + if (is_array($value) && !(array_key_exists('app',$value) && array_key_exists('id', $value))) |
|
152 | + { |
|
153 | + return $value; |
|
154 | + } |
|
152 | 155 | |
153 | - if(is_array($value) && array_key_exists('app', $value) && array_key_exists('id', $value)) $value = $value['id']; |
|
156 | + if(is_array($value) && array_key_exists('app', $value) && array_key_exists('id', $value)) |
|
157 | + { |
|
158 | + $value = $value['id']; |
|
159 | + } |
|
154 | 160 | switch($attrs['type']) |
155 | 161 | { |
156 | 162 | case 'contact-account': |
@@ -162,7 +168,11 @@ discard block |
||
162 | 168 | // fall-through |
163 | 169 | case 'contact-value': |
164 | 170 | default: |
165 | - if (substr($value,0,12) == 'addressbook:') $value = substr($value,12); // link-entry syntax |
|
171 | + if (substr($value,0,12) == 'addressbook:') |
|
172 | + { |
|
173 | + $value = substr($value,12); |
|
174 | + } |
|
175 | + // link-entry syntax |
|
166 | 176 | if (!($contact = $this->contacts->read($value))) |
167 | 177 | { |
168 | 178 | $contact = array(); |
@@ -27,7 +27,10 @@ discard block |
||
27 | 27 | |
28 | 28 | public function __construct($xml='') |
29 | 29 | { |
30 | - if($xml) parent::__construct($xml); |
|
30 | + if($xml) |
|
31 | + { |
|
32 | + parent::__construct($xml); |
|
33 | + } |
|
31 | 34 | } |
32 | 35 | |
33 | 36 | /** |
@@ -64,9 +67,15 @@ discard block |
||
64 | 67 | } |
65 | 68 | $value =& self::get_array(self::$request->content, $form_name, true); |
66 | 69 | $path = Api\Link::vfs_path($app,$id,'',true); |
67 | - if (!empty($relpath)) $path .= '/'.$relpath; |
|
70 | + if (!empty($relpath)) |
|
71 | + { |
|
72 | + $path .= '/'.$relpath; |
|
73 | + } |
|
68 | 74 | |
69 | - if (true) $value = array(); |
|
75 | + if (true) |
|
76 | + { |
|
77 | + $value = array(); |
|
78 | + } |
|
70 | 79 | |
71 | 80 | // Single file, already existing |
72 | 81 | if (substr($path,-1) != '/' && Api\Vfs::file_exists($path) && !Api\Vfs::is_dir($path)) |
@@ -194,7 +203,10 @@ discard block |
||
194 | 203 | $replace[substr($link['id']['tmp_name'], strlen(Api\Vfs::PREFIX))] = |
195 | 204 | Api\Link::vfs_path($app, $id, Api\Vfs::basename($link['id']['tmp_name']), true); |
196 | 205 | |
197 | - if (!in_array($matches[1], $remove_dir)) $remove_dir[] = $matches[1]; |
|
206 | + if (!in_array($matches[1], $remove_dir)) |
|
207 | + { |
|
208 | + $remove_dir[] = $matches[1]; |
|
209 | + } |
|
198 | 210 | } |
199 | 211 | } |
200 | 212 | if ($replace) |
@@ -218,7 +230,10 @@ discard block |
||
218 | 230 | */ |
219 | 231 | static function get_temp_dir($app, $postfix=null) |
220 | 232 | { |
221 | - if (!isset($postfix)) $postfix = md5(time().session_id()); |
|
233 | + if (!isset($postfix)) |
|
234 | + { |
|
235 | + $postfix = md5(time().session_id()); |
|
236 | + } |
|
222 | 237 | |
223 | 238 | return '/home/'.$GLOBALS['egw_info']['user']['account_lid'].'/.tmp/'.$app.'_'.$postfix; |
224 | 239 | } |
@@ -245,10 +260,13 @@ discard block |
||
245 | 260 | { |
246 | 261 | // add extension to path |
247 | 262 | $parts = explode('.',$filename); |
248 | - if (($extension = array_pop($parts)) && Api\MimeMagic::ext2mime($extension)) // really an extension --> add it to path |
|
263 | + if (($extension = array_pop($parts)) && Api\MimeMagic::ext2mime($extension)) |
|
264 | + { |
|
265 | + // really an extension --> add it to path |
|
249 | 266 | { |
250 | 267 | $path .= '.'.$extension; |
251 | 268 | } |
269 | + } |
|
252 | 270 | } |
253 | 271 | else // multiple upload with dir given (trailing slash) |
254 | 272 | { |
@@ -294,7 +312,10 @@ discard block |
||
294 | 312 | switch($this->type) |
295 | 313 | { |
296 | 314 | case 'vfs-upload': |
297 | - if(!is_array($value)) $value = array(); |
|
315 | + if(!is_array($value)) |
|
316 | + { |
|
317 | + $value = array(); |
|
318 | + } |
|
298 | 319 | /* Check & skip files that made it asyncronously |
299 | 320 | list($app,$id,$relpath) = explode(':',$this->id,3); |
300 | 321 | //... |
@@ -305,7 +326,10 @@ discard block |
||
305 | 326 | parent::validate($cname, $content, $validated); |
306 | 327 | break; |
307 | 328 | } |
308 | - if (true) $valid = $value; |
|
329 | + if (true) |
|
330 | + { |
|
331 | + $valid = $value; |
|
332 | + } |
|
309 | 333 | } |
310 | 334 | |
311 | 335 | /** |
@@ -317,14 +341,20 @@ discard block |
||
317 | 341 | if (empty($id) || $id == 'undefined') |
318 | 342 | { |
319 | 343 | static $tmppath = array(); // static var, so all vfs-uploads get created in the same temporary dir |
320 | - if (!isset($tmppath[$app])) $tmppath[$app] = self::get_temp_dir ($app); |
|
344 | + if (!isset($tmppath[$app])) |
|
345 | + { |
|
346 | + $tmppath[$app] = self::get_temp_dir ($app); |
|
347 | + } |
|
321 | 348 | $path = $tmppath[$app]; |
322 | 349 | } |
323 | 350 | else |
324 | 351 | { |
325 | 352 | $path = Api\Link::vfs_path($app,$id,'',true); |
326 | 353 | } |
327 | - if (!empty($relpath)) $path .= '/'.$relpath; |
|
354 | + if (!empty($relpath)) |
|
355 | + { |
|
356 | + $path .= '/'.$relpath; |
|
357 | + } |
|
328 | 358 | return $path; |
329 | 359 | } |
330 | 360 | } |
@@ -81,7 +81,8 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function __construct($xml = '') |
83 | 83 | { |
84 | - if($xml) { |
|
84 | + if($xml) |
|
85 | + { |
|
85 | 86 | parent::__construct($xml); |
86 | 87 | } |
87 | 88 | } |
@@ -144,21 +145,33 @@ discard block |
||
144 | 145 | // add option children's values too, "" is not read, therefore we cast to string |
145 | 146 | foreach($this->children as $child) |
146 | 147 | { |
147 | - if ($child->type == 'option') $allowed[] = (string)$child->attrs['value']; |
|
148 | + if ($child->type == 'option') |
|
149 | + { |
|
150 | + $allowed[] = (string)$child->attrs['value']; |
|
151 | + } |
|
148 | 152 | } |
149 | 153 | |
150 | - if (!$this->attrs['multiple'] || !($this->attrs['options'] > 1)) $allowed[] = ''; |
|
154 | + if (!$this->attrs['multiple'] || !($this->attrs['options'] > 1)) |
|
155 | + { |
|
156 | + $allowed[] = ''; |
|
157 | + } |
|
151 | 158 | |
152 | 159 | foreach((array) $value as $val) |
153 | 160 | { |
154 | 161 | // handle empty-label for all widget types |
155 | - if ((string)$val === '' && in_array('', $allowed)) continue; |
|
162 | + if ((string)$val === '' && in_array('', $allowed)) |
|
163 | + { |
|
164 | + continue; |
|
165 | + } |
|
156 | 166 | |
157 | 167 | switch ($widget_type) |
158 | 168 | { |
159 | 169 | case 'select-account': |
160 | 170 | // If in allowed options, skip account check to support app-specific options |
161 | - if(count($allowed) > 0 && in_array($val,$allowed)) continue; |
|
171 | + if(count($allowed) > 0 && in_array($val,$allowed)) |
|
172 | + { |
|
173 | + continue; |
|
174 | + } |
|
162 | 175 | |
163 | 176 | // validate accounts independent of options know to server |
164 | 177 | $account_type = $this->attrs['account_type'] ? $this->attrs['account_type'] : 'accounts'; |
@@ -169,8 +182,7 @@ discard block |
||
169 | 182 | in_array($account_type, array('owngroups', 'memberships')) && |
170 | 183 | !in_array($val, $GLOBALS['egw']->accounts->memberships( |
171 | 184 | $GLOBALS['egw_info']['user']['account_id'], true)) |
172 | - ) |
|
173 | - { |
|
185 | + ) { |
|
174 | 186 | self::set_validation_error($form_name, lang("'%1' is NOT allowed ('%2')!", $val, |
175 | 187 | !$type?'not found' : ($type == 1 ? 'user' : 'group')),''); |
176 | 188 | $value = ''; |
@@ -230,10 +242,13 @@ discard block |
||
230 | 242 | { |
231 | 243 | $value = array_merge($value, (array)self::$request->preserv[$unavailable_name]); |
232 | 244 | } |
233 | - elseif(!$value) // for single cat, we only restore unavailable one, if no other was selected |
|
245 | + elseif(!$value) |
|
246 | + { |
|
247 | + // for single cat, we only restore unavailable one, if no other was selected |
|
234 | 248 | { |
235 | 249 | $value = self::$request->preserv[$unavailable_name]; |
236 | 250 | } |
251 | + } |
|
237 | 252 | } |
238 | 253 | } |
239 | 254 | if (isset($value)) |
@@ -258,10 +273,13 @@ discard block |
||
258 | 273 | { |
259 | 274 | //error_log(__METHOD__."('$cname') this->id=$this->id, this->type=$this->type, this->attrs=".array2string($this->attrs)); |
260 | 275 | $matches = null; |
261 | - if ($cname == '$row') // happens eg. with custom-fields: $cname='$row', this->id='#something' |
|
276 | + if ($cname == '$row') |
|
277 | + { |
|
278 | + // happens eg. with custom-fields: $cname='$row', this->id='#something' |
|
262 | 279 | { |
263 | 280 | $form_name = $this->id; |
264 | 281 | } |
282 | + } |
|
265 | 283 | // happens with fields in nm-header: $cname='nm', this->id='${row}[something]' or '{$row}[something]' |
266 | 284 | elseif (preg_match('/(\${row}|{\$row})\[([^]]+)\]$/', $this->id, $matches)) |
267 | 285 | { |
@@ -281,7 +299,10 @@ discard block |
||
281 | 299 | { |
282 | 300 | $form_name = self::form_name($cname, $this->id, $expand); |
283 | 301 | } |
284 | - if (!is_array(self::$request->sel_options[$form_name])) self::$request->sel_options[$form_name] = array(); |
|
302 | + if (!is_array(self::$request->sel_options[$form_name])) |
|
303 | + { |
|
304 | + self::$request->sel_options[$form_name] = array(); |
|
305 | + } |
|
285 | 306 | $type = $this->attrs['type'] ? $this->attrs['type'] : $this->type; |
286 | 307 | if ($type != 'select' && $type != 'menupopup') |
287 | 308 | { |
@@ -380,7 +401,10 @@ discard block |
||
380 | 401 | if(is_array($label)) |
381 | 402 | { |
382 | 403 | self::fix_encoded_options($label, false); |
383 | - if ($use_array_of_objects && !array_key_exists('value', $label)) $label['value'] = $value; |
|
404 | + if ($use_array_of_objects && !array_key_exists('value', $label)) |
|
405 | + { |
|
406 | + $label['value'] = $value; |
|
407 | + } |
|
384 | 408 | } |
385 | 409 | else |
386 | 410 | { |
@@ -607,13 +631,27 @@ discard block |
||
607 | 631 | |
608 | 632 | case 'select-year': // options: #rows,#before(default=3),#after(default=2) |
609 | 633 | $options[''] = ''; |
610 | - if ($type <= 0) $type = 3; |
|
611 | - if ($type2 <= 0) $type2 = 2; |
|
612 | - if ($type > 100 && $type2 > 100 && $type > $type) { $y = $type; $type=$type2; $type2=$y; } |
|
634 | + if ($type <= 0) |
|
635 | + { |
|
636 | + $type = 3; |
|
637 | + } |
|
638 | + if ($type2 <= 0) |
|
639 | + { |
|
640 | + $type2 = 2; |
|
641 | + } |
|
642 | + if ($type > 100 && $type2 > 100 && $type > $type) |
|
643 | + { |
|
644 | +$y = $type; $type=$type2; $type2=$y; } |
|
613 | 645 | $y = date('Y')-$type; |
614 | - if ($value && $value-$type < $y || $type > 100) $y = $type > 100 ? $type : $value-$type; |
|
646 | + if ($value && $value-$type < $y || $type > 100) |
|
647 | + { |
|
648 | + $y = $type > 100 ? $type : $value-$type; |
|
649 | + } |
|
615 | 650 | $to = date('Y')+$type2; |
616 | - if ($value && $value+$type2 > $to || $type2 > 100) $to = $type2 > 100 ? $type2 : $value+$type2; |
|
651 | + if ($value && $value+$type2 > $to || $type2 > 100) |
|
652 | + { |
|
653 | + $to = $type2 > 100 ? $type2 : $value+$type2; |
|
654 | + } |
|
617 | 655 | for ($n = 0; $y <= $to && $n < 200; ++$n) |
618 | 656 | { |
619 | 657 | $options[$y] = $y++; |
@@ -651,8 +689,14 @@ discard block |
||
651 | 689 | MCAL_M_WEEKEND => 'weekend', |
652 | 690 | ); |
653 | 691 | } |
654 | - if ($weekstart == 'Saturday') $options[MCAL_M_SATURDAY] = 'saturday'; |
|
655 | - if ($weekstart != 'Monday') $options[MCAL_M_SUNDAY] = 'sunday'; |
|
692 | + if ($weekstart == 'Saturday') |
|
693 | + { |
|
694 | + $options[MCAL_M_SATURDAY] = 'saturday'; |
|
695 | + } |
|
696 | + if ($weekstart != 'Monday') |
|
697 | + { |
|
698 | + $options[MCAL_M_SUNDAY] = 'sunday'; |
|
699 | + } |
|
656 | 700 | $options += array( |
657 | 701 | MCAL_M_MONDAY => 'monday', |
658 | 702 | MCAL_M_TUESDAY => 'tuesday', |
@@ -660,8 +704,14 @@ discard block |
||
660 | 704 | MCAL_M_THURSDAY => 'thursday', |
661 | 705 | MCAL_M_FRIDAY => 'friday', |
662 | 706 | ); |
663 | - if ($weekstart != 'Saturday') $options[MCAL_M_SATURDAY] = 'saturday'; |
|
664 | - if ($weekstart == 'Monday') $options[MCAL_M_SUNDAY] = 'sunday'; |
|
707 | + if ($weekstart != 'Saturday') |
|
708 | + { |
|
709 | + $options[MCAL_M_SATURDAY] = 'saturday'; |
|
710 | + } |
|
711 | + if ($weekstart == 'Monday') |
|
712 | + { |
|
713 | + $options[MCAL_M_SUNDAY] = 'sunday'; |
|
714 | + } |
|
665 | 715 | if ($rows >= 2 && $type == 1) |
666 | 716 | { |
667 | 717 | $options += array( |
@@ -698,16 +748,22 @@ discard block |
||
698 | 748 | $type = $type === '' ? 1 : intval($type); // min |
699 | 749 | $type2 = $type2 === '' ? 10 : intval($type2); // max |
700 | 750 | $format = '%d'; |
701 | - if (!empty($type3) && $type3[0] == '0') // leading zero |
|
751 | + if (!empty($type3) && $type3[0] == '0') |
|
752 | + { |
|
753 | + // leading zero |
|
702 | 754 | { |
703 | 755 | $format = '%0'.strlen($type3).'d'; |
704 | 756 | } |
757 | + } |
|
705 | 758 | $type3 = !$type3 ? 1 : intval($type3); // decrement |
706 | 759 | if (($type <= $type2) != ($type3 > 0)) |
707 | 760 | { |
708 | 761 | $type3 = -$type3; // void infinite loop |
709 | 762 | } |
710 | - if (!empty($type4)) $format .= lang($type4); |
|
763 | + if (!empty($type4)) |
|
764 | + { |
|
765 | + $format .= lang($type4); |
|
766 | + } |
|
711 | 767 | for ($i=0,$n=$type; $n <= $type2 && $i <= 100; $n += $type3,++$i) |
712 | 768 | { |
713 | 769 | $options[$n] = sprintf($format,$n); |
@@ -741,10 +797,13 @@ discard block |
||
741 | 797 | { |
742 | 798 | $value = calendar_timezones::id2tz($value); |
743 | 799 | } |
744 | - if ($readonly) // for readonly we dont need to fetch all TZ's |
|
800 | + if ($readonly) |
|
801 | + { |
|
802 | + // for readonly we dont need to fetch all TZ's |
|
745 | 803 | { |
746 | 804 | $options[$value] = calendar_timezones::tz2id($value,'name'); |
747 | 805 | } |
806 | + } |
|
748 | 807 | else |
749 | 808 | { |
750 | 809 | $options = $type ? Api\DateTime::getTimezones() : Api\DateTime::getUserTimezones($value); |
@@ -816,7 +875,10 @@ discard block |
||
816 | 875 | if (!is_array($acc)) |
817 | 876 | { |
818 | 877 | $data = $GLOBALS['egw']->accounts->get_account_data($id); |
819 | - if (!isset($data[$id])) return '#'.$id; |
|
878 | + if (!isset($data[$id])) |
|
879 | + { |
|
880 | + return '#'.$id; |
|
881 | + } |
|
820 | 882 | foreach(array('type','lid','firstname','lastname') as $name) |
821 | 883 | { |
822 | 884 | $acc['account_'.$name] = $data[$id][$name]; |
@@ -844,7 +906,8 @@ discard block |
||
844 | 906 | $acc['account_firstname'],$acc['account_lastname']); |
845 | 907 | break; |
846 | 908 | } |
847 | - if($show_type) { |
|
909 | + if($show_type) |
|
910 | + { |
|
848 | 911 | $info = array( |
849 | 912 | 'label' => $info, |
850 | 913 | 'icon' => $acc['account_type'] == 'g' ? 'addressbook/group' : 'user' |
@@ -49,7 +49,10 @@ discard block |
||
49 | 49 | $old_cname = $params[0]; |
50 | 50 | $old_expand = $params[1]; |
51 | 51 | |
52 | - if ($this->id && $this->type != 'groupbox') $cname = self::form_name($cname, $this->id, $params[1]); |
|
52 | + if ($this->id && $this->type != 'groupbox') |
|
53 | + { |
|
54 | + $cname = self::form_name($cname, $this->id, $params[1]); |
|
55 | + } |
|
53 | 56 | if ($expand['cname'] !== $cname && $cname) |
54 | 57 | { |
55 | 58 | $expand['cont'] =& self::get_array(self::$request->content, $cname); |
@@ -121,10 +124,13 @@ discard block |
||
121 | 124 | // need to break if fname ends in [] as get_array() will ignore it and returns whole array |
122 | 125 | // for an id like "run[$row_cont[appname]]" |
123 | 126 | substr($fname, -2) != '[]' && |
124 | - ($value = self::get_array(self::$request->content, $fname)) !== null) // null = not found (can be false!) |
|
127 | + ($value = self::get_array(self::$request->content, $fname)) !== null) |
|
128 | + { |
|
129 | + // null = not found (can be false!) |
|
125 | 130 | { |
126 | 131 | //error_log(__METHOD__."($widget,$cname) $this autorepeating row $expand[row] because of $check_widget->id = '$fname' is ".array2string($value)); |
127 | 132 | unset($value); |
133 | + } |
|
128 | 134 | return true; |
129 | 135 | } |
130 | 136 | } |
@@ -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 | { |
@@ -90,12 +90,18 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function set_row_value($cname, Array $expand, Array &$data) |
92 | 92 | { |
93 | - if($this->type == 'date-duration') return; |
|
93 | + if($this->type == 'date-duration') |
|
94 | + { |
|
95 | + return; |
|
96 | + } |
|
94 | 97 | |
95 | 98 | $form_name = self::form_name($cname, $this->id, $expand); |
96 | 99 | $value =& $this->get_array($data, $form_name, true); |
97 | 100 | |
98 | - if (true) $value = $this->format_date($value); |
|
101 | + if (true) |
|
102 | + { |
|
103 | + $value = $this->format_date($value); |
|
104 | + } |
|
99 | 105 | } |
100 | 106 | |
101 | 107 | /** |
@@ -105,7 +111,11 @@ discard block |
||
105 | 111 | */ |
106 | 112 | public function format_date($value) |
107 | 113 | { |
108 | - if (!$value) return $value; // otherwise we will get current date or 1970-01-01 instead of an empty value |
|
114 | + if (!$value) |
|
115 | + { |
|
116 | + return $value; |
|
117 | + } |
|
118 | + // otherwise we will get current date or 1970-01-01 instead of an empty value |
|
109 | 119 | |
110 | 120 | if ($this->attrs['dataformat'] && !is_numeric($value)) |
111 | 121 | { |
@@ -145,9 +155,12 @@ discard block |
||
145 | 155 | { |
146 | 156 | $form_name = self::form_name($cname, $this->id, $expand); |
147 | 157 | |
148 | - if (!$this->is_readonly($cname, $form_name) && $this->type != 'date-since') // date-since is always readonly |
|
158 | + if (!$this->is_readonly($cname, $form_name) && $this->type != 'date-since') |
|
159 | + { |
|
160 | + // date-since is always readonly |
|
149 | 161 | { |
150 | 162 | $value = self::get_array($content, $form_name); |
163 | + } |
|
151 | 164 | $valid =& self::get_array($validated, $form_name, true); |
152 | 165 | |
153 | 166 | if ((string)$value === '' && $this->attrs['needed']) |
@@ -209,10 +222,13 @@ discard block |
||
209 | 222 | // Not null, blank |
210 | 223 | $value = ''; |
211 | 224 | } |
212 | - elseif (empty($this->attrs['dataformat'])) // integer timestamp |
|
225 | + elseif (empty($this->attrs['dataformat'])) |
|
226 | + { |
|
227 | + // integer timestamp |
|
213 | 228 | { |
214 | 229 | $valid = $date->format('ts'); |
215 | 230 | } |
231 | + } |
|
216 | 232 | // string with formatting letters like for php's date() method |
217 | 233 | elseif ($date && ($valid = $date->format($this->attrs['dataformat']))) |
218 | 234 | { |
@@ -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 | } |
@@ -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]') |