00001 <?php
00003
00004
00005
00006
00007
00008
00010
00028 function html_dropdown_list($name, $arr, $selected = null, $extra = null) {
00029 echo "<select name=\"{$name}\" {$extra} >\n";
00030 foreach ($arr as $value => $title) {
00031 echo '<option value="' . h($value) . '"';
00032 if ($selected == $value) { echo ' selected'; }
00033 echo '>' . h($title) . " </option>\n";
00034 }
00035 echo "</select>\n";
00036 }
00037
00047 function html_radio_group($name, $arr, $checked = null, $separator = '', $extra = null) {
00048 $ix = 0;
00049 foreach ($arr as $value => $title) {
00050 $value_h = h($value);
00051 $title = t($title);
00052 echo "<input name=\"{$name}\" type=\"radio\" id=\"{$name}_{$ix}\" value=\"{$value_h}\" ";
00053 if ($value == $checked) {
00054 echo "checked=\"checked\"";
00055 }
00056 echo " {$extra} />";
00057 echo "<label for=\"{$name}_{$ix}\">{$title}</label>";
00058 echo $separator;
00059 $ix++;
00060 echo "\n";
00061 }
00062 }
00063
00073 function html_checkbox_group($name, $arr, $selected = array(), $separator = '', $extra = null) {
00074 $ix = 0;
00075 if (!is_array($selected)) {
00076 $selected = array($selected);
00077 }
00078 foreach ($arr as $value => $title) {
00079 $value_h = h($value);
00080 $title = t($title);
00081 echo "<input name=\"{$name}[]\" type=\"checkbox\" id=\"{$name}_{$ix}\" value=\"{$value_h}\" ";
00082 if (in_array($value, $selected)) {
00083 echo "checked=\"checked\"";
00084 }
00085 echo " {$extra} />";
00086 echo "<label for=\"{$name}_{$ix}\">{$title}</label>";
00087 echo $separator;
00088 $ix++;
00089 echo "\n";
00090 }
00091 }
00092
00102 function html_checkbox($name, $value = 1, $checked = false, $label = '', $extra = null) {
00103 echo "<input name=\"{$name}\" type=\"checkbox\" id=\"{$name}_1\" value=\"{$value}\"";
00104 if ($checked) { echo " checked"; }
00105 echo " {$extra} />\n";
00106 if ($label) {
00107 echo "<label for=\"{$name}_1\">" . h($label) . "</label>\n";
00108 }
00109 }
00110
00120 function html_textbox($name, $value = '', $width = null, $maxLength = null, $extra = null) {
00121 echo "<input name=\"{$name}\" type=\"text\" value=\"" . h($value) . "\" ";
00122 if ($width) {
00123 echo "size=\"{$width}\" ";
00124 }
00125 if ($maxLength) {
00126 echo "maxlength=\"{$maxLength}\" ";
00127 }
00128 echo " {$extra} />\n";
00129 }
00130
00140 function html_password($name, $value = '', $width = null, $maxLength = null, $extra = null) {
00141 echo "<input name=\"{$name}\" type=\"password\" value=\"" . h($value) . "\" ";
00142 if ($width) {
00143 echo "size=\"{$width}\" ";
00144 }
00145 if ($maxLength) {
00146 echo "maxlength=\"{$maxLength}\" ";
00147 }
00148 echo " {$extra} />\n";
00149 }
00150
00160 function html_textarea($name, $value = '', $width = null, $height = null, $extra = null) {
00161 echo "<textarea name=\"{$name}\"";
00162 if ($width) { echo "cols=\"{$width}\" "; }
00163 if ($height) { echo "rows=\"{$height}\" "; }
00164 echo " {$extra} >";
00165 echo h($value);
00166 echo "</textarea>\n";
00167 }
00168
00176 function html_hidden($name, $value = '', $extra = null) {
00177 echo "<input name=\"{$name}\" type=\"hidden\" value=\"";
00178 echo h($value);
00179 echo "\" {$extra} />\n";
00180 }
00181
00189 function html_filefield($name, $width = null, $extra = null) {
00190 echo "<input name=\"{$name}\" type=\"file\"";
00191 if ($width) {
00192 echo " size=\"{$width}\"";
00193 }
00194 echo " {$extra} />\n";
00195 }
00196
00206 function html_form($name, $action, $method='post', $onsubmit='', $extra = null) {
00207 echo "<form name=\"{$name}\" action=\"{$action}\" method=\"{$method}\" ";
00208 if ($onsubmit) {
00209 echo "onsubmit=\"{$onsubmit}\"";
00210 }
00211 echo " {$extra} >\n";
00212 }
00213
00217 function html_form_close() {
00218 echo "</form>\n";
00219 }