1 <?php
defined('SYSPATH') OR die('No direct access allowed.');
4 if (!isset($info['brief'])) {
5 echo "Unknown command: $cmd_typ<br />\n";
9 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>";
11 echo "<h2>{$info['brief']}</h2>\n";
12 echo "<p>{$info['description']}</p>\n";
13 echo form
::open('command/commit', array('id' => 'command_form'));
16 $params = $info['params'];
18 # check if we need to make room for help icon
20 foreach ($params as $pname => $ary) {
21 if (array_key_exists('help', $ary)) {
27 foreach ($params as $pname => $ary) {
28 $form_name = "cmd_param[$pname]";
30 if (isset($ary['default']))
31 $dflt = $ary['default'];
33 # help column only printed if we really have a help key
35 echo "<tr><td style='width: 100px'>";
36 echo $use_help ?
(isset($ary['help']) ?
'<span style="width: 16px">'.$ary['help'].'</span> ' : '') : '';
37 if($ary['type'] === 'immutable') {
40 echo "<label for='field_$pname'>".$ary['name'].'</label>';
45 switch ($ary['type']) {
47 if (!is_array($dflt) && $cmd_typ != 'DEL_ALL_HOST_COMMENTS' && $cmd_typ != 'DEL_ALL_SVC_COMMENTS') {
48 if ($dflt && false !== array_search($dflt, $ary['options'])) {
49 $dflt = array_search($dflt, $ary['options']);
51 echo form
::dropdown(array('name' => $form_name, 'id' => 'field_'.$pname, 'style' => 'width: auto;'), $ary['options'], $dflt);
52 } elseif ($cmd_typ == 'DEL_ALL_SVC_COMMENTS' ||
$cmd_typ == 'DEL_ALL_HOST_COMMENTS') {
53 if ($dflt && false !== array_search($dflt, $ary['options'])) {
54 $dflt = array_search($dflt, $ary['options']);
56 echo form
::dropdown(array('name' => $form_name.'[]', 'id' => 'field_'.$pname, 'multiple' => 'multiple', 'style' => 'width: auto;'), $ary['options'], $dflt);
57 } else if (!empty($dflt)) {
59 foreach($dflt as $tmp) {
60 $tmp_obj[$tmp] = isset($ary['options'][$tmp]) ?
$ary['options'][$tmp] : $tmp;
62 $size = count($tmp_obj);
66 echo '<br />' . form
::dropdown(array('name' => $form_name.'[]', 'multiple' => 'multiple', 'id' => 'field_'.$pname, 'size' => $size, 'style' => 'width: 350px;'), $tmp_obj);
70 if (isset($ary['options'])) {
71 foreach ($ary['options'] as $k => $v) {
72 echo form
::checkbox($form_name . "[$k]", 'class="checkbox"');
78 $checked = (bool)$dflt;
79 echo form
::checkbox(array('name' => $form_name, 'id' => 'field_'.$pname), true, $checked, 'class="checkbox"');
83 echo form
::input(array('name' => $form_name, 'id' => 'field_'.$pname), $dflt, 'size="10"');
87 $dflt = current($dflt);
89 echo form
::hidden($form_name, $dflt);
90 echo '<b style="font-weight: bold;">'.$dflt.'</b>';
94 if ($form_name == 'cmd_param[comment]')
95 echo form
::input(array('class' => 'autotest-required', 'id' => 'field_'.$pname, 'name' => $form_name, 'title' => _('Required field'), 'style' => 'width: 280px'), $dflt, '');
104 $classname = 'float';
107 $classname = 'required';
109 echo form
::input(array('class' => "autotest-$classname", 'name' => $form_name, 'title' => _('Required field'), 'id' => 'field_'.$pname), $dflt, '');
117 echo "<tr><td colspan='2'>";
118 echo form
::hidden('cmd_typ', $cmd_typ);
119 echo form
::submit('Commit', _('Submit'), 'class="submit"');
120 if (!empty($params)) {
121 echo " <input type='reset' value='" . _("Reset") . "'>\n";
123 echo "</td></tr></table>";