@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @param string $cname |
62 | 62 | */ |
63 | - public function beforeSendToClient($cname, array $expand=array()) |
|
63 | + public function beforeSendToClient($cname, array $expand = array()) |
|
64 | 64 | { |
65 | 65 | $attrs = $this->attrs; |
66 | 66 | |
@@ -68,14 +68,14 @@ discard block |
||
68 | 68 | $attrs['id'] = $this->id; |
69 | 69 | |
70 | 70 | $form_name = self::form_name($cname, $this->id); |
71 | - $data_id = $attrs['value'] ? self::form_name($cname, $attrs['value']) : self::form_name($cname, self::ID_PREFIX . $this->id); |
|
71 | + $data_id = $attrs['value'] ? self::form_name($cname, $attrs['value']) : self::form_name($cname, self::ID_PREFIX.$this->id); |
|
72 | 72 | |
73 | 73 | // No need to proceed |
74 | - if(!$data_id) return; |
|
74 | + if (!$data_id) return; |
|
75 | 75 | |
76 | 76 | // Find out which record to load |
77 | 77 | $value = self::get_array(self::$request->content, $form_name, false, true); |
78 | - if(!$value) |
|
78 | + if (!$value) |
|
79 | 79 | { |
80 | 80 | // Try here... legacy / fallback / just make it work |
81 | 81 | $value = self::get_array(self::$request->content, $data_id, true, false); |
@@ -85,23 +85,23 @@ discard block |
||
85 | 85 | { |
86 | 86 | // Get the record itself |
87 | 87 | $data = self::get_array(self::$request->content, $data_id, true, false); |
88 | - if(!$data) |
|
88 | + if (!$data) |
|
89 | 89 | { |
90 | 90 | $data = static::get_entry($value, $attrs); |
91 | 91 | } |
92 | 92 | } |
93 | 93 | |
94 | 94 | // Set the new value so transformer can find it. Use prefix to avoid changing the original value |
95 | - $new_value =& self::get_array(self::$request->content, self::ID_PREFIX .$this->id, true, false); |
|
95 | + $new_value = & self::get_array(self::$request->content, self::ID_PREFIX.$this->id, true, false); |
|
96 | 96 | if (true) $new_value = $data; |
97 | - $this->id = self::ID_PREFIX . $this->id . "[{$attrs['field']}]"; |
|
97 | + $this->id = self::ID_PREFIX.$this->id."[{$attrs['field']}]"; |
|
98 | 98 | |
99 | 99 | $old_type = self::getElementAttribute($this->id, 'type'); |
100 | 100 | |
101 | 101 | parent::beforeSendToClient($cname, $expand); |
102 | 102 | |
103 | 103 | // Check for conflict - more than one with same id/field and different type |
104 | - if($old_type && $old_type != $this->type) |
|
104 | + if ($old_type && $old_type != $this->type) |
|
105 | 105 | { |
106 | 106 | //self::set_validation_error($this->id, lang('%1, duplicate ID', $this)); |
107 | 107 | } |
@@ -71,7 +71,10 @@ discard block |
||
71 | 71 | $data_id = $attrs['value'] ? self::form_name($cname, $attrs['value']) : self::form_name($cname, self::ID_PREFIX . $this->id); |
72 | 72 | |
73 | 73 | // No need to proceed |
74 | - if(!$data_id) return; |
|
74 | + if(!$data_id) |
|
75 | + { |
|
76 | + return; |
|
77 | + } |
|
75 | 78 | |
76 | 79 | // Find out which record to load |
77 | 80 | $value = self::get_array(self::$request->content, $form_name, false, true); |
@@ -93,7 +96,10 @@ discard block |
||
93 | 96 | |
94 | 97 | // Set the new value so transformer can find it. Use prefix to avoid changing the original value |
95 | 98 | $new_value =& self::get_array(self::$request->content, self::ID_PREFIX .$this->id, true, false); |
96 | - if (true) $new_value = $data; |
|
99 | + if (true) |
|
100 | + { |
|
101 | + $new_value = $data; |
|
102 | + } |
|
97 | 103 | $this->id = self::ID_PREFIX . $this->id . "[{$attrs['field']}]"; |
98 | 104 | |
99 | 105 | $old_type = self::getElementAttribute($this->id, 'type'); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @param array &$validated=array() validated content |
55 | 55 | * @param array $expand=array values for keys 'c', 'row', 'c_', 'row_', 'cont' |
56 | 56 | */ |
57 | - public function validate($cname, array $expand, array $content, &$validated=array()) |
|
57 | + public function validate($cname, array $expand, array $content, &$validated = array()) |
|
58 | 58 | { |
59 | 59 | $form_name = self::form_name($cname, $this->id, $expand); |
60 | 60 | |
@@ -64,12 +64,12 @@ discard block |
||
64 | 64 | |
65 | 65 | if ((string)$value === '' && $this->attrs['needed']) |
66 | 66 | { |
67 | - self::set_validation_error($form_name,lang('Field must not be empty !!!'),''); |
|
67 | + self::set_validation_error($form_name, lang('Field must not be empty !!!'), ''); |
|
68 | 68 | return; |
69 | 69 | } |
70 | 70 | elseif ((string)$value != '' && !isset($this->attrs['preg'])) |
71 | 71 | { |
72 | - switch($this->type) |
|
72 | + switch ($this->type) |
|
73 | 73 | { |
74 | 74 | case 'url': |
75 | 75 | // if no protocol given eg. "www.egroupware.org" prepend "http://" for validation |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | } |
80 | 80 | $url_valid = filter_var($value, FILTER_VALIDATE_URL) || |
81 | 81 | // Remove intl chars & check again, but if it passes we'll keep the original |
82 | - filter_var(preg_replace('/[^[:print:]]/','',$value), FILTER_VALIDATE_URL); |
|
82 | + filter_var(preg_replace('/[^[:print:]]/', '', $value), FILTER_VALIDATE_URL); |
|
83 | 83 | //error_log(__METHOD__."() filter_var(value=".array2string($value).", FILTER_VALIDATE_URL)=".array2string(filter_var($value, FILTER_VALIDATE_URL))." --> url_valid=".array2string($url_valid)); |
84 | 84 | // remove http:// validation prefix again |
85 | 85 | if ($missing_protocol) |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | } |
89 | 89 | if (!$url_valid) |
90 | 90 | { |
91 | - self::set_validation_error($form_name,lang("'%1' has an invalid format !!!",$value),''); |
|
91 | + self::set_validation_error($form_name, lang("'%1' has an invalid format !!!", $value), ''); |
|
92 | 92 | return; |
93 | 93 | } |
94 | 94 | break; |
@@ -98,19 +98,19 @@ discard block |
||
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
101 | - $valid =& self::get_array($validated, $form_name, true); |
|
101 | + $valid = & self::get_array($validated, $form_name, true); |
|
102 | 102 | |
103 | - if ((int) $this->attrs['maxlength'] > 0 && strlen($value) > (int) $this->attrs['maxlength']) |
|
103 | + if ((int)$this->attrs['maxlength'] > 0 && strlen($value) > (int)$this->attrs['maxlength']) |
|
104 | 104 | { |
105 | - $value = substr($value,0,(int) $this->attrs['maxlength']); |
|
105 | + $value = substr($value, 0, (int)$this->attrs['maxlength']); |
|
106 | 106 | } |
107 | - if ($this->attrs['preg'] && !preg_match($this->attrs['preg'],$value)) |
|
107 | + if ($this->attrs['preg'] && !preg_match($this->attrs['preg'], $value)) |
|
108 | 108 | { |
109 | - switch($this->type) |
|
109 | + switch ($this->type) |
|
110 | 110 | { |
111 | 111 | default: |
112 | 112 | //error_log("preg_match('{$this->attrs['preg']}', '$value')=".array2string(preg_match($this->attrs['preg'], $value))); |
113 | - self::set_validation_error($form_name,lang("'%1' has an invalid format !!!",$value)/*." !preg_match('$this->attrs[preg]', '$value')"*/,''); |
|
113 | + self::set_validation_error($form_name, lang("'%1' has an invalid format !!!", $value)/*." !preg_match('$this->attrs[preg]', '$value')"*/, ''); |
|
114 | 114 | break; |
115 | 115 | } |
116 | 116 | } |
@@ -114,7 +114,10 @@ |
||
114 | 114 | break; |
115 | 115 | } |
116 | 116 | } |
117 | - if (true) $valid = $value; |
|
117 | + if (true) |
|
118 | + { |
|
119 | + $valid = $value; |
|
120 | + } |
|
118 | 121 | //error_log(__METHOD__."() $form_name: ".array2string($value_in).' --> '.array2string($value)); |
119 | 122 | } |
120 | 123 | } |
@@ -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 | { |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @param string $cname |
75 | 75 | */ |
76 | - public function beforeSendToClient($cname, array $expand=array()) |
|
76 | + public function beforeSendToClient($cname, array $expand = array()) |
|
77 | 77 | { |
78 | 78 | $attrs = $this->attrs; |
79 | 79 | $form_name = self::form_name($cname, $this->id); |
@@ -82,14 +82,14 @@ discard block |
||
82 | 82 | error_log(__METHOD__."() $this has no id!"); |
83 | 83 | return; |
84 | 84 | } |
85 | - $attrs['value'] = $value =& self::get_array(self::$request->content, $form_name, false, true); |
|
85 | + $attrs['value'] = $value = & self::get_array(self::$request->content, $form_name, false, true); |
|
86 | 86 | $attrs['type'] = $this->type; |
87 | 87 | $attrs['id'] = $this->id; |
88 | 88 | |
89 | 89 | $unmodified = $attrs; |
90 | 90 | |
91 | 91 | // run the transformation |
92 | - foreach(static::$transformation as $filter => $data) |
|
92 | + foreach (static::$transformation as $filter => $data) |
|
93 | 93 | { |
94 | 94 | $this->action($filter, $data, $attrs); |
95 | 95 | } |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | //echo $this; _debug_array($unmodified); _debug_array($attrs); _debug_array(array_diff_assoc($attrs, $unmodified)); |
98 | 98 | // compute the difference and send it to the client as modifications |
99 | 99 | $type_changed = false; |
100 | - foreach(array_diff_assoc($attrs, $unmodified) as $attr => $val) |
|
100 | + foreach (array_diff_assoc($attrs, $unmodified) as $attr => $val) |
|
101 | 101 | { |
102 | - switch($attr) |
|
102 | + switch ($attr) |
|
103 | 103 | { |
104 | 104 | case 'value': |
105 | 105 | if ($val != $value) |
106 | 106 | { |
107 | - $value = $val; // $value is reference to self::$request->content |
|
107 | + $value = $val; // $value is reference to self::$request->content |
|
108 | 108 | } |
109 | 109 | break; |
110 | 110 | case 'sel_options': |
@@ -112,15 +112,15 @@ discard block |
||
112 | 112 | break; |
113 | 113 | case 'type': // not an attribute in etemplate2 |
114 | 114 | $type_changed = true; |
115 | - if($val == 'template') |
|
115 | + if ($val == 'template') |
|
116 | 116 | { |
117 | 117 | // If the widget has been transformed into a template, we |
118 | 118 | // also need to try and instanciate & parse the template too |
119 | 119 | $transformed_template = Template::instance($attrs['template']); |
120 | - if($transformed_template) |
|
120 | + if ($transformed_template) |
|
121 | 121 | { |
122 | 122 | $this->expand_widget($transformed_template, $expand); |
123 | - $transformed_template->run('beforeSendToClient',array($cname,$expand)); |
|
123 | + $transformed_template->run('beforeSendToClient', array($cname, $expand)); |
|
124 | 124 | } |
125 | 125 | $type_changed = false; |
126 | 126 | } |
@@ -129,14 +129,14 @@ discard block |
||
129 | 129 | break; |
130 | 130 | } |
131 | 131 | } |
132 | - if($type_changed) |
|
132 | + if ($type_changed) |
|
133 | 133 | { |
134 | 134 | // Run the new widget type's beforeSendToClient |
135 | - $expanded_child = self::factory($attrs['type'], false,$this->id); |
|
135 | + $expanded_child = self::factory($attrs['type'], false, $this->id); |
|
136 | 136 | $expanded_child->id = $this->id; |
137 | 137 | $expanded_child->type = $attrs['type']; |
138 | 138 | $expanded_child->attrs = $attrs; |
139 | - $expanded_child->run('beforeSendToClient',array($cname,$expand)); |
|
139 | + $expanded_child->run('beforeSendToClient', array($cname, $expand)); |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | if (strpos($action, '@') !== false) |
159 | 159 | { |
160 | 160 | $replace = array(); |
161 | - foreach($attrs as $a => $v) |
|
161 | + foreach ($attrs as $a => $v) |
|
162 | 162 | { |
163 | 163 | if (is_scalar($v) || is_null($v)) $replace['@'.$a] = $v; |
164 | 164 | } |
@@ -166,14 +166,14 @@ discard block |
||
166 | 166 | // now replace with non-scalar value, eg. if values is an array: "@value", "@value[key] or "@value[@key]" |
167 | 167 | if (($a = strstr($action, '@'))) |
168 | 168 | { |
169 | - $action = self::get_array($attrs, substr($a,1)); |
|
169 | + $action = self::get_array($attrs, substr($a, 1)); |
|
170 | 170 | } |
171 | 171 | } |
172 | 172 | $attrs[$attr] = $action; |
173 | 173 | if (self::DEBUG) error_log(__METHOD__."('$attr', ".array2string($action).") attrs['$attr'] = ".array2string($action).', attrs='.array2string($attrs)); |
174 | 174 | } |
175 | 175 | // action is a serverside callback |
176 | - elseif(is_array($action) && isset($action['__callback__'])) |
|
176 | + elseif (is_array($action) && isset($action['__callback__'])) |
|
177 | 177 | { |
178 | 178 | if (!is_string(($callback = $action['__callback__']))) |
179 | 179 | { |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | { |
184 | 184 | $attrs[$attr] = $this->$callback($attrs[$attr], $attrs); |
185 | 185 | } |
186 | - elseif(count(explode('.', $callback)) == 3) |
|
186 | + elseif (count(explode('.', $callback)) == 3) |
|
187 | 187 | { |
188 | 188 | $attrs[$attr] = ExecMethod($callback, $attrs[$attr], $attrs); |
189 | 189 | } |
@@ -197,29 +197,29 @@ discard block |
||
197 | 197 | } |
198 | 198 | } |
199 | 199 | // action is a clientside callback |
200 | - elseif(is_array($action) && isset($action['__js__'])) |
|
200 | + elseif (is_array($action) && isset($action['__js__'])) |
|
201 | 201 | { |
202 | 202 | // nothing to do here |
203 | 203 | } |
204 | 204 | // TODO: Might be a better way to handle when value to be set is an array |
205 | - elseif(is_array($action) && $attr == 'sel_options') |
|
205 | + elseif (is_array($action) && $attr == 'sel_options') |
|
206 | 206 | { |
207 | 207 | $attrs[$attr] = $action; |
208 | 208 | } |
209 | 209 | // action is a switch --> check cases |
210 | - elseif(is_array($action)) |
|
210 | + elseif (is_array($action)) |
|
211 | 211 | { |
212 | 212 | // case matches --> run all actions |
213 | 213 | if (isset($action[$attrs[$attr]]) || !isset($action[$attrs[$attr]]) && isset($action['__default__'])) |
214 | 214 | { |
215 | 215 | $actions = isset($action[$attrs[$attr]]) ? $action[$attrs[$attr]] : $action['__default__']; |
216 | - if(!is_array($actions)) |
|
216 | + if (!is_array($actions)) |
|
217 | 217 | { |
218 | 218 | $attrs[$attr] = $actions; |
219 | 219 | $actions = array($attr => $actions); |
220 | 220 | } |
221 | 221 | if (self::DEBUG) error_log(__METHOD__."(attr='$attr', action=".array2string($action).") attrs['$attr']=='{$attrs[$attr]}' --> running actions"); |
222 | - foreach($actions as $attr => $action) |
|
222 | + foreach ($actions as $attr => $action) |
|
223 | 223 | { |
224 | 224 | $this->action($attr, $action, $attrs); |
225 | 225 | } |
@@ -150,7 +150,10 @@ discard block |
||
150 | 150 | */ |
151 | 151 | protected function action($attr, $action, array &$attrs) |
152 | 152 | { |
153 | - if (self::DEBUG) error_log(__METHOD__."('$attr', ".array2string($action).')'); |
|
153 | + if (self::DEBUG) |
|
154 | + { |
|
155 | + error_log(__METHOD__."('$attr', ".array2string($action).')'); |
|
156 | + } |
|
154 | 157 | // action is an assignment |
155 | 158 | if (is_scalar($action) || is_null($action)) |
156 | 159 | { |
@@ -160,7 +163,10 @@ discard block |
||
160 | 163 | $replace = array(); |
161 | 164 | foreach($attrs as $a => $v) |
162 | 165 | { |
163 | - if (is_scalar($v) || is_null($v)) $replace['@'.$a] = $v; |
|
166 | + if (is_scalar($v) || is_null($v)) |
|
167 | + { |
|
168 | + $replace['@'.$a] = $v; |
|
169 | + } |
|
164 | 170 | } |
165 | 171 | $action = strtr($action, $replace); |
166 | 172 | // now replace with non-scalar value, eg. if values is an array: "@value", "@value[key] or "@value[@key]" |
@@ -170,7 +176,10 @@ discard block |
||
170 | 176 | } |
171 | 177 | } |
172 | 178 | $attrs[$attr] = $action; |
173 | - if (self::DEBUG) error_log(__METHOD__."('$attr', ".array2string($action).") attrs['$attr'] = ".array2string($action).', attrs='.array2string($attrs)); |
|
179 | + if (self::DEBUG) |
|
180 | + { |
|
181 | + error_log(__METHOD__."('$attr', ".array2string($action).") attrs['$attr'] = ".array2string($action).', attrs='.array2string($attrs)); |
|
182 | + } |
|
174 | 183 | } |
175 | 184 | // action is a serverside callback |
176 | 185 | elseif(is_array($action) && isset($action['__callback__'])) |
@@ -218,7 +227,10 @@ discard block |
||
218 | 227 | $attrs[$attr] = $actions; |
219 | 228 | $actions = array($attr => $actions); |
220 | 229 | } |
221 | - if (self::DEBUG) error_log(__METHOD__."(attr='$attr', action=".array2string($action).") attrs['$attr']=='{$attrs[$attr]}' --> running actions"); |
|
230 | + if (self::DEBUG) |
|
231 | + { |
|
232 | + error_log(__METHOD__."(attr='$attr', action=".array2string($action).") attrs['$attr']=='{$attrs[$attr]}' --> running actions"); |
|
233 | + } |
|
222 | 234 | foreach($actions as $attr => $action) |
223 | 235 | { |
224 | 236 | $this->action($attr, $action, $attrs); |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | |
129 | 129 | $this->contacts->__construct(); |
130 | 130 | $options = $this->contacts->contact_fields; |
131 | - foreach($this->contacts->customfields as $name => $data) |
|
131 | + foreach ($this->contacts->customfields as $name => $data) |
|
132 | 132 | { |
133 | 133 | $options['#'.$name] = $data['label']; |
134 | 134 | } |
@@ -148,28 +148,28 @@ discard block |
||
148 | 148 | */ |
149 | 149 | public function get_contact($value, array $attrs) |
150 | 150 | { |
151 | - if (is_array($value) && !(array_key_exists('app',$value) && array_key_exists('id', $value))) return $value; |
|
151 | + if (is_array($value) && !(array_key_exists('app', $value) && array_key_exists('id', $value))) return $value; |
|
152 | 152 | |
153 | - if(is_array($value) && array_key_exists('app', $value) && array_key_exists('id', $value)) $value = $value['id']; |
|
154 | - switch($attrs['type']) |
|
153 | + if (is_array($value) && array_key_exists('app', $value) && array_key_exists('id', $value)) $value = $value['id']; |
|
154 | + switch ($attrs['type']) |
|
155 | 155 | { |
156 | 156 | case 'contact-account': |
157 | 157 | case 'contact-template': |
158 | - if (substr($value,0,8) != 'account:') |
|
158 | + if (substr($value, 0, 8) != 'account:') |
|
159 | 159 | { |
160 | 160 | $value = 'account:'.($attrs['name'] != 'account:' ? $value : $GLOBALS['egw_info']['user']['account_id']); |
161 | 161 | } |
162 | 162 | // fall-through |
163 | 163 | case 'contact-value': |
164 | 164 | default: |
165 | - if (substr($value,0,12) == 'addressbook:') $value = substr($value,12); // link-entry syntax |
|
165 | + if (substr($value, 0, 12) == 'addressbook:') $value = substr($value, 12); // link-entry syntax |
|
166 | 166 | if (!($contact = $this->contacts->read($value))) |
167 | 167 | { |
168 | 168 | $contact = array(); |
169 | 169 | } |
170 | 170 | break; |
171 | 171 | } |
172 | - unset($contact['jpegphoto']); // makes no sense to return binary image |
|
172 | + unset($contact['jpegphoto']); // makes no sense to return binary image |
|
173 | 173 | |
174 | 174 | //error_log(__METHOD__."('$value') returning ".array2string($contact)); |
175 | 175 | return $contact; |
@@ -148,9 +148,15 @@ discard block |
||
148 | 148 | */ |
149 | 149 | public function get_contact($value, array $attrs) |
150 | 150 | { |
151 | - if (is_array($value) && !(array_key_exists('app',$value) && array_key_exists('id', $value))) return $value; |
|
151 | + if (is_array($value) && !(array_key_exists('app',$value) && array_key_exists('id', $value))) |
|
152 | + { |
|
153 | + return $value; |
|
154 | + } |
|
152 | 155 | |
153 | - if(is_array($value) && array_key_exists('app', $value) && array_key_exists('id', $value)) $value = $value['id']; |
|
156 | + if(is_array($value) && array_key_exists('app', $value) && array_key_exists('id', $value)) |
|
157 | + { |
|
158 | + $value = $value['id']; |
|
159 | + } |
|
154 | 160 | switch($attrs['type']) |
155 | 161 | { |
156 | 162 | case 'contact-account': |
@@ -162,7 +168,11 @@ discard block |
||
162 | 168 | // fall-through |
163 | 169 | case 'contact-value': |
164 | 170 | default: |
165 | - if (substr($value,0,12) == 'addressbook:') $value = substr($value,12); // link-entry syntax |
|
171 | + if (substr($value,0,12) == 'addressbook:') |
|
172 | + { |
|
173 | + $value = substr($value,12); |
|
174 | + } |
|
175 | + // link-entry syntax |
|
166 | 176 | if (!($contact = $this->contacts->read($value))) |
167 | 177 | { |
168 | 178 | $contact = array(); |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function __construct($xml = '') |
83 | 83 | { |
84 | - if($xml) { |
|
84 | + if ($xml) { |
|
85 | 85 | parent::__construct($xml); |
86 | 86 | } |
87 | 87 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * @return Template current object or clone, if any attribute was set |
97 | 97 | * @todo Use legacy_attributes instead of leaving it to typeOptions method to parse them |
98 | 98 | */ |
99 | - public function set_attrs($xml, $cloned=true) |
|
99 | + public function set_attrs($xml, $cloned = true) |
|
100 | 100 | { |
101 | 101 | parent::set_attrs($xml, $cloned); |
102 | 102 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | unset($this->attrs['options']); |
110 | 110 | } |
111 | 111 | } |
112 | - elseif($this->attrs['rows'] > 1) |
|
112 | + elseif ($this->attrs['rows'] > 1) |
|
113 | 113 | { |
114 | 114 | $this->attrs['multiple'] = true; |
115 | 115 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | * @param array $content |
126 | 126 | * @param array &$validated=array() validated content |
127 | 127 | */ |
128 | - public function validate($cname, array $expand, array $content, &$validated=array()) |
|
128 | + public function validate($cname, array $expand, array $content, &$validated = array()) |
|
129 | 129 | { |
130 | 130 | $form_name = self::form_name($cname, $this->id, $expand); |
131 | 131 | $widget_type = $this->attrs['type'] ? $this->attrs['type'] : $this->type; |
@@ -135,21 +135,21 @@ discard block |
||
135 | 135 | { |
136 | 136 | $value = $value_in = self::get_array($content, $form_name); |
137 | 137 | |
138 | - $allowed2 = self::selOptions($form_name, true); // true = return array of option-values |
|
138 | + $allowed2 = self::selOptions($form_name, true); // true = return array of option-values |
|
139 | 139 | $type_options = self::typeOptions($this, |
140 | 140 | // typeOptions thinks # of rows is the first thing in options |
141 | 141 | ($this->attrs['rows'] && strpos($this->attrs['options'], $this->attrs['rows']) !== 0 ? $this->attrs['rows'].','.$this->attrs['options'] : $this->attrs['options'])); |
142 | - $allowed = array_merge($allowed2,array_keys($type_options)); |
|
142 | + $allowed = array_merge($allowed2, array_keys($type_options)); |
|
143 | 143 | |
144 | 144 | // add option children's values too, "" is not read, therefore we cast to string |
145 | - foreach($this->children as $child) |
|
145 | + foreach ($this->children as $child) |
|
146 | 146 | { |
147 | 147 | if ($child->type == 'option') $allowed[] = (string)$child->attrs['value']; |
148 | 148 | } |
149 | 149 | |
150 | 150 | if (!$this->attrs['multiple'] || !($this->attrs['options'] > 1)) $allowed[] = ''; |
151 | 151 | |
152 | - foreach((array) $value as $val) |
|
152 | + foreach ((array)$value as $val) |
|
153 | 153 | { |
154 | 154 | // handle empty-label for all widget types |
155 | 155 | if ((string)$val === '' && in_array('', $allowed)) continue; |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | { |
159 | 159 | case 'select-account': |
160 | 160 | // If in allowed options, skip account check to support app-specific options |
161 | - if(count($allowed) > 0 && in_array($val,$allowed)) continue; |
|
161 | + if (count($allowed) > 0 && in_array($val, $allowed)) continue; |
|
162 | 162 | |
163 | 163 | // validate accounts independent of options know to server |
164 | 164 | $account_type = $this->attrs['account_type'] ? $this->attrs['account_type'] : 'accounts'; |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | ) |
173 | 173 | { |
174 | 174 | self::set_validation_error($form_name, lang("'%1' is NOT allowed ('%2')!", $val, |
175 | - !$type?'not found' : ($type == 1 ? 'user' : 'group')),''); |
|
175 | + !$type ? 'not found' : ($type == 1 ? 'user' : 'group')), ''); |
|
176 | 176 | $value = ''; |
177 | 177 | break 2; |
178 | 178 | } |
@@ -186,9 +186,9 @@ discard block |
||
186 | 186 | break; |
187 | 187 | |
188 | 188 | default: |
189 | - if(!in_array($val, $allowed)) |
|
189 | + if (!in_array($val, $allowed)) |
|
190 | 190 | { |
191 | - self::set_validation_error($form_name,lang("'%1' is NOT allowed ('%2')!", $val, implode("','",$allowed)),''); |
|
191 | + self::set_validation_error($form_name, lang("'%1' is NOT allowed ('%2')!", $val, implode("','", $allowed)), ''); |
|
192 | 192 | $value = ''; |
193 | 193 | break 2; |
194 | 194 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | } |
197 | 197 | if ($ok && $value === '' && $this->attrs['needed']) |
198 | 198 | { |
199 | - self::set_validation_error($form_name,lang('Field must not be empty !!!',$value),''); |
|
199 | + self::set_validation_error($form_name, lang('Field must not be empty !!!', $value), ''); |
|
200 | 200 | } |
201 | 201 | // some widgets sub-types need some post-processing |
202 | 202 | // ToDo: move it together with preprocessing to clientside |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | { |
205 | 205 | case 'select-dow': |
206 | 206 | $dow = 0; |
207 | - foreach((array)$value as $val) |
|
207 | + foreach ((array)$value as $val) |
|
208 | 208 | { |
209 | 209 | $dow |= $val; |
210 | 210 | } |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | { |
231 | 231 | $value = array_merge($value, (array)self::$request->preserv[$unavailable_name]); |
232 | 232 | } |
233 | - elseif(!$value) // for single cat, we only restore unavailable one, if no other was selected |
|
233 | + elseif (!$value) // for single cat, we only restore unavailable one, if no other was selected |
|
234 | 234 | { |
235 | 235 | $value = self::$request->preserv[$unavailable_name]; |
236 | 236 | } |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | * @param string $cname |
255 | 255 | * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' |
256 | 256 | */ |
257 | - public function beforeSendToClient($cname, array $expand=null) |
|
257 | + public function beforeSendToClient($cname, array $expand = null) |
|
258 | 258 | { |
259 | 259 | //error_log(__METHOD__."('$cname') this->id=$this->id, this->type=$this->type, this->attrs=".array2string($this->attrs)); |
260 | 260 | $matches = null; |
@@ -287,14 +287,14 @@ discard block |
||
287 | 287 | { |
288 | 288 | // Check selection preference, we may be able to skip reading some data |
289 | 289 | $select_pref = $GLOBALS['egw_info']['user']['preferences']['common']['account_selection']; |
290 | - if($this->attrs['type'] == 'select-account' && !$GLOBALS['egw_info']['user']['apps']['admin'] && $select_pref == 'none') |
|
290 | + if ($this->attrs['type'] == 'select-account' && !$GLOBALS['egw_info']['user']['apps']['admin'] && $select_pref == 'none') |
|
291 | 291 | { |
292 | 292 | // Preserve but do not send the value if preference is 'none' |
293 | 293 | self::$request->preserv[$this->id] = self::$request->content[$this->id]; |
294 | 294 | unset(self::$request->content[$this->id]); |
295 | 295 | $this->attrs['readonly'] = true; |
296 | 296 | } |
297 | - if(!in_array($type, self::$cached_types)) |
|
297 | + if (!in_array($type, self::$cached_types)) |
|
298 | 298 | { |
299 | 299 | // adding type specific options here, while keep further options set by app code |
300 | 300 | // we need to make sure to run only once for auto-repeated rows, because |
@@ -324,20 +324,20 @@ discard block |
||
324 | 324 | |
325 | 325 | // Make sure s, etc. are properly encoded when sent, and not double-encoded |
326 | 326 | $options = (isset(self::$request->sel_options[$form_name]) ? $form_name : $this->id); |
327 | - if(is_array(self::$request->sel_options[$options])) |
|
327 | + if (is_array(self::$request->sel_options[$options])) |
|
328 | 328 | { |
329 | - if(in_array($this->attrs['type'], self::$cached_types) && !isset($form_names_done[$options])) |
|
329 | + if (in_array($this->attrs['type'], self::$cached_types) && !isset($form_names_done[$options])) |
|
330 | 330 | { |
331 | 331 | // Fix any custom options from application |
332 | - self::fix_encoded_options(self::$request->sel_options[$options],true); |
|
332 | + self::fix_encoded_options(self::$request->sel_options[$options], true); |
|
333 | 333 | $form_names_done[$options] = true; |
334 | 334 | } |
335 | 335 | // Turn on search, if there's a lot of rows (unless explicitly set) |
336 | - if(!array_key_exists('search',$this->attrs) && count(self::$request->sel_options[$options]) >= self::SEARCH_ROW_LIMIT) |
|
336 | + if (!array_key_exists('search', $this->attrs) && count(self::$request->sel_options[$options]) >= self::SEARCH_ROW_LIMIT) |
|
337 | 337 | { |
338 | 338 | self::setElementAttribute($form_name, "search", true); |
339 | 339 | } |
340 | - if(!self::$request->sel_options[$options]) |
|
340 | + if (!self::$request->sel_options[$options]) |
|
341 | 341 | { |
342 | 342 | unset(self::$request->sel_options[$options]); |
343 | 343 | } |
@@ -352,12 +352,12 @@ discard block |
||
352 | 352 | * @param array $options |
353 | 353 | * @param boolean $use_array_of_objects Re-indexes options, making everything more complicated |
354 | 354 | */ |
355 | - public static function fix_encoded_options(array &$options, $use_array_of_objects=null) |
|
355 | + public static function fix_encoded_options(array &$options, $use_array_of_objects = null) |
|
356 | 356 | { |
357 | 357 | $backup_options = $options; |
358 | 358 | |
359 | 359 | $values = array(); |
360 | - foreach($options as $value => &$label) |
|
360 | + foreach ($options as $value => &$label) |
|
361 | 361 | { |
362 | 362 | // Of course once we re-index the options, we can't detect duplicates |
363 | 363 | // so check here, as we re-index |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | return self::fix_encoded_options($options, true); |
378 | 378 | } |
379 | 379 | // optgroup or values for keys "label" and "title" |
380 | - if(is_array($label)) |
|
380 | + if (is_array($label)) |
|
381 | 381 | { |
382 | 382 | self::fix_encoded_options($label, false); |
383 | 383 | if ($use_array_of_objects && !array_key_exists('value', $label)) $label['value'] = $value; |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | * @param boolean $return_values =false true: return array with option values, instead of value => label pairs |
409 | 409 | * @return array |
410 | 410 | */ |
411 | - public static function selOptions($name, $return_values=false) |
|
411 | + public static function selOptions($name, $return_values = false) |
|
412 | 412 | { |
413 | 413 | $options = array(); |
414 | 414 | |
@@ -419,12 +419,12 @@ discard block |
||
419 | 419 | } |
420 | 420 | |
421 | 421 | // Check for base of name in root of sel_options |
422 | - if(!$options) |
|
422 | + if (!$options) |
|
423 | 423 | { |
424 | - $name_parts = explode('[',str_replace(array('[',']',']'),array('['),$name)); |
|
424 | + $name_parts = explode('[', str_replace(array('[', ']', ']'), array('['), $name)); |
|
425 | 425 | if (count($name_parts)) |
426 | 426 | { |
427 | - $org_name = $name_parts[count($name_parts)-1]; |
|
427 | + $org_name = $name_parts[count($name_parts) - 1]; |
|
428 | 428 | if (isset(self::$request->sel_options[$org_name]) && is_array(self::$request->sel_options[$org_name])) |
429 | 429 | { |
430 | 430 | $options += self::$request->sel_options[$org_name]; |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | if ($return_values) |
445 | 445 | { |
446 | 446 | $values = array(); |
447 | - foreach($options as $key => $val) |
|
447 | + foreach ($options as $key => $val) |
|
448 | 448 | { |
449 | 449 | if (is_array($val)) |
450 | 450 | { |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | } |
461 | 461 | else // optgroup |
462 | 462 | { |
463 | - foreach($val as $k => $v) |
|
463 | + foreach ($val as $k => $v) |
|
464 | 464 | { |
465 | 465 | $values[] = is_array($v) && isset($v['value']) ? $v['value'] : $k; |
466 | 466 | } |
@@ -489,50 +489,50 @@ discard block |
||
489 | 489 | * @param string $form_name =null |
490 | 490 | * @return array with value => label pairs |
491 | 491 | */ |
492 | - public static function typeOptions($widget_type, $_legacy_options, &$no_lang=false, $readonly=false, &$value=null, $form_name=null) |
|
492 | + public static function typeOptions($widget_type, $_legacy_options, &$no_lang = false, $readonly = false, &$value = null, $form_name = null) |
|
493 | 493 | { |
494 | - if($widget_type && is_object($widget_type)) |
|
494 | + if ($widget_type && is_object($widget_type)) |
|
495 | 495 | { |
496 | 496 | $widget = $widget_type; |
497 | 497 | $widget_type = $widget->attrs['type'] ? $widget->attrs['type'] : $widget->type; |
498 | 498 | } |
499 | 499 | // Legacy / static support |
500 | 500 | // Have to do this explicitly, since legacy options is not defined on class level |
501 | - $legacy_options = explode(',',$_legacy_options); |
|
502 | - foreach($legacy_options as &$field) |
|
501 | + $legacy_options = explode(',', $_legacy_options); |
|
502 | + foreach ($legacy_options as &$field) |
|
503 | 503 | { |
504 | - $field = self::expand_name($field, 0, 0,'','',self::$cont); |
|
504 | + $field = self::expand_name($field, 0, 0, '', '', self::$cont); |
|
505 | 505 | } |
506 | 506 | |
507 | - list($rows,$type,$type2,$type3,$type4,$type5) = $legacy_options; |
|
507 | + list($rows, $type, $type2, $type3, $type4, $type5) = $legacy_options; |
|
508 | 508 | $no_lang = false; |
509 | 509 | $options = array(); |
510 | 510 | switch ($widget_type) |
511 | 511 | { |
512 | 512 | case 'select-percent': // options: #row,decrement(default=10) |
513 | 513 | $decr = $type > 0 ? $type : 10; |
514 | - for ($i=0; $i <= 100; $i += $decr) |
|
514 | + for ($i = 0; $i <= 100; $i += $decr) |
|
515 | 515 | { |
516 | 516 | $options[intval($i)] = intval($i).'%'; |
517 | 517 | } |
518 | 518 | $options[100] = '100%'; |
519 | 519 | if (!$rows || !empty($value)) |
520 | 520 | { |
521 | - $value = intval(($value+($decr/2)) / $decr) * $decr; |
|
521 | + $value = intval(($value + ($decr / 2)) / $decr) * $decr; |
|
522 | 522 | } |
523 | 523 | $no_lang = True; |
524 | 524 | break; |
525 | 525 | |
526 | 526 | case 'select-priority': |
527 | - $options = array('','low','normal','high'); |
|
527 | + $options = array('', 'low', 'normal', 'high'); |
|
528 | 528 | break; |
529 | 529 | |
530 | 530 | case 'select-bool': // equal to checkbox, can be used with nextmatch-customfilter to filter a boolean column |
531 | - $options = array(0 => 'no',1 => 'yes'); |
|
531 | + $options = array(0 => 'no', 1 => 'yes'); |
|
532 | 532 | break; |
533 | 533 | |
534 | 534 | case 'select-country': // #Row|Extralabel,1=use country name, 0=use 2 letter-code,custom country field name |
535 | - if($type == 0 && $type2) |
|
535 | + if ($type == 0 && $type2) |
|
536 | 536 | { |
537 | 537 | $custom_label = is_numeric($type2) ? 'Custom' : $type2; |
538 | 538 | $options = array('-custom-' => lang($custom_label)) + Api\Country::countries(); |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | $value = Api\Country::country_code($value); |
547 | 547 | if (!isset($options[$value])) |
548 | 548 | { |
549 | - if($type2) |
|
549 | + if ($type2) |
|
550 | 550 | { |
551 | 551 | $options[$value] = $value; |
552 | 552 | } |
@@ -562,20 +562,20 @@ discard block |
||
562 | 562 | |
563 | 563 | case 'select-cat': // !$type == globals cats too, $type2: extraStyleMultiselect, $type3: application, if not current-app, $type4: parent-id, $type5=owner (-1=global),$type6=show missing |
564 | 564 | if ((!$type3 || $type3 === $GLOBALS['egw']->categories->app_name) && |
565 | - (!$type5 || $type5 == $GLOBALS['egw']->categories->account_id)) |
|
565 | + (!$type5 || $type5 == $GLOBALS['egw']->categories->account_id)) |
|
566 | 566 | { |
567 | 567 | $categories = $GLOBALS['egw']->categories; |
568 | 568 | } |
569 | 569 | else // we need to instanciate a new cat object for the correct application |
570 | 570 | { |
571 | - $categories = new Api\Categories($type5,$type3); |
|
571 | + $categories = new Api\Categories($type5, $type3); |
|
572 | 572 | } |
573 | 573 | // Allow text for global |
574 | 574 | $type = ($type && strlen($type) > 1 ? $type : !$type); |
575 | 575 | // we cast $type4 (parent) to int, to get default of 0 if omitted |
576 | - foreach((array)$categories->return_sorted_array(0,False,'','','',$type,(int)$type4,true) as $cat) |
|
576 | + foreach ((array)$categories->return_sorted_array(0, False, '', '', '', $type, (int)$type4, true) as $cat) |
|
577 | 577 | { |
578 | - $s = str_repeat(' ',$cat['level']) . stripslashes($cat['name']); |
|
578 | + $s = str_repeat(' ', $cat['level']).stripslashes($cat['name']); |
|
579 | 579 | |
580 | 580 | if (Api\Categories::is_global($cat)) |
581 | 581 | { |
@@ -590,13 +590,13 @@ discard block |
||
590 | 590 | 'children' => $cat['children'] |
591 | 591 | ); |
592 | 592 | // Send data too |
593 | - if(is_array($cat['data'])) |
|
593 | + if (is_array($cat['data'])) |
|
594 | 594 | { |
595 | 595 | $options[$cat['id']] += $cat['data']; |
596 | 596 | } |
597 | 597 | } |
598 | 598 | // preserv unavailible cats (eg. private user-cats) |
599 | - if ($value && ($unavailible = array_diff(is_array($value) ? $value : explode(',',$value),array_keys((array)$options)))) |
|
599 | + if ($value && ($unavailible = array_diff(is_array($value) ? $value : explode(',', $value), array_keys((array)$options)))) |
|
600 | 600 | { |
601 | 601 | // unavailable cats need to be merged in again |
602 | 602 | $unavailable_name = $form_name.self::UNAVAILABLE_CAT_POSTFIX; |
@@ -609,11 +609,11 @@ discard block |
||
609 | 609 | $options[''] = ''; |
610 | 610 | if ($type <= 0) $type = 3; |
611 | 611 | if ($type2 <= 0) $type2 = 2; |
612 | - if ($type > 100 && $type2 > 100 && $type > $type) { $y = $type; $type=$type2; $type2=$y; } |
|
613 | - $y = date('Y')-$type; |
|
614 | - if ($value && $value-$type < $y || $type > 100) $y = $type > 100 ? $type : $value-$type; |
|
615 | - $to = date('Y')+$type2; |
|
616 | - if ($value && $value+$type2 > $to || $type2 > 100) $to = $type2 > 100 ? $type2 : $value+$type2; |
|
612 | + if ($type > 100 && $type2 > 100 && $type > $type) { $y = $type; $type = $type2; $type2 = $y; } |
|
613 | + $y = date('Y') - $type; |
|
614 | + if ($value && $value - $type < $y || $type > 100) $y = $type > 100 ? $type : $value - $type; |
|
615 | + $to = date('Y') + $type2; |
|
616 | + if ($value && $value + $type2 > $to || $type2 > 100) $to = $type2 > 100 ? $type2 : $value + $type2; |
|
617 | 617 | for ($n = 0; $y <= $to && $n < 200; ++$n) |
618 | 618 | { |
619 | 619 | $options[$y] = $y++; |
@@ -629,17 +629,17 @@ discard block |
||
629 | 629 | case 'select-dow': // options: rows[,0=summaries befor days, 1=summaries after days, 2=no summaries[,extraStyleMultiselect]] |
630 | 630 | if (!defined('MCAL_M_SUNDAY')) |
631 | 631 | { |
632 | - define('MCAL_M_SUNDAY',1); |
|
633 | - define('MCAL_M_MONDAY',2); |
|
634 | - define('MCAL_M_TUESDAY',4); |
|
635 | - define('MCAL_M_WEDNESDAY',8); |
|
636 | - define('MCAL_M_THURSDAY',16); |
|
637 | - define('MCAL_M_FRIDAY',32); |
|
638 | - define('MCAL_M_SATURDAY',64); |
|
639 | - |
|
640 | - define('MCAL_M_WEEKDAYS',62); |
|
641 | - define('MCAL_M_WEEKEND',65); |
|
642 | - define('MCAL_M_ALLDAYS',127); |
|
632 | + define('MCAL_M_SUNDAY', 1); |
|
633 | + define('MCAL_M_MONDAY', 2); |
|
634 | + define('MCAL_M_TUESDAY', 4); |
|
635 | + define('MCAL_M_WEDNESDAY', 8); |
|
636 | + define('MCAL_M_THURSDAY', 16); |
|
637 | + define('MCAL_M_FRIDAY', 32); |
|
638 | + define('MCAL_M_SATURDAY', 64); |
|
639 | + |
|
640 | + define('MCAL_M_WEEKDAYS', 62); |
|
641 | + define('MCAL_M_WEEKEND', 65); |
|
642 | + define('MCAL_M_ALLDAYS', 127); |
|
643 | 643 | } |
644 | 644 | $weekstart = $GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts']; |
645 | 645 | $options = array(); |
@@ -672,9 +672,9 @@ discard block |
||
672 | 672 | } |
673 | 673 | $value_in = $value; |
674 | 674 | $value = array(); |
675 | - foreach(array_keys($options) as $val) |
|
675 | + foreach (array_keys($options) as $val) |
|
676 | 676 | { |
677 | - if (($value_in & $val) == $val) |
|
677 | + if (($value_in&$val) == $val) |
|
678 | 678 | { |
679 | 679 | $value[] = $val; |
680 | 680 | |
@@ -682,7 +682,7 @@ discard block |
||
682 | 682 | $val == MCAL_M_WEEKDAYS && $value_in == MCAL_M_WEEKDAYS || |
683 | 683 | $val == MCAL_M_WEEKEND && $value_in == MCAL_M_WEEKEND) |
684 | 684 | { |
685 | - break; // dont set the others |
|
685 | + break; // dont set the others |
|
686 | 686 | } |
687 | 687 | } |
688 | 688 | } |
@@ -695,22 +695,22 @@ discard block |
||
695 | 695 | // fall-through |
696 | 696 | |
697 | 697 | case 'select-number': // options: rows,min,max,decrement,suffix |
698 | - $type = $type === '' ? 1 : intval($type); // min |
|
699 | - $type2 = $type2 === '' ? 10 : intval($type2); // max |
|
698 | + $type = $type === '' ? 1 : intval($type); // min |
|
699 | + $type2 = $type2 === '' ? 10 : intval($type2); // max |
|
700 | 700 | $format = '%d'; |
701 | 701 | if (!empty($type3) && $type3[0] == '0') // leading zero |
702 | 702 | { |
703 | 703 | $format = '%0'.strlen($type3).'d'; |
704 | 704 | } |
705 | - $type3 = !$type3 ? 1 : intval($type3); // decrement |
|
705 | + $type3 = !$type3 ? 1 : intval($type3); // decrement |
|
706 | 706 | if (($type <= $type2) != ($type3 > 0)) |
707 | 707 | { |
708 | - $type3 = -$type3; // void infinite loop |
|
708 | + $type3 = -$type3; // void infinite loop |
|
709 | 709 | } |
710 | 710 | if (!empty($type4)) $format .= lang($type4); |
711 | - for ($i=0,$n=$type; $n <= $type2 && $i <= 100; $n += $type3,++$i) |
|
711 | + for ($i = 0, $n = $type; $n <= $type2 && $i <= 100; $n += $type3, ++$i) |
|
712 | 712 | { |
713 | - $options[$n] = sprintf($format,$n); |
|
713 | + $options[$n] = sprintf($format, $n); |
|
714 | 714 | } |
715 | 715 | $no_lang = True; |
716 | 716 | break; |
@@ -720,15 +720,14 @@ discard block |
||
720 | 720 | for ($h = 0; $h <= 23; ++$h) |
721 | 721 | { |
722 | 722 | $options[$h] = $GLOBALS['egw_info']['user']['preferences']['common']['timeformat'] == 12 ? |
723 | - (($h % 12 ? $h % 12 : 12).$minutes.' '.($h < 12 ? lang('am') : lang('pm'))) : |
|
724 | - sprintf('%02d',$h).$minutes; |
|
723 | + (($h % 12 ? $h % 12 : 12).$minutes.' '.($h < 12 ? lang('am') : lang('pm'))) : sprintf('%02d', $h).$minutes; |
|
725 | 724 | } |
726 | 725 | $no_lang = True; |
727 | 726 | break; |
728 | 727 | |
729 | 728 | case 'select-app': // type2: 'user'=apps of current user, 'enabled', 'installed' (default), 'all' = not installed ones too |
730 | 729 | $apps = self::app_options($type2); |
731 | - $options = is_array($options) ? $options+$apps : $apps; |
|
730 | + $options = is_array($options) ? $options + $apps : $apps; |
|
732 | 731 | break; |
733 | 732 | |
734 | 733 | case 'select-lang': |
@@ -743,7 +742,7 @@ discard block |
||
743 | 742 | } |
744 | 743 | if ($readonly) // for readonly we dont need to fetch all TZ's |
745 | 744 | { |
746 | - $options[$value] = calendar_timezones::tz2id($value,'name'); |
|
745 | + $options[$value] = calendar_timezones::tz2id($value, 'name'); |
|
747 | 746 | } |
748 | 747 | else |
749 | 748 | { |
@@ -773,7 +772,7 @@ discard block |
||
773 | 772 | { |
774 | 773 | if ($type2 == 'enabled' && (!$data['enabled'] || !$data['status'] || $data['status'] == 3)) |
775 | 774 | { |
776 | - continue; // app not enabled (user can not have run rights for these apps) |
|
775 | + continue; // app not enabled (user can not have run rights for these apps) |
|
777 | 776 | } |
778 | 777 | if ($type2 != 'user' || $GLOBALS['egw_info']['user']['apps'][$app]) |
779 | 778 | { |
@@ -788,7 +787,7 @@ discard block |
||
788 | 787 | if (@is_dir(EGW_SERVER_ROOT."/$file/setup") && $file[0] != '.' && |
789 | 788 | !isset($apps[$app = basename($file)])) |
790 | 789 | { |
791 | - $apps[$app] = $app . ' (*)'; |
|
790 | + $apps[$app] = $app.' (*)'; |
|
792 | 791 | } |
793 | 792 | } |
794 | 793 | closedir($dir); |
@@ -806,7 +805,7 @@ discard block |
||
806 | 805 | * @param boolean $show_type =false true: return array with values for keys label and icon, false: only label |
807 | 806 | * @return string|array |
808 | 807 | */ |
809 | - public static function accountInfo($id,$acc=null,$longnames=0,$show_type=false) |
|
808 | + public static function accountInfo($id, $acc = null, $longnames = 0, $show_type = false) |
|
810 | 809 | { |
811 | 810 | if (!$id) |
812 | 811 | { |
@@ -817,7 +816,7 @@ discard block |
||
817 | 816 | { |
818 | 817 | $data = $GLOBALS['egw']->accounts->get_account_data($id); |
819 | 818 | if (!isset($data[$id])) return '#'.$id; |
820 | - foreach(array('type','lid','firstname','lastname') as $name) |
|
819 | + foreach (array('type', 'lid', 'firstname', 'lastname') as $name) |
|
821 | 820 | { |
822 | 821 | $acc['account_'.$name] = $data[$id][$name]; |
823 | 822 | } |
@@ -833,18 +832,17 @@ discard block |
||
833 | 832 | $info .= '<'.$acc['account_lid'].'> '; |
834 | 833 | // fall-through |
835 | 834 | case 1: |
836 | - $info .= $acc['account_type'] == 'g' ? lang('group').' '.$acc['account_lid'] : |
|
837 | - $acc['account_firstname'].' '.$acc['account_lastname']; |
|
835 | + $info .= $acc['account_type'] == 'g' ? lang('group').' '.$acc['account_lid'] : $acc['account_firstname'].' '.$acc['account_lastname']; |
|
838 | 836 | break; |
839 | 837 | case '0': |
840 | 838 | $info .= $acc['account_lid']; |
841 | 839 | break; |
842 | 840 | default: // use the phpgw default |
843 | 841 | $info = Api\Accounts::format_username($acc['account_lid'], |
844 | - $acc['account_firstname'],$acc['account_lastname']); |
|
842 | + $acc['account_firstname'], $acc['account_lastname']); |
|
845 | 843 | break; |
846 | 844 | } |
847 | - if($show_type) { |
|
845 | + if ($show_type) { |
|
848 | 846 | $info = array( |
849 | 847 | 'label' => $info, |
850 | 848 | 'icon' => $acc['account_type'] == 'g' ? 'addressbook/group' : 'user' |
@@ -864,8 +862,8 @@ discard block |
||
864 | 862 | public static function ajax_get_options($type, $attributes, $value = null) |
865 | 863 | { |
866 | 864 | $no_lang = false; |
867 | - $options = self::typeOptions($type, $attributes,$no_lang,false,$value); |
|
868 | - self::fix_encoded_options($options,true); |
|
865 | + $options = self::typeOptions($type, $attributes, $no_lang, false, $value); |
|
866 | + self::fix_encoded_options($options, true); |
|
869 | 867 | $response = Api\Json\Response::get(); |
870 | 868 | $response->data($options); |
871 | 869 | } |
@@ -81,7 +81,8 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function __construct($xml = '') |
83 | 83 | { |
84 | - if($xml) { |
|
84 | + if($xml) |
|
85 | + { |
|
85 | 86 | parent::__construct($xml); |
86 | 87 | } |
87 | 88 | } |
@@ -144,21 +145,33 @@ discard block |
||
144 | 145 | // add option children's values too, "" is not read, therefore we cast to string |
145 | 146 | foreach($this->children as $child) |
146 | 147 | { |
147 | - if ($child->type == 'option') $allowed[] = (string)$child->attrs['value']; |
|
148 | + if ($child->type == 'option') |
|
149 | + { |
|
150 | + $allowed[] = (string)$child->attrs['value']; |
|
151 | + } |
|
148 | 152 | } |
149 | 153 | |
150 | - if (!$this->attrs['multiple'] || !($this->attrs['options'] > 1)) $allowed[] = ''; |
|
154 | + if (!$this->attrs['multiple'] || !($this->attrs['options'] > 1)) |
|
155 | + { |
|
156 | + $allowed[] = ''; |
|
157 | + } |
|
151 | 158 | |
152 | 159 | foreach((array) $value as $val) |
153 | 160 | { |
154 | 161 | // handle empty-label for all widget types |
155 | - if ((string)$val === '' && in_array('', $allowed)) continue; |
|
162 | + if ((string)$val === '' && in_array('', $allowed)) |
|
163 | + { |
|
164 | + continue; |
|
165 | + } |
|
156 | 166 | |
157 | 167 | switch ($widget_type) |
158 | 168 | { |
159 | 169 | case 'select-account': |
160 | 170 | // If in allowed options, skip account check to support app-specific options |
161 | - if(count($allowed) > 0 && in_array($val,$allowed)) continue; |
|
171 | + if(count($allowed) > 0 && in_array($val,$allowed)) |
|
172 | + { |
|
173 | + continue; |
|
174 | + } |
|
162 | 175 | |
163 | 176 | // validate accounts independent of options know to server |
164 | 177 | $account_type = $this->attrs['account_type'] ? $this->attrs['account_type'] : 'accounts'; |
@@ -169,8 +182,7 @@ discard block |
||
169 | 182 | in_array($account_type, array('owngroups', 'memberships')) && |
170 | 183 | !in_array($val, $GLOBALS['egw']->accounts->memberships( |
171 | 184 | $GLOBALS['egw_info']['user']['account_id'], true)) |
172 | - ) |
|
173 | - { |
|
185 | + ) { |
|
174 | 186 | self::set_validation_error($form_name, lang("'%1' is NOT allowed ('%2')!", $val, |
175 | 187 | !$type?'not found' : ($type == 1 ? 'user' : 'group')),''); |
176 | 188 | $value = ''; |
@@ -230,10 +242,13 @@ discard block |
||
230 | 242 | { |
231 | 243 | $value = array_merge($value, (array)self::$request->preserv[$unavailable_name]); |
232 | 244 | } |
233 | - elseif(!$value) // for single cat, we only restore unavailable one, if no other was selected |
|
245 | + elseif(!$value) |
|
246 | + { |
|
247 | + // for single cat, we only restore unavailable one, if no other was selected |
|
234 | 248 | { |
235 | 249 | $value = self::$request->preserv[$unavailable_name]; |
236 | 250 | } |
251 | + } |
|
237 | 252 | } |
238 | 253 | } |
239 | 254 | if (isset($value)) |
@@ -258,10 +273,13 @@ discard block |
||
258 | 273 | { |
259 | 274 | //error_log(__METHOD__."('$cname') this->id=$this->id, this->type=$this->type, this->attrs=".array2string($this->attrs)); |
260 | 275 | $matches = null; |
261 | - if ($cname == '$row') // happens eg. with custom-fields: $cname='$row', this->id='#something' |
|
276 | + if ($cname == '$row') |
|
277 | + { |
|
278 | + // happens eg. with custom-fields: $cname='$row', this->id='#something' |
|
262 | 279 | { |
263 | 280 | $form_name = $this->id; |
264 | 281 | } |
282 | + } |
|
265 | 283 | // happens with fields in nm-header: $cname='nm', this->id='${row}[something]' or '{$row}[something]' |
266 | 284 | elseif (preg_match('/(\${row}|{\$row})\[([^]]+)\]$/', $this->id, $matches)) |
267 | 285 | { |
@@ -281,7 +299,10 @@ discard block |
||
281 | 299 | { |
282 | 300 | $form_name = self::form_name($cname, $this->id, $expand); |
283 | 301 | } |
284 | - if (!is_array(self::$request->sel_options[$form_name])) self::$request->sel_options[$form_name] = array(); |
|
302 | + if (!is_array(self::$request->sel_options[$form_name])) |
|
303 | + { |
|
304 | + self::$request->sel_options[$form_name] = array(); |
|
305 | + } |
|
285 | 306 | $type = $this->attrs['type'] ? $this->attrs['type'] : $this->type; |
286 | 307 | if ($type != 'select' && $type != 'menupopup') |
287 | 308 | { |
@@ -380,7 +401,10 @@ discard block |
||
380 | 401 | if(is_array($label)) |
381 | 402 | { |
382 | 403 | self::fix_encoded_options($label, false); |
383 | - if ($use_array_of_objects && !array_key_exists('value', $label)) $label['value'] = $value; |
|
404 | + if ($use_array_of_objects && !array_key_exists('value', $label)) |
|
405 | + { |
|
406 | + $label['value'] = $value; |
|
407 | + } |
|
384 | 408 | } |
385 | 409 | else |
386 | 410 | { |
@@ -607,13 +631,27 @@ discard block |
||
607 | 631 | |
608 | 632 | case 'select-year': // options: #rows,#before(default=3),#after(default=2) |
609 | 633 | $options[''] = ''; |
610 | - if ($type <= 0) $type = 3; |
|
611 | - if ($type2 <= 0) $type2 = 2; |
|
612 | - if ($type > 100 && $type2 > 100 && $type > $type) { $y = $type; $type=$type2; $type2=$y; } |
|
634 | + if ($type <= 0) |
|
635 | + { |
|
636 | + $type = 3; |
|
637 | + } |
|
638 | + if ($type2 <= 0) |
|
639 | + { |
|
640 | + $type2 = 2; |
|
641 | + } |
|
642 | + if ($type > 100 && $type2 > 100 && $type > $type) |
|
643 | + { |
|
644 | +$y = $type; $type=$type2; $type2=$y; } |
|
613 | 645 | $y = date('Y')-$type; |
614 | - if ($value && $value-$type < $y || $type > 100) $y = $type > 100 ? $type : $value-$type; |
|
646 | + if ($value && $value-$type < $y || $type > 100) |
|
647 | + { |
|
648 | + $y = $type > 100 ? $type : $value-$type; |
|
649 | + } |
|
615 | 650 | $to = date('Y')+$type2; |
616 | - if ($value && $value+$type2 > $to || $type2 > 100) $to = $type2 > 100 ? $type2 : $value+$type2; |
|
651 | + if ($value && $value+$type2 > $to || $type2 > 100) |
|
652 | + { |
|
653 | + $to = $type2 > 100 ? $type2 : $value+$type2; |
|
654 | + } |
|
617 | 655 | for ($n = 0; $y <= $to && $n < 200; ++$n) |
618 | 656 | { |
619 | 657 | $options[$y] = $y++; |
@@ -651,8 +689,14 @@ discard block |
||
651 | 689 | MCAL_M_WEEKEND => 'weekend', |
652 | 690 | ); |
653 | 691 | } |
654 | - if ($weekstart == 'Saturday') $options[MCAL_M_SATURDAY] = 'saturday'; |
|
655 | - if ($weekstart != 'Monday') $options[MCAL_M_SUNDAY] = 'sunday'; |
|
692 | + if ($weekstart == 'Saturday') |
|
693 | + { |
|
694 | + $options[MCAL_M_SATURDAY] = 'saturday'; |
|
695 | + } |
|
696 | + if ($weekstart != 'Monday') |
|
697 | + { |
|
698 | + $options[MCAL_M_SUNDAY] = 'sunday'; |
|
699 | + } |
|
656 | 700 | $options += array( |
657 | 701 | MCAL_M_MONDAY => 'monday', |
658 | 702 | MCAL_M_TUESDAY => 'tuesday', |
@@ -660,8 +704,14 @@ discard block |
||
660 | 704 | MCAL_M_THURSDAY => 'thursday', |
661 | 705 | MCAL_M_FRIDAY => 'friday', |
662 | 706 | ); |
663 | - if ($weekstart != 'Saturday') $options[MCAL_M_SATURDAY] = 'saturday'; |
|
664 | - if ($weekstart == 'Monday') $options[MCAL_M_SUNDAY] = 'sunday'; |
|
707 | + if ($weekstart != 'Saturday') |
|
708 | + { |
|
709 | + $options[MCAL_M_SATURDAY] = 'saturday'; |
|
710 | + } |
|
711 | + if ($weekstart == 'Monday') |
|
712 | + { |
|
713 | + $options[MCAL_M_SUNDAY] = 'sunday'; |
|
714 | + } |
|
665 | 715 | if ($rows >= 2 && $type == 1) |
666 | 716 | { |
667 | 717 | $options += array( |
@@ -698,16 +748,22 @@ discard block |
||
698 | 748 | $type = $type === '' ? 1 : intval($type); // min |
699 | 749 | $type2 = $type2 === '' ? 10 : intval($type2); // max |
700 | 750 | $format = '%d'; |
701 | - if (!empty($type3) && $type3[0] == '0') // leading zero |
|
751 | + if (!empty($type3) && $type3[0] == '0') |
|
752 | + { |
|
753 | + // leading zero |
|
702 | 754 | { |
703 | 755 | $format = '%0'.strlen($type3).'d'; |
704 | 756 | } |
757 | + } |
|
705 | 758 | $type3 = !$type3 ? 1 : intval($type3); // decrement |
706 | 759 | if (($type <= $type2) != ($type3 > 0)) |
707 | 760 | { |
708 | 761 | $type3 = -$type3; // void infinite loop |
709 | 762 | } |
710 | - if (!empty($type4)) $format .= lang($type4); |
|
763 | + if (!empty($type4)) |
|
764 | + { |
|
765 | + $format .= lang($type4); |
|
766 | + } |
|
711 | 767 | for ($i=0,$n=$type; $n <= $type2 && $i <= 100; $n += $type3,++$i) |
712 | 768 | { |
713 | 769 | $options[$n] = sprintf($format,$n); |
@@ -741,10 +797,13 @@ discard block |
||
741 | 797 | { |
742 | 798 | $value = calendar_timezones::id2tz($value); |
743 | 799 | } |
744 | - if ($readonly) // for readonly we dont need to fetch all TZ's |
|
800 | + if ($readonly) |
|
801 | + { |
|
802 | + // for readonly we dont need to fetch all TZ's |
|
745 | 803 | { |
746 | 804 | $options[$value] = calendar_timezones::tz2id($value,'name'); |
747 | 805 | } |
806 | + } |
|
748 | 807 | else |
749 | 808 | { |
750 | 809 | $options = $type ? Api\DateTime::getTimezones() : Api\DateTime::getUserTimezones($value); |
@@ -816,7 +875,10 @@ discard block |
||
816 | 875 | if (!is_array($acc)) |
817 | 876 | { |
818 | 877 | $data = $GLOBALS['egw']->accounts->get_account_data($id); |
819 | - if (!isset($data[$id])) return '#'.$id; |
|
878 | + if (!isset($data[$id])) |
|
879 | + { |
|
880 | + return '#'.$id; |
|
881 | + } |
|
820 | 882 | foreach(array('type','lid','firstname','lastname') as $name) |
821 | 883 | { |
822 | 884 | $acc['account_'.$name] = $data[$id][$name]; |
@@ -844,7 +906,8 @@ discard block |
||
844 | 906 | $acc['account_firstname'],$acc['account_lastname']); |
845 | 907 | break; |
846 | 908 | } |
847 | - if($show_type) { |
|
909 | + if($show_type) |
|
910 | + { |
|
848 | 911 | $info = array( |
849 | 912 | 'label' => $info, |
850 | 913 | 'icon' => $acc['account_type'] == 'g' ? 'addressbook/group' : 'user' |
@@ -42,17 +42,17 @@ discard block |
||
42 | 42 | * @param array $params =array('') parameter(s) first parameter has to be cname! |
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 | - $cname =& $params[0]; |
|
48 | - $expand =& $params[1]; |
|
47 | + $cname = & $params[0]; |
|
48 | + $expand = & $params[1]; |
|
49 | 49 | $old_cname = $params[0]; |
50 | 50 | $old_expand = $params[1]; |
51 | 51 | |
52 | 52 | if ($this->id && $this->type != 'groupbox') $cname = self::form_name($cname, $this->id, $params[1]); |
53 | 53 | if ($expand['cname'] !== $cname && $cname) |
54 | 54 | { |
55 | - $expand['cont'] =& self::get_array(self::$request->content, $cname); |
|
55 | + $expand['cont'] = & self::get_array(self::$request->content, $cname); |
|
56 | 56 | $expand['cname'] = $cname; |
57 | 57 | } |
58 | 58 | if ($respect_disabled && ($disabled = $this->attrs['disabled'] && self::check_disabled($this->attrs['disabled'], $expand))) |
@@ -67,11 +67,11 @@ discard block |
||
67 | 67 | |
68 | 68 | // Expand children |
69 | 69 | $columns_disabled = null; |
70 | - for($n = 0; ; ++$n) |
|
70 | + for ($n = 0; ; ++$n) |
|
71 | 71 | { |
72 | 72 | if (isset($this->children[$n])) |
73 | 73 | { |
74 | - $child =& $this->children[$n]; |
|
74 | + $child = & $this->children[$n]; |
|
75 | 75 | // If type has something that can be expanded, we need to expand it so the correct method is run |
76 | 76 | $this->expand_widget($child, $expand); |
77 | 77 | } |
@@ -107,17 +107,17 @@ discard block |
||
107 | 107 | */ |
108 | 108 | private function need_autorepeat(Etemplate\Widget $widget, $cname, array $expand) |
109 | 109 | { |
110 | - foreach(array($widget) + $widget->children as $check_widget) |
|
110 | + foreach (array($widget) + $widget->children as $check_widget) |
|
111 | 111 | { |
112 | 112 | $pat = $check_widget->id; |
113 | - while(($pattern = strstr($pat, '$'))) |
|
113 | + while (($pattern = strstr($pat, '$'))) |
|
114 | 114 | { |
115 | - $pat = substr($pattern,$pattern[1] == '{' ? 2 : 1); |
|
115 | + $pat = substr($pattern, $pattern[1] == '{' ? 2 : 1); |
|
116 | 116 | |
117 | - $Ok = $pat[0] == 'r' && !(substr($pat,0,2) == 'r_' || |
|
118 | - substr($pat,0,4) == 'row_' && substr($pat,0,8) != 'row_cont'); |
|
117 | + $Ok = $pat[0] == 'r' && !(substr($pat, 0, 2) == 'r_' || |
|
118 | + substr($pat, 0, 4) == 'row_' && substr($pat, 0, 8) != 'row_cont'); |
|
119 | 119 | |
120 | - if ($Ok && ($fname=self::form_name($cname, $check_widget->id, $expand)) && |
|
120 | + if ($Ok && ($fname = self::form_name($cname, $check_widget->id, $expand)) && |
|
121 | 121 | // need to break if fname ends in [] as get_array() will ignore it and returns whole array |
122 | 122 | // for an id like "run[$row_cont[appname]]" |
123 | 123 | substr($fname, -2) != '[]' && |
@@ -49,7 +49,10 @@ discard block |
||
49 | 49 | $old_cname = $params[0]; |
50 | 50 | $old_expand = $params[1]; |
51 | 51 | |
52 | - if ($this->id && $this->type != 'groupbox') $cname = self::form_name($cname, $this->id, $params[1]); |
|
52 | + if ($this->id && $this->type != 'groupbox') |
|
53 | + { |
|
54 | + $cname = self::form_name($cname, $this->id, $params[1]); |
|
55 | + } |
|
53 | 56 | if ($expand['cname'] !== $cname && $cname) |
54 | 57 | { |
55 | 58 | $expand['cont'] =& self::get_array(self::$request->content, $cname); |
@@ -121,10 +124,13 @@ discard block |
||
121 | 124 | // need to break if fname ends in [] as get_array() will ignore it and returns whole array |
122 | 125 | // for an id like "run[$row_cont[appname]]" |
123 | 126 | substr($fname, -2) != '[]' && |
124 | - ($value = self::get_array(self::$request->content, $fname)) !== null) // null = not found (can be false!) |
|
127 | + ($value = self::get_array(self::$request->content, $fname)) !== null) |
|
128 | + { |
|
129 | + // null = not found (can be false!) |
|
125 | 130 | { |
126 | 131 | //error_log(__METHOD__."($widget,$cname) $this autorepeating row $expand[row] because of $check_widget->id = '$fname' is ".array2string($value)); |
127 | 132 | unset($value); |
133 | + } |
|
128 | 134 | return true; |
129 | 135 | } |
130 | 136 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * @param string $cname |
27 | 27 | * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' |
28 | 28 | */ |
29 | - public function beforeSendToClient($cname, array $expand=null) |
|
29 | + public function beforeSendToClient($cname, array $expand = null) |
|
30 | 30 | { |
31 | 31 | $matches = null; |
32 | 32 | if ($cname == '$row') // happens eg. with custom-fields: $cname='$row', this->id='#something' |
@@ -55,13 +55,13 @@ discard block |
||
55 | 55 | |
56 | 56 | // Make sure s, etc. are properly encoded when sent, and not double-encoded |
57 | 57 | $options = (isset(self::$request->sel_options[$form_name]) ? $form_name : $this->id); |
58 | - if(is_array(self::$request->sel_options[$options])) |
|
58 | + if (is_array(self::$request->sel_options[$options])) |
|
59 | 59 | { |
60 | 60 | |
61 | 61 | // Fix any custom options from application |
62 | - self::fix_encoded_options(self::$request->sel_options[$options],true); |
|
62 | + self::fix_encoded_options(self::$request->sel_options[$options], true); |
|
63 | 63 | |
64 | - if(!self::$request->sel_options[$options]) |
|
64 | + if (!self::$request->sel_options[$options]) |
|
65 | 65 | { |
66 | 66 | unset(self::$request->sel_options[$options]); |
67 | 67 | } |
@@ -29,10 +29,13 @@ |
||
29 | 29 | public function beforeSendToClient($cname, array $expand=null) |
30 | 30 | { |
31 | 31 | $matches = null; |
32 | - if ($cname == '$row') // happens eg. with custom-fields: $cname='$row', this->id='#something' |
|
32 | + if ($cname == '$row') |
|
33 | + { |
|
34 | + // happens eg. with custom-fields: $cname='$row', this->id='#something' |
|
33 | 35 | { |
34 | 36 | $form_name = $this->id; |
35 | 37 | } |
38 | + } |
|
36 | 39 | // happens with fields in nm-header: $cname='nm', this->id='${row}[something]' or '{$row}[something]' |
37 | 40 | elseif (preg_match('/(\${row}|{\$row})\[([^]]+)\]$/', $this->id, $matches)) |
38 | 41 | { |
@@ -26,7 +26,7 @@ |
||
26 | 26 | * @param string|XMLReader $xml |
27 | 27 | * @param boolean $cloned =true true: object does NOT need to be cloned, false: to set attribute, set them in cloned object |
28 | 28 | */ |
29 | - public function set_attrs($xml, $cloned=true) |
|
29 | + public function set_attrs($xml, $cloned = true) |
|
30 | 30 | { |
31 | 31 | parent::set_attrs($xml, $cloned); |
32 | 32 |
@@ -29,18 +29,18 @@ discard block |
||
29 | 29 | * @param string $cname |
30 | 30 | * @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont' |
31 | 31 | */ |
32 | - public function beforeSendToClient($cname, array $expand=null) |
|
32 | + public function beforeSendToClient($cname, array $expand = null) |
|
33 | 33 | { |
34 | - switch($this->attrs['type']) |
|
34 | + switch ($this->attrs['type']) |
|
35 | 35 | { |
36 | 36 | case "link-entry": |
37 | 37 | self::$transformation['type'] = $this->attrs['type'] = 'nextmatch-entryheader'; |
38 | 38 | break; |
39 | 39 | default: |
40 | - list($type) = explode('-',$this->attrs['type']); |
|
41 | - if($type == 'select') |
|
40 | + list($type) = explode('-', $this->attrs['type']); |
|
41 | + if ($type == 'select') |
|
42 | 42 | { |
43 | - if(in_array($this->attrs['type'], Widget\Select::$cached_types)) |
|
43 | + if (in_array($this->attrs['type'], Widget\Select::$cached_types)) |
|
44 | 44 | { |
45 | 45 | $widget_type = $this->attrs['type']; |
46 | 46 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $this->setElementAttribute($form_name, 'options', trim($this->attrs['widget_options']) != '' ? $this->attrs['widget_options'] : ''); |
54 | 54 | |
55 | 55 | $this->setElementAttribute($form_name, 'type', $this->attrs['type']); |
56 | - if($widget_type) |
|
56 | + if ($widget_type) |
|
57 | 57 | { |
58 | 58 | $this->setElementAttribute($form_name, 'widget_type', $widget_type); |
59 | 59 | } |
@@ -69,11 +69,11 @@ discard block |
||
69 | 69 | * @param array $content |
70 | 70 | * @param array &$validated=array() validated content |
71 | 71 | */ |
72 | - public function validate($cname, array $expand, array $content, &$validated=array()) |
|
72 | + public function validate($cname, array $expand, array $content, &$validated = array()) |
|
73 | 73 | { |
74 | 74 | $value = $value_in = self::get_array($content, $form_name); |
75 | 75 | |
76 | - $valid =& self::get_array($validated, $form_name, true); |
|
76 | + $valid = & self::get_array($validated, $form_name, true); |
|
77 | 77 | // returning null instead of array(), as array() will be overwritten by etemplate_new::complete_array_merge() |
78 | 78 | // with preserved old content and therefore user can not empty a taglist |
79 | 79 | $valid = $value ? $value : null; |