<?php

class SpecialTestForm extends SpecialPage {
	function __construct() {
		parent::__construct( 'TestForm' );
	}
	
	function execute( $par ) {
		global $wgOut;
		
		$wgOut->setPageTitle( 'LOL TEST FORM' );
		
		$formDescriptor = array(
			'myfield1' => array(
				'section' => 'section1/subsection',
				'label-message' => 'testform-myfield1',
				'class' => 'HTMLTextField',
				'default' => 'Meep',
			),
			'myfield2' => array(
				'section' => 'section1',
				'label-message' => 'testform-myfield2',
				'class' => 'HTMLTextField',
			),
			'myfield3' => array(
				'class' => 'HTMLTextField',
				'label' => 'Foo bar baz',
			),
			'myfield4' => array(
				'class' => 'HTMLCheckField',
				'label' => 'This be a pirate checkbox',
				'default' => true,
			),
			'omgaselectbox' => array(
				'class' => 'HTMLSelectField',
				'label' => 'Select an oooption',
				'options' => array(
								'pirate' => 'Pirates',
								'ninja' => 'Ninjas',
								'ninjars' => 'Back to the NINJAR!'
							),
			),
			'omgmultiselect' => array(
				'class' => 'HTMLMultiSelectField',
				'label' => 'Weapons to use',
				'options' => array( 'cannon' => 'Cannons', 'sword' => 'Swords' ),
				'default' => array( 'sword' ),
			),
			'radiolol' => array(
				'class' => 'HTMLRadioField',
				'label' => 'Who do you like?',
				'options' => array( 'pirates' => 'Pirates', 'ninjas' => 'Ninjas',
									'both' => 'Both' ),
				'default' => 'pirates',
			),
		);
		
		$htmlForm = new HTMLForm( $formDescriptor, 'testform' );
		
		$htmlForm->setSubmitText( 'Foo submit' );
		$htmlForm->setTitle( $this->getTitle() );
		$htmlForm->setSubmitCallback( array( 'SpecialTestForm', 'trySubmit' ) );
		
		$htmlForm->show();
	}
	
	static function trySubmit( $formData ) {
		if ($formData['myfield1'] == 'Fleep')
			return true;
		
		return "HAHA FAIL";
	}
}

$wgSpecialPages['TestForm'] = 'SpecialTestForm';