@@ -87,7 +87,7 @@ |
||
87 | 87 | * Converts the selected options according to the multiple_storagemode setting. |
88 | 88 | * |
89 | 89 | * @return mixed The data converted to the final data storage. |
90 | - */ |
|
90 | + */ |
|
91 | 91 | function convert_multiple_to_storage() |
92 | 92 | { |
93 | 93 | switch ($this->config['type_config']['multiple_storagemode']) { |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | { |
45 | 45 | //workaround for weird mgd API behavior where setting falsy (i.e. deleting) a nonexistent parameter |
46 | 46 | //returns an error |
47 | - if ( !$this->value |
|
47 | + if (!$this->value |
|
48 | 48 | && $this->load() === null) { |
49 | 49 | return true; |
50 | 50 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | switch ($this->config['type_config']['multiple_storagemode']) { |
64 | 64 | case 'serialized': |
65 | 65 | case 'array': |
66 | - if ( !is_array($source) |
|
66 | + if (!is_array($source) |
|
67 | 67 | && empty($source)) { |
68 | 68 | $source = array(); |
69 | 69 | } |
@@ -244,8 +244,8 @@ |
||
244 | 244 | } |
245 | 245 | } elseif ( $item_name == 'username' |
246 | 246 | && $object instanceof midcom_db_person) { |
247 | - $account = new midcom_core_account($object); |
|
248 | - return $account->get_username(); |
|
247 | + $account = new midcom_core_account($object); |
|
248 | + return $account->get_username(); |
|
249 | 249 | } |
250 | 250 | return $object->$item_name; |
251 | 251 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | { |
53 | 53 | $qb = call_user_func(array($this->_request['class'], 'new_query_builder')); |
54 | 54 | |
55 | - if ( !empty($this->_request['constraints']) |
|
55 | + if (!empty($this->_request['constraints']) |
|
56 | 56 | && is_array($this->_request['constraints'])) { |
57 | 57 | $this->_apply_constraints($qb, $this->_request['constraints']); |
58 | 58 | } |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | $qb->end_group(); |
65 | 65 | } |
66 | 66 | |
67 | - if ( !empty($this->_request['orders']) |
|
67 | + if (!empty($this->_request['orders']) |
|
68 | 68 | && is_array($this->_request['orders'])) { |
69 | 69 | ksort($this->_request['orders']); |
70 | 70 | foreach ($this->_request['orders'] as $data) { |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | |
84 | 84 | ksort($constraints); |
85 | 85 | foreach ($constraints as $key => $data) { |
86 | - if ( !array_key_exists('value', $data) |
|
86 | + if (!array_key_exists('value', $data) |
|
87 | 87 | || empty($data['field']) |
88 | 88 | || empty($data['op'])) { |
89 | 89 | debug_add("Constraint #{$key} is not correctly defined, skipping", MIDCOM_LOG_WARN); |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | { |
157 | 157 | $query = $this->_request["term"]; |
158 | 158 | $wildcard_query = $query; |
159 | - if ( isset($this->_request['auto_wildcards']) |
|
159 | + if (isset($this->_request['auto_wildcards']) |
|
160 | 160 | && strpos($query, '%') === false) { |
161 | 161 | switch ($this->_request['auto_wildcards']) { |
162 | 162 | case 'start': |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | } |
243 | 243 | break; |
244 | 244 | } |
245 | - } elseif ( $item_name == 'username' |
|
245 | + } elseif ($item_name == 'username' |
|
246 | 246 | && $object instanceof midcom_db_person) { |
247 | 247 | $account = new midcom_core_account($object); |
248 | 248 | return $account->get_username(); |
@@ -144,15 +144,15 @@ discard block |
||
144 | 144 | 'validation' => array() |
145 | 145 | )); |
146 | 146 | |
147 | - $normalize_widget = function (Options $options, $value) { |
|
148 | - if ( $value == 'images' |
|
147 | + $normalize_widget = function(Options $options, $value) { |
|
148 | + if ($value == 'images' |
|
149 | 149 | || $value == 'downloads') { |
150 | 150 | return 'subform'; |
151 | 151 | } |
152 | 152 | return $value; |
153 | 153 | }; |
154 | 154 | |
155 | - $normalize_storage = function (Options $options, $value) use ($name) { |
|
155 | + $normalize_storage = function(Options $options, $value) use ($name) { |
|
156 | 156 | $default = array( |
157 | 157 | 'location' => 'parameter', |
158 | 158 | 'domain' => 'midcom.helper.datamanager2', |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | } |
164 | 164 | if ($value === null) { |
165 | 165 | |
166 | - if($options['type'] === 'privilege') |
|
166 | + if ($options['type'] === 'privilege') |
|
167 | 167 | { |
168 | 168 | return array( |
169 | 169 | 'location' => 'privilege', |
@@ -193,9 +193,9 @@ discard block |
||
193 | 193 | return $value; |
194 | 194 | }; |
195 | 195 | |
196 | - $normalize_validation = function (Options $options, $config) { |
|
196 | + $normalize_validation = function(Options $options, $config) { |
|
197 | 197 | $validation = array(); |
198 | - if (array_key_exists('validation',(array) $config)) { |
|
198 | + if (array_key_exists('validation', (array) $config)) { |
|
199 | 199 | $validation = (array) $config['validation']; |
200 | 200 | } |
201 | 201 | |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | $rule = array('type' => $rule); |
205 | 205 | } elseif (!array_key_exists('type', $rule)) { |
206 | 206 | throw new midcom_error("Missing validation rule type for rule {$key} on field {$config['name']}, this is a required option."); |
207 | - } elseif ( $rule['type'] == 'compare' |
|
207 | + } elseif ($rule['type'] == 'compare' |
|
208 | 208 | && !array_key_exists('compare_with', $rule)) { |
209 | 209 | throw new midcom_error("Missing compare_with option for compare type rule {$key} on field {$config['name']}, this is a required option."); |
210 | 210 | } |
@@ -163,8 +163,7 @@ |
||
163 | 163 | } |
164 | 164 | if ($value === null) { |
165 | 165 | |
166 | - if($options['type'] === 'privilege') |
|
167 | - { |
|
166 | + if($options['type'] === 'privilege') { |
|
168 | 167 | return array( |
169 | 168 | 'location' => 'privilege', |
170 | 169 | 'name' => $name |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function configureOptions(OptionsResolver $resolver) |
31 | 31 | { |
32 | - $resolver->setNormalizer('widget_config', function (Options $options, $value) { |
|
32 | + $resolver->setNormalizer('widget_config', function(Options $options, $value) { |
|
33 | 33 | $widget_defaults = array( |
34 | 34 | 'creation_mode_enabled' => false, |
35 | 35 | 'class' => null, |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | |
62 | 62 | return helper::resolve_options($widget_defaults, $value); |
63 | 63 | }); |
64 | - $resolver->setNormalizer('type_config', function (Options $options, $value) { |
|
64 | + $resolver->setNormalizer('type_config', function(Options $options, $value) { |
|
65 | 65 | $type_defaults = array( |
66 | 66 | 'options' => array(), |
67 | 67 | 'allow_other' => false, |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | public function configureOptions(OptionsResolver $resolver) |
46 | 46 | { |
47 | 47 | $this->res = $resolver; |
48 | - $map_privilege = function (Options $options) { |
|
48 | + $map_privilege = function(Options $options) { |
|
49 | 49 | $return_options = $this->defaultChoices; |
50 | 50 | return $return_options; |
51 | 51 | }; |
@@ -66,21 +66,21 @@ discard block |
||
66 | 66 | $view->vars['type_conf'] = $options['type_config']; |
67 | 67 | } |
68 | 68 | |
69 | - public function get_effective_value(array $options,$object = null) |
|
69 | + public function get_effective_value(array $options, $object = null) |
|
70 | 70 | { |
71 | 71 | if (!$object) |
72 | 72 | { |
73 | 73 | $defaults = midcom::get()->auth->acl->get_default_privileges(); |
74 | 74 | return(($defaults[$options['privilege_name']] === MIDCOM_PRIVILEGE_ALLOW)); |
75 | 75 | } |
76 | - if ($options['assignee']== 'SELF') { |
|
76 | + if ($options['assignee'] == 'SELF') { |
|
77 | 77 | if ($object instanceof midcom_db_group) { |
78 | 78 | //There's no sane way to query group privileges in auth right now, so we only return defaults |
79 | 79 | $defaults = midcom::get()->auth->acl->get_default_privileges(); |
80 | 80 | return(($defaults[$options['privilege_name']] === MIDCOM_PRIVILEGE_ALLOW)); |
81 | 81 | } |
82 | 82 | return(midcom::get()->auth->can_user_do($options['privilege_name'], |
83 | - new midcom_core_user($object->__object->id),$options['classname'])); |
|
83 | + new midcom_core_user($object->__object->id), $options['classname'])); |
|
84 | 84 | } |
85 | 85 | if ($principal = midcom::get()->auth->get_assignee($options['assignee'])) { |
86 | 86 | return $object->can_do($options['privilege_name'], $principal); |
@@ -88,21 +88,21 @@ discard block |
||
88 | 88 | return $object->can_do($options['privilege_name'], $options['assignee']); |
89 | 89 | } |
90 | 90 | |
91 | - public function render_choices(array $options,$object = null) |
|
91 | + public function render_choices(array $options, $object = null) |
|
92 | 92 | { |
93 | 93 | $l10n = midcom::get()->i18n->get_l10n('midcom.datamanager'); |
94 | - $inherit = $this->get_effective_value($options,$object); |
|
94 | + $inherit = $this->get_effective_value($options, $object); |
|
95 | 95 | $allow = 'widget privilege: allow'; |
96 | 96 | $deny = 'widget privilege: deny'; |
97 | 97 | |
98 | 98 | if ($inherit === true) { |
99 | 99 | $base = $l10n->get('widget privilege: inherit %s'); |
100 | 100 | $allow = $l10n->get($allow); |
101 | - $d = sprintf($base,$allow); |
|
101 | + $d = sprintf($base, $allow); |
|
102 | 102 | } elseif ($inherit === false) { |
103 | 103 | $base = $l10n->get('widget privilege: inherit %s'); |
104 | 104 | $deny = $l10n->get($deny); |
105 | - $d = sprintf($base,$deny); |
|
105 | + $d = sprintf($base, $deny); |
|
106 | 106 | } |
107 | 107 | return $d; |
108 | 108 | } |
@@ -68,8 +68,7 @@ discard block |
||
68 | 68 | |
69 | 69 | public function get_effective_value(array $options,$object = null) |
70 | 70 | { |
71 | - if (!$object) |
|
72 | - { |
|
71 | + if (!$object) { |
|
73 | 72 | $defaults = midcom::get()->auth->acl->get_default_privileges(); |
74 | 73 | return(($defaults[$options['privilege_name']] === MIDCOM_PRIVILEGE_ALLOW)); |
75 | 74 | } |
@@ -112,8 +111,7 @@ discard block |
||
112 | 111 | $object_found = false; |
113 | 112 | $help_obj = $object; |
114 | 113 | |
115 | - while (!$object_found) |
|
116 | - { |
|
114 | + while (!$object_found) { |
|
117 | 115 | if ($help_obj instanceof dbacontainer) { |
118 | 116 | $object_found = true; |
119 | 117 | return $help_obj->get_value(); |
@@ -22,7 +22,7 @@ |
||
22 | 22 | $this->config['type_config']['privilege_name'], |
23 | 23 | $this->config['type_config']['assignee'], |
24 | 24 | $this->config['type_config']['classname'] |
25 | - ); |
|
25 | + ); |
|
26 | 26 | |
27 | 27 | return $source->__get('value'); |
28 | 28 | } |
@@ -34,7 +34,7 @@ |
||
34 | 34 | { |
35 | 35 | //workaround for weird mgd API behavior where setting falsy (i.e. deleting) a nonexistent parameter |
36 | 36 | //returns an error |
37 | - if ( !$this->value |
|
37 | + if (!$this->value |
|
38 | 38 | && $this->load() === null) { |
39 | 39 | return true; |
40 | 40 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | { |
37 | 37 | $string = ''; |
38 | 38 | foreach ($view as $child) { |
39 | - if ( array_key_exists('start_fieldset', $child->vars) |
|
39 | + if (array_key_exists('start_fieldset', $child->vars) |
|
40 | 40 | && $child->vars['start_fieldset'] !== null) { |
41 | 41 | $string .= '<fieldset class="fieldset">'; |
42 | 42 | if (!empty($child->vars['start_fieldset']['title'])) { |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | } |
45 | 45 | } |
46 | 46 | $string .= $this->renderer->row($child); |
47 | - if ( array_key_exists('end_fieldset', $child->vars) |
|
47 | + if (array_key_exists('end_fieldset', $child->vars) |
|
48 | 48 | && $child->vars['end_fieldset'] !== null) { |
49 | 49 | $end_fieldsets = max(1, (int) $child->vars['end_fieldset']); |
50 | 50 | for ($i = 0; $i < $end_fieldsets; $i++) { |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | public function form_end(FormView $view, array $data) |
59 | 59 | { |
60 | 60 | $string = ''; |
61 | - if ( !isset($data['render_rest']) |
|
61 | + if (!isset($data['render_rest']) |
|
62 | 62 | || $data['render_rest']) { |
63 | 63 | $string .= $this->renderer->rest($view); |
64 | 64 | } |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | public function form_widget_simple(FormView $view, array $data) |
144 | 144 | { |
145 | 145 | $type = isset($data['type']) ? $data['type'] : 'text'; |
146 | - if ( $type == 'text' |
|
146 | + if ($type == 'text' |
|
147 | 147 | || $type == 'password' |
148 | 148 | || $type == 'email') { |
149 | 149 | $view->vars['attr']['class'] = 'shorttext'; |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | |
152 | 152 | $string = '<input type="' . $type . '"'; |
153 | 153 | $string .= $this->renderer->block($view, 'widget_attributes'); |
154 | - if ( !empty($data['value']) |
|
154 | + if (!empty($data['value']) |
|
155 | 155 | || is_numeric($data['value'])) { |
156 | 156 | $string .= ' value="' . $this->escape($data['value']) . '"'; |
157 | 157 | } |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | $jsinit .= "midcom_helper_datamanager2_autocomplete.create_dm2_widget('{$element_id}_search_input', {$data['min_chars']});\n"; |
185 | 185 | |
186 | 186 | $string = '<fieldset ' . $this->renderer->block($view, 'widget_container_attributes') . '>'; |
187 | - $string .= $this->renderer->widget($view['selection']); |
|
187 | + $string .= $this->renderer->widget($view['selection']); |
|
188 | 188 | $string .= ' ' . $this->renderer->widget($view['search_input']); |
189 | 189 | $string .= '</fieldset>'; |
190 | 190 | return $string . $this->jsinit($jsinit); |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | public function choice_widget_collapsed(FormView $view, array $data) |
220 | 220 | { |
221 | 221 | $string = '<select'; |
222 | - if ( $data['required'] |
|
222 | + if ($data['required'] |
|
223 | 223 | && null === $data['empty_value'] |
224 | 224 | && $data['empty_value_in_choices'] === false |
225 | 225 | && $data['multiple'] === false) { |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | $string .= '>'; |
234 | 234 | if (null !== $data['empty_value']) { |
235 | 235 | $string .= '<option value=""'; |
236 | - if ( $data['required'] |
|
236 | + if ($data['required'] |
|
237 | 237 | && empty($data['value']) |
238 | 238 | && "0" !== $data['value']) { |
239 | 239 | $string .= ' selected="selected"'; |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | if (!empty($data['form']->vars['privilege'])) { |
256 | 256 | $obj = $data['form']; |
257 | 257 | $obj = $data['form']->vars['privilege']->search_for_object($obj); |
258 | - $new_label = $data['form']->vars['privilege']->render_choices($data['form']->vars['type_conf'],$obj); |
|
258 | + $new_label = $data['form']->vars['privilege']->render_choices($data['form']->vars['type_conf'], $obj); |
|
259 | 259 | $view->children[2]->vars['label'] = $new_label; |
260 | 260 | } |
261 | 261 | return $this->choice_widget_expanded($view, $data); |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | $string .= $this->renderer->widget($view['date']); |
310 | 310 | |
311 | 311 | if (isset($view['time'])) { |
312 | - $string .= ' '. $this->renderer->widget($view['time']); |
|
312 | + $string .= ' ' . $this->renderer->widget($view['time']); |
|
313 | 313 | } |
314 | 314 | $string .= $data['jsinit']; |
315 | 315 | return $string . '</fieldset>'; |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | if (!empty($data['value'])) { |
324 | 324 | $string .= '<a href="' . $view->vars['value']['url'] . '" target="_new"><img src="' . $view->vars['value']['url'] . '" class="preview-image">'; |
325 | 325 | |
326 | - if ( $data['value']['size_x'] |
|
326 | + if ($data['value']['size_x'] |
|
327 | 327 | && $data['value']['size_y']) { |
328 | 328 | $size = "{$data['value']['size_x']}×{$data['value']['size_y']}"; |
329 | 329 | } else { |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | if (!empty($values)) { |
363 | 363 | $string .= '<ul>'; |
364 | 364 | foreach ($values as $identifier => $info) { |
365 | - if ( $info['size_x'] |
|
365 | + if ($info['size_x'] |
|
366 | 366 | && $info['size_y']) { |
367 | 367 | $size = "{$info['size_x']}x{$info['size_y']}"; |
368 | 368 | } else { |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | $string .= '<label class="midcom_datamanager_photo_lable">' . $this->renderer->humanize('delete photo') . ' ' . $this->renderer->widget($data['form']['delete']) . '</label>'; |
381 | 381 | $string .= '</td></tr></table></div>'; |
382 | 382 | |
383 | - return $string . $this->jsinit('init_photo_widget("' . $view->vars['id'] .'");'); |
|
383 | + return $string . $this->jsinit('init_photo_widget("' . $view->vars['id'] . '");'); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | public function subform_widget(FormView $view, array $data) |