function show_form_select($name, $options = array()) { $options = array_merge(array('type' => 'select', 'value' => null, 'options' => array(), 'attrs' => array(), 'newline' => false), $options); $attrs = array_merge(array('name' => $name, 'id' => str_replace(array('[', ']'), '_', $name)), $options['attrs']); if ($options['type'] == 'select') { echo '<select ' . attrs_to_html($attrs) . '>'; } else { if ($options['type'] == 'radio') { echo '<div class="radio-container">'; } } foreach ($options['options'] as $key => $opt) { if ($options['type'] == 'select') { if ($options['value'] and $options['value'] == $key) { echo '<option value="' . htmlspecialchars($key) . '" selected="selected">' . htmlspecialchars($opt) . '</option>'; } else { echo '<option value="' . htmlspecialchars($key) . '">' . htmlspecialchars($opt) . '</option>'; } } else { if ($options['type'] == 'radio') { $id = $name . '_' . $key; $input_attrs = array_merge($attrs, array('id' => $id)); if ($options['value'] and $options['value'] == $key) { $input_attrs['checked'] = 'checked'; } show_form_input($name, array('type' => 'radio', 'value' => $key, 'attrs' => $input_attrs)); show_form_label($id, $opt); if ($options['newline']) { echo '<br/>'; } } } } if ($options['type'] == 'select') { echo '</select>'; } else { if ($options['type'] == 'radio') { echo '</div>'; } } }
function show_user_messages_frame($data, $errors) { global $l; if ($data['OS'] != 'WINDOWS') { $messages_style = ' style="display: none"'; } else { $messages_style = ''; } echo '<div class="form-frame form-frame-user-messages"' . $messages_style . '>'; echo '<h4>'; show_form_input('NOTIFY_USER', array('type' => 'checkbox', 'value' => $data['NOTIFY_USER'])); show_form_label('NOTIFY_USER', $l->g(448)); echo '</h4>'; if ($data['NOTIFY_USER'] != 'on') { echo '<div class="notify-fields" style="display: none">'; } else { echo '<div class="notify-fields">'; } show_form_field($data, $errors, 'textarea', 'NOTIFY_TEXT', $l->g(449)); show_form_field($data, $errors, 'input', 'NOTIFY_COUNTDOWN', $l->g(450)); show_form_field($data, $errors, 'input', 'NOTIFY_CAN_CANCEL', $l->g(451), array('type' => 'checkbox')); show_form_field($data, $errors, 'input', 'NOTIFY_CAN_DELAY', $l->g(452), array('type' => 'checkbox')); echo '</div>'; echo '</div>'; echo '<div class="form-frame form-frame-user-messages"' . $messages_style . '>'; echo '<h4>'; show_form_input('NEED_DONE_ACTION', array('type' => 'checkbox', 'value' => $data['NEED_DONE_ACTION'])); show_form_label('NEED_DONE_ACTION', 'Post-execution text'); // TODO translation echo '</h4>'; if ($data['NEED_DONE_ACTION'] != 'on') { echo '<div class="done-action-fields" style="display: none">'; } else { echo '<div class="done-action-fields">'; } show_form_field($data, $errors, 'textarea', 'NEED_DONE_ACTION_TEXT', $l->g(449)); echo '</div>'; echo '</div>'; }