diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index 9bb0788424..6468f1d2ac 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -567,7 +567,60 @@ class Wizard ], ]; - $this->printFormAsList($form); + $this->printForm($form); + } + + + /** + * Print a block of inputs. + * + * @param array $input Definition of target block to be printed. + * @param boolean $return Return as string or direct output. + * + * @return string HTML content. + */ + public function printBlock(array $input, bool $return=false) + { + $output = ''; + if ($input['hidden'] == 1) { + $class = ' hidden'; + } else { + $class = ''; + } + + if (isset($input['class']) === true) { + $class = $input['class'].$class; + } + + if (is_array($input['block_content']) === true) { + // Print independent block of inputs. + $output .= '
  • '; + $output .= '
  • '; + } else { + if ($input['arguments']['type'] != 'hidden') { + $output .= '
  • '; + $output .= ''; + $output .= $this->printInput($input['arguments']); + // Allow dynamic content. + $output .= $input['extra']; + $output .= '
  • '; + } else { + $output .= $this->printInput($input['arguments']); + // Allow dynamic content. + $output .= $input['extra']; + } + } + + if ($return === false) { + echo $output; + } + + return $output; } @@ -727,6 +780,76 @@ class Wizard } + /** + * Print a form. + * + * @param array $data Definition of target form to be printed. + * @param boolean $return Return as string or direct output. + * + * @return string HTML code. + */ + public function printForm(array $data, bool $return=false, bool $print_white_box=false) + { + $form = $data['form']; + $inputs = $data['inputs']; + $js = $data['js']; + $cb_function = $data['cb_function']; + $cb_args = $data['cb_args']; + + $output_head = '
    '; + + if ($return === false) { + echo $output_head; + } + + try { + if (isset($cb_function) === true) { + call_user_func_array( + $cb_function, + (isset($cb_args) === true) ? $cb_args : [] + ); + } + } catch (Exception $e) { + error_log('Error executing wizard callback: ', $e->getMessage()); + } + + $output_submit = ''; + $output = ''; + + if ($print_white_box === true) { + $output .= '
    '; + } + + $output .= ''; + + if ($print_white_box === true) { + $output .= '
    '; + } + + $output .= ''; + $output .= '
    '; + $output .= ''; + + if ($return === false) { + echo $output; + } + + return $output_head.$output; + + } + + /** * Print a form as a grid of inputs. *