@@ -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 | } |
@@ -90,9 +90,9 @@ discard block |
||
90 | 90 | */ |
91 | 91 | const ICON_PATH = '/api/images'; |
92 | 92 | |
93 | - public function __construct($xml='') |
|
93 | + public function __construct($xml = '') |
|
94 | 94 | { |
95 | - if($xml) { |
|
95 | + if ($xml) { |
|
96 | 96 | parent::__construct($xml); |
97 | 97 | } |
98 | 98 | } |
@@ -115,13 +115,13 @@ discard block |
||
115 | 115 | * @param string $cname |
116 | 116 | * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' |
117 | 117 | */ |
118 | - public function beforeSendToClient($cname, array $expand=null) |
|
118 | + public function beforeSendToClient($cname, array $expand = null) |
|
119 | 119 | { |
120 | 120 | $form_name = self::form_name($cname, $this->id, $expand); |
121 | 121 | $value = self::get_array(self::$request->content, $form_name, true); |
122 | 122 | |
123 | 123 | $value['start'] = 0; |
124 | - if(!array_key_exists('num_rows',$value)) |
|
124 | + if (!array_key_exists('num_rows', $value)) |
|
125 | 125 | { |
126 | 126 | $value['num_rows'] = self::INITIAL_ROWS; |
127 | 127 | } |
@@ -130,40 +130,40 @@ discard block |
||
130 | 130 | |
131 | 131 | $send_value = $value; |
132 | 132 | |
133 | - list($app) = explode('.',$value['get_rows']); |
|
134 | - if(!$GLOBALS['egw_info']['apps'][$app]) |
|
133 | + list($app) = explode('.', $value['get_rows']); |
|
134 | + if (!$GLOBALS['egw_info']['apps'][$app]) |
|
135 | 135 | { |
136 | - list($app) = explode('.',$this->attrs['template']); |
|
136 | + list($app) = explode('.', $this->attrs['template']); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | // Check for a favorite in URL |
140 | - if($_GET['favorite'] && $value['favorites']) |
|
140 | + if ($_GET['favorite'] && $value['favorites']) |
|
141 | 141 | { |
142 | - $safe_name = preg_replace('/[^A-Za-z0-9-_]/','_',strip_tags($_GET['favorite'])); |
|
143 | - $pref_name = "favorite_" .$safe_name; |
|
142 | + $safe_name = preg_replace('/[^A-Za-z0-9-_]/', '_', strip_tags($_GET['favorite'])); |
|
143 | + $pref_name = "favorite_".$safe_name; |
|
144 | 144 | |
145 | 145 | // Do some easy applying of filters server side |
146 | 146 | $favorite = $GLOBALS['egw_info']['user']['preferences'][$app][$pref_name]; |
147 | - if(!$favorite && $_GET['favorite'] == 'blank') |
|
147 | + if (!$favorite && $_GET['favorite'] == 'blank') |
|
148 | 148 | { |
149 | 149 | // Have to go through each of these |
150 | - foreach(array('search','cat_id','filter','filter2') as $filter) |
|
150 | + foreach (array('search', 'cat_id', 'filter', 'filter2') as $filter) |
|
151 | 151 | { |
152 | 152 | $send_value[$filter] = ''; |
153 | 153 | } |
154 | 154 | unset($send_value['col_filter']); |
155 | 155 | } |
156 | 156 | // Old type |
157 | - if($favorite && $favorite['filter']) |
|
157 | + if ($favorite && $favorite['filter']) |
|
158 | 158 | { |
159 | 159 | $favorite['state'] = $favorite['filter']; |
160 | 160 | } |
161 | - if($favorite && $favorite['state']) |
|
161 | + if ($favorite && $favorite['state']) |
|
162 | 162 | { |
163 | 163 | $send_value = array_merge($value, $favorite['state']); |
164 | 164 | |
165 | 165 | // Ajax call can handle the saved sort here, but this can't |
166 | - if($favorite['state']['sort']) |
|
166 | + if ($favorite['state']['sort']) |
|
167 | 167 | { |
168 | 168 | unset($send_value['sort']); |
169 | 169 | $send_value['order'] = $favorite['state']['sort']['id']; |
@@ -175,19 +175,19 @@ discard block |
||
175 | 175 | unset($send_value['favorite']); |
176 | 176 | |
177 | 177 | // Parse sort into something that get_rows functions are expecting: db_field in order, ASC/DESC in sort |
178 | - if(is_array($send_value['sort'])) |
|
178 | + if (is_array($send_value['sort'])) |
|
179 | 179 | { |
180 | 180 | $send_value['order'] = $send_value['sort']['id']; |
181 | 181 | $send_value['sort'] = $send_value['sort']['asc'] ? 'ASC' : 'DESC'; |
182 | 182 | } |
183 | - if($value['num_rows'] != 0) |
|
183 | + if ($value['num_rows'] != 0) |
|
184 | 184 | { |
185 | 185 | $total = self::call_get_rows($send_value, $send_value['rows'], self::$request->readonlys, null, null, $this); |
186 | 186 | } |
187 | - if (true) $value =& self::get_array(self::$request->content, $form_name, true); |
|
187 | + if (true) $value = & self::get_array(self::$request->content, $form_name, true); |
|
188 | 188 | |
189 | 189 | // Add favorite here so app doesn't save it in the session |
190 | - if($_GET['favorite']) |
|
190 | + if ($_GET['favorite']) |
|
191 | 191 | { |
192 | 192 | $send_value['favorite'] = $safe_name; |
193 | 193 | } |
@@ -195,32 +195,32 @@ discard block |
||
195 | 195 | $value['total'] = $total; |
196 | 196 | |
197 | 197 | // Send categories |
198 | - if(!$value['no_cat'] && !$value['cat_is_select']) |
|
198 | + if (!$value['no_cat'] && !$value['cat_is_select']) |
|
199 | 199 | { |
200 | 200 | $cat_app = $value['cat_app'] ? $value['cat_app'] : $GLOBALS['egw_info']['flags']['current_app']; |
201 | 201 | $value['options-cat_id'] = self::$request->sel_options['cat_id'] ? self::$request->sel_options['cat_id'] : array(); |
202 | 202 | |
203 | 203 | // Add 'All', if not already there |
204 | - if(!$value['options-cat_id'][''] && !$value['options-cat_id'][0]) |
|
204 | + if (!$value['options-cat_id'][''] && !$value['options-cat_id'][0]) |
|
205 | 205 | { |
206 | 206 | $value['options-cat_id'][''] = lang('All categories'); |
207 | 207 | } |
208 | - $value['options-cat_id'] += Select::typeOptions('select-cat', ',,'.$cat_app,$no_lang=true,false,$value['cat_id']); |
|
208 | + $value['options-cat_id'] += Select::typeOptions('select-cat', ',,'.$cat_app, $no_lang = true, false, $value['cat_id']); |
|
209 | 209 | Select::fix_encoded_options($value['options-cat_id']); |
210 | 210 | } |
211 | 211 | |
212 | 212 | // Favorite group for admins |
213 | - if($GLOBALS['egw_info']['apps']['admin'] && $value['favorites']) |
|
213 | + if ($GLOBALS['egw_info']['apps']['admin'] && $value['favorites']) |
|
214 | 214 | { |
215 | 215 | self::$request->sel_options[$form_name]['favorite']['group'] = array('all' => lang('All users')) + |
216 | - Select::typeOptions('select-account',',groups'); |
|
216 | + Select::typeOptions('select-account', ',groups'); |
|
217 | 217 | } |
218 | - foreach($value as $name => &$_value) |
|
218 | + foreach ($value as $name => &$_value) |
|
219 | 219 | { |
220 | - if(strpos($name, 'options-') !== false && $_value) |
|
220 | + if (strpos($name, 'options-') !== false && $_value) |
|
221 | 221 | { |
222 | 222 | $select = substr($name, 8); |
223 | - if(!self::$request->sel_options[$select]) |
|
223 | + if (!self::$request->sel_options[$select]) |
|
224 | 224 | { |
225 | 225 | self::$request->sel_options[$select] = array(); |
226 | 226 | } |
@@ -231,14 +231,14 @@ discard block |
||
231 | 231 | //unset($value[$name]); |
232 | 232 | } |
233 | 233 | } |
234 | - if($value['rows']['sel_options']) |
|
234 | + if ($value['rows']['sel_options']) |
|
235 | 235 | { |
236 | - self::$request->sel_options = array_merge(self::$request->sel_options,$value['rows']['sel_options']); |
|
236 | + self::$request->sel_options = array_merge(self::$request->sel_options, $value['rows']['sel_options']); |
|
237 | 237 | unset($value['rows']['sel_options']); |
238 | 238 | } |
239 | 239 | |
240 | 240 | // If column selection preference is forced, set a flag to turn off UI |
241 | - $pref_name = 'nextmatch-' . (isset($value['columnselection_pref']) ? $value['columnselection_pref'] : $this->attrs['template']); |
|
241 | + $pref_name = 'nextmatch-'.(isset($value['columnselection_pref']) ? $value['columnselection_pref'] : $this->attrs['template']); |
|
242 | 242 | $value['no_columnselection'] = $value['no_columnselection'] || ( |
243 | 243 | $GLOBALS['egw']->preferences->forced[$app][$pref_name] && |
244 | 244 | // Need to check admin too, or it will be impossible to turn off |
@@ -278,8 +278,8 @@ discard block |
||
278 | 278 | * @todo for $queriedRange[refresh] first check if there's any modification since $lastModified, return $result[order]===null |
279 | 279 | * @return array with values for keys 'total', 'rows', 'readonlys', 'order', 'data' and 'lastModification' |
280 | 280 | */ |
281 | - static public function ajax_get_rows($exec_id, array $queriedRange, array $filters = array(), $form_name='nm', |
|
282 | - array $knownUids=null, $lastModified=null) |
|
281 | + static public function ajax_get_rows($exec_id, array $queriedRange, array $filters = array(), $form_name = 'nm', |
|
282 | + array $knownUids = null, $lastModified = null) |
|
283 | 283 | { |
284 | 284 | self::$request = Etemplate\Request::read($exec_id); |
285 | 285 | // fix for somehow empty etemplate request content |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | self::$response = Api\Json\Response::get(); |
291 | 291 | |
292 | 292 | $value = self::get_array(self::$request->content, $form_name, true); |
293 | - if(!is_array($value)) |
|
293 | + if (!is_array($value)) |
|
294 | 294 | { |
295 | 295 | $value = ($value) ? array($value) : array(); |
296 | 296 | } |
@@ -305,15 +305,15 @@ discard block |
||
305 | 305 | ); |
306 | 306 | $valid_filters = array(); |
307 | 307 | |
308 | - if($template) |
|
308 | + if ($template) |
|
309 | 309 | { |
310 | - $template->run('validate', array('', $expand, $expand['cont'], &$valid_filters), false); // $respect_disabled=false: as client may disable things, here we validate everything and leave it to the get_rows to interpret |
|
310 | + $template->run('validate', array('', $expand, $expand['cont'], &$valid_filters), false); // $respect_disabled=false: as client may disable things, here we validate everything and leave it to the get_rows to interpret |
|
311 | 311 | $filters = $valid_filters[$form_name]; |
312 | 312 | } |
313 | 313 | // Avoid empty arrays, they cause problems with db filtering |
314 | - foreach($filters['col_filter'] as $col => &$val) |
|
314 | + foreach ($filters['col_filter'] as $col => &$val) |
|
315 | 315 | { |
316 | - if(is_array($val) && count($val) == 0) |
|
316 | + if (is_array($val) && count($val) == 0) |
|
317 | 317 | { |
318 | 318 | unset($filters['col_filter'][$col]); |
319 | 319 | } |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | $result = array(); |
329 | 329 | |
330 | 330 | // Parse sort into something that get_rows functions are expecting: db_field in order, ASC/DESC in sort |
331 | - if(is_array($value['sort'])) |
|
331 | + if (is_array($value['sort'])) |
|
332 | 332 | { |
333 | 333 | $value['order'] = $value['sort']['id']; |
334 | 334 | $value['sort'] = $value['sort']['asc'] ? 'ASC' : 'DESC'; |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | |
337 | 337 | $value['start'] = (int)$queriedRange['start']; |
338 | 338 | $value['num_rows'] = (int)$queriedRange['num_rows']; |
339 | - if($value['num_rows'] == 0) $value['num_rows'] = self::INITIAL_ROWS; |
|
339 | + if ($value['num_rows'] == 0) $value['num_rows'] = self::INITIAL_ROWS; |
|
340 | 340 | // if app supports parent_id / hierarchy ($value['parent_id'] not empty), set parent_id as filter |
341 | 341 | if (($parent_id = $value['parent_id'])) |
342 | 342 | { |
@@ -346,9 +346,9 @@ discard block |
||
346 | 346 | } |
347 | 347 | |
348 | 348 | // Set current app for get_rows |
349 | - list($app) = explode('.',self::$request->method); |
|
350 | - if(!$app) list($app) = explode('::',self::$request->method); |
|
351 | - if($app) |
|
349 | + list($app) = explode('.', self::$request->method); |
|
350 | + if (!$app) list($app) = explode('::', self::$request->method); |
|
351 | + if ($app) |
|
352 | 352 | { |
353 | 353 | $GLOBALS['egw_info']['flags']['currentapp'] = $app; |
354 | 354 | Api\Translation::add_app($app); |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | } |
362 | 362 | $rows = $result['data'] = $result['order'] = array(); |
363 | 363 | $result['total'] = self::call_get_rows($value, $rows, $result['readonlys'], null, null, $template); |
364 | - $result['lastModification'] = Api\DateTime::to('now', 'ts')-1; |
|
364 | + $result['lastModification'] = Api\DateTime::to('now', 'ts') - 1; |
|
365 | 365 | |
366 | 366 | if (isset($GLOBALS['egw_info']['flags']['app_header']) && self::$request->app_header != $GLOBALS['egw_info']['flags']['app_header']) |
367 | 367 | { |
@@ -372,12 +372,12 @@ discard block |
||
372 | 372 | $row_id = isset($value['row_id']) ? $value['row_id'] : 'id'; |
373 | 373 | $row_modified = $value['row_modified']; |
374 | 374 | |
375 | - foreach($rows as $n => $row) |
|
375 | + foreach ($rows as $n => $row) |
|
376 | 376 | { |
377 | 377 | $kUkey = false; |
378 | 378 | if (is_int($n) && $row) |
379 | 379 | { |
380 | - if (!isset($row[$row_id])) unset($row_id); // unset default row_id of 'id', if not used |
|
380 | + if (!isset($row[$row_id])) unset($row_id); // unset default row_id of 'id', if not used |
|
381 | 381 | if (!isset($row[$row_modified])) unset($row_modified); |
382 | 382 | |
383 | 383 | $id = $row_id ? $row[$row_id] : $n; |
@@ -405,11 +405,11 @@ discard block |
||
405 | 405 | { |
406 | 406 | // Encode all select options and re-index to avoid Firefox's problem with |
407 | 407 | // '' => 'All' |
408 | - if($n == 'sel_options') |
|
408 | + if ($n == 'sel_options') |
|
409 | 409 | { |
410 | - foreach($row as &$options) |
|
410 | + foreach ($row as &$options) |
|
411 | 411 | { |
412 | - Select::fix_encoded_options($options,true); |
|
412 | + Select::fix_encoded_options($options, true); |
|
413 | 413 | } |
414 | 414 | } |
415 | 415 | $result['rows'][$n] = $row; |
@@ -481,23 +481,23 @@ discard block |
||
481 | 481 | |
482 | 482 | // Check for anything changed in the query |
483 | 483 | // Tell the client about the changes |
484 | - $request_value =& self::get_array(self::$request->content, $form_name,true); |
|
484 | + $request_value = & self::get_array(self::$request->content, $form_name, true); |
|
485 | 485 | $changes = $no_rows = false; |
486 | 486 | |
487 | - foreach($value_in as $key => $original_value) |
|
487 | + foreach ($value_in as $key => $original_value) |
|
488 | 488 | { |
489 | 489 | // These keys are ignored |
490 | - if(in_array($key, array('col_filter','start','num_rows','total','order','sort'))) |
|
490 | + if (in_array($key, array('col_filter', 'start', 'num_rows', 'total', 'order', 'sort'))) |
|
491 | 491 | { |
492 | 492 | continue; |
493 | 493 | } |
494 | - if($original_value == $value[$key]) continue; |
|
494 | + if ($original_value == $value[$key]) continue; |
|
495 | 495 | |
496 | 496 | // These keys we don't send row data back, as they cause a partial reload |
497 | - if(in_array($key, array('template'))) $no_rows = true; |
|
497 | + if (in_array($key, array('template'))) $no_rows = true; |
|
498 | 498 | |
499 | 499 | // Actions still need extra handling |
500 | - if($key == 'actions' && !isset($value['actions'][0])) |
|
500 | + if ($key == 'actions' && !isset($value['actions'][0])) |
|
501 | 501 | { |
502 | 502 | $value['action_links'] = array(); |
503 | 503 | $template_name = isset($value['template']) ? $value['template'] : ''; |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | )); |
517 | 517 | } |
518 | 518 | // Request doesn't handle changing by reference, so force it |
519 | - if($changes) |
|
519 | + if ($changes) |
|
520 | 520 | { |
521 | 521 | $content = self::$request->content; |
522 | 522 | self::$request->content = array(); |
@@ -556,27 +556,27 @@ discard block |
||
556 | 556 | * @param Etemplate\Widget $widget =null instanciated nextmatch widget to let it's widgets transform each row |
557 | 557 | * @return int|boolean total items found of false on error ($value['get_rows'] not callable) |
558 | 558 | */ |
559 | - private static function call_get_rows(array &$value,array &$rows,array &$readonlys=null,$obj=null,$method=null, Etemplate\Widget $widget=null) |
|
559 | + private static function call_get_rows(array &$value, array &$rows, array &$readonlys = null, $obj = null, $method = null, Etemplate\Widget $widget = null) |
|
560 | 560 | { |
561 | 561 | if (is_null($method)) $method = $value['get_rows']; |
562 | 562 | |
563 | 563 | if (is_null($obj)) |
564 | 564 | { |
565 | 565 | // allow static callbacks |
566 | - if(strpos($method,'::') !== false) |
|
566 | + if (strpos($method, '::') !== false) |
|
567 | 567 | { |
568 | - list($class,$method) = explode('::',$method); |
|
568 | + list($class, $method) = explode('::', $method); |
|
569 | 569 | |
570 | 570 | // workaround for php < 5.2.3: do NOT call it static, but allow application code to specify static callbacks |
571 | - if (version_compare(PHP_VERSION,'5.2.3','>=')) |
|
571 | + if (version_compare(PHP_VERSION, '5.2.3', '>=')) |
|
572 | 572 | { |
573 | - $method = array($class,$method); |
|
573 | + $method = array($class, $method); |
|
574 | 574 | unset($class); |
575 | 575 | } |
576 | 576 | } |
577 | 577 | else |
578 | 578 | { |
579 | - list($app,$class,$method) = explode('.',$value['get_rows']); |
|
579 | + list($app, $class, $method) = explode('.', $value['get_rows']); |
|
580 | 580 | } |
581 | 581 | if ($class) |
582 | 582 | { |
@@ -596,23 +596,23 @@ discard block |
||
596 | 596 | } |
597 | 597 | $raw_rows = array(); |
598 | 598 | if (!is_array($readonlys)) $readonlys = array(); |
599 | - if(is_callable($method)) // php5.2.3+ static call (value is always a var param!) |
|
599 | + if (is_callable($method)) // php5.2.3+ static call (value is always a var param!) |
|
600 | 600 | { |
601 | - $total = call_user_func_array($method,array(&$value,&$raw_rows,&$readonlys)); |
|
601 | + $total = call_user_func_array($method, array(&$value, &$raw_rows, &$readonlys)); |
|
602 | 602 | } |
603 | - elseif(is_object($obj) && method_exists($obj,$method)) |
|
603 | + elseif (is_object($obj) && method_exists($obj, $method)) |
|
604 | 604 | { |
605 | - $total = $obj->$method($value,$raw_rows,$readonlys); |
|
605 | + $total = $obj->$method($value, $raw_rows, $readonlys); |
|
606 | 606 | } |
607 | 607 | else |
608 | 608 | { |
609 | - $total = false; // method not callable |
|
609 | + $total = false; // method not callable |
|
610 | 610 | } |
611 | 611 | // if we have a nextmatch widget, find the repeating row |
612 | 612 | if ($widget && $widget->attrs['template']) |
613 | 613 | { |
614 | 614 | $row_template = $widget->getElementById($widget->attrs['template']); |
615 | - if(!$row_template) |
|
615 | + if (!$row_template) |
|
616 | 616 | { |
617 | 617 | $row_template = Template::instance($widget->attrs['template']); |
618 | 618 | } |
@@ -620,9 +620,9 @@ discard block |
||
620 | 620 | // Try to find just the repeating part |
621 | 621 | $repeating_row = null; |
622 | 622 | // First child should be a grid, we want last row |
623 | - foreach($row_template->children[0]->children[1]->children as $child) |
|
623 | + foreach ($row_template->children[0]->children[1]->children as $child) |
|
624 | 624 | { |
625 | - if($child->type == 'row') $repeating_row = $child; |
|
625 | + if ($child->type == 'row') $repeating_row = $child; |
|
626 | 626 | } |
627 | 627 | } |
628 | 628 | // otherwise we might get stoped by max_excutiontime |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | |
635 | 635 | // remove empty rows required by old etemplate to compensate for header rows |
636 | 636 | $first = $total ? null : 0; |
637 | - foreach($raw_rows as $n => $row) |
|
637 | + foreach ($raw_rows as $n => $row) |
|
638 | 638 | { |
639 | 639 | // skip empty rows inserted for each header-line in old etemplate |
640 | 640 | if (is_int($n) && is_array($rows)) |
@@ -645,14 +645,14 @@ discard block |
||
645 | 645 | { |
646 | 646 | $row['is_parent'] = isset($is_parent_value) ? |
647 | 647 | $row[$is_parent] == $is_parent_value : (boolean)$row[$is_parent]; |
648 | - $row['parent_id'] = $row[$parent_id]; // seems NOT used on client! |
|
648 | + $row['parent_id'] = $row[$parent_id]; // seems NOT used on client! |
|
649 | 649 | } |
650 | 650 | // run beforeSendToClient methods of widgets in row on row-data |
651 | - if($repeating_row) |
|
651 | + if ($repeating_row) |
|
652 | 652 | { |
653 | 653 | // Change anything by widget for each row ($row set to 1) |
654 | 654 | $_row = array(1 => &$row); |
655 | - $repeating_row->run('set_row_value', array('',array('row' => 1), &$_row), true); |
|
655 | + $repeating_row->run('set_row_value', array('', array('row' => 1), &$_row), true); |
|
656 | 656 | } |
657 | 657 | else if (!$widget || get_class($widget) != __NAMESPACE__.'\\HistoryLog') |
658 | 658 | { |
@@ -660,13 +660,13 @@ discard block |
||
660 | 660 | //error_log(self::$request->template['name'] . ' had to fallback to run_beforeSendToClient() because it could not find the row'); |
661 | 661 | $row = self::run_beforeSendToClient($row); |
662 | 662 | } |
663 | - $rows[$n-$first+$value['start']] = $row; |
|
663 | + $rows[$n - $first + $value['start']] = $row; |
|
664 | 664 | } |
665 | - elseif(!is_numeric($n)) // rows with string-keys, after numeric rows |
|
665 | + elseif (!is_numeric($n)) // rows with string-keys, after numeric rows |
|
666 | 666 | { |
667 | - if($n == 'sel_options') |
|
667 | + if ($n == 'sel_options') |
|
668 | 668 | { |
669 | - foreach($row as $name => &$options) |
|
669 | + foreach ($row as $name => &$options) |
|
670 | 670 | { |
671 | 671 | // remember newly set options for validation of nextmatch filters |
672 | 672 | self::$request->sel_options[$name] = $options; |
@@ -695,7 +695,7 @@ discard block |
||
695 | 695 | { |
696 | 696 | $timestamps = self::get_timestamps(); |
697 | 697 | |
698 | - foreach($row as $name => &$value) |
|
698 | + foreach ($row as $name => &$value) |
|
699 | 699 | { |
700 | 700 | if ($name[0] != '#' && in_array($name, $timestamps) && $value && |
701 | 701 | (is_int($value) || is_string($value) && is_numeric($value)) && |
@@ -717,15 +717,15 @@ discard block |
||
717 | 717 | return Api\Cache::getTree(__CLASS__, 'timestamps', function() |
718 | 718 | { |
719 | 719 | $timestamps = array(); |
720 | - foreach(scandir(EGW_SERVER_ROOT) as $app) |
|
720 | + foreach (scandir(EGW_SERVER_ROOT) as $app) |
|
721 | 721 | { |
722 | 722 | $dir = EGW_SERVER_ROOT.'/'.$app; |
723 | 723 | if (is_dir($dir) && file_exists($dir.'/setup/tables_current.inc.php') && |
724 | 724 | ($tables_defs = $GLOBALS['egw']->db->get_table_definitions($app))) |
725 | 725 | { |
726 | - foreach($tables_defs as $defintion) |
|
726 | + foreach ($tables_defs as $defintion) |
|
727 | 727 | { |
728 | - foreach($defintion['fd'] as $col => $data) |
|
728 | + foreach ($defintion['fd'] as $col => $data) |
|
729 | 729 | { |
730 | 730 | if ($data['type'] == 'timestamp' || $data['meta'] == 'timestamp') |
731 | 731 | { |
@@ -743,7 +743,7 @@ discard block |
||
743 | 743 | } |
744 | 744 | //error_log(__METHOD__."() returning ".array2string($timestamps)); |
745 | 745 | return $timestamps; |
746 | - }, array(), 86400); // cache for 1 day |
|
746 | + }, array(), 86400); // cache for 1 day |
|
747 | 747 | } |
748 | 748 | |
749 | 749 | /** |
@@ -795,18 +795,18 @@ discard block |
||
795 | 795 | * @param array $default_attrs =null default attributes |
796 | 796 | * @return array |
797 | 797 | */ |
798 | - public static function egw_actions(array $actions=null, $template_name='', $prefix='', array &$action_links=array(), |
|
799 | - $max_length=self::DEFAULT_MAX_MENU_LENGTH, array $default_attrs=null) |
|
798 | + public static function egw_actions(array $actions = null, $template_name = '', $prefix = '', array &$action_links = array(), |
|
799 | + $max_length = self::DEFAULT_MAX_MENU_LENGTH, array $default_attrs = null) |
|
800 | 800 | { |
801 | 801 | //echo "<p>".__METHOD__."(\$actions, '$template_name', '$prefix', \$action_links, $max_length) \$actions="; _debug_array($actions); |
802 | - $first_level = !$action_links; // add all first level actions |
|
802 | + $first_level = !$action_links; // add all first level actions |
|
803 | 803 | |
804 | 804 | //echo "actions="; _debug_array($actions); |
805 | 805 | $egw_actions = array(); |
806 | 806 | $n = 1; |
807 | 807 | $group = false; |
808 | 808 | |
809 | - foreach((array)$actions as $id => $action) |
|
809 | + foreach ((array)$actions as $id => $action) |
|
810 | 810 | { |
811 | 811 | // in case it's only selectbox id => label pairs |
812 | 812 | if (!is_array($action)) $action = array('caption' => $action); |
@@ -834,12 +834,12 @@ discard block |
||
834 | 834 | |
835 | 835 | if (!$first_level && $n == $max_length && count($actions) > $max_length) |
836 | 836 | { |
837 | - $id = 'more_'.count($actions); // we need a new unique id |
|
837 | + $id = 'more_'.count($actions); // we need a new unique id |
|
838 | 838 | $action = array( |
839 | 839 | 'caption' => 'More', |
840 | 840 | 'prefix' => $prefix, |
841 | 841 | // display rest of actions incl. current one as children |
842 | - 'children' => array_slice($actions, $max_length-1, count($actions)-$max_length+1, true), |
|
842 | + 'children' => array_slice($actions, $max_length - 1, count($actions) - $max_length + 1, true), |
|
843 | 843 | ); |
844 | 844 | //echo "*** Inserting id=$prefix$id"; _debug_array($action); |
845 | 845 | // we break at end of foreach loop, as rest of actions is already dealt with |
@@ -847,8 +847,8 @@ discard block |
||
847 | 847 | } |
848 | 848 | |
849 | 849 | // add all first level popup actions plus ones with enabled = 'javaScript:...' to action_links |
850 | - if ((!isset($action['type']) || in_array($action['type'],array('popup','drag','drop'))) && // popup is the default |
|
851 | - ($first_level || substr($action['enabled'],0,11) == 'javaScript:')) |
|
850 | + if ((!isset($action['type']) || in_array($action['type'], array('popup', 'drag', 'drop'))) && // popup is the default |
|
851 | + ($first_level || substr($action['enabled'], 0, 11) == 'javaScript:')) |
|
852 | 852 | { |
853 | 853 | $action_links[] = $prefix.$id; |
854 | 854 | } |
@@ -856,7 +856,7 @@ discard block |
||
856 | 856 | // add sub-menues |
857 | 857 | if ($action['children']) |
858 | 858 | { |
859 | - static $inherit_attrs = array('url','popup','nm_action','onExecute','type','egw_open','allowOnMultiple','confirm','confirm_multiple'); |
|
859 | + static $inherit_attrs = array('url', 'popup', 'nm_action', 'onExecute', 'type', 'egw_open', 'allowOnMultiple', 'confirm', 'confirm_multiple'); |
|
860 | 860 | $inherit_keys = array_flip($inherit_attrs); |
861 | 861 | $action['children'] = self::egw_actions($action['children'], $template_name, $action['prefix'], $action_links, $max_length, |
862 | 862 | array_intersect_key($action, $inherit_keys)); |
@@ -864,28 +864,28 @@ discard block |
||
864 | 864 | unset($action['prefix']); |
865 | 865 | |
866 | 866 | // Allow default actions to keep their onExecute |
867 | - if($action['default']) unset($inherit_keys['onExecute']); |
|
867 | + if ($action['default']) unset($inherit_keys['onExecute']); |
|
868 | 868 | $action = array_diff_key($action, $inherit_keys); |
869 | 869 | } |
870 | 870 | |
871 | 871 | // link or popup action |
872 | 872 | if ($action['url']) |
873 | 873 | { |
874 | - $action['url'] = Api\Framework::link('/index.php',str_replace('$action',$id,$action['url'])); |
|
874 | + $action['url'] = Api\Framework::link('/index.php', str_replace('$action', $id, $action['url'])); |
|
875 | 875 | if ($action['popup']) |
876 | 876 | { |
877 | - list($action['data']['width'],$action['data']['height']) = explode('x',$action['popup']); |
|
877 | + list($action['data']['width'], $action['data']['height']) = explode('x', $action['popup']); |
|
878 | 878 | unset($action['popup']); |
879 | 879 | $action['data']['nm_action'] = 'popup'; |
880 | 880 | } |
881 | 881 | else |
882 | 882 | { |
883 | 883 | $action['data']['nm_action'] = 'location'; |
884 | - if(!$action['target'] && strpos($action['url'],'menuaction') > 0) |
|
884 | + if (!$action['target'] && strpos($action['url'], 'menuaction') > 0) |
|
885 | 885 | { |
886 | 886 | // It would be better if app set target, but we'll auto-detect if not |
887 | - list(,$menuaction) = explode('=',$action['url']); |
|
888 | - list($app) = explode('.',$menuaction); |
|
887 | + list(,$menuaction) = explode('=', $action['url']); |
|
888 | + list($app) = explode('.', $menuaction); |
|
889 | 889 | $action['data']['target'] = $app; |
890 | 890 | } |
891 | 891 | } |
@@ -901,12 +901,12 @@ discard block |
||
901 | 901 | } |
902 | 902 | |
903 | 903 | // Make sure select all is in a group by itself |
904 | - foreach($egw_actions as $id => &$_action) |
|
904 | + foreach ($egw_actions as $id => &$_action) |
|
905 | 905 | { |
906 | - if($id == $prefix . 'select_all') continue; |
|
907 | - if($_action['group'] >= $egw_actions[$prefix.'select_all']['group'] ) |
|
906 | + if ($id == $prefix.'select_all') continue; |
|
907 | + if ($_action['group'] >= $egw_actions[$prefix.'select_all']['group']) |
|
908 | 908 | { |
909 | - $egw_actions[$id]['group']+=1; |
|
909 | + $egw_actions[$id]['group'] += 1; |
|
910 | 910 | } |
911 | 911 | } |
912 | 912 | //echo "egw_actions="; _debug_array($egw_actions); |
@@ -927,11 +927,11 @@ discard block |
||
927 | 927 | * @param int $max_cats_flat =self::DEFAULT_MAX_MENU_LENGTH use hierarchical display if more cats |
928 | 928 | * @return array like self::egw_actions |
929 | 929 | */ |
930 | - public static function category_action($app, $group=0, $caption='Change category', |
|
931 | - $prefix='cat_', $globals=true, $parent_id=0, $max_cats_flat=self::DEFAULT_MAX_MENU_LENGTH) |
|
930 | + public static function category_action($app, $group = 0, $caption = 'Change category', |
|
931 | + $prefix = 'cat_', $globals = true, $parent_id = 0, $max_cats_flat = self::DEFAULT_MAX_MENU_LENGTH) |
|
932 | 932 | { |
933 | - $cat = new Api\Categories(null,$app); |
|
934 | - $cats = $cat->return_sorted_array($start=0, false, '', 'ASC', 'cat_name', $globals, $parent_id, true); |
|
933 | + $cat = new Api\Categories(null, $app); |
|
934 | + $cats = $cat->return_sorted_array($start = 0, false, '', 'ASC', 'cat_name', $globals, $parent_id, true); |
|
935 | 935 | |
936 | 936 | // if more then max_length cats, switch automatically to hierarchical display |
937 | 937 | if (count($cats) > $max_cats_flat) |
@@ -941,9 +941,9 @@ discard block |
||
941 | 941 | else // flat, indented categories |
942 | 942 | { |
943 | 943 | $cat_actions = array(); |
944 | - foreach((array)$cats as $cat) |
|
944 | + foreach ((array)$cats as $cat) |
|
945 | 945 | { |
946 | - $name = str_repeat(' ',2*$cat['level']) . stripslashes($cat['name']); |
|
946 | + $name = str_repeat(' ', 2 * $cat['level']).stripslashes($cat['name']); |
|
947 | 947 | |
948 | 948 | $cat_actions[$cat['id']] = array( |
949 | 949 | 'caption' => $name, |
@@ -973,10 +973,10 @@ discard block |
||
973 | 973 | * @param int $parent_id =0 only returns cats of a certain parent |
974 | 974 | * @return array |
975 | 975 | */ |
976 | - private static function category_hierarchy(array $cats, $prefix, $parent_id=0) |
|
976 | + private static function category_hierarchy(array $cats, $prefix, $parent_id = 0) |
|
977 | 977 | { |
978 | 978 | $cat_actions = array(); |
979 | - foreach($cats as $key => $cat) |
|
979 | + foreach ($cats as $key => $cat) |
|
980 | 980 | { |
981 | 981 | // current hierarchy level |
982 | 982 | if ($cat['parent'] == $parent_id) |
@@ -996,14 +996,14 @@ discard block |
||
996 | 996 | unset($cats[$key]); |
997 | 997 | } |
998 | 998 | // direct children |
999 | - elseif(isset($cat_actions[$cat['parent']])) |
|
999 | + elseif (isset($cat_actions[$cat['parent']])) |
|
1000 | 1000 | { |
1001 | 1001 | $cat_actions['sub_'.$cat['parent']] = $cat_actions[$cat['parent']]; |
1002 | 1002 | // have to add category itself to children, to be able to select it! |
1003 | - $cat_actions[$cat['parent']]['group'] = -1; // own group on top |
|
1003 | + $cat_actions[$cat['parent']]['group'] = -1; // own group on top |
|
1004 | 1004 | $cat_actions['sub_'.$cat['parent']]['children'] = array( |
1005 | 1005 | $cat['parent'] => $cat_actions[$cat['parent']], |
1006 | - )+self::category_hierarchy($cats, $prefix, $cat['parent']); |
|
1006 | + ) + self::category_hierarchy($cats, $prefix, $cat['parent']); |
|
1007 | 1007 | unset($cat_actions[$cat['parent']]); |
1008 | 1008 | } |
1009 | 1009 | } |
@@ -1026,7 +1026,7 @@ discard block |
||
1026 | 1026 | * @param array $content |
1027 | 1027 | * @param array &$validated =array() validated content |
1028 | 1028 | */ |
1029 | - public function validate($cname, array $expand, array $content, &$validated=array()) |
|
1029 | + public function validate($cname, array $expand, array $content, &$validated = array()) |
|
1030 | 1030 | { |
1031 | 1031 | $form_name = self::form_name($cname, $this->id, $expand); |
1032 | 1032 | $value = self::get_array($content, $form_name); |
@@ -1035,7 +1035,7 @@ discard block |
||
1035 | 1035 | // $content. Fetch them from the request, so we actually have them. |
1036 | 1036 | $content_value = self::get_array(self::$request->content, $form_name); |
1037 | 1037 | |
1038 | - list($app) = explode('.',$this->attrs['template']); |
|
1038 | + list($app) = explode('.', $this->attrs['template']); |
|
1039 | 1039 | |
1040 | 1040 | unset($value['favorite']); |
1041 | 1041 | |
@@ -1044,18 +1044,18 @@ discard block |
||
1044 | 1044 | |
1045 | 1045 | // Legacy support - action popups were not properly namespaced |
1046 | 1046 | $preserve = self::get_array(self::$request->preserv, $form_name); |
1047 | - if($value[$preserve['action_var']] && $content[$value[$preserve['action_var']].'_popup']) |
|
1047 | + if ($value[$preserve['action_var']] && $content[$value[$preserve['action_var']].'_popup']) |
|
1048 | 1048 | { |
1049 | 1049 | $validated += $content[$value[$preserve['action_var']].'_popup']; |
1050 | 1050 | } |
1051 | 1051 | |
1052 | 1052 | |
1053 | 1053 | // Save current column settings as default, clear, or force (admins only) |
1054 | - if($GLOBALS['egw_info']['user']['apps']['admin'] && $app && $value['selectcols']) |
|
1054 | + if ($GLOBALS['egw_info']['user']['apps']['admin'] && $app && $value['selectcols']) |
|
1055 | 1055 | { |
1056 | - $pref_name = 'nextmatch-' . (isset($content_value['columnselection_pref']) ? $content_value['columnselection_pref'] : $this->attrs['template']); |
|
1056 | + $pref_name = 'nextmatch-'.(isset($content_value['columnselection_pref']) ? $content_value['columnselection_pref'] : $this->attrs['template']); |
|
1057 | 1057 | $refresh_pref_name = $pref_name.'-autorefresh'; |
1058 | - switch($value['nm_col_preference']) { |
|
1058 | + switch ($value['nm_col_preference']) { |
|
1059 | 1059 | case 'force': |
1060 | 1060 | $pref_level = 'forced'; |
1061 | 1061 | break; |
@@ -1068,39 +1068,39 @@ discard block |
||
1068 | 1068 | } |
1069 | 1069 | |
1070 | 1070 | // Clear forced pref before setting default |
1071 | - if($pref_level != 'forced') |
|
1071 | + if ($pref_level != 'forced') |
|
1072 | 1072 | { |
1073 | - $GLOBALS['egw']->preferences->delete($app,$pref_name,'forced'); |
|
1074 | - $GLOBALS['egw']->preferences->delete($app,$refresh_pref_name,'forced'); |
|
1075 | - $GLOBALS['egw']->preferences->delete($app,$pref_name.'-size','forced'); |
|
1076 | - $GLOBALS['egw']->preferences->delete($app,$pref_name.'-lettersearch','forced'); |
|
1077 | - $GLOBALS['egw']->preferences->save_repository(true,'forced'); |
|
1073 | + $GLOBALS['egw']->preferences->delete($app, $pref_name, 'forced'); |
|
1074 | + $GLOBALS['egw']->preferences->delete($app, $refresh_pref_name, 'forced'); |
|
1075 | + $GLOBALS['egw']->preferences->delete($app, $pref_name.'-size', 'forced'); |
|
1076 | + $GLOBALS['egw']->preferences->delete($app, $pref_name.'-lettersearch', 'forced'); |
|
1077 | + $GLOBALS['egw']->preferences->save_repository(true, 'forced'); |
|
1078 | 1078 | } |
1079 | 1079 | |
1080 | 1080 | // Set columns + refresh as default for all users |
1081 | 1081 | // Columns included in submit, preference might not be updated yet |
1082 | 1082 | $cols = $value['selectcols']; |
1083 | 1083 | $GLOBALS['egw']->preferences->read_repository(true); |
1084 | - $GLOBALS['egw']->preferences->add($app,$pref_name,is_array($cols) ? implode(',',$cols) : $cols, $pref_level); |
|
1084 | + $GLOBALS['egw']->preferences->add($app, $pref_name, is_array($cols) ? implode(',', $cols) : $cols, $pref_level); |
|
1085 | 1085 | |
1086 | 1086 | // Autorefresh |
1087 | 1087 | $refresh = $value['nm_autorefresh']; |
1088 | - $GLOBALS['egw']->preferences->add($app,$refresh_pref_name,(int)$refresh,$pref_level); |
|
1088 | + $GLOBALS['egw']->preferences->add($app, $refresh_pref_name, (int)$refresh, $pref_level); |
|
1089 | 1089 | |
1090 | 1090 | // Lettersearch |
1091 | 1091 | $lettersearch = is_array($cols) && in_array('lettersearch', $cols); |
1092 | - $GLOBALS['egw']->preferences->add($app,$pref_name.'-lettersearch',(int)$lettersearch,$pref_level); |
|
1092 | + $GLOBALS['egw']->preferences->add($app, $pref_name.'-lettersearch', (int)$lettersearch, $pref_level); |
|
1093 | 1093 | |
1094 | - $GLOBALS['egw']->preferences->save_repository(true,$pref_level); |
|
1094 | + $GLOBALS['egw']->preferences->save_repository(true, $pref_level); |
|
1095 | 1095 | $GLOBALS['egw']->preferences->read(true); |
1096 | 1096 | |
1097 | - if($value['nm_col_preference'] == 'reset') |
|
1097 | + if ($value['nm_col_preference'] == 'reset') |
|
1098 | 1098 | { |
1099 | 1099 | // Clear column + refresh preference so users go back to default |
1100 | - $GLOBALS['egw']->preferences->delete_preference($app,$pref_name); |
|
1101 | - $GLOBALS['egw']->preferences->delete_preference($app,$pref_name.'-size'); |
|
1102 | - $GLOBALS['egw']->preferences->delete_preference($app,$pref_name.'-lettersearch'); |
|
1103 | - $GLOBALS['egw']->preferences->delete_preference($app,$refresh_pref_name); |
|
1100 | + $GLOBALS['egw']->preferences->delete_preference($app, $pref_name); |
|
1101 | + $GLOBALS['egw']->preferences->delete_preference($app, $pref_name.'-size'); |
|
1102 | + $GLOBALS['egw']->preferences->delete_preference($app, $pref_name.'-lettersearch'); |
|
1103 | + $GLOBALS['egw']->preferences->delete_preference($app, $refresh_pref_name); |
|
1104 | 1104 | } |
1105 | 1105 | } |
1106 | 1106 | unset($value['nm_col_preference']); |
@@ -1117,20 +1117,20 @@ discard block |
||
1117 | 1117 | * @param array $params =array('') parameter(s) first parameter has to be cname, second $expand! |
1118 | 1118 | * @param boolean $respect_disabled =false false (default): ignore disabled, true: method is NOT run for disabled widgets AND their children |
1119 | 1119 | */ |
1120 | - public function run($method_name, $params=array(''), $respect_disabled=false) |
|
1120 | + public function run($method_name, $params = array(''), $respect_disabled = false) |
|
1121 | 1121 | { |
1122 | 1122 | $old_param0 = $params[0]; |
1123 | - $cname =& $params[0]; |
|
1123 | + $cname = & $params[0]; |
|
1124 | 1124 | // Need this check or the headers will get involved too |
1125 | - if($this->type == 'nextmatch') |
|
1125 | + if ($this->type == 'nextmatch') |
|
1126 | 1126 | { |
1127 | 1127 | parent::run($method_name, $params, $respect_disabled); |
1128 | 1128 | if ($this->id) $cname = self::form_name($cname, $this->id, $params[1]); |
1129 | 1129 | |
1130 | 1130 | // Run on all the sub-templates |
1131 | - foreach(array('template', 'header_left', 'header_right', 'header_row') as $sub_template) |
|
1131 | + foreach (array('template', 'header_left', 'header_right', 'header_row') as $sub_template) |
|
1132 | 1132 | { |
1133 | - if($this->attrs[$sub_template]) |
|
1133 | + if ($this->attrs[$sub_template]) |
|
1134 | 1134 | { |
1135 | 1135 | $row_template = Template::instance($this->attrs[$sub_template]); |
1136 | 1136 | $row_template->run($method_name, $params, $respect_disabled); |
@@ -1141,10 +1141,10 @@ discard block |
||
1141 | 1141 | |
1142 | 1142 | // Prevent troublesome keys from breaking the nextmatch |
1143 | 1143 | // TODO: Figure out where these come from |
1144 | - foreach(array('$row','${row}', '$', '0','1','2') as $key) |
|
1144 | + foreach (array('$row', '${row}', '$', '0', '1', '2') as $key) |
|
1145 | 1145 | { |
1146 | - if(is_array(self::$request->content[$cname])) unset(self::$request->content[$cname][$key]); |
|
1147 | - if(is_array(self::$request->preserve[$cname])) unset(self::$request->preserve[$cname][$key]); |
|
1146 | + if (is_array(self::$request->content[$cname])) unset(self::$request->content[$cname][$key]); |
|
1147 | + if (is_array(self::$request->preserve[$cname])) unset(self::$request->preserve[$cname][$key]); |
|
1148 | 1148 | } |
1149 | 1149 | } |
1150 | 1150 | |
@@ -1159,9 +1159,9 @@ discard block |
||
1159 | 1159 | * @param array|string $row_ids rows to refresh |
1160 | 1160 | * @param string $type ='edit' "edit" (default), "delete" or "add" |
1161 | 1161 | */ |
1162 | - public function refresh($row_ids, $type='edit') |
|
1162 | + public function refresh($row_ids, $type = 'edit') |
|
1163 | 1163 | { |
1164 | - unset($row_ids, $type); // not used, but required by function signature |
|
1164 | + unset($row_ids, $type); // not used, but required by function signature |
|
1165 | 1165 | |
1166 | 1166 | throw new Api\Exception('Not yet implemented'); |
1167 | 1167 | } |
@@ -92,7 +92,8 @@ discard block |
||
92 | 92 | |
93 | 93 | public function __construct($xml='') |
94 | 94 | { |
95 | - if($xml) { |
|
95 | + if($xml) |
|
96 | + { |
|
96 | 97 | parent::__construct($xml); |
97 | 98 | } |
98 | 99 | } |
@@ -184,14 +185,20 @@ discard block |
||
184 | 185 | { |
185 | 186 | $total = self::call_get_rows($send_value, $send_value['rows'], self::$request->readonlys, null, null, $this); |
186 | 187 | } |
187 | - if (true) $value =& self::get_array(self::$request->content, $form_name, true); |
|
188 | + if (true) |
|
189 | + { |
|
190 | + $value =& self::get_array(self::$request->content, $form_name, true); |
|
191 | + } |
|
188 | 192 | |
189 | 193 | // Add favorite here so app doesn't save it in the session |
190 | 194 | if($_GET['favorite']) |
191 | 195 | { |
192 | 196 | $send_value['favorite'] = $safe_name; |
193 | 197 | } |
194 | - if (true) $value = $send_value; |
|
198 | + if (true) |
|
199 | + { |
|
200 | + $value = $send_value; |
|
201 | + } |
|
195 | 202 | $value['total'] = $total; |
196 | 203 | |
197 | 204 | // Send categories |
@@ -257,7 +264,10 @@ discard block |
||
257 | 264 | { |
258 | 265 | $value['action_links'] = array(); |
259 | 266 | $template_name = isset($value['template']) ? $value['template'] : $this->attrs['options']; |
260 | - if (!is_array($value['action_links'])) $value['action_links'] = array(); |
|
267 | + if (!is_array($value['action_links'])) |
|
268 | + { |
|
269 | + $value['action_links'] = array(); |
|
270 | + } |
|
261 | 271 | $value['actions'] = self::egw_actions($value['actions'], $template_name, '', $value['action_links']); |
262 | 272 | } |
263 | 273 | } |
@@ -321,7 +331,10 @@ discard block |
||
321 | 331 | //error_log($this . " Valid filters: " . array2string($filters)); |
322 | 332 | } |
323 | 333 | |
324 | - if (true) $value = $value_in = array_merge($value, $filters); |
|
334 | + if (true) |
|
335 | + { |
|
336 | + $value = $value_in = array_merge($value, $filters); |
|
337 | + } |
|
325 | 338 | |
326 | 339 | //error_log(__METHOD__."('".substr($exec_id,0,10)."...', range=".array2string($queriedRange).', filters='.array2string($filters).", '$form_name', knownUids=".array2string($knownUids).", lastModified=$lastModified) parent_id=$value[parent_id], is_parent=$value[is_parent]"); |
327 | 340 | |
@@ -336,18 +349,27 @@ discard block |
||
336 | 349 | |
337 | 350 | $value['start'] = (int)$queriedRange['start']; |
338 | 351 | $value['num_rows'] = (int)$queriedRange['num_rows']; |
339 | - if($value['num_rows'] == 0) $value['num_rows'] = self::INITIAL_ROWS; |
|
352 | + if($value['num_rows'] == 0) |
|
353 | + { |
|
354 | + $value['num_rows'] = self::INITIAL_ROWS; |
|
355 | + } |
|
340 | 356 | // if app supports parent_id / hierarchy ($value['parent_id'] not empty), set parent_id as filter |
341 | 357 | if (($parent_id = $value['parent_id'])) |
342 | 358 | { |
343 | 359 | // Infolog at least wants 'parent_id' instead of $parent_id |
344 | 360 | $value['col_filter'][$parent_id] = $queriedRange['parent_id']; |
345 | - if ($queriedRange['parent_id']) $value['csv_export'] = 'children'; |
|
361 | + if ($queriedRange['parent_id']) |
|
362 | + { |
|
363 | + $value['csv_export'] = 'children'; |
|
364 | + } |
|
346 | 365 | } |
347 | 366 | |
348 | 367 | // Set current app for get_rows |
349 | 368 | list($app) = explode('.',self::$request->method); |
350 | - if(!$app) list($app) = explode('::',self::$request->method); |
|
369 | + if(!$app) |
|
370 | + { |
|
371 | + list($app) = explode('::',self::$request->method); |
|
372 | + } |
|
351 | 373 | if($app) |
352 | 374 | { |
353 | 375 | $GLOBALS['egw_info']['flags']['currentapp'] = $app; |
@@ -377,8 +399,15 @@ discard block |
||
377 | 399 | $kUkey = false; |
378 | 400 | if (is_int($n) && $row) |
379 | 401 | { |
380 | - if (!isset($row[$row_id])) unset($row_id); // unset default row_id of 'id', if not used |
|
381 | - if (!isset($row[$row_modified])) unset($row_modified); |
|
402 | + if (!isset($row[$row_id])) |
|
403 | + { |
|
404 | + unset($row_id); |
|
405 | + } |
|
406 | + // unset default row_id of 'id', if not used |
|
407 | + if (!isset($row[$row_modified])) |
|
408 | + { |
|
409 | + unset($row_modified); |
|
410 | + } |
|
382 | 411 | |
383 | 412 | $id = $row_id ? $row[$row_id] : $n; |
384 | 413 | $result['order'][] = $id; |
@@ -394,12 +423,14 @@ discard block |
||
394 | 423 | if (!$row_id || !$knownUids || ($kUkey = array_search($id, $knownUids)) === false || |
395 | 424 | !$lastModified || !isset($modified) || $modified > $lastModified || |
396 | 425 | $queriedRange['refresh'] && $id == $queriedRange['refresh'] |
397 | - ) |
|
398 | - { |
|
426 | + ) { |
|
399 | 427 | $result['data'][$id] = $row; |
400 | 428 | } |
401 | 429 | |
402 | - if ($kUkey !== false) unset($knownUids[$kUkey]); |
|
430 | + if ($kUkey !== false) |
|
431 | + { |
|
432 | + unset($knownUids[$kUkey]); |
|
433 | + } |
|
403 | 434 | } |
404 | 435 | else // non-row data set by get_rows method |
405 | 436 | { |
@@ -491,17 +522,26 @@ discard block |
||
491 | 522 | { |
492 | 523 | continue; |
493 | 524 | } |
494 | - if($original_value == $value[$key]) continue; |
|
525 | + if($original_value == $value[$key]) |
|
526 | + { |
|
527 | + continue; |
|
528 | + } |
|
495 | 529 | |
496 | 530 | // These keys we don't send row data back, as they cause a partial reload |
497 | - if(in_array($key, array('template'))) $no_rows = true; |
|
531 | + if(in_array($key, array('template'))) |
|
532 | + { |
|
533 | + $no_rows = true; |
|
534 | + } |
|
498 | 535 | |
499 | 536 | // Actions still need extra handling |
500 | 537 | if($key == 'actions' && !isset($value['actions'][0])) |
501 | 538 | { |
502 | 539 | $value['action_links'] = array(); |
503 | 540 | $template_name = isset($value['template']) ? $value['template'] : ''; |
504 | - if (!is_array($value['action_links'])) $value['action_links'] = array(); |
|
541 | + if (!is_array($value['action_links'])) |
|
542 | + { |
|
543 | + $value['action_links'] = array(); |
|
544 | + } |
|
505 | 545 | $value['actions'] = self::egw_actions($value['actions'], $template_name, '', $value['action_links']); |
506 | 546 | } |
507 | 547 | |
@@ -558,7 +598,10 @@ discard block |
||
558 | 598 | */ |
559 | 599 | private static function call_get_rows(array &$value,array &$rows,array &$readonlys=null,$obj=null,$method=null, Etemplate\Widget $widget=null) |
560 | 600 | { |
561 | - if (is_null($method)) $method = $value['get_rows']; |
|
601 | + if (is_null($method)) |
|
602 | + { |
|
603 | + $method = $value['get_rows']; |
|
604 | + } |
|
562 | 605 | |
563 | 606 | if (is_null($obj)) |
564 | 607 | { |
@@ -584,10 +627,13 @@ discard block |
||
584 | 627 | { |
585 | 628 | $GLOBALS[$class] = new $class(); |
586 | 629 | } |
587 | - if (is_object($GLOBALS[$class])) // use existing instance (put there by a previous CreateObject) |
|
630 | + if (is_object($GLOBALS[$class])) |
|
631 | + { |
|
632 | + // use existing instance (put there by a previous CreateObject) |
|
588 | 633 | { |
589 | 634 | $obj = $GLOBALS[$class]; |
590 | 635 | } |
636 | + } |
|
591 | 637 | else |
592 | 638 | { |
593 | 639 | $obj = CreateObject($app.'.'.$class); |
@@ -595,11 +641,17 @@ discard block |
||
595 | 641 | } |
596 | 642 | } |
597 | 643 | $raw_rows = array(); |
598 | - if (!is_array($readonlys)) $readonlys = array(); |
|
599 | - if(is_callable($method)) // php5.2.3+ static call (value is always a var param!) |
|
644 | + if (!is_array($readonlys)) |
|
645 | + { |
|
646 | + $readonlys = array(); |
|
647 | + } |
|
648 | + if(is_callable($method)) |
|
649 | + { |
|
650 | + // php5.2.3+ static call (value is always a var param!) |
|
600 | 651 | { |
601 | 652 | $total = call_user_func_array($method,array(&$value,&$raw_rows,&$readonlys)); |
602 | 653 | } |
654 | + } |
|
603 | 655 | elseif(is_object($obj) && method_exists($obj,$method)) |
604 | 656 | { |
605 | 657 | $total = $obj->$method($value,$raw_rows,$readonlys); |
@@ -622,11 +674,17 @@ discard block |
||
622 | 674 | // First child should be a grid, we want last row |
623 | 675 | foreach($row_template->children[0]->children[1]->children as $child) |
624 | 676 | { |
625 | - if($child->type == 'row') $repeating_row = $child; |
|
677 | + if($child->type == 'row') |
|
678 | + { |
|
679 | + $repeating_row = $child; |
|
680 | + } |
|
626 | 681 | } |
627 | 682 | } |
628 | 683 | // otherwise we might get stoped by max_excutiontime |
629 | - if ($total > 200) @set_time_limit(0); |
|
684 | + if ($total > 200) |
|
685 | + { |
|
686 | + @set_time_limit(0); |
|
687 | + } |
|
630 | 688 | |
631 | 689 | $is_parent = $value['is_parent']; |
632 | 690 | $is_parent_value = $value['is_parent_value']; |
@@ -639,12 +697,18 @@ discard block |
||
639 | 697 | // skip empty rows inserted for each header-line in old etemplate |
640 | 698 | if (is_int($n) && is_array($rows)) |
641 | 699 | { |
642 | - if (is_null($first)) $first = $n; |
|
700 | + if (is_null($first)) |
|
701 | + { |
|
702 | + $first = $n; |
|
703 | + } |
|
643 | 704 | |
644 | - if ($row[$is_parent]) // if app supports parent_id / hierarchy, set parent_id and is_parent |
|
705 | + if ($row[$is_parent]) |
|
706 | + { |
|
707 | + // if app supports parent_id / hierarchy, set parent_id and is_parent |
|
645 | 708 | { |
646 | 709 | $row['is_parent'] = isset($is_parent_value) ? |
647 | 710 | $row[$is_parent] == $is_parent_value : (boolean)$row[$is_parent]; |
711 | + } |
|
648 | 712 | $row['parent_id'] = $row[$parent_id]; // seems NOT used on client! |
649 | 713 | } |
650 | 714 | // run beforeSendToClient methods of widgets in row on row-data |
@@ -662,7 +726,9 @@ discard block |
||
662 | 726 | } |
663 | 727 | $rows[$n-$first+$value['start']] = $row; |
664 | 728 | } |
665 | - elseif(!is_numeric($n)) // rows with string-keys, after numeric rows |
|
729 | + elseif(!is_numeric($n)) |
|
730 | + { |
|
731 | + // rows with string-keys, after numeric rows |
|
666 | 732 | { |
667 | 733 | if($n == 'sel_options') |
668 | 734 | { |
@@ -670,6 +736,7 @@ discard block |
||
670 | 736 | { |
671 | 737 | // remember newly set options for validation of nextmatch filters |
672 | 738 | self::$request->sel_options[$name] = $options; |
739 | + } |
|
673 | 740 | |
674 | 741 | Select::fix_encoded_options($options, true); |
675 | 742 | } |
@@ -809,8 +876,14 @@ discard block |
||
809 | 876 | foreach((array)$actions as $id => $action) |
810 | 877 | { |
811 | 878 | // in case it's only selectbox id => label pairs |
812 | - if (!is_array($action)) $action = array('caption' => $action); |
|
813 | - if ($default_attrs) $action += $default_attrs; |
|
879 | + if (!is_array($action)) |
|
880 | + { |
|
881 | + $action = array('caption' => $action); |
|
882 | + } |
|
883 | + if ($default_attrs) |
|
884 | + { |
|
885 | + $action += $default_attrs; |
|
886 | + } |
|
814 | 887 | |
815 | 888 | // Add 'Select All' after first group |
816 | 889 | if ($first_level && $group !== false && $action['group'] != $group && !$egw_actions[$prefix.'select_all']) |
@@ -864,7 +937,10 @@ discard block |
||
864 | 937 | unset($action['prefix']); |
865 | 938 | |
866 | 939 | // Allow default actions to keep their onExecute |
867 | - if($action['default']) unset($inherit_keys['onExecute']); |
|
940 | + if($action['default']) |
|
941 | + { |
|
942 | + unset($inherit_keys['onExecute']); |
|
943 | + } |
|
868 | 944 | $action = array_diff_key($action, $inherit_keys); |
869 | 945 | } |
870 | 946 | |
@@ -897,13 +973,19 @@ discard block |
||
897 | 973 | |
898 | 974 | $egw_actions[$prefix.$id] = $action; |
899 | 975 | |
900 | - if (!$first_level && $n++ == $max_length) break; |
|
976 | + if (!$first_level && $n++ == $max_length) |
|
977 | + { |
|
978 | + break; |
|
979 | + } |
|
901 | 980 | } |
902 | 981 | |
903 | 982 | // Make sure select all is in a group by itself |
904 | 983 | foreach($egw_actions as $id => &$_action) |
905 | 984 | { |
906 | - if($id == $prefix . 'select_all') continue; |
|
985 | + if($id == $prefix . 'select_all') |
|
986 | + { |
|
987 | + continue; |
|
988 | + } |
|
907 | 989 | if($_action['group'] >= $egw_actions[$prefix.'select_all']['group'] ) |
908 | 990 | { |
909 | 991 | $egw_actions[$id]['group']+=1; |
@@ -1055,7 +1137,8 @@ discard block |
||
1055 | 1137 | { |
1056 | 1138 | $pref_name = 'nextmatch-' . (isset($content_value['columnselection_pref']) ? $content_value['columnselection_pref'] : $this->attrs['template']); |
1057 | 1139 | $refresh_pref_name = $pref_name.'-autorefresh'; |
1058 | - switch($value['nm_col_preference']) { |
|
1140 | + switch($value['nm_col_preference']) |
|
1141 | + { |
|
1059 | 1142 | case 'force': |
1060 | 1143 | $pref_level = 'forced'; |
1061 | 1144 | break; |
@@ -1125,7 +1208,10 @@ discard block |
||
1125 | 1208 | if($this->type == 'nextmatch') |
1126 | 1209 | { |
1127 | 1210 | parent::run($method_name, $params, $respect_disabled); |
1128 | - if ($this->id) $cname = self::form_name($cname, $this->id, $params[1]); |
|
1211 | + if ($this->id) |
|
1212 | + { |
|
1213 | + $cname = self::form_name($cname, $this->id, $params[1]); |
|
1214 | + } |
|
1129 | 1215 | |
1130 | 1216 | // Run on all the sub-templates |
1131 | 1217 | foreach(array('template', 'header_left', 'header_right', 'header_row') as $sub_template) |
@@ -1143,8 +1229,14 @@ discard block |
||
1143 | 1229 | // TODO: Figure out where these come from |
1144 | 1230 | foreach(array('$row','${row}', '$', '0','1','2') as $key) |
1145 | 1231 | { |
1146 | - if(is_array(self::$request->content[$cname])) unset(self::$request->content[$cname][$key]); |
|
1147 | - if(is_array(self::$request->preserve[$cname])) unset(self::$request->preserve[$cname][$key]); |
|
1232 | + if(is_array(self::$request->content[$cname])) |
|
1233 | + { |
|
1234 | + unset(self::$request->content[$cname][$key]); |
|
1235 | + } |
|
1236 | + if(is_array(self::$request->preserve[$cname])) |
|
1237 | + { |
|
1238 | + unset(self::$request->preserve[$cname][$key]); |
|
1239 | + } |
|
1148 | 1240 | } |
1149 | 1241 | } |
1150 | 1242 |
@@ -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 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | { |
37 | 37 | $this->attrs['allowFreeEntries'] = true; |
38 | 38 | |
39 | - if($xml) { |
|
39 | + if ($xml) { |
|
40 | 40 | parent::__construct($xml); |
41 | 41 | } |
42 | 42 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | if ($type == "account") |
57 | 57 | { |
58 | 58 | // Only search if a query was provided - don't search for all accounts |
59 | - if($query) |
|
59 | + if ($query) |
|
60 | 60 | { |
61 | 61 | $options['account_type'] = $_REQUEST['account_type']; |
62 | 62 | $links = Api\Accounts::link_query($query, $options); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | $links = Api\Link::query($app, $query, $options); |
68 | 68 | } |
69 | 69 | $results = array(); |
70 | - foreach($links as $id => $name) |
|
70 | + foreach ($links as $id => $name) |
|
71 | 71 | { |
72 | 72 | $results[] = array('id' => $id, 'label' => $name); |
73 | 73 | } |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | public static function ajax_email() |
88 | 88 | { |
89 | 89 | // If no mail app access, use link system -> addressbook |
90 | - if(!$GLOBALS['egw_info']['apps']['mail']) |
|
90 | + if (!$GLOBALS['egw_info']['apps']['mail']) |
|
91 | 91 | { |
92 | 92 | $_REQUEST['app'] = 'addressbook-email'; |
93 | 93 | return self::ajax_search(); |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @param array $content |
106 | 106 | * @param array &$validated=array() validated content |
107 | 107 | */ |
108 | - public function validate($cname, array $expand, array $content, &$validated=array()) |
|
108 | + public function validate($cname, array $expand, array $content, &$validated = array()) |
|
109 | 109 | { |
110 | 110 | $form_name = self::form_name($cname, $this->id, $expand); |
111 | 111 | |
@@ -115,38 +115,38 @@ discard block |
||
115 | 115 | $value = $value_in = self::get_array($content, $form_name); |
116 | 116 | $allowed = Select::selOptions($form_name); |
117 | 117 | |
118 | - foreach((array) $value as $key => $val) |
|
118 | + foreach ((array)$value as $key => $val) |
|
119 | 119 | { |
120 | - if(count($allowed) && !$this->attrs['allowFreeEntries'] && !array_key_exists($val,$allowed)) |
|
120 | + if (count($allowed) && !$this->attrs['allowFreeEntries'] && !array_key_exists($val, $allowed)) |
|
121 | 121 | { |
122 | - self::set_validation_error($form_name,lang("'%1' is NOT allowed ('%2')!",$val,implode("','",array_keys($allowed))),''); |
|
122 | + self::set_validation_error($form_name, lang("'%1' is NOT allowed ('%2')!", $val, implode("','", array_keys($allowed))), ''); |
|
123 | 123 | unset($value[$key]); |
124 | 124 | } |
125 | - if($this->type == 'taglist-email' && $this->attrs['include_lists'] && is_numeric($val)) |
|
125 | + if ($this->type == 'taglist-email' && $this->attrs['include_lists'] && is_numeric($val)) |
|
126 | 126 | { |
127 | 127 | $lists = $GLOBALS['egw']->contacts->get_lists(Api\Acl::READ); |
128 | - if(!array_key_exists($val, $lists)) |
|
128 | + if (!array_key_exists($val, $lists)) |
|
129 | 129 | { |
130 | - self::set_validation_error($form_name,lang("'%1' is NOT allowed ('%2')!",$val,implode("','",array_keys($lists))),''); |
|
130 | + self::set_validation_error($form_name, lang("'%1' is NOT allowed ('%2')!", $val, implode("','", array_keys($lists))), ''); |
|
131 | 131 | } |
132 | 132 | } |
133 | - else if($this->type == 'taglist-email' && !preg_match(Url::EMAIL_PREG, $val) && |
|
133 | + else if ($this->type == 'taglist-email' && !preg_match(Url::EMAIL_PREG, $val) && |
|
134 | 134 | // Allow merge placeholders. Might be a better way to do this though. |
135 | - !preg_match('/{{.+}}|\$\$.+\$\$/',$val) |
|
135 | + !preg_match('/{{.+}}|\$\$.+\$\$/', $val) |
|
136 | 136 | ) |
137 | 137 | { |
138 | - self::set_validation_error($form_name,lang("'%1' has an invalid format",$val),''); |
|
138 | + self::set_validation_error($form_name, lang("'%1' has an invalid format", $val), ''); |
|
139 | 139 | } |
140 | 140 | } |
141 | 141 | if ($ok && $value === '' && $this->attrs['needed']) |
142 | 142 | { |
143 | - self::set_validation_error($form_name,lang('Field must not be empty !!!',$value),''); |
|
143 | + self::set_validation_error($form_name, lang('Field must not be empty !!!', $value), ''); |
|
144 | 144 | } |
145 | - if(array_key_exists('multiple', $this->attrs) && $this->attrs['multiple'] == false) |
|
145 | + if (array_key_exists('multiple', $this->attrs) && $this->attrs['multiple'] == false) |
|
146 | 146 | { |
147 | 147 | $value = array_shift($value); |
148 | 148 | } |
149 | - $valid =& self::get_array($validated, $form_name, true); |
|
149 | + $valid = & self::get_array($validated, $form_name, true); |
|
150 | 150 | // returning null instead of array(), as array() will be overwritten by etemplate_new::complete_array_merge() |
151 | 151 | // with preserved old content and therefore user can not empty a taglist |
152 | 152 | if (true) $valid = $value ? $value : null; |
@@ -36,7 +36,8 @@ discard block |
||
36 | 36 | { |
37 | 37 | $this->attrs['allowFreeEntries'] = true; |
38 | 38 | |
39 | - if($xml) { |
|
39 | + if($xml) |
|
40 | + { |
|
40 | 41 | parent::__construct($xml); |
41 | 42 | } |
42 | 43 | } |
@@ -133,8 +134,7 @@ discard block |
||
133 | 134 | else if($this->type == 'taglist-email' && !preg_match(Url::EMAIL_PREG, $val) && |
134 | 135 | // Allow merge placeholders. Might be a better way to do this though. |
135 | 136 | !preg_match('/{{.+}}|\$\$.+\$\$/',$val) |
136 | - ) |
|
137 | - { |
|
137 | + ) { |
|
138 | 138 | self::set_validation_error($form_name,lang("'%1' has an invalid format",$val),''); |
139 | 139 | } |
140 | 140 | } |
@@ -149,7 +149,10 @@ discard block |
||
149 | 149 | $valid =& self::get_array($validated, $form_name, true); |
150 | 150 | // returning null instead of array(), as array() will be overwritten by etemplate_new::complete_array_merge() |
151 | 151 | // with preserved old content and therefore user can not empty a taglist |
152 | - if (true) $valid = $value ? $value : null; |
|
152 | + if (true) |
|
153 | + { |
|
154 | + $valid = $value ? $value : null; |
|
155 | + } |
|
153 | 156 | //error_log(__METHOD__."() $form_name: ".array2string($value_in).' --> '.array2string($value).', allowed='.array2string($allowed)); |
154 | 157 | } |
155 | 158 | } |
@@ -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; |
@@ -91,19 +91,19 @@ discard block |
||
91 | 91 | * |
92 | 92 | * @var array |
93 | 93 | */ |
94 | - protected $data=array(); |
|
94 | + protected $data = array(); |
|
95 | 95 | /** |
96 | 96 | * Flag if data has been modified and therefor need to be stored again in the session |
97 | 97 | * |
98 | 98 | * @var boolean |
99 | 99 | */ |
100 | - protected $data_modified=false; |
|
100 | + protected $data_modified = false; |
|
101 | 101 | /** |
102 | 102 | * Flag that stored data should be removed by destructor, if not modified. |
103 | 103 | * |
104 | 104 | * @var boolean |
105 | 105 | */ |
106 | - protected $remove_if_not_modified=false; |
|
106 | + protected $remove_if_not_modified = false; |
|
107 | 107 | /** |
108 | 108 | * mcrypt resource |
109 | 109 | * |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | * @param string $id =null |
142 | 142 | * @return Request |
143 | 143 | */ |
144 | - public static function read($id=null) |
|
144 | + public static function read($id = null) |
|
145 | 145 | { |
146 | 146 | if (is_null(self::$request_class)) |
147 | 147 | { |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | // decrypt the data if available |
168 | 168 | if (self::init_crypt()) |
169 | 169 | { |
170 | - $id = mdecrypt_generic(self::$mcrypt,$id); |
|
170 | + $id = mdecrypt_generic(self::$mcrypt, $id); |
|
171 | 171 | } |
172 | 172 | // uncompress the data if available |
173 | 173 | if (self::$compression_level && function_exists('gzcompress')) |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * |
221 | 221 | * @param string $id =null |
222 | 222 | */ |
223 | - private function __construct($id=null) |
|
223 | + private function __construct($id = null) |
|
224 | 224 | { |
225 | 225 | unset($id); |
226 | 226 | } |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | * @param string $type etemplate type |
264 | 264 | * @param array $data =array() optional extra data |
265 | 265 | */ |
266 | - public function set_to_process($_form_name, $type, $data=array()) |
|
266 | + public function set_to_process($_form_name, $type, $data = array()) |
|
267 | 267 | { |
268 | 268 | if (!$_form_name || !$type) return; |
269 | 269 | |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | $data['type'] = $type; |
272 | 272 | |
273 | 273 | // unquote single and double quotes, as this is how they get returned in $_POST |
274 | - $form_name = str_replace(array('\\\'','"'), array('\'','"'), $_form_name); |
|
274 | + $form_name = str_replace(array('\\\'', '"'), array('\'', '"'), $_form_name); |
|
275 | 275 | |
276 | 276 | $this->data['to_process'][$form_name] = $data; |
277 | 277 | $this->data_modified = true; |
@@ -285,13 +285,13 @@ discard block |
||
285 | 285 | * @param array $value |
286 | 286 | * @param boolean $add_to_array =false should $value be added to the attribute array |
287 | 287 | */ |
288 | - public function set_to_process_attribute($_form_name, $attribute, $value, $add_to_array=false) |
|
288 | + public function set_to_process_attribute($_form_name, $attribute, $value, $add_to_array = false) |
|
289 | 289 | { |
290 | 290 | //echo '<p>'.__METHOD__."($form_name,$attribute,$value,$add_to_array)</p>\n"; |
291 | 291 | if (!$_form_name) return; |
292 | 292 | |
293 | 293 | // unquote single and double quotes, as this is how they get returned in $_POST |
294 | - $form_name = str_replace(array('\\\'','"'), array('\'','"'), $_form_name); |
|
294 | + $form_name = str_replace(array('\\\'', '"'), array('\'', '"'), $_form_name); |
|
295 | 295 | |
296 | 296 | if ($add_to_array) |
297 | 297 | { |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | * @param string $form_name =null |
323 | 323 | * @return array |
324 | 324 | */ |
325 | - public function get_to_process($form_name=null) |
|
325 | + public function get_to_process($form_name = null) |
|
326 | 326 | { |
327 | 327 | //echo '<p>'.__METHOD__."($form_name)</p>\n"; |
328 | 328 | return $form_name ? $this->data['to_process'][$form_name] : $this->data['to_process']; |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | * @param string $var |
347 | 347 | * @param mixed $val |
348 | 348 | */ |
349 | - public function __set($var,$val) |
|
349 | + public function __set($var, $val) |
|
350 | 350 | { |
351 | 351 | if ($this->data[$var] !== $val) |
352 | 352 | { |
@@ -397,23 +397,23 @@ discard block |
||
397 | 397 | * @param double $min_share minimum share to be reported (in percent of the whole request) |
398 | 398 | * @param double $dump_share minimum share from which on a variable get output |
399 | 399 | */ |
400 | - public function debug($min_share=1.0,$dump_share=25.0) |
|
400 | + public function debug($min_share = 1.0, $dump_share = 25.0) |
|
401 | 401 | { |
402 | - echo "<p><b>total size request data = ".($total=strlen(serialize($this->data)))."</b></p>\n"; |
|
402 | + echo "<p><b>total size request data = ".($total = strlen(serialize($this->data)))."</b></p>\n"; |
|
403 | 403 | echo "<p>shares bigger then $min_share% percent of it:</p>\n"; |
404 | - foreach($this->data as $key => $val) |
|
404 | + foreach ($this->data as $key => $val) |
|
405 | 405 | { |
406 | 406 | $len = strlen(is_array($val) ? serialize($val) : $val); |
407 | - $len .= ' ('.sprintf('%2.1lf',($percent = 100.0 * $len / $total)).'%)'; |
|
407 | + $len .= ' ('.sprintf('%2.1lf', ($percent = 100.0 * $len / $total)).'%)'; |
|
408 | 408 | if ($percent < $min_share) continue; |
409 | 409 | echo "<p><b>$key</b>: strlen(\$val)=$len</p>\n"; |
410 | 410 | if ($percent >= $dump_share) _debug_array($val); |
411 | 411 | if (is_array($val) && $len > 2000) |
412 | 412 | { |
413 | - foreach($val as $k => $v) |
|
413 | + foreach ($val as $k => $v) |
|
414 | 414 | { |
415 | 415 | $l = strlen(is_array($v) ? serialize($v) : $v); |
416 | - $l .= ' ('.sprintf('%2.1lf',($p = 100.0 * $l / $total)).'%)'; |
|
416 | + $l .= ' ('.sprintf('%2.1lf', ($p = 100.0 * $l / $total)).'%)'; |
|
417 | 417 | if ($p < $min_share) continue; |
418 | 418 | echo "<p> - {$key}[$k]: strlen(\$v)=$l</p>\n"; |
419 | 419 | } |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | * @param string $mode ='ecb' |
429 | 429 | * @return boolean true if encryption is used, false otherwise |
430 | 430 | */ |
431 | - static public function init_crypt($algo='tripledes',$mode='ecb') |
|
431 | + static public function init_crypt($algo = 'tripledes', $mode = 'ecb') |
|
432 | 432 | { |
433 | 433 | if (is_null(self::$mcrypt)) |
434 | 434 | { |
@@ -452,12 +452,12 @@ discard block |
||
452 | 452 | } |
453 | 453 | $iv_size = mcrypt_enc_get_iv_size(self::$mcrypt); |
454 | 454 | $iv = !isset($GLOBALS['egw_info']['server']['mcrypt_iv']) || strlen($GLOBALS['egw_info']['server']['mcrypt_iv']) < $iv_size ? |
455 | - mcrypt_create_iv ($iv_size, MCRYPT_RAND) : substr($GLOBALS['egw_info']['server']['mcrypt_iv'],0,$iv_size); |
|
455 | + mcrypt_create_iv($iv_size, MCRYPT_RAND) : substr($GLOBALS['egw_info']['server']['mcrypt_iv'], 0, $iv_size); |
|
456 | 456 | |
457 | 457 | $key_size = mcrypt_enc_get_key_size(self::$mcrypt); |
458 | - if (bytes($key) > $key_size) $key = cut_bytes($key,0,$key_size-1); |
|
458 | + if (bytes($key) > $key_size) $key = cut_bytes($key, 0, $key_size - 1); |
|
459 | 459 | |
460 | - if (mcrypt_generic_init(self::$mcrypt,$key, $iv) < 0) |
|
460 | + if (mcrypt_generic_init(self::$mcrypt, $key, $iv) < 0) |
|
461 | 461 | { |
462 | 462 | error_log(__METHOD__."() could not initialise mcrypt, sessions get NOT encrypted!"); |
463 | 463 | return self::$mcrypt = false; |
@@ -189,9 +189,12 @@ discard block |
||
189 | 189 | //error_log(__METHOD__."() size of request = ".bytes($id)); |
190 | 190 | } |
191 | 191 | } |
192 | - if (!$request) // eT2 request/session expired |
|
192 | + if (!$request) |
|
193 | + { |
|
194 | + // eT2 request/session expired |
|
193 | 195 | { |
194 | 196 | list($app) = explode('.', $_GET['menuaction']); |
197 | + } |
|
195 | 198 | $index_url = isset($GLOBALS['egw_info']['apps'][$app]['index']) ? |
196 | 199 | '/index.php?menuaction='.$GLOBALS['egw_info']['apps'][$app]['index'] : '/'.$app.'/index.php'; |
197 | 200 | // add a unique token to redirect to avoid client-side framework tries refreshing via nextmatch |
@@ -265,7 +268,10 @@ discard block |
||
265 | 268 | */ |
266 | 269 | public function set_to_process($_form_name, $type, $data=array()) |
267 | 270 | { |
268 | - if (!$_form_name || !$type) return; |
|
271 | + if (!$_form_name || !$type) |
|
272 | + { |
|
273 | + return; |
|
274 | + } |
|
269 | 275 | |
270 | 276 | //echo '<p>'.__METHOD__."($form_name,$type,".array2string($data).")</p>\n"; |
271 | 277 | $data['type'] = $type; |
@@ -288,7 +294,10 @@ discard block |
||
288 | 294 | public function set_to_process_attribute($_form_name, $attribute, $value, $add_to_array=false) |
289 | 295 | { |
290 | 296 | //echo '<p>'.__METHOD__."($form_name,$attribute,$value,$add_to_array)</p>\n"; |
291 | - if (!$_form_name) return; |
|
297 | + if (!$_form_name) |
|
298 | + { |
|
299 | + return; |
|
300 | + } |
|
292 | 301 | |
293 | 302 | // unquote single and double quotes, as this is how they get returned in $_POST |
294 | 303 | $form_name = str_replace(array('\\\'','"'), array('\'','"'), $_form_name); |
@@ -364,7 +373,10 @@ discard block |
||
364 | 373 | */ |
365 | 374 | public function &__get($var) |
366 | 375 | { |
367 | - if ($var == 'data_modified') return $this->data_modified; |
|
376 | + if ($var == 'data_modified') |
|
377 | + { |
|
378 | + return $this->data_modified; |
|
379 | + } |
|
368 | 380 | |
369 | 381 | return $this->data[$var]; |
370 | 382 | } |
@@ -405,16 +417,25 @@ discard block |
||
405 | 417 | { |
406 | 418 | $len = strlen(is_array($val) ? serialize($val) : $val); |
407 | 419 | $len .= ' ('.sprintf('%2.1lf',($percent = 100.0 * $len / $total)).'%)'; |
408 | - if ($percent < $min_share) continue; |
|
420 | + if ($percent < $min_share) |
|
421 | + { |
|
422 | + continue; |
|
423 | + } |
|
409 | 424 | echo "<p><b>$key</b>: strlen(\$val)=$len</p>\n"; |
410 | - if ($percent >= $dump_share) _debug_array($val); |
|
425 | + if ($percent >= $dump_share) |
|
426 | + { |
|
427 | + _debug_array($val); |
|
428 | + } |
|
411 | 429 | if (is_array($val) && $len > 2000) |
412 | 430 | { |
413 | 431 | foreach($val as $k => $v) |
414 | 432 | { |
415 | 433 | $l = strlen(is_array($v) ? serialize($v) : $v); |
416 | 434 | $l .= ' ('.sprintf('%2.1lf',($p = 100.0 * $l / $total)).'%)'; |
417 | - if ($p < $min_share) continue; |
|
435 | + if ($p < $min_share) |
|
436 | + { |
|
437 | + continue; |
|
438 | + } |
|
418 | 439 | echo "<p> - {$key}[$k]: strlen(\$v)=$l</p>\n"; |
419 | 440 | } |
420 | 441 | } |
@@ -455,7 +476,10 @@ discard block |
||
455 | 476 | mcrypt_create_iv ($iv_size, MCRYPT_RAND) : substr($GLOBALS['egw_info']['server']['mcrypt_iv'],0,$iv_size); |
456 | 477 | |
457 | 478 | $key_size = mcrypt_enc_get_key_size(self::$mcrypt); |
458 | - if (bytes($key) > $key_size) $key = cut_bytes($key,0,$key_size-1); |
|
479 | + if (bytes($key) > $key_size) |
|
480 | + { |
|
481 | + $key = cut_bytes($key,0,$key_size-1); |
|
482 | + } |
|
459 | 483 | |
460 | 484 | if (mcrypt_generic_init(self::$mcrypt,$key, $iv) < 0) |
461 | 485 | { |
@@ -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'); |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * |
62 | 62 | * @param array $id |
63 | 63 | */ |
64 | - private function __construct($id=null) |
|
64 | + private function __construct($id = null) |
|
65 | 65 | { |
66 | 66 | if (!$id) $id = self::request_id(); |
67 | 67 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @param string $id =null |
89 | 89 | * @return etemplate_request|boolean the object or false if $id is not found |
90 | 90 | */ |
91 | - static function read($id=null) |
|
91 | + static function read($id = null) |
|
92 | 92 | { |
93 | 93 | $request = new Session($id); |
94 | 94 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | { |
97 | 97 | if (!($data = Api\Cache::getSession('etemplate', $id))) |
98 | 98 | { |
99 | - return false; // request not found |
|
99 | + return false; // request not found |
|
100 | 100 | } |
101 | 101 | $request->data = $data; |
102 | 102 | } |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | */ |
112 | 112 | static function request_id() |
113 | 113 | { |
114 | - $time = (int) (100 * microtime(true)); // gives precision of 1/100 sec |
|
115 | - $id = $GLOBALS['egw_info']['flags']['currentapp'] .':'. $time; |
|
114 | + $time = (int)(100 * microtime(true)); // gives precision of 1/100 sec |
|
115 | + $id = $GLOBALS['egw_info']['flags']['currentapp'].':'.$time; |
|
116 | 116 | |
117 | 117 | return $id; |
118 | 118 | } |
@@ -152,30 +152,30 @@ discard block |
||
152 | 152 | protected function _php4_request_garbage_collection() |
153 | 153 | { |
154 | 154 | // now we are on php4 sessions and do a bit of garbage collection |
155 | - $appsessions =& $_SESSION[Api\Session::EGW_APPSESSION_VAR]['etemplate']; |
|
156 | - $session_used =& $appsessions['session_used']; |
|
155 | + $appsessions = & $_SESSION[Api\Session::EGW_APPSESSION_VAR]['etemplate']; |
|
156 | + $session_used = & $appsessions['session_used']; |
|
157 | 157 | |
158 | 158 | if ($this->id) |
159 | 159 | { |
160 | 160 | //echo "session_used[$id_used]='".$session_used[$id_used]."'<br/>\n"; |
161 | - ++$session_used[$this->id]; // count the number of times a session got used |
|
161 | + ++$session_used[$this->id]; // count the number of times a session got used |
|
162 | 162 | } |
163 | 163 | $this->garbage_collection_done = true; |
164 | 164 | |
165 | - if (count($appsessions) < 20) return; // we dont need to care |
|
165 | + if (count($appsessions) < 20) return; // we dont need to care |
|
166 | 166 | |
167 | - $now = (int) (100 * microtime(true)); // gives precision of 1/100 sec |
|
167 | + $now = (int)(100 * microtime(true)); // gives precision of 1/100 sec |
|
168 | 168 | |
169 | - foreach(array_keys($appsessions) as $id) |
|
169 | + foreach (array_keys($appsessions) as $id) |
|
170 | 170 | { |
171 | - list(,$time) = explode(':',$id); |
|
171 | + list(,$time) = explode(':', $id); |
|
172 | 172 | |
173 | - if (!$time) continue; // other data, no session |
|
173 | + if (!$time) continue; // other data, no session |
|
174 | 174 | |
175 | 175 | //echo ++$n.') '.$id.': '.(($now-$time)/100.0)."secs old, used=".$session_used[$id].", size=".strlen($appsessions[$id])."<br>\n"; |
176 | 176 | |
177 | - if ($session_used[$id] == 1 && $time < $now - 10*6000 || // session used and older then 10min |
|
178 | - $time < $now - 30*6000) // session not used and older then 30min |
|
177 | + if ($session_used[$id] == 1 && $time < $now - 10 * 6000 || // session used and older then 10min |
|
178 | + $time < $now - 30 * 6000) // session not used and older then 30min |
|
179 | 179 | { |
180 | 180 | //echo "<p>boetemplate::php4_session_garbage_collection('$id_used'): unsetting session '$id' (now=$now)</p>\n"; |
181 | 181 | unset($appsessions[$id]); |
@@ -63,12 +63,18 @@ discard block |
||
63 | 63 | */ |
64 | 64 | private function __construct($id=null) |
65 | 65 | { |
66 | - if (!$id) $id = self::request_id(); |
|
66 | + if (!$id) |
|
67 | + { |
|
68 | + $id = self::request_id(); |
|
69 | + } |
|
67 | 70 | |
68 | 71 | $this->id = $id; |
69 | 72 | |
70 | 73 | // hack to quiten IDE Warning for not calling parent::__construct, which we can not! |
71 | - if (false) parent::__construct(); |
|
74 | + if (false) |
|
75 | + { |
|
76 | + parent::__construct(); |
|
77 | + } |
|
72 | 78 | } |
73 | 79 | |
74 | 80 | /** |
@@ -162,7 +168,11 @@ discard block |
||
162 | 168 | } |
163 | 169 | $this->garbage_collection_done = true; |
164 | 170 | |
165 | - if (count($appsessions) < 20) return; // we dont need to care |
|
171 | + if (count($appsessions) < 20) |
|
172 | + { |
|
173 | + return; |
|
174 | + } |
|
175 | + // we dont need to care |
|
166 | 176 | |
167 | 177 | $now = (int) (100 * microtime(true)); // gives precision of 1/100 sec |
168 | 178 | |
@@ -170,15 +180,22 @@ discard block |
||
170 | 180 | { |
171 | 181 | list(,$time) = explode(':',$id); |
172 | 182 | |
173 | - if (!$time) continue; // other data, no session |
|
183 | + if (!$time) |
|
184 | + { |
|
185 | + continue; |
|
186 | + } |
|
187 | + // other data, no session |
|
174 | 188 | |
175 | 189 | //echo ++$n.') '.$id.': '.(($now-$time)/100.0)."secs old, used=".$session_used[$id].", size=".strlen($appsessions[$id])."<br>\n"; |
176 | 190 | |
177 | 191 | if ($session_used[$id] == 1 && $time < $now - 10*6000 || // session used and older then 10min |
178 | - $time < $now - 30*6000) // session not used and older then 30min |
|
192 | + $time < $now - 30*6000) |
|
193 | + { |
|
194 | + // session not used and older then 30min |
|
179 | 195 | { |
180 | 196 | //echo "<p>boetemplate::php4_session_garbage_collection('$id_used'): unsetting session '$id' (now=$now)</p>\n"; |
181 | 197 | unset($appsessions[$id]); |
198 | + } |
|
182 | 199 | unset($session_used[$id]); |
183 | 200 | } |
184 | 201 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @param array $id |
73 | 73 | */ |
74 | - private function __construct($id=null) |
|
74 | + private function __construct($id = null) |
|
75 | 75 | { |
76 | 76 | if (is_null(self::$directory)) |
77 | 77 | { |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @param string $id =null |
103 | 103 | * @return etemplate_request|boolean the object or false if $id is not found |
104 | 104 | */ |
105 | - static function read($id=null) |
|
105 | + static function read($id = null) |
|
106 | 106 | { |
107 | 107 | $request = new Files($id); |
108 | 108 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | { |
130 | 130 | do |
131 | 131 | { |
132 | - $id = uniqid('etemplate_'.$GLOBALS['egw_info']['flags']['currentapp'].'_',true); |
|
132 | + $id = uniqid('etemplate_'.$GLOBALS['egw_info']['flags']['currentapp'].'_', true); |
|
133 | 133 | } |
134 | 134 | while (file_exists(self::$directory.'/'.$id)); |
135 | 135 | |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | @unlink(self::$directory.'/'.$this->id); |
153 | 153 | } |
154 | 154 | elseif (!$this->destroyed && $this->data_modified && |
155 | - !file_put_contents($filename = self::$directory.'/'.$this->id,serialize($this->data))) |
|
155 | + !file_put_contents($filename = self::$directory.'/'.$this->id, serialize($this->data))) |
|
156 | 156 | { |
157 | 157 | error_log("Error opening '$filename' to store the etemplate request data!"); |
158 | 158 | } |
@@ -77,12 +77,18 @@ discard block |
||
77 | 77 | { |
78 | 78 | self::$directory = $GLOBALS['egw_info']['server']['temp_dir']; |
79 | 79 | } |
80 | - if (!$id) $id = self::request_id(); |
|
80 | + if (!$id) |
|
81 | + { |
|
82 | + $id = self::request_id(); |
|
83 | + } |
|
81 | 84 | |
82 | 85 | $this->id = $id; |
83 | 86 | |
84 | 87 | // hack to quiten IDE Warning for not calling parent::__construct, which we can not! |
85 | - if (false) parent::__construct(); |
|
88 | + if (false) |
|
89 | + { |
|
90 | + parent::__construct(); |
|
91 | + } |
|
86 | 92 | } |
87 | 93 | |
88 | 94 | /** |
@@ -114,7 +120,10 @@ discard block |
||
114 | 120 | return false; |
115 | 121 | } |
116 | 122 | $request->data = unserialize(file_get_contents($filename)); |
117 | - if ($request->data === false) error_log("Error unserializing '$filename' to read the etemplate request data!"); |
|
123 | + if ($request->data === false) |
|
124 | + { |
|
125 | + error_log("Error unserializing '$filename' to read the etemplate request data!"); |
|
126 | + } |
|
118 | 127 | } |
119 | 128 | //error_log(__METHOD__."(id=$id"); |
120 | 129 | return $request; |