X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FHTMLForm.php;h=1a2f5810a957b76e9975a3c1bcb3f753433ef26f;hb=4e250a20b9fde4e72128f391fae65760196795fb;hp=a13831f7a27688d24cb76d4cd54f2ecee19422df;hpb=bd46c557ca0f82f52378596600da718c47e89ef9;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/HTMLForm.php b/includes/HTMLForm.php index a13831f7a2..1a2f5810a9 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,35 +28,40 @@ 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( $_POST[$varname] ) && $_POST[$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( $_POST[$varname] ) ? $_POST[$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 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 ) { @@ -56,35 +69,88 @@ class HTMLForm { ( $checked ? ' checked="checked"' : '' ) . " />" . wfMsg( $this->mName.'-'.$varname.'-'.$value ) . "\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( $_POST[$varname] ) ? $_POST[$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( $_POST[$varname] ) && is_array( $_POST[$varname] ) ) { - foreach ( $_POST[$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 "