mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 08:14:38 +02:00
Merge branch 'ent-3937-eliminar-echos-y-prints-de-las-subclases-de-wizard' into 'develop'
Ent 3937 eliminar echos y prints de las subclases de wizard See merge request artica/pandorafms!2430
This commit is contained in:
commit
ce359bfaf6
@ -594,78 +594,42 @@ class HostDevices extends Wizard
|
|||||||
if (isset($this->page) === false
|
if (isset($this->page) === false
|
||||||
|| $this->page == 0
|
|| $this->page == 0
|
||||||
) {
|
) {
|
||||||
// Comment input
|
$form = [];
|
||||||
$comment_input = '<div class="label_select"><label>'.__('Comment').':</label></div>';
|
|
||||||
|
|
||||||
$comment_input .= $this->printInput(
|
$str = __('Next');
|
||||||
[
|
|
||||||
'name' => 'comment',
|
|
||||||
'rows' => 1,
|
|
||||||
'columns' => 1,
|
|
||||||
'value' => $this->task['description'],
|
|
||||||
'type' => 'textarea',
|
|
||||||
'size' => 25,
|
|
||||||
'class' => 'discovery_textarea_input',
|
|
||||||
'return' => true,
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
// Task input
|
if (isset($this->task['id_rt']) === true) {
|
||||||
$taskname_input_label = '<div class="label_select"><label>'.__('Task name').':</label></div>';
|
$str = __('Update and continue');
|
||||||
|
}
|
||||||
|
|
||||||
$taskname_input = $this->printInput(
|
// Interval and schedules.
|
||||||
[
|
|
||||||
'name' => 'taskname',
|
|
||||||
'value' => $this->task['name'],
|
|
||||||
'type' => 'text',
|
|
||||||
'size' => 25,
|
|
||||||
'class' => 'discovery_full_width_input',
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
// Network input
|
|
||||||
$network_input_label .= '<div class="label_select discovery_label_hint"><label>'.__('Network').':</label>'.ui_print_help_tip(__('You can specify several networks, separated by commas, for example: 192.168.50.0/24,192.168.60.0/24'), true).'</div>';
|
|
||||||
|
|
||||||
$network_input = $this->printInput(
|
|
||||||
[
|
|
||||||
'name' => 'network',
|
|
||||||
'value' => $this->task['subnet'],
|
|
||||||
'type' => 'text',
|
|
||||||
'size' => 25,
|
|
||||||
'class' => 'discovery_full_width_input',
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
// Discovery server input
|
|
||||||
$discovery_server_select_label = '<div class="label_select discovery_label_hint"><label>'.__('Discovery server').':</label>'.ui_print_help_tip(__('You must select a Discovery Server to run the Task, otherwise the Recon Task will never run'), true).'</div>';
|
|
||||||
|
|
||||||
$discovery_server_select = $this->printInput(
|
|
||||||
[
|
|
||||||
'type' => 'select_from_sql',
|
|
||||||
'sql' => sprintf(
|
|
||||||
'SELECT id_server, name
|
|
||||||
FROM tserver
|
|
||||||
WHERE server_type = %d
|
|
||||||
ORDER BY name',
|
|
||||||
SERVER_TYPE_DISCOVERY
|
|
||||||
),
|
|
||||||
'name' => 'id_recon_server',
|
|
||||||
'selected' => $this->task['id_recon_server'],
|
|
||||||
'return' => true,
|
|
||||||
'style' => 'width: 100%',
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
// Interval input
|
|
||||||
$interv_manual = 0;
|
$interv_manual = 0;
|
||||||
if ((int) $this->task['interval_sweep'] == 0) {
|
if ((int) $this->task['interval_sweep'] == 0) {
|
||||||
$interv_manual = 1;
|
$interv_manual = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$interval_input_label = '<div class="label_select discovery_label_hint" style="padding-top: 6px;"><label>'.__('Interval').':</label>'.ui_print_help_tip(__('Manual interval means that it will run only on demand.'), true).'</div>';
|
$form['rows'][0]['new_form_block'] = true;
|
||||||
|
|
||||||
$interval_input = $this->printInput(
|
$form['rows'][0]['columns'][0] = [
|
||||||
[
|
'width' => '30%',
|
||||||
|
'style' => 'padding: 9px;',
|
||||||
|
'inputs' => [
|
||||||
|
'0' => [
|
||||||
|
'arguments' => [
|
||||||
|
'name' => 'submit',
|
||||||
|
'label' => $str,
|
||||||
|
'type' => 'submit',
|
||||||
|
'attributes' => 'class="sub next"',
|
||||||
|
'return' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'1' => '<div style="height: 50%; margin-bottom: 35px;">'.html_print_image('images/wizard/netscan_green.png', true, ['title' => __('Close')], false).'</div>',
|
||||||
|
'2' => [
|
||||||
|
'label' => '<b>'.__('Interval').':</b>'.ui_print_help_tip(
|
||||||
|
__('Manual interval means that it will be executed only On-demand'),
|
||||||
|
true
|
||||||
|
),
|
||||||
|
'arguments' => [
|
||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
'selected' => $interv_manual,
|
'selected' => $interv_manual,
|
||||||
'fields' => [
|
'fields' => [
|
||||||
@ -674,11 +638,8 @@ class HostDevices extends Wizard
|
|||||||
],
|
],
|
||||||
'name' => 'interval_manual_defined',
|
'name' => 'interval_manual_defined',
|
||||||
'return' => true,
|
'return' => true,
|
||||||
'style' => 'float: right;',
|
],
|
||||||
]
|
'extra' => '<span id="interval_manual_container">'.html_print_extended_select_for_time(
|
||||||
);
|
|
||||||
|
|
||||||
$interval_input_extra = '<span id="interval_manual_container">'.html_print_extended_select_for_time(
|
|
||||||
'interval',
|
'interval',
|
||||||
$this->task['interval_sweep'],
|
$this->task['interval_sweep'],
|
||||||
'',
|
'',
|
||||||
@ -691,9 +652,64 @@ class HostDevices extends Wizard
|
|||||||
).ui_print_help_tip(
|
).ui_print_help_tip(
|
||||||
__('The minimum recomended interval for Recon Task is 5 minutes'),
|
__('The minimum recomended interval for Recon Task is 5 minutes'),
|
||||||
true
|
true
|
||||||
).'</span>';
|
).'</span>',
|
||||||
|
|
||||||
// Group select
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
$form['rows'][0]['columns'][1] = [
|
||||||
|
'width' => '40%',
|
||||||
|
'padding-right' => '12%',
|
||||||
|
'padding-left' => '5%',
|
||||||
|
'inputs' => [
|
||||||
|
'0' => [
|
||||||
|
'label' => '<b>'.__('Task name').':</b>',
|
||||||
|
'arguments' => [
|
||||||
|
'name' => 'taskname',
|
||||||
|
'value' => $this->task['name'],
|
||||||
|
'type' => 'text',
|
||||||
|
'size' => 25,
|
||||||
|
'class' => 'discovery_full_width_input',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'1' => [
|
||||||
|
'label' => '<b>'.__('Discovery server').':</b>'.ui_print_help_tip(
|
||||||
|
__('You must select a Discovery Server to run the Task, otherwise the Recon Task will never run'),
|
||||||
|
true
|
||||||
|
),
|
||||||
|
'arguments' => [
|
||||||
|
'type' => 'select_from_sql',
|
||||||
|
'sql' => sprintf(
|
||||||
|
'SELECT id_server, name
|
||||||
|
FROM tserver
|
||||||
|
WHERE server_type = %d
|
||||||
|
ORDER BY name',
|
||||||
|
SERVER_TYPE_DISCOVERY
|
||||||
|
),
|
||||||
|
'name' => 'id_recon_server',
|
||||||
|
'style' => 'width: 100%;',
|
||||||
|
'selected' => $this->task['id_recon_server'],
|
||||||
|
'return' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'2' => [
|
||||||
|
'label' => '<b>'.__('Network').':</b>'.ui_print_help_tip(
|
||||||
|
__('You can specify several networks, separated by commas, for example: 192.168.50.0/24,192.168.60.0/24'),
|
||||||
|
true
|
||||||
|
),
|
||||||
|
'arguments' => [
|
||||||
|
'name' => 'network',
|
||||||
|
'value' => $this->task['subnet'],
|
||||||
|
'type' => 'text',
|
||||||
|
'size' => 25,
|
||||||
|
'class' => 'discovery_full_width_input',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
// Group select (custom for this section).
|
||||||
$group_select = '<div class="label_select"><label>'.__('Group').':</label></div>';
|
$group_select = '<div class="label_select"><label>'.__('Group').':</label></div>';
|
||||||
|
|
||||||
$group_select .= $this->printInput(
|
$group_select .= $this->printInput(
|
||||||
@ -710,22 +726,41 @@ class HostDevices extends Wizard
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isset($this->task['id_rt']) === true) {
|
$form['rows'][0]['columns'][2] = [
|
||||||
// Propagate ID
|
'width' => '30%',
|
||||||
$task_hidden = $this->printInput(
|
'inputs' => ['0' => $group_select],
|
||||||
[
|
];
|
||||||
'name' => 'task',
|
|
||||||
'value' => $this->task['id_rt'],
|
$form['rows'][1]['style'] = 'style de row';
|
||||||
'type' => 'hidden',
|
$form['rows'][1]['columns'][0] = [
|
||||||
]
|
'padding-right' => '0',
|
||||||
);
|
'inputs' => [
|
||||||
}
|
'0' => [
|
||||||
|
'label' => '<b>'.__('Comment').':</b>',
|
||||||
|
'arguments' => [
|
||||||
|
'name' => 'comment',
|
||||||
|
'rows' => 1,
|
||||||
|
'columns' => 1,
|
||||||
|
'value' => $this->task['description'],
|
||||||
|
'type' => 'textarea',
|
||||||
|
'size' => 25,
|
||||||
|
'class' => 'discovery_textarea_input',
|
||||||
|
'return' => true,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
$task_url = '';
|
$task_url = '';
|
||||||
if (isset($this->task['id_rt'])) {
|
if (isset($this->task['id_rt'])) {
|
||||||
$task_url = '&task='.$this->task['id_rt'];
|
$task_url = '&task='.$this->task['id_rt'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$form['form'] = [
|
||||||
|
'method' => 'POST',
|
||||||
|
'action' => $this->url.'&mode=netscan&page='.($this->page + 1).$task_url,
|
||||||
|
];
|
||||||
|
|
||||||
// Default.
|
// Default.
|
||||||
$interval = 600;
|
$interval = 600;
|
||||||
$unit = 60;
|
$unit = 60;
|
||||||
@ -734,34 +769,7 @@ class HostDevices extends Wizard
|
|||||||
$unit = $this->getTimeUnit($interval);
|
$unit = $this->getTimeUnit($interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX: Could be improved validating inputs before continue (JS)
|
$form['js'] = '
|
||||||
// Print NetScan page 0.
|
|
||||||
// $this->printForm($form);
|
|
||||||
echo '<form action="'.$this->url.'&mode=netscan&page='.($this->page + 1).$task_url.'" method="POST">';
|
|
||||||
echo $task_hidden;
|
|
||||||
|
|
||||||
echo '<div class="white_box">
|
|
||||||
<div class="edit_discovery_info" style="margin-bottom: 15px;">
|
|
||||||
<div style="width: 25%; padding: 9px;">'.'<div style="height: 50%; margin-bottom: 35px;">'.html_print_image('images/wizard/netscan_green.png', true, ['title' => __('Close')], false).'</div>'.'<div class="edit_discovery_input"><div style="display: flex;">'.$interval_input_label.'<div style="margin-left: 15 px; width: 50%;">'.$interval_input.'</div></div>'.$interval_input_extra.'</div>'.'</div>
|
|
||||||
|
|
||||||
<div style="width: 40%; padding-left: 5%; padding-right: 12%;">
|
|
||||||
<div class="edit_discovery_input">'.$taskname_input_label.'<div class="discovery_text_input">'.$taskname_input.'</div></div>'.'<div class="edit_discovery_input discovery_select_input">'.$discovery_server_select_label.$discovery_server_select.'<div class="discovery_hint"></div></div>'.'<div class="edit_discovery_input">'.$network_input_label.'<div class="discovery_text_input">'.$network_input.'</div></div>'.'</div>'.'<div style="width: 35%;">'.$group_select.'</div>'.'</div>'.'<div class="edit_discovery_info">
|
|
||||||
<div style="width: 100%;">
|
|
||||||
'.$comment_input.'
|
|
||||||
</div>
|
|
||||||
</div>'.'</div>';
|
|
||||||
|
|
||||||
$str = __('Next');
|
|
||||||
|
|
||||||
if (isset($this->task['id_rt']) === true) {
|
|
||||||
$str = __('Update and continue');
|
|
||||||
}
|
|
||||||
|
|
||||||
echo '<div class="action-buttons" style="width: 100%; margin-top: 10px;">'.html_print_submit_button($str, 'submit', false, 'class="sub next"', true).'</div>';
|
|
||||||
echo '</form>';
|
|
||||||
|
|
||||||
echo '<script>
|
|
||||||
|
|
||||||
$("select#interval_manual_defined").change(function() {
|
$("select#interval_manual_defined").change(function() {
|
||||||
if ($("#interval_manual_defined").val() == 1) {
|
if ($("#interval_manual_defined").val() == 1) {
|
||||||
$("#interval_manual_container").hide();
|
$("#interval_manual_container").hide();
|
||||||
@ -774,9 +782,9 @@ class HostDevices extends Wizard
|
|||||||
$("#hidden-interval").val('.$interval.');
|
$("#hidden-interval").val('.$interval.');
|
||||||
$("#interval_units").val('.$unit.');
|
$("#interval_units").val('.$unit.');
|
||||||
}
|
}
|
||||||
}).change();
|
}).change();';
|
||||||
|
|
||||||
</script>';
|
$this->printFormAsGrid($form);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -793,7 +801,6 @@ class HostDevices extends Wizard
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
// Hidden, page.
|
|
||||||
$form['inputs'][] = [
|
$form['inputs'][] = [
|
||||||
'arguments' => [
|
'arguments' => [
|
||||||
'name' => 'page',
|
'name' => 'page',
|
||||||
@ -807,7 +814,6 @@ class HostDevices extends Wizard
|
|||||||
'extra' => '<p><h3>Please, configure task <b>'.io_safe_output($this->task['name']).'</b></h3></p>',
|
'extra' => '<p><h3>Please, configure task <b>'.io_safe_output($this->task['name']).'</b></h3></p>',
|
||||||
];
|
];
|
||||||
|
|
||||||
// Input: Module template.
|
|
||||||
$form['inputs'][] = [
|
$form['inputs'][] = [
|
||||||
'label' => __('Module template'),
|
'label' => __('Module template'),
|
||||||
'arguments' => [
|
'arguments' => [
|
||||||
@ -870,7 +876,7 @@ class HostDevices extends Wizard
|
|||||||
'action' => $this->url.'&mode=netscan&page='.($this->page + 1).'&task='.$this->task['id_rt'],
|
'action' => $this->url.'&mode=netscan&page='.($this->page + 1).'&task='.$this->task['id_rt'],
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->printForm($form, false, true);
|
$this->printFormAsList($form);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->page == 2) {
|
if ($this->page == 2) {
|
||||||
|
@ -624,6 +624,162 @@ class Wizard
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a block of inputs with grid format.
|
||||||
|
*
|
||||||
|
* @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 printBlockAsGrid(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 .= '<li id="'.$input['block_id'].'" class="'.$class.'">';
|
||||||
|
$output .= '<ul class="wizard">';
|
||||||
|
foreach ($input['block_content'] as $input) {
|
||||||
|
$output .= $this->printBlockAsGrid($input, $return);
|
||||||
|
}
|
||||||
|
|
||||||
|
$output .= '</ul></li>';
|
||||||
|
} else {
|
||||||
|
if ($input['arguments']['type'] != 'hidden') {
|
||||||
|
if ($input['arguments']['inline'] != 'true') {
|
||||||
|
$output .= '<div class="edit_discovery_input">';
|
||||||
|
} else {
|
||||||
|
$output .= '<div style="display: flex; margin-bottom: 25px;">';
|
||||||
|
if (!isset($input['extra'])) {
|
||||||
|
$output .= '<div style="width: 50%;">';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($input['extra'])) {
|
||||||
|
$output .= '<div style="width: 50%; display: flex;">';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($input['arguments']['inline'] == 'true' && isset($input['extra'])) {
|
||||||
|
$output .= '<div style="width: 50%">';
|
||||||
|
}
|
||||||
|
|
||||||
|
$output .= '<div class="label_select">';
|
||||||
|
$output .= $input['label'];
|
||||||
|
$output .= '</div>';
|
||||||
|
|
||||||
|
if ($input['arguments']['inline'] == 'true' && isset($input['extra'])) {
|
||||||
|
$output .= '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($input['arguments']['inline'] == 'true' && !isset($input['extra'])) {
|
||||||
|
$output .= '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($input['arguments']['type'] == 'text' || $input['arguments']['type'] == 'text_extended') {
|
||||||
|
$output .= '<div class="discovery_text_input">';
|
||||||
|
$output .= $this->printInput($input['arguments']);
|
||||||
|
$output .= '</div>';
|
||||||
|
} else if ($input['arguments']['inline'] == 'true') {
|
||||||
|
$output .= '<div style="width: 50%;">';
|
||||||
|
|
||||||
|
if (isset($input['extra'])) {
|
||||||
|
$output .= '<div style="float: center;">';
|
||||||
|
} else {
|
||||||
|
$output .= '<div style="float: right;">';
|
||||||
|
}
|
||||||
|
|
||||||
|
$output .= $this->printInput($input['arguments']);
|
||||||
|
$output .= '</div>';
|
||||||
|
$output .= '</div>';
|
||||||
|
|
||||||
|
if (isset($input['extra'])) {
|
||||||
|
$output .= '</div>';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$output .= $this->printInput($input['arguments']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow dynamic content.
|
||||||
|
$output .= $input['extra'];
|
||||||
|
$output .= '</div>';
|
||||||
|
} else {
|
||||||
|
$output .= $this->printInput($input['arguments']);
|
||||||
|
// Allow dynamic content.
|
||||||
|
$output .= $input['extra'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($return === false) {
|
||||||
|
echo $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a block of inputs as a list element.
|
||||||
|
*
|
||||||
|
* @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 printBlockAsList(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 .= '<li id="'.$input['block_id'].'" class="'.$class.'">';
|
||||||
|
$output .= '<ul class="wizard">';
|
||||||
|
foreach ($input['block_content'] as $input) {
|
||||||
|
$output .= $this->printBlockAsList($input, $return);
|
||||||
|
}
|
||||||
|
|
||||||
|
$output .= '</ul></li>';
|
||||||
|
} else {
|
||||||
|
if ($input['arguments']['type'] != 'hidden') {
|
||||||
|
$output .= '<li id="'.$input['id'].'" class="'.$class.'">';
|
||||||
|
$output .= '<label>'.$input['label'].'</label>';
|
||||||
|
$output .= $this->printInput($input['arguments']);
|
||||||
|
// Allow dynamic content.
|
||||||
|
$output .= $input['extra'];
|
||||||
|
$output .= '</li>';
|
||||||
|
} else {
|
||||||
|
$output .= $this->printInput($input['arguments']);
|
||||||
|
// Allow dynamic content.
|
||||||
|
$output .= $input['extra'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($return === false) {
|
||||||
|
echo $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print a form.
|
* Print a form.
|
||||||
*
|
*
|
||||||
@ -694,6 +850,163 @@ class Wizard
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a form as a grid of inputs.
|
||||||
|
*
|
||||||
|
* @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 printFormAsGrid(array $data, bool $return=false)
|
||||||
|
{
|
||||||
|
$form = $data['form'];
|
||||||
|
|
||||||
|
$rows = $data['rows'];
|
||||||
|
|
||||||
|
$js = $data['js'];
|
||||||
|
$cb_function = $data['cb_function'];
|
||||||
|
$cb_args = $data['cb_args'];
|
||||||
|
|
||||||
|
$output_head = '<form enctype="'.$form['enctype'].'" action="'.$form['action'].'" method="'.$form['method'];
|
||||||
|
$output_head .= '" '.$form['extra'].'>';
|
||||||
|
|
||||||
|
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 = '';
|
||||||
|
|
||||||
|
$first_block_printed = false;
|
||||||
|
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
if ($row['new_form_block'] == true) {
|
||||||
|
if ($first_block_printed === true) {
|
||||||
|
// If first form block has been placed, then close it before starting a new one.
|
||||||
|
$output .= '</div>';
|
||||||
|
$output .= '<div class="white_box" style="margin-top: 30px;">';
|
||||||
|
} else {
|
||||||
|
$output .= '<div class="white_box">';
|
||||||
|
}
|
||||||
|
|
||||||
|
$first_block_printed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$output .= '<div class="edit_discovery_info" style="'.$row['style'].'">';
|
||||||
|
|
||||||
|
foreach ($row['columns'] as $column) {
|
||||||
|
$width = isset($column['width']) ? 'width: '.$column['width'].';' : 'width: 100%;';
|
||||||
|
$padding_left = isset($column['padding-left']) ? 'padding-left: '.$column['padding-left'].';' : 'padding-left: 0;';
|
||||||
|
$padding_right = isset($column['padding-right']) ? 'padding-right: '.$column['padding-right'].';' : 'padding-right: 0;';
|
||||||
|
$extra_styles = isset($column['style']) ? $column['style'] : '';
|
||||||
|
|
||||||
|
$output .= '<div style="'.$width.$padding_left.$padding_right.$extra_styles.'">';
|
||||||
|
|
||||||
|
foreach ($column['inputs'] as $input) {
|
||||||
|
if (is_array($input)) {
|
||||||
|
if ($input['arguments']['type'] != 'submit') {
|
||||||
|
$output .= $this->printBlockAsGrid($input, true);
|
||||||
|
} else {
|
||||||
|
$output_submit .= $this->printBlockAsGrid($input, true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$output .= $input;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$output .= '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$output .= '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$output .= '</div>';
|
||||||
|
|
||||||
|
$output .= '<ul class="wizard">'.$output_submit.'</ul>';
|
||||||
|
$output .= '</form>';
|
||||||
|
$output .= '<script>'.$js.'</script>';
|
||||||
|
|
||||||
|
if ($return === false) {
|
||||||
|
echo $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $output_head.$output;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print a form as a list.
|
||||||
|
*
|
||||||
|
* @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 printFormAsList(array $data, bool $return=false)
|
||||||
|
{
|
||||||
|
$form = $data['form'];
|
||||||
|
$inputs = $data['inputs'];
|
||||||
|
$js = $data['js'];
|
||||||
|
$cb_function = $data['cb_function'];
|
||||||
|
$cb_args = $data['cb_args'];
|
||||||
|
|
||||||
|
$output_head = '<form enctype="'.$form['enctype'].'" action="'.$form['action'].'" method="'.$form['method'];
|
||||||
|
$output_head .= '" '.$form['extra'].'>';
|
||||||
|
|
||||||
|
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 = '<div class="white_box">';
|
||||||
|
$output .= '<ul class="wizard">';
|
||||||
|
|
||||||
|
foreach ($inputs as $input) {
|
||||||
|
if ($input['arguments']['type'] != 'submit') {
|
||||||
|
$output .= $this->printBlockAsList($input, true);
|
||||||
|
} else {
|
||||||
|
$output_submit .= $this->printBlockAsList($input, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$output .= '</ul>';
|
||||||
|
$output .= '</div>';
|
||||||
|
$output .= '<ul class="wizard">'.$output_submit.'</ul>';
|
||||||
|
$output .= '</form>';
|
||||||
|
$output .= '<script>'.$js.'</script>';
|
||||||
|
|
||||||
|
if ($return === false) {
|
||||||
|
echo $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $output_head.$output;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print a big button element (huge image, big text and link).
|
* Print a big button element (huge image, big text and link).
|
||||||
*
|
*
|
||||||
|
@ -360,7 +360,7 @@ class CustomNetScan extends Wizard
|
|||||||
// Avoid to print header out of wizard.
|
// Avoid to print header out of wizard.
|
||||||
$this->prepareBreadcrum($breadcrum);
|
$this->prepareBreadcrum($breadcrum);
|
||||||
|
|
||||||
// Header
|
// Header.
|
||||||
ui_print_page_header(__('NetScan Custom'), '', false, '', true, '', false, '', GENERIC_SIZE_TEXT, '', $this->printHeader(true));
|
ui_print_page_header(__('NetScan Custom'), '', false, '', true, '', false, '', GENERIC_SIZE_TEXT, '', $this->printHeader(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,7 +385,7 @@ class CustomNetScan extends Wizard
|
|||||||
// Avoid to print header out of wizard.
|
// Avoid to print header out of wizard.
|
||||||
$this->prepareBreadcrum($breadcrum);
|
$this->prepareBreadcrum($breadcrum);
|
||||||
|
|
||||||
// Header
|
// Header.
|
||||||
ui_print_page_header(__('NetScan Custom'), '', false, '', true, '', false, '', GENERIC_SIZE_TEXT, '', $this->printHeader(true));
|
ui_print_page_header(__('NetScan Custom'), '', false, '', true, '', false, '', GENERIC_SIZE_TEXT, '', $this->printHeader(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -594,7 +594,7 @@ class CustomNetScan extends Wizard
|
|||||||
|
|
||||||
// XXX: Could be improved validating inputs before continue (JS)
|
// XXX: Could be improved validating inputs before continue (JS)
|
||||||
// Print NetScan page 0.
|
// Print NetScan page 0.
|
||||||
$this->printForm($form, false, true);
|
$this->printFormAsList($form);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -742,7 +742,7 @@ class CustomNetScan extends Wizard
|
|||||||
get_explanation_recon_script($(this).val(), "'.$id_task.'", "'.$url_ajax.'");
|
get_explanation_recon_script($(this).val(), "'.$id_task.'", "'.$url_ajax.'");
|
||||||
})'.$change;
|
})'.$change;
|
||||||
|
|
||||||
$this->printForm($form, false, true);
|
$this->printFormAsList($form);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($this->page) === true && $this->page === 2) {
|
if (isset($this->page) === true && $this->page === 2) {
|
||||||
|
@ -230,8 +230,8 @@ li > input[type="password"],
|
|||||||
height: 100px;
|
height: 100px;
|
||||||
max-height: 100px;
|
max-height: 100px;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
|
-webkit-box-sizing: border-box;
|
||||||
-moz-box-sizing: border-box; /* Firefox, other Gecko */
|
-moz-box-sizing: border-box;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
resize: none;
|
resize: none;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user