cvs: php4 /pear/HTML Form.php

From: Date: Wed, 30 Jan 2002 09:26:25 +0000
Subject: cvs: php4 /pear/HTML Form.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-2239@lists.php.net to get a copy of this message
ssb Wed Jan 30 04:26:25 2002 EDT Modified files: /php4/pear/HTML Form.php Log: * XHTML fixes by Hans Westerbeek

Index: php4/pear/HTML/Form.php diff -u php4/pear/HTML/Form.php:1.21 php4/pear/HTML/Form.php:1.22 --- php4/pear/HTML/Form.php:1.21 Tue Jan 8 14:54:44 2002 +++ php4/pear/HTML/Form.php Wed Jan 30 04:26:25 2002 @@ -1,7 +1,7 @@ <?php // // +----------------------------------------------------------------------+ -// | PHP Version 4 | +// | PHP version 4 | // +----------------------------------------------------------------------+ // | Copyright (c) 1997-2002 The PHP Group | // +----------------------------------------------------------------------+ @@ -17,7 +17,7 @@ // | Urs Gehrig <urs@circle.ch> | // +----------------------------------------------------------------------+ // -// $Id: Form.php,v 1.21 2002/01/08 19:54:44 jan Exp $ +// $Id: Form.php,v 1.22 2002/01/30 09:26:25 ssb Exp $ // // HTML form utility functions. // @@ -38,13 +38,13 @@ { // {{{ properties - /** ACTION attribute of <FORM> tag */ + /** ACTION attribute of <form> tag */ var $action; - /** METHOD attribute of <FORM> tag */ + /** METHOD attribute of <form> tag */ var $method; - /** NAME attribute of <FORM> tag */ + /** NAME attribute of <form> tag */ var $name; /** an array of entries for this form */ @@ -53,17 +53,17 @@ /** DB_storage object, if tied to one */ var $storageObject; - /** TARGET attribute of <FORM> tag */ + /** TARGET attribute of <form> tag */ var $target; - /** ENCTYPE attribute of <FORM> tag */ + /** ENCTYPE attribute of <form> tag */ var $enctype; // }}} // {{{ constructor - function HTML_Form($action, $method = 'GET', $name = '', $target = '', $enctype = '') + function HTML_Form($action, $method = 'get', $name = '', $target = '', $enctype = '') { $this->action = $action; $this->method = $method; @@ -182,15 +182,15 @@ function start() { - print "<FORM ACTION=\"" . basename($this->action) . "\" METHOD=\"$this->method\""; + print "<form action=\"" . basename($this->action) . "\" method=\"$this->method\""; if ($this->name) { - print " NAME=\"$this->name\""; + print " name=\"$this->name\""; } if ($this->target) { - print " TARGET=\"$this->target\""; + print " target=\"$this->target\""; } if ($this->enctype) { - print " ENCTYPE=\"$this->enctype\""; + print " enctype=\"$this->enctype\""; } print ">\n"; } @@ -209,7 +209,7 @@ $fields[$data[1]] = true; } $this->displayHidden("_fields", implode(":", array_keys($fields))); - print "</FORM>"; + print "</form>"; } // }}} @@ -220,11 +220,11 @@ $size = HTML_FORM_TEXT_SIZE, $maxlength = '') { if (!$maxlength) { - print "<INPUT NAME=\"$name\" VALUE=\"$default\" SIZE=\"$size\""; + print "<input name=\"$name\" value=\"$default\" size=\"$size\""; } else { - print "<INPUT NAME=\"$name\" VALUE=\"$default\" SIZE=\"$size\" MAXLENGTH=\"$maxlength\""; + print "<input name=\"$name\" value=\"$default\" size=\"$size\" maxlength=\"$maxlength\""; } - print ">"; + print " />"; } // }}} @@ -233,12 +233,12 @@ function displayTextRow($name, $title, $default = '', $size = HTML_FORM_TEXT_SIZE, $maxlength = '') { - print " <TR>\n"; - print " <TH ALIGN=\"right\">$title</TH>"; - print " <TD>"; + print " <tr>\n"; + print " <th align=\"right\">$title</th>"; + print " <td>"; $this->displayText($name, $default, $size, $maxlength); - print "</TD>\n"; - print " </TR>\n"; + print "</td>\n"; + print " </tr>\n"; } // }}} @@ -296,13 +296,13 @@ $height = 5, $maxlength = '') { if (!$maxlength) { - print "<TEXTAREA NAME=\"$name\" COLS=\"$width\" ROWS=\"$height\""; + print "<textarea name=\"$name\" cols=\"$width\" rows=\"$height\""; } else { - print "<TEXTAREA NAME=\"$name\" COLS=\"$width\" ROWS=\"$height\" MAXLENGTH=\"$maxlength\""; + print "<textarea name=\"$name\" cols=\"$width\" rows=\"$height\" maxlength=\"$maxlength\""; } print ">"; print $default; - print "</TEXTAREA>"; + print "</textarea>"; } // }}} @@ -311,12 +311,12 @@ function displayTextareaRow($name, $title, $default = '', $width = 40, $height = 5, $maxlength = '') { - print " <TR>\n"; - print " <TH ALIGN=\"right\" VALIGN=\"top\">$title</TH>\n"; - print " <TD>"; - $this->displayTextarea($name, $default, $width, $height, $maxlength); - print "</TD>\n"; - print " </TR>\n"; + print " <tr>\n"; + print " <th align=\"right\" valign=\"top\">$title</th>\n"; + print " <td>"; + $this->displayTextarea($name, &$default, $width, $height, $maxlength); + print "</td>\n"; + print " </tr>\n"; } // }}} @@ -388,26 +388,26 @@ function displayRadio($name, $value, $default = false) { if ($default == false) { - print "<INPUT type='radio' name=\"$name\" value=\"$value\">"; + print "<input type='radio' name=\"$name\" value=\"$value\" />"; } else { - print "<INPUT type='radio' name=\"$name\" checked value=\"$value\">"; + print "<input type='radio' name=\"$name\" checked value=\"$value\" />"; } } - // }}}displayRadio() + // }}} // {{{ displayRadioRow() function displayRadioRow($name, $title, $value, $default = false) { - print " <TR>\n"; - print "<TH ALIGN=\"right\">$title</TH>"; - print " <TD>"; + print " <tr>\n"; + print "<th align=\"right\">$title</th>"; + print " <td>"; $this->displayRadio($name, $value, $default); - print "</TD>\n"; - print " </TR>\n"; + print "</td>\n"; + print " </tr>\n"; } - // }}}displayRadioRow() + // }}} // {{{ displayBlank() function displayBlank() @@ -422,20 +422,20 @@ { if (!$title) { for ($j = 0;$j < $i;$j++) { - print " <TR>\n"; - print " <TH ALIGN=\"right\">&nbsp;</TH>"; - print " <TD>"; + print " <tr>\n"; + print " <th align=\"right\">&nbsp;</th>"; + print " <td>"; $this->displayBlank(); - print "</TD>\n"; - print " </TR>\n"; + print "</td>\n"; + print " </tr>\n"; } } else { - print " <TR>\n"; - print " <TH ALIGN=\"right\">$title</TH>"; - print " <TD>"; + print " <tr>\n"; + print " <th align=\"right\">$title</th>"; + print " <td>"; $this->displayBlank(); - print "</TD>\n"; - print " </TR>\n"; + print "</td>\n"; + print " </tr>\n"; } } @@ -445,30 +445,29 @@ function displayFile($name, $maxsize = HTML_FORM_MAX_FILE_SIZE, $size = HTML_FORM_TEXT_SIZE, $accept = '') { - print "<INPUT TYPE=\"file\" NAME=\"$name\" MAXSIZE=\"$maxsize\" SIZE=\"$size\""; + print "<input type=\"file\" name=\"$name\" maxsize=\"$maxsize\" size=\"$size\""; if ($accept) { - print " ACCEPT=\"$accept\""; + print " accept=\"$accept\""; } - print ">"; + print "/>"; } - // }}}displayFile() + // }}} // {{{ displayFileRow() function displayFileRow($name, $title, $maxsize = HTML_FORM_MAX_FILE_SIZE, $size = HTML_FORM_TEXT_SIZE, $accept = '') { - print " <TR>\n"; - print " <TH ALIGN=\"right\">$title:</TH>"; - print " <TD>"; + print " <tr>\n"; + print " <th align=\"right\">$title</th>"; + print " <td>"; $this->displayFile($name, $maxsize, $size, $accept); - print "</TD>\n"; - print " </TR>\n"; + print "</td>\n"; + print " </tr>\n"; } - // }}}displayFileRow() - + // }}} // {{{ returnText() @@ -633,7 +632,7 @@ $str .= " size=\"$size\""; } if ($multiple) { - $str .= " multiple"; + $str .= " multiple=\"multiple\""; } if ($attrib) { $str .= " $attrib"; @@ -648,10 +647,10 @@ if ($multiple && is_array($default)) { if ((is_string(key($default)) && $default[$val]) || (is_int(key($default)) && in_array($val, $default))) { - $str .= 'selected '; + $str .= 'selected="selected" '; } } elseif ($default == $val) { - $str .= 'selected '; + $str .= 'selected="selected" '; } } $str .= "value=\"$val\">$text</option>\n"; @@ -668,7 +667,7 @@ $blank = '', $multiple = false, $attribs = '') { $str = " <tr>\n"; - $str .= " <th align=\"right\">$title:</th>\n"; + $str .= " <th align=\"right\">$title</th>\n"; $str .= " <td>\n"; $str .= $this->returnSelect($name, $entries, $default, $size, $blank, $multiple, $attribs); $str .= " </td>\n";
« previous php.pear.cvs (#2239) next »