@@ -41,12 +41,12 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function add_elements_to_form($attributes) |
43 | 43 | { |
44 | - if ( $this->_type->storage->object |
|
44 | + if ($this->_type->storage->object |
|
45 | 45 | && !$this->_type->storage->object->can_do('midgard:privileges')) { |
46 | 46 | return; |
47 | 47 | } |
48 | 48 | $effective_value = $this->_type->get_effective_value(); |
49 | - if ( $this->_type->get_value() === MIDCOM_PRIVILEGE_INHERIT |
|
49 | + if ($this->_type->get_value() === MIDCOM_PRIVILEGE_INHERIT |
|
50 | 50 | || ($this->_type->get_value() !== MIDCOM_PRIVILEGE_DENY) !== $effective_value) { |
51 | 51 | $effective_value = $effective_value ? 'allow' : 'deny'; |
52 | 52 | $inherit_label = sprintf($this->_l10n->get('widget privilege: inherit %s'), $this->_l10n->get('widget privilege: ' . $effective_value)); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public function sync_type_with_widget($results) |
104 | 104 | { |
105 | - if ( $this->_type->storage->object |
|
105 | + if ($this->_type->storage->object |
|
106 | 106 | && !$this->_type->storage->object->can_do('midgard:privileges')) { |
107 | 107 | return; |
108 | 108 | } |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | |
113 | 113 | public function is_frozen() |
114 | 114 | { |
115 | - if ( ( $this->_type->storage->object |
|
115 | + if (($this->_type->storage->object |
|
116 | 116 | && !$this->_type->storage->object->can_do('midgard:privileges')) |
117 | 117 | || !$this->_elements) { |
118 | 118 | return false; |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | |
123 | 123 | public function freeze() |
124 | 124 | { |
125 | - if ( ( $this->_type->storage->object |
|
125 | + if (($this->_type->storage->object |
|
126 | 126 | && !$this->_type->storage->object->can_do('midgard:privileges')) |
127 | 127 | || !$this->_elements) { |
128 | 128 | return; |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | |
136 | 136 | public function unfreeze() |
137 | 137 | { |
138 | - if ( ( $this->_type->storage->object |
|
138 | + if (($this->_type->storage->object |
|
139 | 139 | && !$this->_type->storage->object->can_do('midgard:privileges')) |
140 | 140 | || !$this->_elements) { |
141 | 141 | return; |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | |
185 | 185 | if ($path === $schemadb) { |
186 | 186 | // Infinite loop, set an UI message and stop executing |
187 | - if ( !isset($schema['extends']['name']) |
|
187 | + if (!isset($schema['extends']['name']) |
|
188 | 188 | || $schema['extends']['name'] === $schema_name) { |
189 | 189 | $snippet_path = $this->_get_snippet_link($path); |
190 | 190 | midcom::get()->uimessages->add($this->_l10n->get('midcom.helper.datamanager2'), sprintf($this->_l10n->get('schema %s:%s extends itself'), $snippet_path, $schema_name), 'error'); |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | return $schemadb; |
283 | 283 | } |
284 | 284 | debug_print_r('Passed schema db was:', $schemadb); |
285 | - throw new midcom_error( 'Failed to access the schema database: Invalid variable type while constructing.'); |
|
285 | + throw new midcom_error('Failed to access the schema database: Invalid variable type while constructing.'); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | /** |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | if (!array_key_exists($name, $this->_raw_schemadb)) { |
301 | 301 | throw new midcom_error("The schema {$name} was not found in the schema database."); |
302 | 302 | } |
303 | - $this->_raw_schema =& $this->_raw_schemadb[$name]; |
|
303 | + $this->_raw_schema = & $this->_raw_schemadb[$name]; |
|
304 | 304 | |
305 | 305 | // Populate the l10n_schema member |
306 | 306 | if (array_key_exists('l10n_db', $this->_raw_schema)) { |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | $this->append_field($name, $data); |
335 | 335 | } |
336 | 336 | |
337 | - if ( $this->_config->get('include_metadata_required') |
|
337 | + if ($this->_config->get('include_metadata_required') |
|
338 | 338 | && $this->_schemadb_path |
339 | 339 | && $this->_schemadb_path != midcom::get()->config->get('metadata_schema')) { |
340 | 340 | // Include required fields from metadata schema to the schema |
@@ -446,11 +446,11 @@ discard block |
||
446 | 446 | } |
447 | 447 | } |
448 | 448 | |
449 | - if ( !array_key_exists('type_config', $config) |
|
449 | + if (!array_key_exists('type_config', $config) |
|
450 | 450 | || !is_array($config['type_config'])) { |
451 | 451 | $config['type_config'] = array(); |
452 | 452 | } |
453 | - if ( !array_key_exists('widget_config', $config) |
|
453 | + if (!array_key_exists('widget_config', $config) |
|
454 | 454 | || !is_array($config['type_config'])) { |
455 | 455 | $config['widget_config'] = array(); |
456 | 456 | } |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | $rule = array('type' => $rule); |
471 | 471 | } elseif (!array_key_exists('type', $rule)) { |
472 | 472 | throw new midcom_error("Missing validation rule type for rule {$key} on field {$config['name']}, this is a required option."); |
473 | - } elseif ( $rule['type'] == 'compare' |
|
473 | + } elseif ($rule['type'] == 'compare' |
|
474 | 474 | && !array_key_exists('compare_with', $rule)) { |
475 | 475 | throw new midcom_error("Missing compare_with option for compare type rule {$key} on field {$config['name']}, this is a required option."); |
476 | 476 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | public function __construct(array &$schemadb) |
94 | 94 | { |
95 | 95 | parent::__construct(); |
96 | - $this->_schemadb =& $schemadb; |
|
96 | + $this->_schemadb = & $schemadb; |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | return false; |
120 | 120 | } |
121 | 121 | |
122 | - $this->schema =& $this->_schemadb[$name]; |
|
122 | + $this->schema = & $this->_schemadb[$name]; |
|
123 | 123 | $this->schema_name = $name; |
124 | 124 | |
125 | 125 | return $this->_load_types(); |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | } |
240 | 240 | |
241 | 241 | if (!$this->set_schema($schema)) { |
242 | - if ( $strict |
|
242 | + if ($strict |
|
243 | 243 | || $schema == null) { |
244 | 244 | return false; |
245 | 245 | } |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | echo "<div class=\"midcom_helper_datamanager2_view\">\n"; |
463 | 463 | $fieldset_count = 0; |
464 | 464 | foreach ($this->schema->field_order as $name) { |
465 | - $config =& $this->schema->fields[$name]; |
|
465 | + $config = & $this->schema->fields[$name]; |
|
466 | 466 | if (!empty($config['hidden'])) { |
467 | 467 | continue; |
468 | 468 | } |
@@ -490,17 +490,17 @@ discard block |
||
490 | 490 | } |
491 | 491 | |
492 | 492 | echo " <h2{$class}>\n"; |
493 | - echo " ". $this->schema->translate_schema_string($fieldset['title']) ."\n"; |
|
493 | + echo " " . $this->schema->translate_schema_string($fieldset['title']) . "\n"; |
|
494 | 494 | echo " </h2>\n"; |
495 | 495 | } |
496 | 496 | if (isset($fieldset['description'])) { |
497 | - echo "<p>". $this->schema->translate_schema_string($fieldset['description']) . "</p>\n"; |
|
497 | + echo "<p>" . $this->schema->translate_schema_string($fieldset['description']) . "</p>\n"; |
|
498 | 498 | } |
499 | 499 | $fieldset_count++; |
500 | 500 | } |
501 | 501 | |
502 | 502 | $field_value = $values[$name]; |
503 | - if ( !$skip_empty |
|
503 | + if (!$skip_empty |
|
504 | 504 | || trim($field_value) !== '') { |
505 | 505 | echo "<div class=\"field\">\n"; |
506 | 506 | echo '<div class="title">' . $this->schema->translate_schema_string($this->schema->fields[$name]['title']) . "</div>\n"; |
@@ -512,7 +512,7 @@ discard block |
||
512 | 512 | echo "</div>\n"; |
513 | 513 | } |
514 | 514 | |
515 | - if ( !isset($config['end_fieldset']) |
|
515 | + if (!isset($config['end_fieldset']) |
|
516 | 516 | || $fieldset_count <= 0) { |
517 | 517 | // No more fieldsets to close |
518 | 518 | continue; |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | parent::__construct(); |
126 | 126 | |
127 | 127 | $this->_schema = $schema; |
128 | - $this->_types =& $types; |
|
128 | + $this->_types = & $types; |
|
129 | 129 | $this->state = $state; |
130 | 130 | } |
131 | 131 | |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | private function _load_field_default($name, $config) |
261 | 261 | { |
262 | 262 | $field_default = $this->widgets[$name]->get_default(); |
263 | - if ( null === $field_default |
|
263 | + if (null === $field_default |
|
264 | 264 | && !empty($config['default'])) { |
265 | 265 | // Empty value from widget, run defaults |
266 | 266 | $field_default = $config['default']; |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | $accesskey = ''; |
297 | 297 | if ($operation == 'save') { |
298 | 298 | $accesskey = 's'; |
299 | - $class .= ' save_'.$key; |
|
299 | + $class .= ' save_' . $key; |
|
300 | 300 | } elseif ($operation == 'cancel') { |
301 | 301 | $accesskey = 'c'; |
302 | 302 | } |
@@ -394,12 +394,12 @@ discard block |
||
394 | 394 | } |
395 | 395 | |
396 | 396 | $html .= " <legend{$class}>\n"; |
397 | - $html .= " ". $this->_translate($fieldset['title']) ."\n"; |
|
397 | + $html .= " " . $this->_translate($fieldset['title']) . "\n"; |
|
398 | 398 | $html .= " </legend>\n"; |
399 | 399 | } |
400 | 400 | |
401 | 401 | if (isset($fieldset['description'])) { |
402 | - $html .= "<p>". $this->_translate($fieldset['description']) . "</p>\n"; |
|
402 | + $html .= "<p>" . $this->_translate($fieldset['description']) . "</p>\n"; |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | $set = $this->form->createElement('static', "__fieldset_start_{$name}_{$key}", ""); |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | */ |
419 | 419 | private function _end_fieldset($name, $config) |
420 | 420 | { |
421 | - if ( !isset($config['end_fieldset']) |
|
421 | + if (!isset($config['end_fieldset']) |
|
422 | 422 | || $this->_fieldsets <= 0) { |
423 | 423 | return; |
424 | 424 | } |
@@ -494,11 +494,11 @@ discard block |
||
494 | 494 | } |
495 | 495 | |
496 | 496 | if ($config['read_privilege'] !== null) { |
497 | - if ( array_key_exists('group', $config['read_privilege']) |
|
497 | + if (array_key_exists('group', $config['read_privilege']) |
|
498 | 498 | && !midcom::get()->auth->is_group_member($config['read_privilege']['group'])) { |
499 | 499 | return false; |
500 | 500 | } |
501 | - if ( array_key_exists('privilege', $config['read_privilege']) |
|
501 | + if (array_key_exists('privilege', $config['read_privilege']) |
|
502 | 502 | && !$this->_types[$name]->can_do($config['read_privilege']['privilege'])) { |
503 | 503 | return false; |
504 | 504 | } |
@@ -543,11 +543,11 @@ discard block |
||
543 | 543 | $widget->freeze(); |
544 | 544 | } |
545 | 545 | if ($config['write_privilege'] !== null) { |
546 | - if ( array_key_exists('group', $config['write_privilege']) |
|
546 | + if (array_key_exists('group', $config['write_privilege']) |
|
547 | 547 | && !midcom::get()->auth->is_group_member($config['write_privilege']['group'])) { |
548 | 548 | $widget->freeze(); |
549 | 549 | } |
550 | - if ( array_key_exists('privilege', $config['write_privilege']) |
|
550 | + if (array_key_exists('privilege', $config['write_privilege']) |
|
551 | 551 | && !$this->_types[$name]->can_do($config['write_privilege']['privilege'])) { |
552 | 552 | $widget->freeze(); |
553 | 553 | } |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | */ |
602 | 602 | function display_form() |
603 | 603 | { |
604 | - if ( !$this->renderer |
|
604 | + if (!$this->renderer |
|
605 | 605 | || (is_string($this->renderer) && $this->renderer == 'none')) { |
606 | 606 | echo $this->form->toHtml(); |
607 | 607 | } else { |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | $this->form->getSubmitValues(true); |
643 | 643 | $exitcode = self::get_clicked_button(); |
644 | 644 | |
645 | - if ( $exitcode == 'save' |
|
645 | + if ($exitcode == 'save' |
|
646 | 646 | || $exitcode == 'next') { |
647 | 647 | // Validate the form. |
648 | 648 | if (!$this->form->validate()) { |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | */ |
662 | 662 | function get_submit_values() |
663 | 663 | { |
664 | - return $this->form->getSubmitValues( true ); |
|
664 | + return $this->form->getSubmitValues(true); |
|
665 | 665 | } |
666 | 666 | |
667 | 667 | /** |
@@ -703,14 +703,14 @@ discard block |
||
703 | 703 | |
704 | 704 | // Check if we were really submitted, if yes, trigger the on_submit event |
705 | 705 | // on the widgets as well: |
706 | - if ( $exitcode != 'cancel' |
|
706 | + if ($exitcode != 'cancel' |
|
707 | 707 | && $exitcode != 'previous') { |
708 | 708 | foreach ($this->widgets as $name => $copy) { |
709 | 709 | $this->widgets[$name]->on_submit($results); |
710 | 710 | } |
711 | 711 | } |
712 | 712 | |
713 | - if ( $exitcode == 'save' |
|
713 | + if ($exitcode == 'save' |
|
714 | 714 | || $exitcode == 'next' |
715 | 715 | || $exitcode == 'preview') { |
716 | 716 | // Iterate over the widgets and tell them to re-synchronize with their |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | public function finishForm(&$form) |
199 | 199 | { |
200 | 200 | // add a required note if needed |
201 | - if ( !empty($form->_required) |
|
201 | + if (!empty($form->_required) |
|
202 | 202 | && !$form->_freezeAll) { |
203 | 203 | $this->_html .= str_replace('{requiredNote}', $form->getRequiredNote(), $this->_required_note_template); |
204 | 204 | } |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | public function renderHeader(&$header) |
347 | 347 | { |
348 | 348 | $name = $header->getName(); |
349 | - if ( !empty($name) |
|
349 | + if (!empty($name) |
|
350 | 350 | && isset($this->_templates[$name])) { |
351 | 351 | $this->_html .= str_replace('{header}', $header->toHtml(), $this->_templates[$name]); |
352 | 352 | } else { |
@@ -205,7 +205,8 @@ |
||
205 | 205 | // FIXME figure out why this always tries to put something to the default cache dir (it does put stuff to the defined one as well) |
206 | 206 | try { |
207 | 207 | $ret = $purifier->purify($content); |
208 | - } catch (Exception $e) { |
|
208 | + } |
|
209 | + catch (Exception $e) { |
|
209 | 210 | debug_add("HTML Purifier failed to purify contents of field {$this->name}: " . $e->getMessage(), MIDCOM_LOG_WARN); |
210 | 211 | } |
211 | 212 |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | $this->purify_markdown_on_output = $this->_config->get('html_purify_markdown'); |
147 | 147 | } |
148 | 148 | |
149 | - if ( !empty($this->forbidden_patterns) |
|
149 | + if (!empty($this->forbidden_patterns) |
|
150 | 150 | && !empty($this->allowed_patterns)) { |
151 | 151 | debug_add('Both allowed and forbidden patterns are set, allowed has precedence', MIDCOM_LOG_ERROR); |
152 | 152 | $this->forbidden_patterns = null; |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | |
161 | 161 | function purify_string($content) |
162 | 162 | { |
163 | - if ( isset($this->purify_config['Cache']['SerializerPath']) |
|
163 | + if (isset($this->purify_config['Cache']['SerializerPath']) |
|
164 | 164 | && !file_exists($this->purify_config['Cache']['SerializerPath'])) { |
165 | 165 | mkdir($this->purify_config['Cache']['SerializerPath']); |
166 | 166 | } |
@@ -184,16 +184,16 @@ discard block |
||
184 | 184 | |
185 | 185 | // Load custom element/attribute definitions |
186 | 186 | $config_defs = $this->_config->get('html_purify_HTMLDefinition'); |
187 | - if ( is_array($config_defs) |
|
187 | + if (is_array($config_defs) |
|
188 | 188 | && !empty($config_defs) |
189 | 189 | && $def = $purifier_config_object->maybeGetRawHTMLDefinition(true)) { |
190 | - if ( !empty($config_defs['addAttribute']) |
|
190 | + if (!empty($config_defs['addAttribute']) |
|
191 | 191 | && is_array($config_defs['addAttribute'])) { |
192 | 192 | foreach (array_filter($config_defs['addAttribute'], 'is_array') as $attrdef) { |
193 | 193 | call_user_func_array(array($def, 'addAttribute'), $attrdef); |
194 | 194 | } |
195 | 195 | } |
196 | - if ( !empty($config_defs['addElement']) |
|
196 | + if (!empty($config_defs['addElement']) |
|
197 | 197 | && is_array($config_defs['addElement'])) { |
198 | 198 | foreach (array_filter($config_defs['addElement'], 'is_array') as $elemdef) { |
199 | 199 | call_user_func_array(array($def, 'addElement'), $elemdef); |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | */ |
248 | 248 | public function _on_validate() |
249 | 249 | { |
250 | - if ( is_array($this->value) |
|
250 | + if (is_array($this->value) |
|
251 | 251 | || is_object($this->value)) { |
252 | 252 | $this->validation_error = $this->_l10n->get('type text: value may not be array or object'); |
253 | 253 | return false; |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | $this->purify_content(); |
260 | 260 | } |
261 | 261 | |
262 | - if ( $this->maxlength > 0 |
|
262 | + if ($this->maxlength > 0 |
|
263 | 263 | && strlen($this->value) > $this->maxlength) { |
264 | 264 | $this->validation_error = sprintf($this->_l10n->get('type text: value is longer than %d characters'), |
265 | 265 | $this->maxlength); |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | |
284 | 284 | public function validate_allowed_patterns($fields) |
285 | 285 | { |
286 | - if ( !empty($this->allowed_patterns) |
|
286 | + if (!empty($this->allowed_patterns) |
|
287 | 287 | && is_array($this->allowed_patterns)) { |
288 | 288 | foreach ($this->allowed_patterns as $condition) { |
289 | 289 | if (!isset($condition['explanation'])) { |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | return midcom_helper_formatter::format($this->value, 'F'); |
366 | 366 | |
367 | 367 | case 'markdown': |
368 | - if ( !$this->purify |
|
368 | + if (!$this->purify |
|
369 | 369 | || !$this->purify_markdown_on_output) { |
370 | 370 | // Return the Markdown straight away |
371 | 371 | return MarkdownExtra::defaultTransform($this->value); |
@@ -186,11 +186,11 @@ discard block |
||
186 | 186 | */ |
187 | 187 | public function _on_initialize() |
188 | 188 | { |
189 | - if ( !is_array($this->options) |
|
189 | + if (!is_array($this->options) |
|
190 | 190 | && $this->option_callback === null) { |
191 | 191 | throw new midcom_error("Either 'options' or 'option_callback' must be defined for the field {$this->name}"); |
192 | 192 | } |
193 | - if ( !empty($this->options) |
|
193 | + if (!empty($this->options) |
|
194 | 194 | && $this->option_callback !== null) { |
195 | 195 | throw new midcom_error("Both 'options' and 'option_callback' was defined for the field {$this->name}"); |
196 | 196 | } |
@@ -231,13 +231,13 @@ discard block |
||
231 | 231 | private function _get_name_from_object($key) |
232 | 232 | { |
233 | 233 | $widget_config = $this->storage->_schema->fields[$this->name]['widget_config']; |
234 | - if ( empty($widget_config['class']) |
|
234 | + if (empty($widget_config['class']) |
|
235 | 235 | || empty($widget_config['titlefield']) |
236 | 236 | || !$key) { |
237 | 237 | return null; |
238 | 238 | } |
239 | 239 | |
240 | - if ( !empty($widget_config['component']) |
|
240 | + if (!empty($widget_config['component']) |
|
241 | 241 | && !midcom::get()->componentloader->is_loaded($widget_config['component'])) { |
242 | 242 | // Ensure the corresponding component is loaded |
243 | 243 | midcom::get()->componentloader->load($widget_config['component']); |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | return array_key_exists($key, $this->options); |
276 | 276 | } |
277 | 277 | |
278 | - if ( isset($this->_callback) |
|
278 | + if (isset($this->_callback) |
|
279 | 279 | && method_exists($this->_callback, 'key_exists')) { |
280 | 280 | return $this->_callback->key_exists($key); |
281 | 281 | } |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | $this->selection = array(); |
306 | 306 | $this->others = array(); |
307 | 307 | |
308 | - if ( $source === false |
|
308 | + if ($source === false |
|
309 | 309 | || $source === null) { |
310 | 310 | // We are fine at this point. |
311 | 311 | return; |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | if ($this->allow_multiple) { |
362 | 362 | return $this->_convert_multiple_to_storage(); |
363 | 363 | } |
364 | - if ( $this->allow_other |
|
364 | + if ($this->allow_other |
|
365 | 365 | && !empty($this->others)) { |
366 | 366 | return $this->others[0]; |
367 | 367 | } |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | switch ($this->multiple_storagemode) { |
385 | 385 | case 'serialized': |
386 | 386 | case 'array': |
387 | - if ( !is_array($source) |
|
387 | + if (!is_array($source) |
|
388 | 388 | && empty($source)) { |
389 | 389 | $source = array(); |
390 | 390 | } |
@@ -507,20 +507,20 @@ discard block |
||
507 | 507 | */ |
508 | 508 | public function _on_validate() |
509 | 509 | { |
510 | - if ( !$this->allow_other |
|
510 | + if (!$this->allow_other |
|
511 | 511 | && $this->others) { |
512 | 512 | $this->validation_error = $this->_l10n->get('type select: other selection not allowed'); |
513 | 513 | return false; |
514 | 514 | } |
515 | 515 | |
516 | - if ( !$this->allow_multiple |
|
516 | + if (!$this->allow_multiple |
|
517 | 517 | && count($this->selection) > 1) { |
518 | 518 | $this->validation_error = $this->_l10n->get('type select: multiselect not allowed'); |
519 | 519 | return false; |
520 | 520 | } |
521 | 521 | |
522 | 522 | $field = $this->_datamanager->schema->fields[$this->name]; |
523 | - if ( $field['required'] |
|
523 | + if ($field['required'] |
|
524 | 524 | && count($this->selection) == 0) { |
525 | 525 | $this->validation_error = sprintf($this->_l10n->get('field %s is required'), $field['title']); |
526 | 526 | return false; |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | */ |
216 | 216 | public function _on_initialize() |
217 | 217 | { |
218 | - if ( !$this->mapping_class_name |
|
218 | + if (!$this->mapping_class_name |
|
219 | 219 | || !$this->master_fieldname |
220 | 220 | || !$this->member_fieldname) { |
221 | 221 | throw new midcom_error( |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | $qb = midcom::get()->dbfactory->new_query_builder($this->mapping_class_name); |
256 | 256 | $qb->add_constraint($this->master_fieldname, '=', $this->_get_master_foreign_key()); |
257 | 257 | |
258 | - if ( $this->sortable |
|
258 | + if ($this->sortable |
|
259 | 259 | && preg_match('/^(ASC|DESC)/i', $this->sortable_sort_order, $regs)) { |
260 | 260 | $order = strtoupper($regs[1]); |
261 | 261 | $qb->add_order('metadata.score', $order); |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | |
303 | 303 | foreach ($this->_membership_objects as $member) { |
304 | 304 | $key = $member->{$this->member_fieldname}; |
305 | - if ( !$this->require_corresponding_option |
|
305 | + if (!$this->require_corresponding_option |
|
306 | 306 | || $this->key_exists($key)) { |
307 | 307 | $this->selection[] = $key; |
308 | 308 | } else { |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | { |
358 | 358 | $new_membership_objects = array(); |
359 | 359 | // Cache the total quantity of items and get the order if the field is supposed to store the member order |
360 | - if ( $this->sortable |
|
360 | + if ($this->sortable |
|
361 | 361 | && isset($this->sorted_order)) { |
362 | 362 | $count = count($this->sorted_order); |
363 | 363 |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | */ |
236 | 236 | function recreate_main_image() |
237 | 237 | { |
238 | - if ( !$this->_prepare_recreate() |
|
238 | + if (!$this->_prepare_recreate() |
|
239 | 239 | || !$this->_auto_convert_to_web_type() |
240 | 240 | || !$this->_save_image('main', $this->filter_chain)) { |
241 | 241 | return false; |
@@ -268,14 +268,14 @@ discard block |
||
268 | 268 | */ |
269 | 269 | protected function _prepare_recreate($force = false) |
270 | 270 | { |
271 | - if ( ( !empty($this->auto_thumbnail) |
|
271 | + if ((!empty($this->auto_thumbnail) |
|
272 | 272 | || !empty($this->filter_chain) |
273 | 273 | || !empty($this->derived_images)) |
274 | 274 | && !$this->imagemagick_available()) { |
275 | - throw new midcom_error( 'DM2 type image requires ImageMagick for manipulation operations, see debug log for details'); |
|
275 | + throw new midcom_error('DM2 type image requires ImageMagick for manipulation operations, see debug log for details'); |
|
276 | 276 | } |
277 | 277 | |
278 | - if ( !empty($this->_original_tmpname) |
|
278 | + if (!empty($this->_original_tmpname) |
|
279 | 279 | && !$force) { |
280 | 280 | // We have prepared. |
281 | 281 | return true; |
@@ -407,11 +407,11 @@ discard block |
||
407 | 407 | */ |
408 | 408 | protected function _set_image($filename, $tmpname, $title, $force_pending_attachments = false) |
409 | 409 | { |
410 | - if ( ( !empty($this->auto_thumbnail) |
|
410 | + if ((!empty($this->auto_thumbnail) |
|
411 | 411 | || !empty($this->filter_chain) |
412 | 412 | || !empty($this->derived_images)) |
413 | 413 | && !$this->imagemagick_available()) { |
414 | - throw new midcom_error( 'DM2 type image requires ImageMagick for manipulation operations, see debug log for details'); |
|
414 | + throw new midcom_error('DM2 type image requires ImageMagick for manipulation operations, see debug log for details'); |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | if (empty($filename)) { |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | $this->_original_tmpname = $tmpname; |
436 | 436 | |
437 | 437 | // 1st step: original image storage and auto-conversion |
438 | - if ( !$this->_save_original() |
|
438 | + if (!$this->_save_original() |
|
439 | 439 | || !$this->_filter->set_file($tmpname) |
440 | 440 | || !$this->_auto_convert_to_web_type()) { |
441 | 441 | // TODO: Raise uimessage |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | } |
453 | 453 | $this->_add_thumbnail_to_derived_images(); |
454 | 454 | // Prepare all other images |
455 | - if ( !$this->_save_image('main', $this->filter_chain) |
|
455 | + if (!$this->_save_image('main', $this->filter_chain) |
|
456 | 456 | || !$this->_save_derived_images()) { |
457 | 457 | // TODO: Raise uimessage |
458 | 458 |
@@ -364,7 +364,8 @@ discard block |
||
364 | 364 | $filter = new midcom_helper_imagefilter($this->attachments[$identifier]); |
365 | 365 | try { |
366 | 366 | $filter->process_chain($filterchain); |
367 | - } catch (midcom_error $e) { |
|
367 | + } |
|
368 | + catch (midcom_error $e) { |
|
368 | 369 | midcom::get()->uimessages->add('midcom.helper.imagefilter', $e->getMessage(), 'error'); |
369 | 370 | $e->log(); |
370 | 371 | return false; |
@@ -529,7 +530,8 @@ discard block |
||
529 | 530 | if ($filter_chain) { |
530 | 531 | try { |
531 | 532 | $this->_filter->process_chain($filter_chain); |
532 | - } catch (midcom_error $e) { |
|
533 | + } |
|
534 | + catch (midcom_error $e) { |
|
533 | 535 | midcom::get()->uimessages->add('midcom.helper.imagefilter', $e->getMessage(), 'error'); |
534 | 536 | $e->log(); |
535 | 537 | return false; |
@@ -620,7 +622,8 @@ discard block |
||
620 | 622 | |
621 | 623 | try { |
622 | 624 | $this->_filter->convert($conversion); |
623 | - } catch (midcom_error $e) { |
|
625 | + } |
|
626 | + catch (midcom_error $e) { |
|
624 | 627 | $e->log(); |
625 | 628 | return false; |
626 | 629 | } |