1 <?php
defined('SYSPATH') OR die('No direct access allowed.');
3 if (!isset($info['brief'])) {
4 echo "Unknown command: $cmd_typ<br />\n";
8 echo "<style>table td {vertical-align: top;border: none;} input, select {margin: 0 0 6px 0;} b {margin: 0 0 6px 0; display: inline-block;}</style>";
10 echo '<div style="margin: 4px 8px">';
11 echo "<h2>{$info['brief']}</h2>\n";
12 echo "<p>{$info['description']}</p>\n";
15 echo form
::open('command/commit', array('id' => 'command_form'));
18 $params = $info['params'];
20 # check if we need to make room for help icon
22 foreach ($params as $pname => $ary) {
23 if (array_key_exists('help', $ary)) {
29 foreach ($params as $pname => $ary) {
30 $form_name = "cmd_param[$pname]";
32 if (isset($ary['default']))
33 $dflt = $ary['default'];
35 # help column only printed if we really have a help key
37 echo "<tr><td style='width: 100px'>";
38 echo $use_help ?
(isset($ary['help']) ?
'<span style="width: 16px">'.$ary['help'].'</span> ' : '') : '';
39 if($ary['type'] === 'immutable') {
42 echo "<label for='field_$pname'>".$ary['name'].'</label>';
47 switch ($ary['type']) {
49 if (!is_array($dflt) && $cmd_typ != 'DEL_ALL_HOST_COMMENTS' && $cmd_typ != 'DEL_ALL_SVC_COMMENTS') {
50 if ($dflt && false !== array_search($dflt, $ary['options'])) {
51 $dflt = array_search($dflt, $ary['options']);
53 echo form
::dropdown(array('name' => $form_name, 'id' => 'field_'.$pname, 'style' => 'width: auto;'), $ary['options'], $dflt);
54 } elseif ($cmd_typ == 'DEL_ALL_SVC_COMMENTS' ||
$cmd_typ == 'DEL_ALL_HOST_COMMENTS') {
55 if ($dflt && false !== array_search($dflt, $ary['options'])) {
56 $dflt = array_search($dflt, $ary['options']);
58 echo form
::dropdown(array('name' => $form_name.'[]', 'id' => 'field_'.$pname, 'multiple' => 'multiple', 'style' => 'width: auto;'), $ary['options'], $dflt);
59 } else if (!empty($dflt)) {
61 foreach($dflt as $tmp) {
62 $tmp_obj[$tmp] = isset($ary['options'][$tmp]) ?
$ary['options'][$tmp] : $tmp;
64 $size = count($tmp_obj);
68 echo '<br />' . form
::dropdown(array('name' => $form_name.'[]', 'multiple' => 'multiple', 'id' => 'field_'.$pname, 'size' => $size, 'style' => 'width: 350px;'), $tmp_obj);
72 if (isset($ary['options'])) {
73 foreach ($ary['options'] as $k => $v) {
74 echo form
::checkbox($form_name . "[$k]", 'class="checkbox"');
80 $checked = (bool)$dflt;
81 echo form
::checkbox(array('name' => $form_name, 'id' => 'field_'.$pname), true, $checked, 'class="checkbox"');
85 echo form
::input(array('name' => $form_name, 'id' => 'field_'.$pname), $dflt, 'size="10"');
89 $dflt = current($dflt);
91 echo form
::hidden($form_name, $dflt);
92 echo '<b style="font-weight: bold;">'.$dflt.'</b>';
96 if ($form_name == 'cmd_param[comment]')
97 echo form
::input(array('class' => 'autotest-required', 'id' => 'field_'.$pname, 'name' => $form_name, 'title' => _('Required field'), 'style' => 'width: 280px'), $dflt, '');
106 $classname = 'float';
109 $classname = 'required';
111 echo form
::input(array('class' => "autotest-$classname", 'name' => $form_name, 'title' => _('Required field'), 'id' => 'field_'.$pname), $dflt, '');
119 echo "<tr><td colspan='2'>";
120 echo form
::hidden('cmd_typ', $cmd_typ);
121 echo form
::submit('Commit', _('Submit'), 'class="submit"');
122 if (!empty($params)) {
123 echo " <input type='reset' value='" . _("Reset") . "'>\n";
125 echo "</td></tr></table>";