@@ -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 | { |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @param array &$validated=array() validated content |
45 | 45 | * @return boolean true if no validation error, false otherwise |
46 | 46 | */ |
47 | - public function validate($cname, array $expand, array $content, &$validated=array()) |
|
47 | + public function validate($cname, array $expand, array $content, &$validated = array()) |
|
48 | 48 | { |
49 | 49 | $form_name = self::form_name($cname, $this->id, $expand); |
50 | 50 | |
@@ -56,28 +56,28 @@ discard block |
||
56 | 56 | if (!$this->is_readonly($cname, $form_name)) |
57 | 57 | { |
58 | 58 | $value = self::get_array($content, $form_name); |
59 | - if (!isset($value)) return; // value not transmitted --> nothing to validate |
|
60 | - $valid =& self::get_array($validated, $form_name, true); |
|
59 | + if (!isset($value)) return; // value not transmitted --> nothing to validate |
|
60 | + $valid = & self::get_array($validated, $form_name, true); |
|
61 | 61 | |
62 | 62 | if (!$value && $this->attrs['needed']) |
63 | 63 | { |
64 | - self::set_validation_error($form_name,lang('Field must not be empty !!!'),''); |
|
64 | + self::set_validation_error($form_name, lang('Field must not be empty !!!'), ''); |
|
65 | 65 | } |
66 | 66 | $type = $this->type ? $this->type : $this->attrs['type']; |
67 | 67 | $value_attr = $type == 'radio' ? 'set_value' : 'selected_value'; |
68 | 68 | // defaults for set and unset values |
69 | 69 | $selected_value = true; |
70 | 70 | $unselected_value = false; |
71 | - if (array_key_exists($value_attr, $this->attrs) || array_key_exists('unselected_value',$this->attrs)) |
|
71 | + if (array_key_exists($value_attr, $this->attrs) || array_key_exists('unselected_value', $this->attrs)) |
|
72 | 72 | { |
73 | - if(array_key_exists($value_attr, $this->attrs)) |
|
73 | + if (array_key_exists($value_attr, $this->attrs)) |
|
74 | 74 | { |
75 | 75 | // Expand any content stuff |
76 | - $selected_value = self::expand_name($this->attrs[$value_attr], $expand['c'], $expand['row'], $expand['c_'], $expand['row_'],$expand['cont']); |
|
76 | + $selected_value = self::expand_name($this->attrs[$value_attr], $expand['c'], $expand['row'], $expand['c_'], $expand['row_'], $expand['cont']); |
|
77 | 77 | } |
78 | - if(array_key_exists('unselected_value',$this->attrs)) |
|
78 | + if (array_key_exists('unselected_value', $this->attrs)) |
|
79 | 79 | { |
80 | - $unselected_value = self::expand_name($this->attrs['unselected_value'], $expand['c'], $expand['row'], $expand['c_'], $expand['row_'],$expand['cont']); |
|
80 | + $unselected_value = self::expand_name($this->attrs['unselected_value'], $expand['c'], $expand['row'], $expand['c_'], $expand['row_'], $expand['cont']); |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | if ($type == 'radio') |
@@ -87,14 +87,14 @@ discard block |
||
87 | 87 | { |
88 | 88 | $valid = $value; |
89 | 89 | } |
90 | - elseif ( !$options && $selected_value && $value == $selected_value) |
|
90 | + elseif (!$options && $selected_value && $value == $selected_value) |
|
91 | 91 | { |
92 | 92 | // Options set in template, not in sel_options |
93 | 93 | $valid = $selected_value; |
94 | 94 | } |
95 | 95 | elseif (!isset($valid)) |
96 | 96 | { |
97 | - $valid = ''; // do not overwrite value of an other radio-button of the same group (identical name)! |
|
97 | + $valid = ''; // do not overwrite value of an other radio-button of the same group (identical name)! |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | elseif (in_array((string)$selected_value, (array)$value)) |
@@ -56,7 +56,11 @@ discard block |
||
56 | 56 | if (!$this->is_readonly($cname, $form_name)) |
57 | 57 | { |
58 | 58 | $value = self::get_array($content, $form_name); |
59 | - if (!isset($value)) return; // value not transmitted --> nothing to validate |
|
59 | + if (!isset($value)) |
|
60 | + { |
|
61 | + return; |
|
62 | + } |
|
63 | + // value not transmitted --> nothing to validate |
|
60 | 64 | $valid =& self::get_array($validated, $form_name, true); |
61 | 65 | |
62 | 66 | if (!$value && $this->attrs['needed']) |
@@ -101,7 +105,10 @@ discard block |
||
101 | 105 | { |
102 | 106 | if ($multiple) |
103 | 107 | { |
104 | - if (!isset($valid)) $valid = array(); |
|
108 | + if (!isset($valid)) |
|
109 | + { |
|
110 | + $valid = array(); |
|
111 | + } |
|
105 | 112 | $valid[] = $selected_value; |
106 | 113 | } |
107 | 114 | else |
@@ -113,7 +120,10 @@ discard block |
||
113 | 120 | { |
114 | 121 | if ($multiple) |
115 | 122 | { |
116 | - if (!isset($valid)) $valid = array(); |
|
123 | + if (!isset($valid)) |
|
124 | + { |
|
125 | + $valid = array(); |
|
126 | + } |
|
117 | 127 | } |
118 | 128 | elseif ($value === 'true') |
119 | 129 | { |
@@ -101,7 +101,6 @@ discard block |
||
101 | 101 | /** |
102 | 102 | * Put date in the proper format for sending to client |
103 | 103 | * @param string|int $value |
104 | - * @param string $format |
|
105 | 104 | */ |
106 | 105 | public function format_date($value) |
107 | 106 | { |
@@ -139,7 +138,7 @@ discard block |
||
139 | 138 | * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' |
140 | 139 | * @param array $content |
141 | 140 | * @param array &$validated=array() validated content |
142 | - * @return boolean true if no validation error, false otherwise |
|
141 | + * @return boolean|null true if no validation error, false otherwise |
|
143 | 142 | */ |
144 | 143 | public function validate($cname, array $expand, array $content, &$validated=array()) |
145 | 144 | { |
@@ -88,7 +88,7 @@ |
||
88 | 88 | * @param array $data Row data |
89 | 89 | * @return type |
90 | 90 | */ |
91 | - public function set_row_value($cname, Array $expand, Array &$data) |
|
91 | + public function set_row_value($cname, array $expand, array &$data) |
|
92 | 92 | { |
93 | 93 | if($this->type == 'date-duration') return; |
94 | 94 |
@@ -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']) |
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($value) |
@@ -232,10 +245,13 @@ discard block |
||
232 | 245 | // Not null, blank |
233 | 246 | $value = ''; |
234 | 247 | } |
235 | - elseif ($date && empty($this->attrs['dataformat'])) // integer timestamp |
|
248 | + elseif ($date && empty($this->attrs['dataformat'])) |
|
249 | + { |
|
250 | + // integer timestamp |
|
236 | 251 | { |
237 | 252 | $valid = $date->format('ts'); |
238 | 253 | } |
254 | + } |
|
239 | 255 | // string with formatting letters like for php's date() method |
240 | 256 | elseif ($date && ($valid = $date->format($this->attrs['dataformat']))) |
241 | 257 | { |
@@ -60,17 +60,17 @@ discard block |
||
60 | 60 | * @param string $cname |
61 | 61 | * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' |
62 | 62 | */ |
63 | - public function beforeSendToClient($cname, array $expand=null) |
|
63 | + public function beforeSendToClient($cname, array $expand = null) |
|
64 | 64 | { |
65 | - if($this->type == 'date-houronly') |
|
65 | + if ($this->type == 'date-houronly') |
|
66 | 66 | { |
67 | 67 | return parent::beforeSendToClient($cname, $expand); |
68 | 68 | } |
69 | 69 | |
70 | 70 | $form_name = self::form_name($cname, $this->id, $expand); |
71 | - $value =& self::get_array(self::$request->content, $form_name, false, true); |
|
71 | + $value = & self::get_array(self::$request->content, $form_name, false, true); |
|
72 | 72 | |
73 | - if($this->type != 'date-duration' && $value) |
|
73 | + if ($this->type != 'date-duration' && $value) |
|
74 | 74 | { |
75 | 75 | $value = $this->format_date($value); |
76 | 76 | } |
@@ -90,10 +90,10 @@ 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') return; |
|
94 | 94 | |
95 | 95 | $form_name = self::form_name($cname, $this->id, $expand); |
96 | - $value =& $this->get_array($data, $form_name, true); |
|
96 | + $value = & $this->get_array($data, $form_name, true); |
|
97 | 97 | |
98 | 98 | if (true) $value = $this->format_date($value); |
99 | 99 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function format_date($value) |
107 | 107 | { |
108 | - if (!$value) return $value; // otherwise we will get current date or 1970-01-01 instead of an empty value |
|
108 | + if (!$value) return $value; // otherwise we will get current date or 1970-01-01 instead of an empty value |
|
109 | 109 | |
110 | 110 | if ($this->attrs['dataformat']) |
111 | 111 | { |
@@ -115,11 +115,11 @@ discard block |
||
115 | 115 | { |
116 | 116 | $date = new Api\DateTime($value); |
117 | 117 | } |
118 | - if($this->type == 'date-timeonly' && $date) |
|
118 | + if ($this->type == 'date-timeonly' && $date) |
|
119 | 119 | { |
120 | 120 | $date->setDate(1970, 1, 1); |
121 | 121 | } |
122 | - if($date) |
|
122 | + if ($date) |
|
123 | 123 | { |
124 | 124 | // postfix date-string with "Z" so javascript doesn't add/subtract anything |
125 | 125 | $value = $date->format('Y-m-d\TH:i:s\Z'); |
@@ -141,34 +141,34 @@ discard block |
||
141 | 141 | * @param array &$validated=array() validated content |
142 | 142 | * @return boolean true if no validation error, false otherwise |
143 | 143 | */ |
144 | - public function validate($cname, array $expand, array $content, &$validated=array()) |
|
144 | + public function validate($cname, array $expand, array $content, &$validated = array()) |
|
145 | 145 | { |
146 | 146 | $form_name = self::form_name($cname, $this->id, $expand); |
147 | 147 | |
148 | 148 | if (!$this->is_readonly($cname, $form_name) && $this->type != 'date-since') // date-since is always readonly |
149 | 149 | { |
150 | 150 | $value = self::get_array($content, $form_name); |
151 | - $valid =& self::get_array($validated, $form_name, true); |
|
151 | + $valid = & self::get_array($validated, $form_name, true); |
|
152 | 152 | |
153 | - if($value) |
|
153 | + if ($value) |
|
154 | 154 | { |
155 | 155 | try |
156 | 156 | { |
157 | 157 | $date = new Api\DateTime($value); |
158 | 158 | } |
159 | - catch(\Exception $e) |
|
159 | + catch (\Exception $e) |
|
160 | 160 | { |
161 | 161 | unset($e); |
162 | 162 | $date = null; |
163 | 163 | $value = ''; |
164 | 164 | // this is not really a user error, but one of the clientside engine |
165 | - self::set_validation_error($form_name,lang("'%1' is not a valid date !!!", $value).' '.$this->dataformat); |
|
165 | + self::set_validation_error($form_name, lang("'%1' is not a valid date !!!", $value).' '.$this->dataformat); |
|
166 | 166 | } |
167 | 167 | } |
168 | 168 | |
169 | 169 | if ((string)$value === '' && $this->attrs['needed']) |
170 | 170 | { |
171 | - self::set_validation_error($form_name,lang('Field must not be empty !!!')); |
|
171 | + self::set_validation_error($form_name, lang('Field must not be empty !!!')); |
|
172 | 172 | } |
173 | 173 | elseif (is_null($value)) |
174 | 174 | { |
@@ -181,53 +181,53 @@ discard block |
||
181 | 181 | |
182 | 182 | if (!empty($this->attrs['min'])) |
183 | 183 | { |
184 | - if(is_numeric($this->attrs['min'])) |
|
184 | + if (is_numeric($this->attrs['min'])) |
|
185 | 185 | { |
186 | - $min = new Api\DateTime(strtotime( $this->attrs['min'] . 'days')); |
|
186 | + $min = new Api\DateTime(strtotime($this->attrs['min'].'days')); |
|
187 | 187 | } |
188 | - elseif (preg_match('/[+-][[:digit:]]+[ymwd]/',$this->attrs['min'])) |
|
188 | + elseif (preg_match('/[+-][[:digit:]]+[ymwd]/', $this->attrs['min'])) |
|
189 | 189 | { |
190 | 190 | // Relative date with periods |
191 | - $min = new Api\DateTime(strtotime(str_replace(array('y','m','w','d'), array('years','months','weeks','days'), $this->attrs['min']))); |
|
191 | + $min = new Api\DateTime(strtotime(str_replace(array('y', 'm', 'w', 'd'), array('years', 'months', 'weeks', 'days'), $this->attrs['min']))); |
|
192 | 192 | } |
193 | 193 | else |
194 | 194 | { |
195 | 195 | $min = new Api\DateTime(strtotime($this->attrs['min'])); |
196 | 196 | } |
197 | - if($date < $min) |
|
197 | + if ($date < $min) |
|
198 | 198 | { |
199 | - self::set_validation_error($form_name,lang( |
|
199 | + self::set_validation_error($form_name, lang( |
|
200 | 200 | "Value has to be at least '%1' !!!", |
201 | 201 | $min->format($this->type != 'date') |
202 | - ),''); |
|
202 | + ), ''); |
|
203 | 203 | $value = $min; |
204 | 204 | } |
205 | 205 | } |
206 | 206 | if (!empty($this->attrs['max'])) |
207 | 207 | { |
208 | - if(is_numeric($this->attrs['max'])) |
|
208 | + if (is_numeric($this->attrs['max'])) |
|
209 | 209 | { |
210 | - $max = new Api\DateTime(strtotime( $this->attrs['max'] . 'days')); |
|
210 | + $max = new Api\DateTime(strtotime($this->attrs['max'].'days')); |
|
211 | 211 | } |
212 | - elseif (preg_match('/[+-][[:digit:]]+[ymwd]/',$this->attrs['max'])) |
|
212 | + elseif (preg_match('/[+-][[:digit:]]+[ymwd]/', $this->attrs['max'])) |
|
213 | 213 | { |
214 | 214 | // Relative date with periods |
215 | - $max = new Api\DateTime(strtotime(str_replace(array('y','m','w','d'), array('years','months','weeks','days'), $this->attrs['max']))); |
|
215 | + $max = new Api\DateTime(strtotime(str_replace(array('y', 'm', 'w', 'd'), array('years', 'months', 'weeks', 'days'), $this->attrs['max']))); |
|
216 | 216 | } |
217 | 217 | else |
218 | 218 | { |
219 | 219 | $max = new Api\DateTime(strtotime($this->attrs['max'])); |
220 | 220 | } |
221 | - if($date > $max) |
|
221 | + if ($date > $max) |
|
222 | 222 | { |
223 | - self::set_validation_error($form_name,lang( |
|
223 | + self::set_validation_error($form_name, lang( |
|
224 | 224 | "Value has to be at maximum '%1' !!!", |
225 | 225 | $max->format($this->type != 'date') |
226 | - ),''); |
|
226 | + ), ''); |
|
227 | 227 | $value = $max; |
228 | 228 | } |
229 | 229 | } |
230 | - if(!$value) |
|
230 | + if (!$value) |
|
231 | 231 | { |
232 | 232 | // Not null, blank |
233 | 233 | $value = ''; |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | else |
245 | 245 | { |
246 | 246 | // this is not really a user error, but one of the clientside engine |
247 | - self::set_validation_error($form_name,lang("'%1' is not a valid date !!!", $value).' '.$this->dataformat); |
|
247 | + self::set_validation_error($form_name, lang("'%1' is not a valid date !!!", $value).' '.$this->dataformat); |
|
248 | 248 | } |
249 | 249 | //error_log("$this : ($valid)" . Api\DateTime::to($valid)); |
250 | 250 | } |
@@ -102,7 +102,6 @@ |
||
102 | 102 | * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' |
103 | 103 | * @param array $content |
104 | 104 | * @param array &$validated=array() validated content |
105 | - * @param array $expand=array values for keys 'c', 'row', 'c_', 'row_', 'cont' |
|
106 | 105 | */ |
107 | 106 | public function validate($cname, array $expand, array $content, &$validated=array()) |
108 | 107 | { |
@@ -65,7 +65,10 @@ discard block |
||
65 | 65 | foreach($tabs as &$tab) |
66 | 66 | { |
67 | 67 | $template= clone Template::instance($tab['template']); |
68 | - if($tab['id']) $template->attrs['content'] = $tab['id']; |
|
68 | + if($tab['id']) |
|
69 | + { |
|
70 | + $template->attrs['content'] = $tab['id']; |
|
71 | + } |
|
69 | 72 | $this->children[1]->children[] = $template; |
70 | 73 | $tab['url'] = Template::rel2url($template->rel_path); |
71 | 74 | //$this->tabs[] = $tab; |
@@ -112,7 +115,10 @@ discard block |
||
112 | 115 | { |
113 | 116 | $value = self::get_array($content, $form_name); |
114 | 117 | $valid =& self::get_array($validated, $form_name, true); |
115 | - if (true) $valid = $value; |
|
118 | + if (true) |
|
119 | + { |
|
120 | + $valid = $value; |
|
121 | + } |
|
116 | 122 | } |
117 | 123 | } |
118 | 124 | } |
@@ -42,30 +42,30 @@ discard block |
||
42 | 42 | * @param array $params =array('') parameter(s) first parameter has to be the cname, second $expand! |
43 | 43 | * @param boolean $respect_disabled =false false (default): ignore disabled, true: method is NOT run for disabled widgets AND their children |
44 | 44 | */ |
45 | - public function run($method_name, $params=array(''), $respect_disabled=false) |
|
45 | + public function run($method_name, $params = array(''), $respect_disabled = false) |
|
46 | 46 | { |
47 | 47 | $form_name = self::form_name($params[0], $this->id, $params[1]); |
48 | 48 | |
49 | 49 | // Make sure additional tabs are processed for any method |
50 | - if (!($tabs =& self::getElementAttribute($form_name, 'tabs'))) |
|
50 | + if (!($tabs = & self::getElementAttribute($form_name, 'tabs'))) |
|
51 | 51 | { |
52 | 52 | $tabs = $this->attrs['tabs']; |
53 | 53 | } |
54 | - if($tabs && !$this->tabs_attr_evaluated) |
|
54 | + if ($tabs && !$this->tabs_attr_evaluated) |
|
55 | 55 | { |
56 | - $this->tabs_attr_evaluated = true; // we must not evaluate tabs attribte more then once! |
|
56 | + $this->tabs_attr_evaluated = true; // we must not evaluate tabs attribte more then once! |
|
57 | 57 | |
58 | 58 | // add_tabs toggles replacing or adding to existing tabs |
59 | - if(!$this->attrs['add_tabs']) |
|
59 | + if (!$this->attrs['add_tabs']) |
|
60 | 60 | { |
61 | 61 | $this->children[1]->children = array(); |
62 | 62 | } |
63 | 63 | |
64 | 64 | //$this->tabs = array(); |
65 | - foreach($tabs as &$tab) |
|
65 | + foreach ($tabs as &$tab) |
|
66 | 66 | { |
67 | - $template= clone Template::instance($tab['template']); |
|
68 | - if($tab['id']) $template->attrs['content'] = $tab['id']; |
|
67 | + $template = clone Template::instance($tab['template']); |
|
68 | + if ($tab['id']) $template->attrs['content'] = $tab['id']; |
|
69 | 69 | $this->children[1]->children[] = $template; |
70 | 70 | $tab['url'] = Template::rel2url($template->rel_path); |
71 | 71 | //$this->tabs[] = $tab; |
@@ -83,22 +83,22 @@ discard block |
||
83 | 83 | // to avoid checking for server side validation |
84 | 84 | if ($form_name == 'tabs' && is_array($readonlys)) |
85 | 85 | { |
86 | - foreach($this->children[1]->children as $tab) |
|
86 | + foreach ($this->children[1]->children as $tab) |
|
87 | 87 | { |
88 | - if($readonlys[$tab->id]) |
|
88 | + if ($readonlys[$tab->id]) |
|
89 | 89 | { |
90 | 90 | $tab->attrs['disabled'] = $readonlys[$tab->id]; |
91 | 91 | } |
92 | 92 | } |
93 | 93 | } |
94 | 94 | |
95 | - if($respect_disabled && $readonlys) |
|
95 | + if ($respect_disabled && $readonlys) |
|
96 | 96 | { |
97 | - foreach($this->children[1]->children as $tab) |
|
97 | + foreach ($this->children[1]->children as $tab) |
|
98 | 98 | { |
99 | - $parts = explode('.',$tab->template ? $tab->template : $tab->id); |
|
99 | + $parts = explode('.', $tab->template ? $tab->template : $tab->id); |
|
100 | 100 | $ro_id = array_pop($parts); |
101 | - if($readonlys[$ro_id]) |
|
101 | + if ($readonlys[$ro_id]) |
|
102 | 102 | { |
103 | 103 | $tab->attrs['disabled'] = $readonlys[$ro_id]; |
104 | 104 | } |
@@ -118,14 +118,14 @@ discard block |
||
118 | 118 | * @param array &$validated=array() validated content |
119 | 119 | * @param array $expand=array values for keys 'c', 'row', 'c_', 'row_', 'cont' |
120 | 120 | */ |
121 | - public function validate($cname, array $expand, array $content, &$validated=array()) |
|
121 | + public function validate($cname, array $expand, array $content, &$validated = array()) |
|
122 | 122 | { |
123 | 123 | $form_name = self::form_name($cname, $this->id, $expand); |
124 | 124 | |
125 | 125 | if (!empty($form_name)) |
126 | 126 | { |
127 | 127 | $value = self::get_array($content, $form_name); |
128 | - $valid =& self::get_array($validated, $form_name, true); |
|
128 | + $valid = & self::get_array($validated, $form_name, true); |
|
129 | 129 | if (true) $valid = $value; |
130 | 130 | } |
131 | 131 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @param string|XMLReader $xml |
57 | 57 | * @param boolean $cloned =true true: object does NOT need to be cloned, false: to set attribute, set them in cloned object |
58 | - * @return Template current object or clone, if any attribute was set |
|
58 | + * @return Textbox current object or clone, if any attribute was set |
|
59 | 59 | */ |
60 | 60 | public function set_attrs($xml, $cloned=true) |
61 | 61 | { |
@@ -110,7 +110,6 @@ discard block |
||
110 | 110 | * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' |
111 | 111 | * @param array $content |
112 | 112 | * @param array &$validated=array() validated content |
113 | - * @param array $expand=array values for keys 'c', 'row', 'c_', 'row_', 'cont' |
|
114 | 113 | */ |
115 | 114 | public function validate($cname, array $expand, array $content, &$validated=array()) |
116 | 115 | { |
@@ -41,7 +41,10 @@ discard block |
||
41 | 41 | // normalize types |
42 | 42 | if ($this->type !== 'textbox') |
43 | 43 | { |
44 | - if ($this->type == 'int') $this->type = 'integer'; |
|
44 | + if ($this->type == 'int') |
|
45 | + { |
|
46 | + $this->type = 'integer'; |
|
47 | + } |
|
45 | 48 | |
46 | 49 | $this->attrs['type'] = $this->type; |
47 | 50 | $this->type = 'textbox'; |
@@ -90,7 +93,10 @@ discard block |
||
90 | 93 | if (!empty($value)) |
91 | 94 | { |
92 | 95 | $preserv =& self::get_array(self::$request->preserv, $form_name, true); |
93 | - if (true) $preserv = (string)$value; |
|
96 | + if (true) |
|
97 | + { |
|
98 | + $preserv = (string)$value; |
|
99 | + } |
|
94 | 100 | $value = str_repeat('*', strlen($preserv)); |
95 | 101 | } |
96 | 102 | } |
@@ -171,11 +177,15 @@ discard block |
||
171 | 177 | break; |
172 | 178 | } |
173 | 179 | } |
174 | - elseif ($this->attrs['type'] == 'integer' || $this->attrs['type'] == 'float') // cast int and float and check range |
|
180 | + elseif ($this->attrs['type'] == 'integer' || $this->attrs['type'] == 'float') |
|
181 | + { |
|
182 | + // cast int and float and check range |
|
175 | 183 | { |
176 | 184 | if ((string)$value !== '' || $this->attrs['needed']) // empty values are Ok if needed is not set |
177 | 185 | { |
178 | - $value = $this->attrs['type'] == 'integer' ? (int) $value : (float) str_replace(',','.',$value); // allow for german (and maybe other) format |
|
186 | + $value = $this->attrs['type'] == 'integer' ? (int) $value : (float) str_replace(',','.',$value); |
|
187 | + } |
|
188 | + // allow for german (and maybe other) format |
|
179 | 189 | |
180 | 190 | if (!(empty($this->attrs['min']) && $this->attrs['min'] !== 0) && $value < $this->attrs['min']) |
181 | 191 | { |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @param boolean $cloned =true true: object does NOT need to be cloned, false: to set attribute, set them in cloned object |
58 | 58 | * @return Template current object or clone, if any attribute was set |
59 | 59 | */ |
60 | - public function set_attrs($xml, $cloned=true) |
|
60 | + public function set_attrs($xml, $cloned = true) |
|
61 | 61 | { |
62 | 62 | parent::set_attrs($xml, $cloned); |
63 | 63 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $this->setElementAttribute($this->id, 'size', abs($this->attrs['size'])); |
70 | 70 | self::$request->readonlys[$this->id] = false; |
71 | 71 | $this->setElementAttribute($this->id, 'readonly', true); |
72 | - trigger_error("Using a negative size to set textbox readonly. " .$this, E_USER_DEPRECATED); |
|
72 | + trigger_error("Using a negative size to set textbox readonly. ".$this, E_USER_DEPRECATED); |
|
73 | 73 | } |
74 | 74 | return $this; |
75 | 75 | } |
@@ -80,16 +80,16 @@ discard block |
||
80 | 80 | * @param string $cname |
81 | 81 | * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' |
82 | 82 | */ |
83 | - public function beforeSendToClient($cname, array $expand=null) |
|
83 | + public function beforeSendToClient($cname, array $expand = null) |
|
84 | 84 | { |
85 | 85 | // to NOT transmit passwords back to client, we need to store (non-empty) value in preserv |
86 | 86 | if ($this->attrs['type'] == 'passwd' || $this->type == 'passwd') |
87 | 87 | { |
88 | 88 | $form_name = self::form_name($cname, $this->id, $expand); |
89 | - $value =& self::get_array(self::$request->content, $form_name); |
|
89 | + $value = & self::get_array(self::$request->content, $form_name); |
|
90 | 90 | if (!empty($value)) |
91 | 91 | { |
92 | - $preserv =& self::get_array(self::$request->preserv, $form_name, true); |
|
92 | + $preserv = & self::get_array(self::$request->preserv, $form_name, true); |
|
93 | 93 | if (true) $preserv = (string)$value; |
94 | 94 | $value = str_repeat('*', strlen($preserv)); |
95 | 95 | } |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | * @param array &$validated=array() validated content |
113 | 113 | * @param array $expand=array values for keys 'c', 'row', 'c_', 'row_', 'cont' |
114 | 114 | */ |
115 | - public function validate($cname, array $expand, array $content, &$validated=array()) |
|
115 | + public function validate($cname, array $expand, array $content, &$validated = array()) |
|
116 | 116 | { |
117 | 117 | $form_name = self::form_name($cname, $this->id, $expand); |
118 | 118 | |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | { |
121 | 121 | if (!isset($this->attrs['validator'])) |
122 | 122 | { |
123 | - switch($this->attrs['type']) |
|
123 | + switch ($this->attrs['type']) |
|
124 | 124 | { |
125 | 125 | case 'int': |
126 | 126 | case 'integer': |
@@ -150,26 +150,26 @@ discard block |
||
150 | 150 | |
151 | 151 | if ((string)$value === '' && $this->attrs['needed']) |
152 | 152 | { |
153 | - self::set_validation_error($form_name,lang('Field must not be empty !!!'),''); |
|
153 | + self::set_validation_error($form_name, lang('Field must not be empty !!!'), ''); |
|
154 | 154 | } |
155 | - if ((int) $this->attrs['maxlength'] > 0 && mb_strlen($value) > (int) $this->attrs['maxlength']) |
|
155 | + if ((int)$this->attrs['maxlength'] > 0 && mb_strlen($value) > (int)$this->attrs['maxlength']) |
|
156 | 156 | { |
157 | - $value = mb_substr($value,0,(int) $this->attrs['maxlength']); |
|
157 | + $value = mb_substr($value, 0, (int)$this->attrs['maxlength']); |
|
158 | 158 | } |
159 | 159 | // PHP xml parser reads backslashes literal from attributes, while JavaScript ones need them escaped (eg. like PHP strings) |
160 | 160 | // --> replace \\ with \ to get following XML working: validator="/^\\d+$" (server- AND client-side!) |
161 | - if ($this->attrs['validator'] && !preg_match(str_replace('\\\\','\\', $this->attrs['validator']), $value)) |
|
161 | + if ($this->attrs['validator'] && !preg_match(str_replace('\\\\', '\\', $this->attrs['validator']), $value)) |
|
162 | 162 | { |
163 | - switch($this->attrs['type']) |
|
163 | + switch ($this->attrs['type']) |
|
164 | 164 | { |
165 | 165 | case 'integer': |
166 | - self::set_validation_error($form_name,lang("'%1' is not a valid integer !!!",$value),''); |
|
166 | + self::set_validation_error($form_name, lang("'%1' is not a valid integer !!!", $value), ''); |
|
167 | 167 | break; |
168 | 168 | case 'float': |
169 | - self::set_validation_error($form_name,lang("'%1' is not a valid floatingpoint number !!!",$value),''); |
|
169 | + self::set_validation_error($form_name, lang("'%1' is not a valid floatingpoint number !!!", $value), ''); |
|
170 | 170 | break; |
171 | 171 | default: |
172 | - self::set_validation_error($form_name,lang("'%1' has an invalid format !!!",$value)/*." !preg_match('$this->attrs[validator]', '$value')"*/,''); |
|
172 | + self::set_validation_error($form_name, lang("'%1' has an invalid format !!!", $value)/*." !preg_match('$this->attrs[validator]', '$value')"*/, ''); |
|
173 | 173 | break; |
174 | 174 | } |
175 | 175 | } |
@@ -177,17 +177,17 @@ discard block |
||
177 | 177 | { |
178 | 178 | if ((string)$value !== '' || $this->attrs['needed']) // empty values are Ok if needed is not set |
179 | 179 | { |
180 | - $value = $this->attrs['type'] == 'integer' ? (int) $value : (float) str_replace(',','.',$value); // allow for german (and maybe other) format |
|
180 | + $value = $this->attrs['type'] == 'integer' ? (int)$value : (float)str_replace(',', '.', $value); // allow for german (and maybe other) format |
|
181 | 181 | |
182 | 182 | if (!(empty($this->attrs['min']) && $this->attrs['min'] !== 0) && $value < $this->attrs['min']) |
183 | 183 | { |
184 | - self::set_validation_error($form_name,lang("Value has to be at least '%1' !!!",$this->attrs['min']),''); |
|
185 | - $value = $this->attrs['type'] == 'integer' ? (int) $this->attrs['min'] : (float) $this->attrs['min']; |
|
184 | + self::set_validation_error($form_name, lang("Value has to be at least '%1' !!!", $this->attrs['min']), ''); |
|
185 | + $value = $this->attrs['type'] == 'integer' ? (int)$this->attrs['min'] : (float)$this->attrs['min']; |
|
186 | 186 | } |
187 | - if (!(empty($this->attrs['max'])&& $this->attrs['max'] !== 0) && $value > $this->attrs['max']) |
|
187 | + if (!(empty($this->attrs['max']) && $this->attrs['max'] !== 0) && $value > $this->attrs['max']) |
|
188 | 188 | { |
189 | - self::set_validation_error($form_name,lang("Value has to be at maximum '%1' !!!",$this->attrs['max']),''); |
|
190 | - $value = $this->attrs['type'] == 'integer' ? (int) $this->attrs['max'] : (float) $this->attrs['max']; |
|
189 | + self::set_validation_error($form_name, lang("Value has to be at maximum '%1' !!!", $this->attrs['max']), ''); |
|
190 | + $value = $this->attrs['type'] == 'integer' ? (int)$this->attrs['max'] : (float)$this->attrs['max']; |
|
191 | 191 | } |
192 | 192 | } |
193 | 193 | } |
@@ -199,4 +199,4 @@ discard block |
||
199 | 199 | } |
200 | 200 | } |
201 | 201 | } |
202 | -Etemplate\Widget::registerWidget(__NAMESPACE__.'\\Textbox', array('textbox','text','int','integer','float','passwd','hidden','colorpicker','hidden')); |
|
202 | +Etemplate\Widget::registerWidget(__NAMESPACE__.'\\Textbox', array('textbox', 'text', 'int', 'integer', 'float', 'passwd', 'hidden', 'colorpicker', 'hidden')); |
@@ -19,6 +19,9 @@ |
||
19 | 19 | */ |
20 | 20 | class Admin extends App |
21 | 21 | { |
22 | + /** |
|
23 | + * @param string $msg |
|
24 | + */ |
|
22 | 25 | function __construct($msg=null,$code=102) |
23 | 26 | { |
24 | 27 | if (is_null($msg)) $msg = 'admin'; |
@@ -19,10 +19,10 @@ |
||
19 | 19 | */ |
20 | 20 | class Admin extends App |
21 | 21 | { |
22 | - function __construct($msg=null,$code=102) |
|
22 | + function __construct($msg = null, $code = 102) |
|
23 | 23 | { |
24 | 24 | if (is_null($msg)) $msg = 'admin'; |
25 | 25 | |
26 | - parent::__construct($msg,$code); |
|
26 | + parent::__construct($msg, $code); |
|
27 | 27 | } |
28 | 28 | } |
@@ -21,7 +21,10 @@ |
||
21 | 21 | { |
22 | 22 | function __construct($msg=null,$code=102) |
23 | 23 | { |
24 | - if (is_null($msg)) $msg = 'admin'; |
|
24 | + if (is_null($msg)) |
|
25 | + { |
|
26 | + $msg = 'admin'; |
|
27 | + } |
|
25 | 28 | |
26 | 29 | parent::__construct($msg,$code); |
27 | 30 | } |
@@ -356,11 +356,6 @@ |
||
356 | 356 | /** |
357 | 357 | * Add menu items to the topmenu template class to be displayed |
358 | 358 | * |
359 | - * @param array $app application data |
|
360 | - * @param mixed $alt_label string with alternative menu item label default value = null |
|
361 | - * @param string $urlextra string with alternate additional code inside <a>-tag |
|
362 | - * @access protected |
|
363 | - * @return void |
|
364 | 359 | */ |
365 | 360 | function _add_topmenu_item(array $app_data,$alt_label=null) |
366 | 361 | { |
@@ -337,16 +337,16 @@ discard block |
||
337 | 337 | } |
338 | 338 | |
339 | 339 | /** |
340 | - * called by hooks to add an icon in the topmenu info location |
|
341 | - * |
|
342 | - * @param string $id unique element id |
|
343 | - * @param string $icon_src src of the icon image. Make sure this nog height then 18pixels |
|
344 | - * @param string $iconlink where the icon links to |
|
345 | - * @param booleon $blink set true to make the icon blink |
|
346 | - * @param mixed $tooltip string containing the tooltip Api\Html, or null of no tooltip |
|
347 | - * @todo implement in a reasonable way for jdots |
|
348 | - * @return void |
|
349 | - */ |
|
340 | + * called by hooks to add an icon in the topmenu info location |
|
341 | + * |
|
342 | + * @param string $id unique element id |
|
343 | + * @param string $icon_src src of the icon image. Make sure this nog height then 18pixels |
|
344 | + * @param string $iconlink where the icon links to |
|
345 | + * @param booleon $blink set true to make the icon blink |
|
346 | + * @param mixed $tooltip string containing the tooltip Api\Html, or null of no tooltip |
|
347 | + * @todo implement in a reasonable way for jdots |
|
348 | + * @return void |
|
349 | + */ |
|
350 | 350 | function topmenu_info_icon($id,$icon_src,$iconlink,$blink=false,$tooltip=null) |
351 | 351 | { |
352 | 352 | unset($id,$icon_src,$iconlink,$blink,$tooltip); // not used |
@@ -354,14 +354,14 @@ discard block |
||
354 | 354 | } |
355 | 355 | |
356 | 356 | /** |
357 | - * Add menu items to the topmenu template class to be displayed |
|
358 | - * |
|
359 | - * @param array $app application data |
|
360 | - * @param mixed $alt_label string with alternative menu item label default value = null |
|
361 | - * @param string $urlextra string with alternate additional code inside <a>-tag |
|
362 | - * @access protected |
|
363 | - * @return void |
|
364 | - */ |
|
357 | + * Add menu items to the topmenu template class to be displayed |
|
358 | + * |
|
359 | + * @param array $app application data |
|
360 | + * @param mixed $alt_label string with alternative menu item label default value = null |
|
361 | + * @param string $urlextra string with alternate additional code inside <a>-tag |
|
362 | + * @access protected |
|
363 | + * @return void |
|
364 | + */ |
|
365 | 365 | function _add_topmenu_item(array $app_data,$alt_label=null) |
366 | 366 | { |
367 | 367 | switch($app_data['name']) |
@@ -104,7 +104,9 @@ discard block |
||
104 | 104 | |
105 | 105 | //Width may not be smaller than MIN_SIDEBAR_WIDTH |
106 | 106 | if ($width < self::MIN_SIDEBAR_WIDTH) |
107 | - $width = self::MIN_SIDEBAR_WIDTH; |
|
107 | + { |
|
108 | + $width = self::MIN_SIDEBAR_WIDTH; |
|
109 | + } |
|
108 | 110 | |
109 | 111 | return $width; |
110 | 112 | } |
@@ -156,7 +158,10 @@ discard block |
||
156 | 158 | */ |
157 | 159 | static function link($url = '', $extravars = '', $link_app=null) |
158 | 160 | { |
159 | - if (is_null($link_app)) $link_app = self::$link_app; |
|
161 | + if (is_null($link_app)) |
|
162 | + { |
|
163 | + $link_app = self::$link_app; |
|
164 | + } |
|
160 | 165 | $link = parent::link($url, $extravars); |
161 | 166 | |
162 | 167 | // $link_app === true --> detect application, otherwise use given application |
@@ -182,7 +187,10 @@ discard block |
||
182 | 187 | function header(array $extra=array()) |
183 | 188 | { |
184 | 189 | // make sure header is output only once |
185 | - if (self::$header_done) return ''; |
|
190 | + if (self::$header_done) |
|
191 | + { |
|
192 | + return ''; |
|
193 | + } |
|
186 | 194 | self::$header_done = true; |
187 | 195 | |
188 | 196 | $this->send_headers(); |
@@ -249,7 +257,10 @@ discard block |
||
249 | 257 | // for remote manual never check/create framework |
250 | 258 | if (!in_array($GLOBALS['egw_info']['flags']['currentapp'], array('manual', 'login', 'logout', 'sitemgr'))) |
251 | 259 | { |
252 | - if (empty($GLOBALS['egw_info']['flags']['java_script'])) $GLOBALS['egw_info']['flags']['java_script']=''; |
|
260 | + if (empty($GLOBALS['egw_info']['flags']['java_script'])) |
|
261 | + { |
|
262 | + $GLOBALS['egw_info']['flags']['java_script']=''; |
|
263 | + } |
|
253 | 264 | $extra['check-framework'] = $_GET['cd'] !== 'no'; |
254 | 265 | } |
255 | 266 | } |
@@ -522,7 +533,10 @@ discard block |
||
522 | 533 | */ |
523 | 534 | public function sidebox($appname,$menu_title,$file,$type=null) |
524 | 535 | { |
525 | - if (!isset($file['menuOpened'])) $file['menuOpened'] = (boolean)$this->sidebox_menu_opened; |
|
536 | + if (!isset($file['menuOpened'])) |
|
537 | + { |
|
538 | + $file['menuOpened'] = (boolean)$this->sidebox_menu_opened; |
|
539 | + } |
|
526 | 540 | //error_log(__METHOD__."('$appname', '$menu_title', file[menuOpened]=$file[menuOpened], ...) this->sidebox_menu_opened=$this->sidebox_menu_opened"); |
527 | 541 | $this->sidebox_menu_opened = false; |
528 | 542 | |
@@ -663,7 +677,10 @@ discard block |
||
663 | 677 | foreach($tablist as $data) |
664 | 678 | { |
665 | 679 | $tabs[] = $data['appName']; |
666 | - if ($data['active']) $active = $data['appName']; |
|
680 | + if ($data['active']) |
|
681 | + { |
|
682 | + $active = $data['appName']; |
|
683 | + } |
|
667 | 684 | } |
668 | 685 | // send app a notification, that it's tab got closed |
669 | 686 | // used eg. in phpFreeChat to leave the chat |
@@ -790,10 +807,22 @@ discard block |
||
790 | 807 | } |
791 | 808 | |
792 | 809 | unset($apps['logout']); // never display it |
793 | - if (isset($apps['about'])) $apps['about']['noNavbar'] = true; |
|
794 | - if (isset($apps['preferences'])) $apps['preferences']['noNavbar'] = true; |
|
795 | - if (isset($apps['manual'])) $apps['manual']['noNavbar'] = true; |
|
796 | - if (isset($apps['home'])) $apps['home']['noNavbar'] = true; |
|
810 | + if (isset($apps['about'])) |
|
811 | + { |
|
812 | + $apps['about']['noNavbar'] = true; |
|
813 | + } |
|
814 | + if (isset($apps['preferences'])) |
|
815 | + { |
|
816 | + $apps['preferences']['noNavbar'] = true; |
|
817 | + } |
|
818 | + if (isset($apps['manual'])) |
|
819 | + { |
|
820 | + $apps['manual']['noNavbar'] = true; |
|
821 | + } |
|
822 | + if (isset($apps['home'])) |
|
823 | + { |
|
824 | + $apps['home']['noNavbar'] = true; |
|
825 | + } |
|
797 | 826 | |
798 | 827 | // no need for website icon, if we have sitemgr |
799 | 828 | if (isset($apps['sitemgr']) && isset($apps['sitemgr-link'])) |
@@ -855,7 +884,10 @@ discard block |
||
855 | 884 | else |
856 | 885 | { |
857 | 886 | $active_tab = $GLOBALS['egw_info']['user']['preferences']['common']['active_tab']; |
858 | - if (!$active_tab) $active_tab = $default_app; |
|
887 | + if (!$active_tab) |
|
888 | + { |
|
889 | + $active_tab = $default_app; |
|
890 | + } |
|
859 | 891 | } |
860 | 892 | |
861 | 893 | //self::app_from_url might return an application the user has no rights |
@@ -898,9 +930,12 @@ discard block |
||
898 | 930 | // Restore Tabs |
899 | 931 | foreach($open_tabs as $n => $app) |
900 | 932 | { |
901 | - if (isset($apps[$app])) // user might no longer have app rights |
|
933 | + if (isset($apps[$app])) |
|
934 | + { |
|
935 | + // user might no longer have app rights |
|
902 | 936 | { |
903 | 937 | $apps[$app]['opened'] = $n; |
938 | + } |
|
904 | 939 | if ($app == $active_tab) |
905 | 940 | { |
906 | 941 | $apps[$app]['active'] = true; |
@@ -926,7 +961,11 @@ discard block |
||
926 | 961 | function footer($no_framework=true) |
927 | 962 | { |
928 | 963 | //error_log(__METHOD__."($no_framework) footer_done=".array2string(self::$footer_done).' '.function_backtrace()); |
929 | - if (self::$footer_done) return; // prevent (multiple) footers |
|
964 | + if (self::$footer_done) |
|
965 | + { |
|
966 | + return; |
|
967 | + } |
|
968 | + // prevent (multiple) footers |
|
930 | 969 | self::$footer_done = true; |
931 | 970 | |
932 | 971 | if (!isset($GLOBALS['egw_info']['flags']['nofooter']) || !$GLOBALS['egw_info']['flags']['nofooter']) |
@@ -57,11 +57,11 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @param string $template = '' name of the template |
59 | 59 | */ |
60 | - function __construct($template=self::APP) |
|
60 | + function __construct($template = self::APP) |
|
61 | 61 | { |
62 | - parent::__construct($template); // call the constructor of the extended class |
|
62 | + parent::__construct($template); // call the constructor of the extended class |
|
63 | 63 | |
64 | - $this->template_dir = '/'.$template; // we are packaged as an application |
|
64 | + $this->template_dir = '/'.$template; // we are packaged as an application |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -129,16 +129,16 @@ discard block |
||
129 | 129 | public static function app_from_url($url) |
130 | 130 | { |
131 | 131 | $matches = null; |
132 | - if (preg_match('/menuaction=([a-z0-9_-]+)\./i',$url,$matches)) |
|
132 | + if (preg_match('/menuaction=([a-z0-9_-]+)\./i', $url, $matches)) |
|
133 | 133 | { |
134 | 134 | return $matches[1]; |
135 | 135 | } |
136 | 136 | if ($GLOBALS['egw_info']['server']['webserver_url'] && |
137 | - ($webserver_path = parse_url($GLOBALS['egw_info']['server']['webserver_url'],PHP_URL_PATH))) |
|
137 | + ($webserver_path = parse_url($GLOBALS['egw_info']['server']['webserver_url'], PHP_URL_PATH))) |
|
138 | 138 | { |
139 | - list(,$url) = explode($webserver_path, parse_url($url,PHP_URL_PATH),2); |
|
139 | + list(,$url) = explode($webserver_path, parse_url($url, PHP_URL_PATH), 2); |
|
140 | 140 | } |
141 | - if (preg_match('/\/([^\/]+)\/([^\/]+\.php)?(\?|\/|$)/',$url,$matches)) |
|
141 | + if (preg_match('/\/([^\/]+)\/([^\/]+\.php)?(\?|\/|$)/', $url, $matches)) |
|
142 | 142 | { |
143 | 143 | return $matches[1]; |
144 | 144 | } |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | * @param string $link_app = null if appname or true, some templates generate a special link-handler url |
155 | 155 | * @return string The full url after processing |
156 | 156 | */ |
157 | - static function link($url = '', $extravars = '', $link_app=null) |
|
157 | + static function link($url = '', $extravars = '', $link_app = null) |
|
158 | 158 | { |
159 | 159 | if (is_null($link_app)) $link_app = self::$link_app; |
160 | 160 | $link = parent::link($url, $extravars); |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | // Link gets handled in JS, so quotes need slashes as well as url-encoded |
166 | 166 | // encoded ampersands in get parameters (%26) need to be encoded twise, |
167 | 167 | // so they are still encoded when assigned to window.location |
168 | - $link_with_slashes = str_replace(array('%27','%26'), array('\%27','%2526'), $link); |
|
168 | + $link_with_slashes = str_replace(array('%27', '%26'), array('\%27', '%2526'), $link); |
|
169 | 169 | |
170 | 170 | //$link = "javascript:window.egw_link_handler?egw_link_handler('$link','$link_app'):parent.egw_link_handler('$link','$link_app');"; |
171 | 171 | $link = "javascript:egw_link_handler('$link_with_slashes','$link_app')"; |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | * @param array $extra = array() extra attributes passed as data-attribute to egw.js |
180 | 180 | * @return string with Api\Html |
181 | 181 | */ |
182 | - function header(array $extra=array()) |
|
182 | + function header(array $extra = array()) |
|
183 | 183 | { |
184 | 184 | // make sure header is output only once |
185 | 185 | if (self::$header_done) return ''; |
@@ -204,8 +204,8 @@ discard block |
||
204 | 204 | { |
205 | 205 | $this->tpl->set_file(array('_head' => 'head.tpl')); |
206 | 206 | } |
207 | - $this->tpl->set_block('_head','head'); |
|
208 | - $this->tpl->set_block('_head','framework'); |
|
207 | + $this->tpl->set_block('_head', 'head'); |
|
208 | + $this->tpl->set_block('_head', 'framework'); |
|
209 | 209 | |
210 | 210 | // should we draw the framework, or just a header |
211 | 211 | $do_framework = isset($_GET['cd']) && $_GET['cd'] === 'yes'; |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | { |
231 | 231 | self::includeJS('.', 'fw_'.static::APP, static::JS_INCLUDE_APP); |
232 | 232 | } |
233 | - Api\Cache::unsetSession(__CLASS__,'sidebox_md5'); // sideboxes need to be send again |
|
233 | + Api\Cache::unsetSession(__CLASS__, 'sidebox_md5'); // sideboxes need to be send again |
|
234 | 234 | |
235 | 235 | $extra['navbar-apps'] = $this->get_navbar_apps($_SERVER['REQUEST_URI']); |
236 | 236 | } |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | // - if not we need to check if we have an opener (are a popup window) |
240 | 240 | // - as popups can open further popups, we need to decend all the way down until we find a framework |
241 | 241 | // - only if we cant find a framework in all openers, we redirect to create a new framework |
242 | - if(!$do_framework) |
|
242 | + if (!$do_framework) |
|
243 | 243 | { |
244 | 244 | // fetch sidebox from application and set it in extra data, if we are no popup |
245 | 245 | if (!$GLOBALS['egw_info']['flags']['nonavbar']) |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | // for remote manual never check/create framework |
250 | 250 | if (!in_array($GLOBALS['egw_info']['flags']['currentapp'], array('manual', 'login', 'logout', 'sitemgr'))) |
251 | 251 | { |
252 | - if (empty($GLOBALS['egw_info']['flags']['java_script'])) $GLOBALS['egw_info']['flags']['java_script']=''; |
|
252 | + if (empty($GLOBALS['egw_info']['flags']['java_script'])) $GLOBALS['egw_info']['flags']['java_script'] = ''; |
|
253 | 253 | $extra['check-framework'] = $_GET['cd'] !== 'no'; |
254 | 254 | } |
255 | 255 | } |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | )); |
261 | 261 | |
262 | 262 | $this->tpl->set_var($this->_get_header($extra)); |
263 | - $content = $this->tpl->fp('out','head').$content; |
|
263 | + $content = $this->tpl->fp('out', 'head').$content; |
|
264 | 264 | |
265 | 265 | if (!$do_framework) |
266 | 266 | { |
@@ -269,10 +269,10 @@ discard block |
||
269 | 269 | |
270 | 270 | // topmenu |
271 | 271 | $vars = $this->_get_navbar($apps = $this->_get_navbar_apps()); |
272 | - $this->tpl->set_var($this->topmenu($vars,$apps)); |
|
272 | + $this->tpl->set_var($this->topmenu($vars, $apps)); |
|
273 | 273 | |
274 | 274 | // hook after_navbar (eg. notifications) |
275 | - $this->tpl->set_var('hook_after_navbar',$this->_get_after_navbar()); |
|
275 | + $this->tpl->set_var('hook_after_navbar', $this->_get_after_navbar()); |
|
276 | 276 | |
277 | 277 | //Global sidebar width |
278 | 278 | $this->tpl->set_var('sidebox_width', self::get_global_sidebar_width()); |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | |
290 | 290 | // add framework div's |
291 | 291 | $this->tpl->set_var($this->_get_footer()); |
292 | - $content .= $this->tpl->fp('out','framework'); |
|
292 | + $content .= $this->tpl->fp('out', 'framework'); |
|
293 | 293 | $content .= self::footer(false); |
294 | 294 | |
295 | 295 | echo $content; |
@@ -308,14 +308,14 @@ discard block |
||
308 | 308 | * @param array $apps |
309 | 309 | * @return array |
310 | 310 | */ |
311 | - function topmenu(array $vars,array $apps) |
|
311 | + function topmenu(array $vars, array $apps) |
|
312 | 312 | { |
313 | 313 | $this->topmenu_items = $this->topmenu_info_items = array(); |
314 | 314 | |
315 | - parent::topmenu($vars,$apps); |
|
316 | - $vars['topmenu_items'] = "<ul>\n<li>".implode("</li>\n<li>",$this->topmenu_items)."</li>\n</ul>"; |
|
315 | + parent::topmenu($vars, $apps); |
|
316 | + $vars['topmenu_items'] = "<ul>\n<li>".implode("</li>\n<li>", $this->topmenu_items)."</li>\n</ul>"; |
|
317 | 317 | $vars['topmenu_info_items'] = ''; |
318 | - foreach($this->topmenu_info_items as $id => $item) |
|
318 | + foreach ($this->topmenu_info_items as $id => $item) |
|
319 | 319 | { |
320 | 320 | $vars['topmenu_info_items'] .= '<div class="topmenu_info_item"'. |
321 | 321 | (is_numeric($id) ? '' : ' id="topmenu_info_'.$id.'"').'>'.$item."</div>\n"; |
@@ -336,9 +336,9 @@ discard block |
||
336 | 336 | * @todo implement in a reasonable way for jdots |
337 | 337 | * @return void |
338 | 338 | */ |
339 | - function topmenu_info_icon($id,$icon_src,$iconlink,$blink=false,$tooltip=null) |
|
339 | + function topmenu_info_icon($id, $icon_src, $iconlink, $blink = false, $tooltip = null) |
|
340 | 340 | { |
341 | - unset($id,$icon_src,$iconlink,$blink,$tooltip); // not used |
|
341 | + unset($id, $icon_src, $iconlink, $blink, $tooltip); // not used |
|
342 | 342 | // not yet implemented, only used in admin/inc/hook_topmenu_info.inc.php to notify about pending updates |
343 | 343 | } |
344 | 344 | |
@@ -351,9 +351,9 @@ discard block |
||
351 | 351 | * @access protected |
352 | 352 | * @return void |
353 | 353 | */ |
354 | - function _add_topmenu_item(array $app_data,$alt_label=null) |
|
354 | + function _add_topmenu_item(array $app_data, $alt_label = null) |
|
355 | 355 | { |
356 | - switch($app_data['name']) |
|
356 | + switch ($app_data['name']) |
|
357 | 357 | { |
358 | 358 | case 'logout': |
359 | 359 | if (Api\Header\UserAgent::mobile() || $GLOBALS['egw_info']['user']['preferences']['common']['theme'] == 'mobile') |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | } |
363 | 363 | else |
364 | 364 | { |
365 | - return; // no need for logout in topmenu on jdots |
|
365 | + return; // no need for logout in topmenu on jdots |
|
366 | 366 | } |
367 | 367 | break; |
368 | 368 | |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | break; |
372 | 372 | |
373 | 373 | default: |
374 | - if (strpos($app_data['url'],'logout.php') === false && substr($app_data['url'], 0, 11) != 'javascript:') |
|
374 | + if (strpos($app_data['url'], 'logout.php') === false && substr($app_data['url'], 0, 11) != 'javascript:') |
|
375 | 375 | { |
376 | 376 | $app_data['url'] = "javascript:egw_link_handler('".$app_data['url']."','". |
377 | 377 | (isset($GLOBALS['egw_info']['user']['apps'][$app_data['name']]) ? |
@@ -379,8 +379,8 @@ discard block |
||
379 | 379 | } |
380 | 380 | } |
381 | 381 | $id = $app_data['id'] ? $app_data['id'] : ($app_data['name'] ? $app_data['name'] : $app_data['title']); |
382 | - $title = htmlspecialchars($alt_label ? $alt_label : $app_data['title']); |
|
383 | - $this->topmenu_items[] = '<a id="topmenu_' . $id . '" href="'.htmlspecialchars($app_data['url']).'" title="'.$app_data['title'].'">'.$title.'</a>'; |
|
382 | + $title = htmlspecialchars($alt_label ? $alt_label : $app_data['title']); |
|
383 | + $this->topmenu_items[] = '<a id="topmenu_'.$id.'" href="'.htmlspecialchars($app_data['url']).'" title="'.$app_data['title'].'">'.$title.'</a>'; |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | /** |
@@ -391,11 +391,11 @@ discard block |
||
391 | 391 | * @access protected |
392 | 392 | * @return void |
393 | 393 | */ |
394 | - function _add_topmenu_info_item($content, $id=null) |
|
394 | + function _add_topmenu_info_item($content, $id = null) |
|
395 | 395 | { |
396 | - if(strpos($content,'menuaction=admin.admin_accesslog.sessions') !== false) |
|
396 | + if (strpos($content, 'menuaction=admin.admin_accesslog.sessions') !== false) |
|
397 | 397 | { |
398 | - $content = preg_replace('/href="([^"]+)"/',"href=\"javascript:egw_link_handler('\\1','admin')\"",$content); |
|
398 | + $content = preg_replace('/href="([^"]+)"/', "href=\"javascript:egw_link_handler('\\1','admin')\"", $content); |
|
399 | 399 | } |
400 | 400 | if ($id) |
401 | 401 | { |
@@ -414,10 +414,10 @@ discard block |
||
414 | 414 | */ |
415 | 415 | static function ajax_tz_selection($tz) |
416 | 416 | { |
417 | - Api\DateTime::setUserPrefs($tz); // throws exception, if tz is invalid |
|
417 | + Api\DateTime::setUserPrefs($tz); // throws exception, if tz is invalid |
|
418 | 418 | |
419 | 419 | $GLOBALS['egw']->preferences->read_repository(); |
420 | - $GLOBALS['egw']->preferences->add('common','tz',$tz); |
|
420 | + $GLOBALS['egw']->preferences->add('common', 'tz', $tz); |
|
421 | 421 | $GLOBALS['egw']->preferences->save_repository(); |
422 | 422 | } |
423 | 423 | |
@@ -469,13 +469,13 @@ discard block |
||
469 | 469 | // only send admin sidebox, for admin index url (when clicked on admin), |
470 | 470 | // not for other admin pages, called eg. from sidebox menu of other apps |
471 | 471 | // --> that way we always stay in the app, and NOT open admin sidebox for an app tab!!! |
472 | - if ($app == 'admin' && substr($_SERVER['PHP_SELF'],-16) != '/admin/index.php' && |
|
472 | + if ($app == 'admin' && substr($_SERVER['PHP_SELF'], -16) != '/admin/index.php' && |
|
473 | 473 | $_GET['menuaction'] != 'admin.admin_ui.index') |
474 | 474 | { |
475 | 475 | //error_log(__METHOD__."() app=$app, menuaction=$_GET[menuaction], PHP_SELF=$_SERVER[PHP_SELF] --> sidebox request ignored"); |
476 | 476 | return; |
477 | 477 | } |
478 | - $md5_session =& Api\Cache::getSession(__CLASS__,'sidebox_md5'); |
|
478 | + $md5_session = & Api\Cache::getSession(__CLASS__, 'sidebox_md5'); |
|
479 | 479 | |
480 | 480 | //Set the sidebox content |
481 | 481 | $sidebox = $this->get_sidebox($app); |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | if ($md5_session[$app] !== $md5) |
485 | 485 | { |
486 | 486 | //error_log(__METHOD__."() header changed md5_session[$app]!=='$md5' --> setting it on self::\$extra[setSidebox]"); |
487 | - $md5_session[$app] = $md5; // update md5 in session |
|
487 | + $md5_session[$app] = $md5; // update md5 in session |
|
488 | 488 | self::$extra['setSidebox'] = array($app, $sidebox, $md5); |
489 | 489 | } |
490 | 490 | //else error_log(__METHOD__."() md5_session[$app]==='$md5' --> nothing to do"); |
@@ -498,9 +498,9 @@ discard block |
||
498 | 498 | * @return boolean $consider_navbar_not_yet_called_as_true=true ignored by jdots, we only care for cd=yes GET param |
499 | 499 | * @return boolean |
500 | 500 | */ |
501 | - public function isTop($consider_navbar_not_yet_called_as_true=true) |
|
501 | + public function isTop($consider_navbar_not_yet_called_as_true = true) |
|
502 | 502 | { |
503 | - unset($consider_navbar_not_yet_called_as_true); // not used |
|
503 | + unset($consider_navbar_not_yet_called_as_true); // not used |
|
504 | 504 | return isset($_GET['cd']) && $_GET['cd'] === 'yes'; |
505 | 505 | } |
506 | 506 | |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | * @param array $file |
527 | 527 | * @param string $type = null 'admin', 'preferences', 'favorites', ... |
528 | 528 | */ |
529 | - public function sidebox($appname,$menu_title,$file,$type=null) |
|
529 | + public function sidebox($appname, $menu_title, $file, $type = null) |
|
530 | 530 | { |
531 | 531 | if (!isset($file['menuOpened'])) $file['menuOpened'] = (boolean)$this->sidebox_menu_opened; |
532 | 532 | //error_log(__METHOD__."('$appname', '$menu_title', file[menuOpened]=$file[menuOpened], ...) this->sidebox_menu_opened=$this->sidebox_menu_opened"); |
@@ -535,11 +535,11 @@ discard block |
||
535 | 535 | // fix app admin menus to use admin.admin_ui.index loader |
536 | 536 | if (($type == 'admin' || $menu_title == lang('Admin')) && $appname != 'admin') |
537 | 537 | { |
538 | - foreach($file as &$link) |
|
538 | + foreach ($file as &$link) |
|
539 | 539 | { |
540 | 540 | preg_match('/ajax=(true|false)/', $link, $ajax); |
541 | 541 | $link = preg_replace("/^(javascript:egw_link_handler\(')(.*)menuaction=([^&]+)(.*)(','[^']+'\))$/", |
542 | - '$1$2menuaction=admin.admin_ui.index&load=$3$4&ajax=' . ($ajax[1] ? $ajax[1] : 'true') .'\',\'admin\')', $file_was=$link); |
|
542 | + '$1$2menuaction=admin.admin_ui.index&load=$3$4&ajax='.($ajax[1] ? $ajax[1] : 'true').'\',\'admin\')', $file_was = $link); |
|
543 | 543 | } |
544 | 544 | |
545 | 545 | } |
@@ -576,15 +576,15 @@ discard block |
||
576 | 576 | self::$link_app = $appname; |
577 | 577 | // allow other apps to hook into sidebox menu of an app, hook-name: sidebox_$appname |
578 | 578 | $this->sidebox_menu_opened = true; |
579 | - Api\Hooks::process('sidebox_'.$appname,array($appname),true); // true = call independent of app-permissions |
|
579 | + Api\Hooks::process('sidebox_'.$appname, array($appname), true); // true = call independent of app-permissions |
|
580 | 580 | |
581 | 581 | // calling the old hook |
582 | 582 | $this->sidebox_menu_opened = true; |
583 | - Api\Hooks::single('sidebox_menu',$appname); |
|
583 | + Api\Hooks::single('sidebox_menu', $appname); |
|
584 | 584 | self::$link_app = null; |
585 | 585 | |
586 | 586 | // allow other apps to hook into sidebox menu of every app: sidebox_all |
587 | - Api\Hooks::process('sidebox_all',array($GLOBALS['egw_info']['flags']['currentapp']),true); |
|
587 | + Api\Hooks::process('sidebox_all', array($GLOBALS['egw_info']['flags']['currentapp']), true); |
|
588 | 588 | } |
589 | 589 | //If there still is no sidebox content, return null here |
590 | 590 | if (!isset($this->sideboxes[$appname])) |
@@ -594,17 +594,17 @@ discard block |
||
594 | 594 | |
595 | 595 | $data = array(); |
596 | 596 | $sendToBottom = array(); |
597 | - foreach($this->sideboxes[$appname] as $menu_name => &$file) |
|
597 | + foreach ($this->sideboxes[$appname] as $menu_name => &$file) |
|
598 | 598 | { |
599 | 599 | $current_menu = array( |
600 | - 'menu_name' => md5($menu_name), // can contain Api\Html tags and javascript! |
|
600 | + 'menu_name' => md5($menu_name), // can contain Api\Html tags and javascript! |
|
601 | 601 | 'title' => $menu_name, |
602 | 602 | 'entries' => array(), |
603 | 603 | 'opened' => (boolean)$file['menuOpened'], |
604 | 604 | ); |
605 | - foreach($file as $item_text => $item_link) |
|
605 | + foreach ($file as $item_text => $item_link) |
|
606 | 606 | { |
607 | - if ($item_text === 'menuOpened' || $item_text === 'sendToBottom' ||// flag, not menu entry |
|
607 | + if ($item_text === 'menuOpened' || $item_text === 'sendToBottom' || // flag, not menu entry |
|
608 | 608 | $item_text === '_NewLine_' || $item_link === '_NewLine_') |
609 | 609 | { |
610 | 610 | continue; |
@@ -615,14 +615,14 @@ discard block |
||
615 | 615 | } |
616 | 616 | |
617 | 617 | $var = array(); |
618 | - $var['icon_or_star'] = $GLOBALS['egw_info']['server']['webserver_url'] . $this->template_dir.'/images/bullet.png'; |
|
618 | + $var['icon_or_star'] = $GLOBALS['egw_info']['server']['webserver_url'].$this->template_dir.'/images/bullet.png'; |
|
619 | 619 | $var['target'] = ''; |
620 | - if(is_array($item_link)) |
|
620 | + if (is_array($item_link)) |
|
621 | 621 | { |
622 | - if(isset($item_link['icon'])) |
|
622 | + if (isset($item_link['icon'])) |
|
623 | 623 | { |
624 | 624 | $app = isset($item_link['app']) ? $item_link['app'] : $appname; |
625 | - $var['icon_or_star'] = $item_link['icon'] ? Api\Image::find($app,$item_link['icon']) : False; |
|
625 | + $var['icon_or_star'] = $item_link['icon'] ? Api\Image::find($app, $item_link['icon']) : False; |
|
626 | 626 | } |
627 | 627 | $var['lang_item'] = isset($item_link['no_lang']) && $item_link['no_lang'] ? $item_link['text'] : lang($item_link['text']); |
628 | 628 | $var['item_link'] = $item_link['link']; |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | public static function ajax_tab_changed_state($tablist) |
667 | 667 | { |
668 | 668 | $tabs = array(); |
669 | - foreach($tablist as $data) |
|
669 | + foreach ($tablist as $data) |
|
670 | 670 | { |
671 | 671 | $tabs[] = $data['appName']; |
672 | 672 | if ($data['active']) $active = $data['appName']; |
@@ -675,7 +675,7 @@ discard block |
||
675 | 675 | // used eg. in phpFreeChat to leave the chat |
676 | 676 | if (($old_tabs = Api\Cache::getSession(__CLASS__, 'open_tabs'))) |
677 | 677 | { |
678 | - foreach(array_diff(explode(',',$old_tabs),$tabs) as $app) |
|
678 | + foreach (array_diff(explode(',', $old_tabs), $tabs) as $app) |
|
679 | 679 | { |
680 | 680 | //error_log("Tab '$app' closed, old_tabs=$old_tabs"); |
681 | 681 | Api\Hooks::single(array( |
@@ -684,7 +684,7 @@ discard block |
||
684 | 684 | ), $app); |
685 | 685 | } |
686 | 686 | } |
687 | - $open = implode(',',$tabs); |
|
687 | + $open = implode(',', $tabs); |
|
688 | 688 | |
689 | 689 | if ($open != $GLOBALS['egw_info']['user']['preferences']['common']['open_tabs'] || |
690 | 690 | $active != $GLOBALS['egw_info']['user']['preferences']['common']['active_tab']) |
@@ -754,7 +754,7 @@ discard block |
||
754 | 754 | $i = 0; |
755 | 755 | |
756 | 756 | //Parse the "$apps" array for valid content (security) |
757 | - foreach($apps as $app) |
|
757 | + foreach ($apps as $app) |
|
758 | 758 | { |
759 | 759 | //Check whether the app really exists and add it to the $app_arr var |
760 | 760 | if ($GLOBALS['egw_info']['user']['apps'][$app]) |
@@ -785,17 +785,17 @@ discard block |
||
785 | 785 | */ |
786 | 786 | public function navbar_apps() |
787 | 787 | { |
788 | - $apps = parent::_get_navbar_apps(Api\Image::svg_usable()); // use svg if usable in browser |
|
788 | + $apps = parent::_get_navbar_apps(Api\Image::svg_usable()); // use svg if usable in browser |
|
789 | 789 | |
790 | 790 | //Add its sidebox width to each app |
791 | 791 | foreach ($apps as $app => &$data) |
792 | 792 | { |
793 | 793 | $data['sideboxwidth'] = self::get_sidebar_width($app); |
794 | 794 | // overwrite icon with svg, if supported by browser |
795 | - unset($data['icon_hover']); // not used in jdots |
|
795 | + unset($data['icon_hover']); // not used in jdots |
|
796 | 796 | } |
797 | 797 | |
798 | - unset($apps['logout']); // never display it |
|
798 | + unset($apps['logout']); // never display it |
|
799 | 799 | if (isset($apps['about'])) $apps['about']['noNavbar'] = true; |
800 | 800 | if (isset($apps['preferences'])) $apps['preferences']['noNavbar'] = true; |
801 | 801 | if (isset($apps['manual'])) $apps['manual']['noNavbar'] = true; |
@@ -845,7 +845,7 @@ discard block |
||
845 | 845 | } |
846 | 846 | |
847 | 847 | // check if user called a specific url --> open it as active tab |
848 | - $last_direct_url =& Api\Cache::getSession(__CLASS__, 'last_direct_url'); |
|
848 | + $last_direct_url = & Api\Cache::getSession(__CLASS__, 'last_direct_url'); |
|
849 | 849 | if ($last_direct_url) |
850 | 850 | { |
851 | 851 | $url = $last_direct_url; |
@@ -855,7 +855,7 @@ discard block |
||
855 | 855 | { |
856 | 856 | // Coming in with a specific URL, save it and redirect to index.php |
857 | 857 | // so reloads work nicely, but strip cd=yes or we'll get the framework again |
858 | - $last_direct_url = preg_replace('/[&?]cd=yes/','',$url); |
|
858 | + $last_direct_url = preg_replace('/[&?]cd=yes/', '', $url); |
|
859 | 859 | Api\Framework::redirect_link('/index.php?cd=yes'); |
860 | 860 | } |
861 | 861 | else |
@@ -870,11 +870,11 @@ discard block |
||
870 | 870 | if ($active_tab && array_key_exists($active_tab, $apps)) |
871 | 871 | { |
872 | 872 | // Do not remove cd=yes if it's an ajax=true app |
873 | - if (strpos( $apps[$active_tab]['url'],'ajax=true') !== False) |
|
873 | + if (strpos($apps[$active_tab]['url'], 'ajax=true') !== False) |
|
874 | 874 | { |
875 | - $url = preg_replace('/[&?]cd=yes/','',$url); |
|
875 | + $url = preg_replace('/[&?]cd=yes/', '', $url); |
|
876 | 876 | } |
877 | - if($last_direct_url) |
|
877 | + if ($last_direct_url) |
|
878 | 878 | { |
879 | 879 | $apps[$active_tab]['openOnce'] = $url; |
880 | 880 | } |
@@ -886,8 +886,8 @@ discard block |
||
886 | 886 | { |
887 | 887 | $open_tabs = $GLOBALS['egw_info']['user']['preferences']['common']['open_tabs']; |
888 | 888 | } |
889 | - $open_tabs = $open_tabs ? explode(',',$open_tabs) : array(); |
|
890 | - if ($active_tab && !in_array($active_tab,$open_tabs)) |
|
889 | + $open_tabs = $open_tabs ? explode(',', $open_tabs) : array(); |
|
890 | + if ($active_tab && !in_array($active_tab, $open_tabs)) |
|
891 | 891 | { |
892 | 892 | $open_tabs[] = $active_tab; |
893 | 893 | $store_prefs = true; |
@@ -895,14 +895,14 @@ discard block |
||
895 | 895 | if ($store_prefs) |
896 | 896 | { |
897 | 897 | $GLOBALS['egw']->preferences->read_repository(); |
898 | - $GLOBALS['egw']->preferences->add('common', 'open_tabs', implode(',',$open_tabs)); |
|
898 | + $GLOBALS['egw']->preferences->add('common', 'open_tabs', implode(',', $open_tabs)); |
|
899 | 899 | $GLOBALS['egw']->preferences->add('common', 'active_tab', $active_tab); |
900 | 900 | $GLOBALS['egw']->preferences->save_repository(true); |
901 | 901 | } |
902 | 902 | |
903 | 903 | //error_log(__METHOD__."('$url') url_tab='$url_tab', active_tab=$active_tab, open_tabs=".array2string($open_tabs)); |
904 | 904 | // Restore Tabs |
905 | - foreach($open_tabs as $n => $app) |
|
905 | + foreach ($open_tabs as $n => $app) |
|
906 | 906 | { |
907 | 907 | if (isset($apps[$app])) // user might no longer have app rights |
908 | 908 | { |
@@ -929,10 +929,10 @@ discard block |
||
929 | 929 | * @param boolean $no_framework = true |
930 | 930 | * @return string |
931 | 931 | */ |
932 | - function footer($no_framework=true) |
|
932 | + function footer($no_framework = true) |
|
933 | 933 | { |
934 | 934 | //error_log(__METHOD__."($no_framework) footer_done=".array2string(self::$footer_done).' '.function_backtrace()); |
935 | - if (self::$footer_done) return; // prevent (multiple) footers |
|
935 | + if (self::$footer_done) return; // prevent (multiple) footers |
|
936 | 936 | self::$footer_done = true; |
937 | 937 | |
938 | 938 | if (!isset($GLOBALS['egw_info']['flags']['nofooter']) || !$GLOBALS['egw_info']['flags']['nofooter']) |
@@ -944,7 +944,7 @@ discard block |
||
944 | 944 | } |
945 | 945 | } |
946 | 946 | return $footer. |
947 | - $GLOBALS['egw_info']['flags']['need_footer']."\n". // eg. javascript, which need to be at the end of the page |
|
947 | + $GLOBALS['egw_info']['flags']['need_footer']."\n".// eg. javascript, which need to be at the end of the page |
|
948 | 948 | "</body>\n</html>\n"; |
949 | 949 | } |
950 | 950 | |
@@ -982,8 +982,8 @@ discard block |
||
982 | 982 | if ($parts['query']) |
983 | 983 | { |
984 | 984 | $_SERVER['REQUEST_URI'] = '?'.$parts['query']; |
985 | - parse_str($parts['query'],$_GET); |
|
986 | - $_REQUEST = $_GET; // some apps use $_REQUEST to check $_GET or $_POST |
|
985 | + parse_str($parts['query'], $_GET); |
|
986 | + $_REQUEST = $_GET; // some apps use $_REQUEST to check $_GET or $_POST |
|
987 | 987 | } |
988 | 988 | |
989 | 989 | if (!isset($_GET['menuaction'])) |
@@ -993,7 +993,7 @@ discard block |
||
993 | 993 | // set session action |
994 | 994 | $GLOBALS['egw']->session->set_action('Ajax: '.$_GET['menuaction']); |
995 | 995 | |
996 | - list($app,$class,$method) = explode('.',$_GET['menuaction']); |
|
996 | + list($app, $class, $method) = explode('.', $_GET['menuaction']); |
|
997 | 997 | |
998 | 998 | if (!isset($GLOBALS['egw_info']['user']['apps'][$app])) |
999 | 999 | { |
@@ -1005,7 +1005,7 @@ discard block |
||
1005 | 1005 | |
1006 | 1006 | $GLOBALS[$class] = $obj = CreateObject($app.'.'.$class); |
1007 | 1007 | |
1008 | - if(!is_array($obj->public_functions) || !$obj->public_functions[$method]) |
|
1008 | + if (!is_array($obj->public_functions) || !$obj->public_functions[$method]) |
|
1009 | 1009 | { |
1010 | 1010 | throw new Api\Exception\NoPermission("Bad menuaction {$_GET['menuaction']}, not listed in public_functions!"); |
1011 | 1011 | } |
@@ -145,7 +145,7 @@ |
||
145 | 145 | * Parse beginning of given CSS file for /*@import url("...") statements |
146 | 146 | * |
147 | 147 | * @param string $path EGroupware relative path eg. /phpgwapi/templates/default/some.css |
148 | - * @return array parsed pathes (EGroupware relative) including $path itself |
|
148 | + * @return string[] parsed pathes (EGroupware relative) including $path itself |
|
149 | 149 | */ |
150 | 150 | protected static function resolve_css_includes($path, &$pathes=array()) |
151 | 151 | { |
@@ -107,14 +107,20 @@ |
||
107 | 107 | $max_modified = 0; |
108 | 108 | //no more dynamic minifying: $debug_minify = $GLOBALS['egw_info']['server']['debug_minify'] === 'True'; |
109 | 109 | $base_path = $GLOBALS['egw_info']['server']['webserver_url']; |
110 | - if ($base_path[0] != '/') $base_path = parse_url($base_path, PHP_URL_PATH); |
|
110 | + if ($base_path[0] != '/') |
|
111 | + { |
|
112 | + $base_path = parse_url($base_path, PHP_URL_PATH); |
|
113 | + } |
|
111 | 114 | $css_files = ''; |
112 | 115 | foreach(self::$files as $path) |
113 | 116 | { |
114 | 117 | foreach(self::resolve_css_includes($path) as $path) |
115 | 118 | { |
116 | 119 | list($file,$query) = explode('?',$path,2); |
117 | - if (($mod = filemtime(EGW_SERVER_ROOT.$file)) > $max_modified) $max_modified = $mod; |
|
120 | + if (($mod = filemtime(EGW_SERVER_ROOT.$file)) > $max_modified) |
|
121 | + { |
|
122 | + $max_modified = $mod; |
|
123 | + } |
|
118 | 124 | |
119 | 125 | // do NOT include app.css or categories.php, as it changes from app to app |
120 | 126 | //no more dynamic minifying: if ($debug_minify || substr($path, -8) == '/app.css' || substr($file,-14) == 'categories.php') |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @param boolean $clear_includes =false true: clear all previous includes |
35 | 35 | * @return boolean false: css file not found, true: file found |
36 | 36 | */ |
37 | - public static function add($app, $name=null, $append=true, $clear_includes=false) |
|
37 | + public static function add($app, $name = null, $append = true, $clear_includes = false) |
|
38 | 38 | { |
39 | 39 | if ($clear_includes) |
40 | 40 | { |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | |
44 | 44 | if (!is_null($name)) |
45 | 45 | { |
46 | - foreach($GLOBALS['egw']->framework->template_dirs as $dir) |
|
46 | + foreach ($GLOBALS['egw']->framework->template_dirs as $dir) |
|
47 | 47 | { |
48 | 48 | if (file_exists(EGW_SERVER_ROOT.($path = '/'.$app.'/templates/'.$dir.'/'.$name.'.css'))) |
49 | 49 | { |
@@ -55,12 +55,12 @@ discard block |
||
55 | 55 | { |
56 | 56 | $path = $app; |
57 | 57 | } |
58 | - if (!file_exists(EGW_SERVER_ROOT.$path) && !file_exists(EGW_SERVER_ROOT . parse_url($path,PHP_URL_PATH))) |
|
58 | + if (!file_exists(EGW_SERVER_ROOT.$path) && !file_exists(EGW_SERVER_ROOT.parse_url($path, PHP_URL_PATH))) |
|
59 | 59 | { |
60 | 60 | //error_log(__METHOD__."($app,$name) $path NOT found!"); |
61 | 61 | return false; |
62 | 62 | } |
63 | - if (!in_array($path,self::$files)) |
|
63 | + if (!in_array($path, self::$files)) |
|
64 | 64 | { |
65 | 65 | if ($append) |
66 | 66 | { |
@@ -79,16 +79,16 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @return string |
81 | 81 | */ |
82 | - public static function get($resolve=false) |
|
82 | + public static function get($resolve = false) |
|
83 | 83 | { |
84 | 84 | if (!$resolve) |
85 | 85 | { |
86 | 86 | return self::$files; |
87 | 87 | } |
88 | 88 | $files = array(); |
89 | - foreach(self::$files as $path) |
|
89 | + foreach (self::$files as $path) |
|
90 | 90 | { |
91 | - foreach(self::resolve_css_includes($path) as $path) |
|
91 | + foreach (self::resolve_css_includes($path) as $path) |
|
92 | 92 | { |
93 | 93 | $files[] = $path; |
94 | 94 | } |
@@ -109,11 +109,11 @@ discard block |
||
109 | 109 | $base_path = $GLOBALS['egw_info']['server']['webserver_url']; |
110 | 110 | if ($base_path[0] != '/') $base_path = parse_url($base_path, PHP_URL_PATH); |
111 | 111 | $css_files = ''; |
112 | - foreach(self::$files as $path) |
|
112 | + foreach (self::$files as $path) |
|
113 | 113 | { |
114 | - foreach(self::resolve_css_includes($path) as $path) |
|
114 | + foreach (self::resolve_css_includes($path) as $path) |
|
115 | 115 | { |
116 | - list($file,$query) = explode('?',$path,2); |
|
116 | + list($file, $query) = explode('?', $path, 2); |
|
117 | 117 | if (($mod = filemtime(EGW_SERVER_ROOT.$file)) > $max_modified) $max_modified = $mod; |
118 | 118 | |
119 | 119 | // do NOT include app.css or categories.php, as it changes from app to app |
@@ -147,20 +147,20 @@ discard block |
||
147 | 147 | * @param string $path EGroupware relative path eg. /phpgwapi/templates/default/some.css |
148 | 148 | * @return array parsed pathes (EGroupware relative) including $path itself |
149 | 149 | */ |
150 | - protected static function resolve_css_includes($path, &$pathes=array()) |
|
150 | + protected static function resolve_css_includes($path, &$pathes = array()) |
|
151 | 151 | { |
152 | 152 | $matches = null; |
153 | 153 | |
154 | - list($file) = explode('?',$path,2); |
|
155 | - if (($to_check = file_get_contents (EGW_SERVER_ROOT.$file, false, null, 0, 1024)) && |
|
154 | + list($file) = explode('?', $path, 2); |
|
155 | + if (($to_check = file_get_contents(EGW_SERVER_ROOT.$file, false, null, 0, 1024)) && |
|
156 | 156 | stripos($to_check, '/*@import') !== false && preg_match_all('|/\*@import url\("([^"]+)"|i', $to_check, $matches)) |
157 | 157 | { |
158 | - foreach($matches[1] as $import_path) |
|
158 | + foreach ($matches[1] as $import_path) |
|
159 | 159 | { |
160 | 160 | if ($import_path[0] != '/') |
161 | 161 | { |
162 | 162 | $dir = dirname($path); |
163 | - while(substr($import_path,0,3) == '../') |
|
163 | + while (substr($import_path, 0, 3) == '../') |
|
164 | 164 | { |
165 | 165 | $dir = dirname($dir); |
166 | 166 | $import_path = substr($import_path, 3); |
@@ -187,7 +187,7 @@ |
||
187 | 187 | * @param string $action "add" or "delete" |
188 | 188 | * @param boolean|int|String $group ID of the group to create the favorite for, or 'all' for all users |
189 | 189 | * @param array $filters key => value pairs for the filter |
190 | - * @return boolean Success |
|
190 | + * @return boolean|null Success |
|
191 | 191 | */ |
192 | 192 | public static function set_favorite($app, $_name, $action, $group, $filters = array()) |
193 | 193 | { |
@@ -161,7 +161,11 @@ |
||
161 | 161 | { |
162 | 162 | if(strpos($pref_name, $pref_prefix) === 0) |
163 | 163 | { |
164 | - if(!is_array($pref)) continue; // old favorite |
|
164 | + if(!is_array($pref)) |
|
165 | + { |
|
166 | + continue; |
|
167 | + } |
|
168 | + // old favorite |
|
165 | 169 | |
166 | 170 | $favorites[(string)substr($pref_name,strlen($pref_prefix))] = $pref; |
167 | 171 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @return array with a single sidebox menu item (array) containing html for favorites |
44 | 44 | */ |
45 | - public static function list_favorites($app, $default=null) |
|
45 | + public static function list_favorites($app, $default = null) |
|
46 | 46 | { |
47 | 47 | if (!$app) |
48 | 48 | { |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | $target = 'favorite_sidebox_'.$app; |
59 | 59 | |
60 | 60 | /* @var $filters array an array of favorites*/ |
61 | - $filters = self::get_favorites($app); |
|
61 | + $filters = self::get_favorites($app); |
|
62 | 62 | $is_admin = $GLOBALS['egw_info']['user']['apps']['admin']; |
63 | 63 | $html = "<span id='$target' class='ui-helper-clearfix sidebox-favorites'><ul class='ui-menu ui-widget-content ui-corner-all favorites' role='listbox'>\n"; |
64 | 64 | |
@@ -69,25 +69,24 @@ discard block |
||
69 | 69 | } |
70 | 70 | |
71 | 71 | // Get link for if there is no nextmatch - this is the fallback |
72 | - $registry = Api\Link::get_registry($app,'list'); |
|
72 | + $registry = Api\Link::get_registry($app, 'list'); |
|
73 | 73 | if (!$registry) |
74 | 74 | { |
75 | 75 | $registry = Api\Link::get_registry($app, 'index'); |
76 | 76 | } |
77 | - foreach($filters as $name => $filter) |
|
77 | + foreach ($filters as $name => $filter) |
|
78 | 78 | { |
79 | 79 | //filter must not be empty if there's one, ignore it at the moment but it need to be checked how it got there in database |
80 | 80 | if (!$filter) |
81 | 81 | { |
82 | - error_log(__METHOD__.'Favorite filter "'.$name.'" is not supposed to be empty, it should be an array. Skipping, more investigation needed. filter = '. array2string($filters[$name])); |
|
82 | + error_log(__METHOD__.'Favorite filter "'.$name.'" is not supposed to be empty, it should be an array. Skipping, more investigation needed. filter = '.array2string($filters[$name])); |
|
83 | 83 | continue; |
84 | 84 | } |
85 | 85 | $li = "<li data-id='$name' data-group='{$filter['group']}' class='ui-menu-item' role='menuitem'>\n"; |
86 | 86 | $li .= '<a href="#" class="ui-corner-all" tabindex="-1">'; |
87 | - $li .= "<div class='" . ((string)$name === (string)$default_filter ? 'ui-icon ui-icon-heart' : 'sideboxstar') . "'></div>". |
|
87 | + $li .= "<div class='".((string)$name === (string)$default_filter ? 'ui-icon ui-icon-heart' : 'sideboxstar')."'></div>". |
|
88 | 88 | $filter['name']; |
89 | - $li .= ($filter['group'] != false && !$is_admin || $name === 'blank' ? "" : |
|
90 | - "<div class='ui-icon ui-icon-trash' title='" . lang('Delete') . "'></div>"); |
|
89 | + $li .= ($filter['group'] != false && !$is_admin || $name === 'blank' ? "" : "<div class='ui-icon ui-icon-trash' title='".lang('Delete')."'></div>"); |
|
91 | 90 | $li .= "</a></li>\n"; |
92 | 91 | //error_log(__METHOD__."() $name, filter=".array2string($filter)." --> ".$li); |
93 | 92 | $html .= $li; |
@@ -95,7 +94,7 @@ discard block |
||
95 | 94 | |
96 | 95 | // If were're here, the app supports favorites, so add a 'Add' link too |
97 | 96 | $html .= "<li data-id='add' class='ui-menu-item' role='menuitem'><a href='javascript:app.$app.add_favorite()' class='ui-corner-all'>"; |
98 | - $html .= Api\Html::image($app, 'new') . lang('Add current'). '</a></li>'; |
|
97 | + $html .= Api\Html::image($app, 'new').lang('Add current').'</a></li>'; |
|
99 | 98 | |
100 | 99 | $html .= '</ul></span>'; |
101 | 100 | |
@@ -117,7 +116,7 @@ discard block |
||
117 | 116 | * @return (array|boolean) An array of sorted favorites or False if there's no preferenced sorted list |
118 | 117 | * |
119 | 118 | */ |
120 | - public static function get_fav_sort_pref ($app) |
|
119 | + public static function get_fav_sort_pref($app) |
|
121 | 120 | { |
122 | 121 | $fav_sorted_list = array(); |
123 | 122 | |
@@ -157,13 +156,13 @@ discard block |
||
157 | 156 | $fav_sort_pref = self::get_fav_sort_pref($app); |
158 | 157 | |
159 | 158 | // Look through all preferences & pull out favorites |
160 | - foreach((array)$GLOBALS['egw_info']['user']['preferences'][$app] as $pref_name => $pref) |
|
159 | + foreach ((array)$GLOBALS['egw_info']['user']['preferences'][$app] as $pref_name => $pref) |
|
161 | 160 | { |
162 | - if(strpos($pref_name, $pref_prefix) === 0) |
|
161 | + if (strpos($pref_name, $pref_prefix) === 0) |
|
163 | 162 | { |
164 | - if(!is_array($pref)) continue; // old favorite |
|
163 | + if (!is_array($pref)) continue; // old favorite |
|
165 | 164 | |
166 | - $favorites[(string)substr($pref_name,strlen($pref_prefix))] = $pref; |
|
165 | + $favorites[(string)substr($pref_name, strlen($pref_prefix))] = $pref; |
|
167 | 166 | } |
168 | 167 | } |
169 | 168 | if (is_array($fav_sort_pref)) |
@@ -172,7 +171,7 @@ discard block |
||
172 | 171 | { |
173 | 172 | $sorted_list[$key] = $favorites[$key]; |
174 | 173 | } |
175 | - $favorites = array_merge($sorted_list,$favorites); |
|
174 | + $favorites = array_merge($sorted_list, $favorites); |
|
176 | 175 | } |
177 | 176 | return $favorites; |
178 | 177 | } |
@@ -204,7 +203,7 @@ discard block |
||
204 | 203 | } |
205 | 204 | else |
206 | 205 | { |
207 | - foreach($GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true) as $gid) |
|
206 | + foreach ($GLOBALS['egw']->accounts->memberships($GLOBALS['egw_info']['user']['account_id'], true) as $gid) |
|
208 | 207 | { |
209 | 208 | $prefs = new Api\Preferences($gid); |
210 | 209 | $prefs->read_repository(); |
@@ -216,7 +215,7 @@ discard block |
||
216 | 215 | } |
217 | 216 | } |
218 | 217 | } |
219 | - if($group && $GLOBALS['egw_info']['apps']['admin'] && $group !== 'all') |
|
218 | + if ($group && $GLOBALS['egw_info']['apps']['admin'] && $group !== 'all') |
|
220 | 219 | { |
221 | 220 | $prefs = new Api\Preferences(is_numeric($group) ? $group : $GLOBALS['egw_info']['user']['account_id']); |
222 | 221 | } |
@@ -227,7 +226,7 @@ discard block |
||
227 | 226 | $prefs->read_repository(); |
228 | 227 | $type = $group === "all" ? "default" : "user"; |
229 | 228 | //error_log(__METHOD__."('$app', '$name', '$action', ".array2string($group).", ...) pref_name=$pref_name, type=$type"); |
230 | - if($action == "add") |
|
229 | + if ($action == "add") |
|
231 | 230 | { |
232 | 231 | $filters = array( |
233 | 232 | // This is the name as user entered it, minus tags |
@@ -235,9 +234,9 @@ discard block |
||
235 | 234 | 'group' => $group ? $group : false, |
236 | 235 | 'state' => $filters |
237 | 236 | ); |
238 | - $pref_name = "favorite_".preg_replace('/[^A-Za-z0-9-_]/u','_',$name); |
|
239 | - $result = $prefs->add($app,$pref_name,$filters,$type); |
|
240 | - $pref = $prefs->save_repository(false,$type); |
|
237 | + $pref_name = "favorite_".preg_replace('/[^A-Za-z0-9-_]/u', '_', $name); |
|
238 | + $result = $prefs->add($app, $pref_name, $filters, $type); |
|
239 | + $pref = $prefs->save_repository(false, $type); |
|
241 | 240 | |
242 | 241 | // Update preferences client side, or it could disappear |
243 | 242 | Api\Json\Response::get()->call('egw.set_preferences', (array)$pref[$app], $app); |
@@ -247,8 +246,8 @@ discard block |
||
247 | 246 | } |
248 | 247 | else if ($action == "delete") |
249 | 248 | { |
250 | - $result = $prefs->delete($app,$pref_name, $type); |
|
251 | - $pref = $prefs->save_repository(false,$type); |
|
249 | + $result = $prefs->delete($app, $pref_name, $type); |
|
250 | + $pref = $prefs->save_repository(false, $type); |
|
252 | 251 | |
253 | 252 | // Update preferences client side, or it could come back |
254 | 253 | Api\Json\Response::get()->call('egw.set_preferences', (array)$pref[$app], $app); |
@@ -291,7 +290,7 @@ discard block |
||
291 | 290 | { |
292 | 291 | $value = is_array($old_value) ? $old_value : php_safe_unserialize($old_value); |
293 | 292 | |
294 | - switch($attr) |
|
293 | + switch ($attr) |
|
295 | 294 | { |
296 | 295 | case 'index_state': |
297 | 296 | $changes += self::change_account_id($value, self::$app_favorite_attributes[$app], $ids2change); |
@@ -337,7 +336,7 @@ discard block |
||
337 | 336 | if (!empty($value[$attrs_to_change])) |
338 | 337 | { |
339 | 338 | $vals = !is_array($value[$attrs_to_change]) ? explode(',', $value[$attrs_to_change]) : $value[$attrs_to_change]; |
340 | - foreach($vals as &$v) |
|
339 | + foreach ($vals as &$v) |
|
341 | 340 | { |
342 | 341 | if (isset($ids2change[$v])) |
343 | 342 | { |
@@ -350,7 +349,7 @@ discard block |
||
350 | 349 | } |
351 | 350 | else |
352 | 351 | { |
353 | - foreach($attrs_to_change as $key => $names) |
|
352 | + foreach ($attrs_to_change as $key => $names) |
|
354 | 353 | { |
355 | 354 | if (is_int($key)) |
356 | 355 | { |
@@ -234,7 +234,7 @@ |
||
234 | 234 | * @param string $realm |
235 | 235 | * @param string $username |
236 | 236 | * @param string &$password=null password to use or if null, on return stored password |
237 | - * @return string|boolean false if $password not given and can NOT be read |
|
237 | + * @return false|string false if $password not given and can NOT be read |
|
238 | 238 | */ |
239 | 239 | static private function get_digest_A1($realm,$username,&$password=null) |
240 | 240 | { |
@@ -255,20 +255,20 @@ |
||
255 | 255 | */ |
256 | 256 | static public function parse_digest($txt) |
257 | 257 | { |
258 | - // protect against missing data |
|
259 | - $needed_parts = array('nonce'=>1, 'nc'=>1, 'cnonce'=>1, 'qop'=>1, 'username'=>1, 'uri'=>1, 'response'=>1); |
|
260 | - $data = array(); |
|
261 | - $keys = implode('|', array_keys($needed_parts)); |
|
258 | + // protect against missing data |
|
259 | + $needed_parts = array('nonce'=>1, 'nc'=>1, 'cnonce'=>1, 'qop'=>1, 'username'=>1, 'uri'=>1, 'response'=>1); |
|
260 | + $data = array(); |
|
261 | + $keys = implode('|', array_keys($needed_parts)); |
|
262 | 262 | |
263 | 263 | $matches = null; |
264 | - preg_match_all('@(' . $keys . ')=(?:([\'"])([^\2]+?)\2|([^\s,]+))@', $txt, $matches, PREG_SET_ORDER); |
|
264 | + preg_match_all('@(' . $keys . ')=(?:([\'"])([^\2]+?)\2|([^\s,]+))@', $txt, $matches, PREG_SET_ORDER); |
|
265 | 265 | |
266 | - foreach ($matches as $m) |
|
267 | - { |
|
268 | - $data[$m[1]] = $m[3] ? $m[3] : $m[4]; |
|
269 | - unset($needed_parts[$m[1]]); |
|
270 | - } |
|
271 | - //error_log(__METHOD__."('$txt') returning ".array2string($needed_parts ? false : $data)); |
|
272 | - return $needed_parts ? false : $data; |
|
266 | + foreach ($matches as $m) |
|
267 | + { |
|
268 | + $data[$m[1]] = $m[3] ? $m[3] : $m[4]; |
|
269 | + unset($needed_parts[$m[1]]); |
|
270 | + } |
|
271 | + //error_log(__METHOD__."('$txt') returning ".array2string($needed_parts ? false : $data)); |
|
272 | + return $needed_parts ? false : $data; |
|
273 | 273 | } |
274 | 274 | } |
@@ -82,7 +82,10 @@ discard block |
||
82 | 82 | error_log(__METHOD__.'() PHP_AUTH_USER='.array2string($_SERVER['PHP_AUTH_USER']).', PHP_AUTH_PW='.array2string($pw).', PHP_AUTH_DIGEST='.array2string($_SERVER['PHP_AUTH_DIGEST'])); |
83 | 83 | } |
84 | 84 | $realm = $GLOBALS['egw_info']['flags']['auth_realm']; |
85 | - if (empty($realm)) $realm = 'EGroupware'; |
|
85 | + if (empty($realm)) |
|
86 | + { |
|
87 | + $realm = 'EGroupware'; |
|
88 | + } |
|
86 | 89 | |
87 | 90 | $username = $_SERVER['PHP_AUTH_USER']; $password = $_SERVER['PHP_AUTH_PW']; |
88 | 91 | // Support for basic auth when using PHP CGI (what about digest auth?) |
@@ -139,7 +142,8 @@ discard block |
||
139 | 142 | // replace \x encoded non-ascii chars in password, as they are used eg. by Thunderbird for German umlauts |
140 | 143 | if (strpos($password, '\\x') !== false) |
141 | 144 | { |
142 | - $password = preg_replace_callback('/\\\\x([0-9A-F]{2})/i', function($matches){ |
|
145 | + $password = preg_replace_callback('/\\\\x([0-9A-F]{2})/i', function($matches) |
|
146 | + { |
|
143 | 147 | return chr(hexdec($matches[1])); |
144 | 148 | }, $password); |
145 | 149 | } |
@@ -167,7 +171,10 @@ discard block |
||
167 | 171 | if (!($GLOBALS['egw_info']['server']['auth_type'] == 'sql' && $GLOBALS['egw_info']['server']['sql_encryption_type'] == 'plain') || |
168 | 172 | $GLOBALS['egw_info']['server']['auth_type'] == 'ldap' && $GLOBALS['egw_info']['server']['ldap_encryption_type'] == 'plain') |
169 | 173 | { |
170 | - if (self::ERROR_LOG) error_log(__METHOD__."('$username') return false (no plaintext passwords used)"); |
|
174 | + if (self::ERROR_LOG) |
|
175 | + { |
|
176 | + error_log(__METHOD__."('$username') return false (no plaintext passwords used)"); |
|
177 | + } |
|
171 | 178 | return false; // no plain-text passwords used |
172 | 179 | } |
173 | 180 | // check for specific user, if given |
@@ -175,10 +182,16 @@ discard block |
||
175 | 182 | $GLOBALS['egw_info']['server']['auth_type'] == 'sql' && substr($user_pw,0,7) != '{PLAIN}')) |
176 | 183 | { |
177 | 184 | unset($user_pw); |
178 | - if (self::ERROR_LOG) error_log(__METHOD__."('$realm','$username') return false (unknown user or NO plaintext password for user)"); |
|
185 | + if (self::ERROR_LOG) |
|
186 | + { |
|
187 | + error_log(__METHOD__."('$realm','$username') return false (unknown user or NO plaintext password for user)"); |
|
188 | + } |
|
179 | 189 | return false; // user does NOT exist, or has no plaintext passwords (ldap server requires real root_dn or special ACL!) |
180 | 190 | } |
181 | - if (substr($user_pw,0,7) == '{PLAIN}') $user_pw = substr($user_pw,7); |
|
191 | + if (substr($user_pw,0,7) == '{PLAIN}') |
|
192 | + { |
|
193 | + $user_pw = substr($user_pw,7); |
|
194 | + } |
|
182 | 195 | |
183 | 196 | if (self::ERROR_LOG) |
184 | 197 | { |
@@ -200,7 +213,10 @@ discard block |
||
200 | 213 | { |
201 | 214 | $nonce = uniqid(); |
202 | 215 | header('WWW-Authenticate: Digest realm="'.$realm.'",qop="auth",nonce="'.$nonce.'",opaque="'.md5($realm).'"'); |
203 | - if (self::ERROR_LOG) error_log(__METHOD__."() offering digest auth for realm '$realm' using nonce='$nonce'"); |
|
216 | + if (self::ERROR_LOG) |
|
217 | + { |
|
218 | + error_log(__METHOD__."() offering digest auth for realm '$realm' using nonce='$nonce'"); |
|
219 | + } |
|
204 | 220 | } |
205 | 221 | } |
206 | 222 | |
@@ -215,7 +231,10 @@ discard block |
||
215 | 231 | */ |
216 | 232 | static public function is_valid($realm,$auth_digest=null,&$username=null,&$password=null) |
217 | 233 | { |
218 | - if (is_null($auth_digest)) $auth_digest = $_SERVER['PHP_AUTH_DIGEST']; |
|
234 | + if (is_null($auth_digest)) |
|
235 | + { |
|
236 | + $auth_digest = $_SERVER['PHP_AUTH_DIGEST']; |
|
237 | + } |
|
219 | 238 | |
220 | 239 | $data = self::parse_digest($auth_digest); |
221 | 240 | |
@@ -228,7 +247,10 @@ discard block |
||
228 | 247 | |
229 | 248 | $valid_response = md5($A1.':'.$data['nonce'].':'.$data['nc'].':'.$data['cnonce'].':'.$data['qop'].':'.$A2); |
230 | 249 | |
231 | - if (self::ERROR_LOG) error_log(__METHOD__."('$realm','$auth_digest','$username') response='$data[response]', valid_response='$valid_response' returning ".array2string($data['response'] === $valid_response)); |
|
250 | + if (self::ERROR_LOG) |
|
251 | + { |
|
252 | + error_log(__METHOD__."('$realm','$auth_digest','$username') response='$data[response]', valid_response='$valid_response' returning ".array2string($data['response'] === $valid_response)); |
|
253 | + } |
|
232 | 254 | return $data['response'] === $valid_response; |
233 | 255 | } |
234 | 256 | |
@@ -247,10 +269,16 @@ discard block |
||
247 | 269 | { |
248 | 270 | return false; |
249 | 271 | } |
250 | - if (is_null($password)) $password = $user_pw; |
|
272 | + if (is_null($password)) |
|
273 | + { |
|
274 | + $password = $user_pw; |
|
275 | + } |
|
251 | 276 | |
252 | 277 | $A1 = md5($username . ':' . $realm . ':' . $password); |
253 | - if (self::ERROR_LOG > 1) error_log(__METHOD__."('$realm','$username','$password') returning ".array2string($A1)); |
|
278 | + if (self::ERROR_LOG > 1) |
|
279 | + { |
|
280 | + error_log(__METHOD__."('$realm','$username','$password') returning ".array2string($A1)); |
|
281 | + } |
|
254 | 282 | return $A1; |
255 | 283 | } |
256 | 284 |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | */ |
76 | 76 | static public function autocreate_session_callback(&$account) |
77 | 77 | { |
78 | - unset($account); // not used, but required by function signature |
|
78 | + unset($account); // not used, but required by function signature |
|
79 | 79 | if (self::ERROR_LOG) |
80 | 80 | { |
81 | 81 | $pw = self::ERROR_LOG > 1 ? $_SERVER['PHP_AUTH_PW'] : '**********'; |
@@ -86,15 +86,15 @@ discard block |
||
86 | 86 | |
87 | 87 | $username = $_SERVER['PHP_AUTH_USER']; $password = $_SERVER['PHP_AUTH_PW']; |
88 | 88 | // Support for basic auth when using PHP CGI (what about digest auth?) |
89 | - if (!isset($username) && !empty($_SERVER['REDIRECT_HTTP_AUTHORIZATION']) && strpos($_SERVER['REDIRECT_HTTP_AUTHORIZATION'],'Basic ') === 0) |
|
89 | + if (!isset($username) && !empty($_SERVER['REDIRECT_HTTP_AUTHORIZATION']) && strpos($_SERVER['REDIRECT_HTTP_AUTHORIZATION'], 'Basic ') === 0) |
|
90 | 90 | { |
91 | - $hash = base64_decode(substr($_SERVER['REDIRECT_HTTP_AUTHORIZATION'],6)); |
|
91 | + $hash = base64_decode(substr($_SERVER['REDIRECT_HTTP_AUTHORIZATION'], 6)); |
|
92 | 92 | if (strpos($hash, ':') !== false) |
93 | 93 | { |
94 | 94 | list($username, $password) = explode(':', $hash, 2); |
95 | 95 | } |
96 | 96 | } |
97 | - elseif (isset($_SERVER['PHP_AUTH_DIGEST']) && !self::is_valid($realm,$_SERVER['PHP_AUTH_DIGEST'],$username,$password)) |
|
97 | + elseif (isset($_SERVER['PHP_AUTH_DIGEST']) && !self::is_valid($realm, $_SERVER['PHP_AUTH_DIGEST'], $username, $password)) |
|
98 | 98 | { |
99 | 99 | unset($password); |
100 | 100 | } |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | { |
116 | 116 | $realm .= ': '.$GLOBALS['egw']->session->reason; |
117 | 117 | } |
118 | - header('WWW-Authenticate: Basic realm="'.$realm.'"');// draft-reschke-basicauth-enc-06 adds, accept-charset="'.translation::charset().'"'); |
|
118 | + header('WWW-Authenticate: Basic realm="'.$realm.'"'); // draft-reschke-basicauth-enc-06 adds, accept-charset="'.translation::charset().'"'); |
|
119 | 119 | self::digest_header($realm); |
120 | 120 | header('HTTP/1.1 401 Unauthorized'); |
121 | 121 | header('X-WebDAV-Status: 401 Unauthorized', true); |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | // replace \x encoded non-ascii chars in password, as they are used eg. by Thunderbird for German umlauts |
140 | 140 | if (strpos($password, '\\x') !== false) |
141 | 141 | { |
142 | - $password = preg_replace_callback('/\\\\x([0-9A-F]{2})/i', function($matches){ |
|
142 | + $password = preg_replace_callback('/\\\\x([0-9A-F]{2})/i', function($matches) { |
|
143 | 143 | return chr(hexdec($matches[1])); |
144 | 144 | }, $password); |
145 | 145 | } |
@@ -161,24 +161,24 @@ discard block |
||
161 | 161 | * @param string &$user_pw =null stored cleartext password, if $username given AND function returns true |
162 | 162 | * @return boolean true if digest auth is available, false otherwise |
163 | 163 | */ |
164 | - static public function digest_auth_available($realm,$username=null,&$user_pw=null) |
|
164 | + static public function digest_auth_available($realm, $username = null, &$user_pw = null) |
|
165 | 165 | { |
166 | 166 | // we currently require plaintext passwords! |
167 | 167 | if (!($GLOBALS['egw_info']['server']['auth_type'] == 'sql' && $GLOBALS['egw_info']['server']['sql_encryption_type'] == 'plain') || |
168 | 168 | $GLOBALS['egw_info']['server']['auth_type'] == 'ldap' && $GLOBALS['egw_info']['server']['ldap_encryption_type'] == 'plain') |
169 | 169 | { |
170 | 170 | if (self::ERROR_LOG) error_log(__METHOD__."('$username') return false (no plaintext passwords used)"); |
171 | - return false; // no plain-text passwords used |
|
171 | + return false; // no plain-text passwords used |
|
172 | 172 | } |
173 | 173 | // check for specific user, if given |
174 | - if (!is_null($username) && !(($user_pw = $GLOBALS['egw']->accounts->id2name($username,'account_pwd','u')) || |
|
175 | - $GLOBALS['egw_info']['server']['auth_type'] == 'sql' && substr($user_pw,0,7) != '{PLAIN}')) |
|
174 | + if (!is_null($username) && !(($user_pw = $GLOBALS['egw']->accounts->id2name($username, 'account_pwd', 'u')) || |
|
175 | + $GLOBALS['egw_info']['server']['auth_type'] == 'sql' && substr($user_pw, 0, 7) != '{PLAIN}')) |
|
176 | 176 | { |
177 | 177 | unset($user_pw); |
178 | 178 | if (self::ERROR_LOG) error_log(__METHOD__."('$realm','$username') return false (unknown user or NO plaintext password for user)"); |
179 | - return false; // user does NOT exist, or has no plaintext passwords (ldap server requires real root_dn or special ACL!) |
|
179 | + return false; // user does NOT exist, or has no plaintext passwords (ldap server requires real root_dn or special ACL!) |
|
180 | 180 | } |
181 | - if (substr($user_pw,0,7) == '{PLAIN}') $user_pw = substr($user_pw,7); |
|
181 | + if (substr($user_pw, 0, 7) == '{PLAIN}') $user_pw = substr($user_pw, 7); |
|
182 | 182 | |
183 | 183 | if (self::ERROR_LOG) |
184 | 184 | { |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | * @param string $realm |
195 | 195 | * @param string &$nonce=null on return |
196 | 196 | */ |
197 | - static public function digest_header($realm,&$nonce=null) |
|
197 | + static public function digest_header($realm, &$nonce = null) |
|
198 | 198 | { |
199 | 199 | if (self::digest_auth_available($realm)) |
200 | 200 | { |
@@ -213,13 +213,13 @@ discard block |
||
213 | 213 | * @param string &$password on return cleartext password |
214 | 214 | * @return boolean true if digest is correct, false otherwise |
215 | 215 | */ |
216 | - static public function is_valid($realm,$auth_digest=null,&$username=null,&$password=null) |
|
216 | + static public function is_valid($realm, $auth_digest = null, &$username = null, &$password = null) |
|
217 | 217 | { |
218 | 218 | if (is_null($auth_digest)) $auth_digest = $_SERVER['PHP_AUTH_DIGEST']; |
219 | 219 | |
220 | 220 | $data = self::parse_digest($auth_digest); |
221 | 221 | |
222 | - if (!$data || !($A1 = self::get_digest_A1($realm,$username=$data['username'],$password=null))) |
|
222 | + if (!$data || !($A1 = self::get_digest_A1($realm, $username = $data['username'], $password = null))) |
|
223 | 223 | { |
224 | 224 | error_log(__METHOD__."('$realm','$auth_digest','$username') returning FALSE"); |
225 | 225 | return false; |
@@ -240,16 +240,16 @@ discard block |
||
240 | 240 | * @param string &$password=null password to use or if null, on return stored password |
241 | 241 | * @return string|boolean false if $password not given and can NOT be read |
242 | 242 | */ |
243 | - static private function get_digest_A1($realm,$username,&$password=null) |
|
243 | + static private function get_digest_A1($realm, $username, &$password = null) |
|
244 | 244 | { |
245 | 245 | $user_pw = null; |
246 | - if (empty($username) || empty($realm) || !self::digest_auth_available($realm,$username,$user_pw)) |
|
246 | + if (empty($username) || empty($realm) || !self::digest_auth_available($realm, $username, $user_pw)) |
|
247 | 247 | { |
248 | 248 | return false; |
249 | 249 | } |
250 | 250 | if (is_null($password)) $password = $user_pw; |
251 | 251 | |
252 | - $A1 = md5($username . ':' . $realm . ':' . $password); |
|
252 | + $A1 = md5($username.':'.$realm.':'.$password); |
|
253 | 253 | if (self::ERROR_LOG > 1) error_log(__METHOD__."('$realm','$username','$password') returning ".array2string($A1)); |
254 | 254 | return $A1; |
255 | 255 | } |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | $keys = implode('|', array_keys($needed_parts)); |
266 | 266 | |
267 | 267 | $matches = null; |
268 | - preg_match_all('@(' . $keys . ')=(?:([\'"])([^\2]+?)\2|([^\s,]+))@', $txt, $matches, PREG_SET_ORDER); |
|
268 | + preg_match_all('@('.$keys.')=(?:([\'"])([^\2]+?)\2|([^\s,]+))@', $txt, $matches, PREG_SET_ORDER); |
|
269 | 269 | |
270 | 270 | foreach ($matches as $m) |
271 | 271 | { |