protected function OnPreRender()
 {
     require_once 'xhtml/forms/textbox.class.php';
     parent::AddControl('<div>');
     # div inside form required by XHTML
     # persist params as requested
     foreach ($this->a_persisted_params as $s_param) {
         $s_param = trim($s_param);
         $a_fields = $this->IsPostback() ? $_POST : $_GET;
         if (isset($a_fields[$s_param])) {
             $o_param_box = new TextBox($s_param);
             $o_param_box->SetText($a_fields[$s_param]);
             $o_param_box->SetMode(TextBoxMode::Hidden());
             parent::AddControl($o_param_box);
             unset($o_param_box);
         }
     }
     # add default buttons
     if ($this->b_show_buttons_at_top) {
         parent::AddControl($this->CreateDefaultButtons());
     }
     # display validator errors
     if (!$this->IsValid() and $this->GetShowValidationErrors()) {
         require_once 'data/validation/validation-summary.class.php';
         $a_controls = array($this);
         parent::AddControl(new ValidationSummary($a_controls));
     }
     # Adjust headings
     if ($this->b_show_sections) {
         foreach ($this->a_edit_controls as $o_control) {
             $o_control->SetIsInSection(true);
         }
     } else {
         foreach ($this->a_section_headings as $o_heading) {
             $i_key = array_search($o_heading, $this->a_controls_to_render, true);
             if (!($i_key === false)) {
                 if (array_key_exists($i_key, $this->a_controls_to_render)) {
                     unset($this->a_controls_to_render[$i_key]);
                 }
             }
         }
     }
     # Add the edit controls themselves, one at a time so that they're streamed
     foreach ($this->a_controls_to_render as $control) {
         parent::AddControl($control);
     }
     # add ids
     $a_items = $this->GetDataObjects();
     $s_item_ids = '';
     foreach ($a_items as $o_data_object) {
         if (is_object($o_data_object) and method_exists($o_data_object, 'GetId')) {
             if ($s_item_ids) {
                 $s_item_ids .= ';';
             }
             $s_item_ids .= $o_data_object->GetId();
         }
     }
     if ($s_item_ids) {
         $o_id_box = new TextBox('items', $s_item_ids);
         $o_id_box->SetMode(TextBoxMode::Hidden());
         parent::AddControl($o_id_box);
     }
     # add default buttons
     parent::AddControl($this->CreateDefaultButtons());
     parent::AddControl('</div>');
     # div inside form required by XHTML
 }
 function OnPageLoad()
 {
     echo "<h1>Stoolball matches</h1>";
     # Filter controls
     $filter_box = new XhtmlForm();
     $filter_box->SetCssClass('dataFilter');
     $filter_box->AddAttribute('method', 'get');
     $filter_box->AddControl(new XhtmlElement('p', 'Show me: ', "follow-on large"));
     $filter_inner = new XhtmlElement('div');
     $filter_box->AddControl($filter_inner);
     $gender = new XhtmlSelect('player', 'Player type');
     $gender->SetHideLabel(true);
     $gender->AddControl(new XhtmlOption("mixed and ladies", ''));
     $gender->AddControl(new XhtmlOption('mixed', 1));
     $gender->AddControl(new XhtmlOption("ladies", 2));
     if (isset($_GET['player'])) {
         $gender->SelectOption($_GET['player']);
     }
     $filter_inner->AddControl($gender);
     $type = new XhtmlSelect('type', 'Match type');
     $type->SetHideLabel(true);
     $type->AddControl(new XhtmlOption('all matches', ''));
     $type->AddControl(new XhtmlOption('league matches', MatchType::LEAGUE));
     $type->AddControl(new XhtmlOption('cup matches', MatchType::CUP));
     $type->AddControl(new XhtmlOption('friendlies', MatchType::FRIENDLY));
     $type->AddControl(new XhtmlOption('tournaments', MatchType::TOURNAMENT));
     $type->AddControl(new XhtmlOption('practices', MatchType::PRACTICE));
     if (isset($_GET['type'])) {
         $type->SelectOption($_GET['type']);
     }
     $filter_inner->AddControl($type);
     $filter_inner->AddControl(' in ');
     $month = new XhtmlSelect('month', 'Month');
     $month->SetHideLabel(true);
     $month->AddControl(new XhtmlOption('next few matches', ''));
     foreach ($this->a_months as $i_month => $i_matches) {
         $opt = new XhtmlOption(Date::MonthAndYear($i_month), $i_month);
         if (isset($_GET['month']) and $_GET['month'] == $i_month) {
             $opt->AddAttribute('selected', 'selected');
         }
         $month->AddControl($opt);
         unset($opt);
     }
     $filter_inner->AddControl($month);
     $update = new XhtmlElement('input');
     $update->AddAttribute('type', 'submit');
     $update->AddAttribute('value', 'Update');
     $filter_inner->AddControl($update);
     # Content container
     $container = new XhtmlElement('div', $filter_box, "box");
     $content = new XhtmlElement("div", null, "box-content");
     $container->AddControl($content);
     # Display the matches
     if (count($this->a_matches)) {
         $list = new MatchListControl($this->a_matches);
         $content->AddControl($list);
     } else {
         $content->AddControl(new XhtmlElement('p', 'Sorry, there are no matches to show you.'));
         $content->AddControl(new XhtmlElement('p', 'If you know of a match which should be listed, please <a href="/play/manage/website/">add the match to the website</a>.'));
     }
     echo $container;
 }