- /**
- * Assembles an HTMLForm for the Pager and returns the HTML
- *
- * @return string
- */
- public function buildHTMLForm() {
- if ( $this->getHTMLFormFields() === null ) {
- throw new MWException( __METHOD__ . " was called without any form fields being defined" );
- }
-
- $form = new HTMLForm( $this->getHTMLFormFields(), $this->getContext() );
- $form->setMethod( 'get' );
- $form->setWrapperLegendMsg( $this->getHTMLFormLegend() );
- $form->setSubmitTextMsg( $this->getHTMLFormSubmit() );
- $this->addHiddenFields( $form );
- $this->modifyHTMLForm( $form );
- $form->prepareForm();
-
- return $form->getHTML( '' );
- }
-
- /**
- * Adds hidden elements to forms for things that are in the query string.
- * This is so that parameters like offset stick through form submissions
- *
- * @param HTMLForm $form
- */
- protected function addHiddenFields( HTMLForm $form ) {
- $query = $this->getRequest()->getQueryValues();
- $fieldsBlacklist = array( 'title' );
- $fields = $form->getFlatFields();
- foreach ( $fields as $name => $field ) {
- $fieldsBlacklist[] = $field->getName();
- }
- foreach ( $query as $name => $value ) {
- if ( in_array( $name, $fieldsBlacklist ) ) {
- continue;
- }
- $form->addHiddenField( $name, $value );
- }
- }
-