X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FHTMLForm.php;h=0aaa07661577862e7b9d18aa55048654c0f3128c;hb=396524f67413c69576cd84b3c29cfc1045c05718;hp=b5b7084835ecc446b171a22186bc09bb97f6ef99;hpb=d06ec3f12b36c78a0fd031b29457e50b5e049f61;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/HTMLForm.php b/includes/HTMLForm.php index b5b7084835..0aaa076615 100644 --- a/includes/HTMLForm.php +++ b/includes/HTMLForm.php @@ -1,18 +1,26 @@ mRequest = $request; + } /** - * @access private - * @param string $name Name of the fieldset. - * @param string $content HTML content to put in. + * @private + * @param $name String: name of the fieldset. + * @param $content String: HTML content to put in. * @return string HTML fieldset */ function fieldset( $name, $content ) { @@ -20,71 +28,131 @@ class HTMLForm { $content . "\n\n"; } - /* - * @access private - * @param string $varname Name of the checkbox. - * @param boolean $checked Set true to check the box (default False). + /** + * @private + * @param $varname String: name of the checkbox. + * @param $checked Boolean: set true to check the box (default False). */ function checkbox( $varname, $checked=false ) { - $checked = isset( $GLOBALS[$varname] ) && $GLOBALS[$varname] ; + if ( $this->mRequest->wasPosted() && !is_null( $this->mRequest->getVal( $varname ) ) ) { + $checked = $this->mRequest->getCheck( $varname ); + } return "
\n"; } - /* - * @access private - * @param string $varname Name of the textbox. - * @param string $value Optional value (default empty) - * @param integer $size Optional size of the textbox (default 20) + /** + * @private + * @param $varname String: name of the textbox. + * @param $value String: optional value (default empty) + * @param $size Integer: optional size of the textbox (default 20) */ function textbox( $varname, $value='', $size=20 ) { - $value = isset( $GLOBALS[$varname] ) ? $GLOBALS[$varname] : $value; + if ( $this->mRequest->wasPosted() ) { + $value = $this->mRequest->getText( $varname, $value ); + } + $value = htmlspecialchars( $value ); return "
\n"; + "\n"; } - /* - * @access private - * @param string $varname Name of the radiobox. - * @param array $fields Various fields. + /** + * @private + * @param $varname String: name of the radiobox. + * @param $fields Array: Various fields. */ function radiobox( $varname, $fields ) { foreach ( $fields as $value => $checked ) { - $s .= "
\n"; } - return $this->fieldset( $this->mName.'-'.$varname, $s ); + return $this->fieldset( $varname, $s ); } - - /* - * @access private - * @param string $varname Name of the textareabox. - * @param string $value Optional value (default empty) - * @param integer $size Optional size of the textarea (default 20) + + /** + * @private + * @param $varname String: name of the textareabox. + * @param $value String: optional value (default empty) + * @param $size Integer: optional size of the textarea (default 20) */ function textareabox ( $varname, $value='', $size=20 ) { - $value = isset( $GLOBALS[$varname] ) ? $GLOBALS[$varname] : $value; + if ( $this->mRequest->wasPosted() ) { + $value = $this->mRequest->getText( $varname, $value ); + } + $value = htmlspecialchars( $value ); return '
\n"; } - /* - * @access private - * @param string $varname Name of the arraybox. - * @param integer $size Optional size of the textarea (default 20) + /** + * @private + * @param $varname String: name of the arraybox. + * @param $size Integer: Optional size of the textarea (default 20) */ function arraybox( $varname , $size=20 ) { $s = ''; - if ( isset( $GLOBALS[$varname] ) && is_array( $GLOBALS[$varname] ) ) { - foreach ( $GLOBALS[$varname] as $index=>$element ) { - $s .= $element."\n"; + if ( $this->mRequest->wasPosted() ) { + $arr = $this->mRequest->getArray( $varname ); + if ( is_array( $arr ) ) { + foreach ( $_POST[$varname] as $element ) { + $s .= htmlspecialchars( $element )."\n"; + } } } return "