function CreateControls()
 {
     require_once 'xhtml/forms/xhtml-select.class.php';
     require_once 'xhtml/forms/form-part.class.php';
     require_once 'xhtml/forms/textbox.class.php';
     /* @var $o_category Category */
     $o_category = $this->GetDataObject();
     # add categories
     $o_parent_list = new XhtmlSelect('parent_id');
     $o_parent_list->SetBlankFirst(true);
     $a_categories = $this->o_categories->GetItems();
     foreach ($a_categories as $o_parent) {
         if (is_object($o_parent)) {
             $o_opt = new XhtmlOption($o_parent->GetName(), $o_parent->GetId());
             $o_opt->AddAttribute('style', 'padding-left:' . ($o_parent->GetHierarchyLevel() - 1) . '0px');
             $o_parent_list->AddControl($o_opt);
             unset($o_opt);
         }
     }
     $o_parent_list->SelectOption($o_category->GetParentId());
     $o_parent_part = new FormPart('Create in', $o_parent_list);
     $this->AddControl($o_parent_part);
     # add name
     $o_url_box = new TextBox('name', $o_category->GetUrl());
     $o_url = new FormPart('Name', $o_url_box);
     $this->AddControl($o_url);
     # add display name
     $o_name_box = new TextBox('displayName', $o_category->GetName());
     $o_name_box->AddAttribute('maxlength', 255);
     $o_name = new FormPart('Display name', $o_name_box);
     $this->AddControl($o_name);
     # add sort override
     $o_sort_box = new TextBox('sort', $o_category->GetSortOverride());
     $o_sort = new FormPart('Sort order', $o_sort_box);
     $this->AddControl($o_sort);
 }
 /**
  * Creates the controls when the editor is in its fixture view
  *
  */
 private function CreateFixtureControls(Match $match, XhtmlElement $match_box)
 {
     $css_class = 'TournamentEdit';
     if ($this->GetCssClass()) {
         $css_class .= ' ' . $this->GetCssClass();
     }
     $match_outer_1 = new XhtmlElement('div');
     $match_outer_1->SetCssClass($css_class);
     $this->SetCssClass('');
     $match_outer_1->SetXhtmlId($this->GetNamingPrefix());
     $match_outer_2 = new XhtmlElement('div');
     $this->AddControl($match_outer_1);
     $match_outer_1->AddControl($match_outer_2);
     $match_outer_2->AddControl($match_box);
     if ($match->GetId()) {
         $heading = "Edit tournament";
     } else {
         $heading = "Add your tournament";
     }
     if ($this->show_step_number) {
         $heading .= ' – step 1 of 3';
     }
     $o_title_inner_1 = new XhtmlElement('span', $heading);
     $o_title_inner_2 = new XhtmlElement('span', $o_title_inner_1);
     $o_title_inner_3 = new XhtmlElement('span', $o_title_inner_2);
     $match_box->AddControl(new XhtmlElement('h2', $o_title_inner_3, "large"));
     # Tournament title
     $suggested_title = $match->GetTitle();
     if (isset($this->context_season)) {
         $suggested_title = $this->GetContextSeason()->GetCompetition()->GetName();
         if (strpos(strtolower($suggested_title), 'tournament') === false) {
             $suggested_title .= ' tournament';
         }
     } else {
         if (isset($this->context_team)) {
             $suggested_title = $this->GetContextTeam()->GetName();
             if (strpos(strtolower($suggested_title), 'tournament') === false) {
                 $suggested_title .= ' tournament';
             }
         }
     }
     if ($suggested_title == "To be confirmed tournament") {
         $suggested_title = "";
     }
     if ($suggested_title == "To be confirmed v To be confirmed") {
         $suggested_title = "";
     }
     $title = new TextBox($this->GetNamingPrefix() . 'Title', $suggested_title, $this->IsValidSubmit());
     $title->SetMaxLength(200);
     $match_box->AddControl(new FormPart('Tournament name', $title));
     # Open or invite?
     require_once 'xhtml/forms/radio-button.class.php';
     $qualify_set = new XhtmlElement('fieldset');
     $qualify_set->SetCssClass('formPart radioButtonList');
     $qualify_set->AddControl(new XhtmlElement('legend', 'Who can play?', 'formLabel'));
     $qualify_radios = new XhtmlElement('div', null, 'formControl');
     $qualify_set->AddControl($qualify_radios);
     $qualify_radios->AddControl(new RadioButton($this->GetNamingPrefix() . 'Open', $this->GetNamingPrefix() . 'Qualify', 'any team may enter', MatchQualification::OPEN_TOURNAMENT, $match->GetQualificationType() === MatchQualification::OPEN_TOURNAMENT or !$match->GetId(), $this->IsValidSubmit()));
     $qualify_radios->AddControl(new RadioButton($this->GetNamingPrefix() . 'Qualify', $this->GetNamingPrefix() . 'Qualify', 'only invited or qualifying teams can enter', MatchQualification::CLOSED_TOURNAMENT, $match->GetQualificationType() === MatchQualification::CLOSED_TOURNAMENT, $this->IsValidSubmit()));
     $match_box->AddControl($qualify_set);
     # Player type
     $suggested_type = 2;
     if (isset($this->context_season)) {
         $suggested_type = $this->context_season->GetCompetition()->GetPlayerType();
     } elseif (isset($this->context_team)) {
         $suggested_type = $this->context_team->GetPlayerType();
     }
     if (!is_null($match->GetPlayerType())) {
         $suggested_type = $match->GetPlayerType();
     }
     # Saved value overrides suggestion
     $player_set = new XhtmlElement('fieldset');
     $player_set->SetCssClass('formPart radioButtonList');
     $player_set->AddControl(new XhtmlElement('legend', 'Type of teams', 'formLabel'));
     $player_radios = new XhtmlElement('div', null, 'formControl');
     $player_set->AddControl($player_radios);
     $player_radios_1 = new XhtmlElement('div', null, 'column');
     $player_radios_2 = new XhtmlElement('div', null, 'column');
     $player_radios->AddControl($player_radios_1);
     $player_radios->AddControl($player_radios_2);
     $player_radios_1->AddControl(new RadioButton($this->GetNamingPrefix() . 'Ladies', $this->GetNamingPrefix() . 'PlayerType', 'Ladies', 2, $suggested_type === 2, $this->IsValidSubmit()));
     $player_radios_1->AddControl(new RadioButton($this->GetNamingPrefix() . 'Mixed', $this->GetNamingPrefix() . 'PlayerType', 'Mixed', 1, $suggested_type === 1, $this->IsValidSubmit()));
     $player_radios_2->AddControl(new RadioButton($this->GetNamingPrefix() . 'Girls', $this->GetNamingPrefix() . 'PlayerType', 'Junior girls', 5, $suggested_type === 5, $this->IsValidSubmit()));
     $player_radios_2->AddControl(new RadioButton($this->GetNamingPrefix() . 'Children', $this->GetNamingPrefix() . 'PlayerType', 'Junior mixed', 4, $suggested_type === 6, $this->IsValidSubmit()));
     $match_box->AddControl($player_set);
     # How many?
     $per_side_box = new XhtmlSelect($this->GetNamingPrefix() . "Players", null, $this->IsValid());
     $per_side_box->SetBlankFirst(true);
     for ($i = 6; $i <= 16; $i++) {
         $per_side_box->AddControl(new XhtmlOption($i));
     }
     if ($match->GetIsMaximumPlayersPerTeamKnown()) {
         $per_side_box->SelectOption($match->GetMaximumPlayersPerTeam());
     } else {
         if (!$match->GetId()) {
             # Use eight as sensible default for new tournaments
             $per_side_box->SelectOption(8);
         }
     }
     $players_per_team = new XhtmlElement("label", $per_side_box);
     $players_per_team->AddAttribute("for", $this->GetNamingPrefix() . "Players");
     $players_per_team->AddControl(" players per team");
     $players_part = new FormPart("How many players?", $players_per_team);
     $players_part->AddCssClass("playersPerTeam");
     $match_box->AddControl($players_part);
     # Overs
     $overs_box = new XhtmlSelect($this->GetNamingPrefix() . "Overs", null, $this->IsValid());
     $overs_box->SetBlankFirst(true);
     for ($i = 2; $i <= 8; $i++) {
         $overs_box->AddControl(new XhtmlOption($i));
     }
     if ($match->GetIsOversKnown()) {
         $overs_box->SelectOption($match->GetOvers());
     }
     $overs_label = new XhtmlElement("label", "Overs per innings");
     $overs_label->AddAttribute("for", $overs_box->GetXhtmlId());
     $overs_part = new FormPart($overs_label, new XhtmlElement("div", $overs_box));
     $overs_part->AddCssClass("overs");
     $match_box->AddControl($overs_part);
     # Start date and time
     if (!$match->GetStartTime()) {
         # if no date set, use specified default
         if ($this->i_default_time) {
             $match->SetStartTime($this->i_default_time);
         } else {
             # if no date set and no default, default to today at 10.30am BST
             # NOTE that if this is a new tournament in an old season, this date won't be selected because the available
             # dates will be limited below and won't include today. It'll be the same day in the relevant year though.
             $i_now = gmdate('U');
             $match->SetStartTime(gmmktime(9, 30, 00, (int) gmdate('n', $i_now), (int) gmdate('d', $i_now), (int) gmdate('Y', $i_now)));
             $match->SetIsStartTimeKnown(true);
         }
     }
     $o_date = new DateControl($this->GetNamingPrefix() . 'Start', $match->GetStartTime(), $match->GetIsStartTimeKnown(), $this->IsValidSubmit());
     $o_date->SetShowTime(true);
     $o_date->SetRequireTime(false);
     $o_date->SetMinuteInterval(5);
     # if only one season to choose from, limit available dates to the length of that season
     if ($this->context_season instanceof Season) {
         if ($this->context_season->GetStartYear() == $this->context_season->GetEndYear()) {
             $i_mid_season = gmmktime(0, 0, 0, 6, 30, $this->context_season->GetStartYear());
         } else {
             $i_mid_season = gmmktime(0, 0, 0, 12, 31, $this->context_season->GetStartYear());
         }
         $season_dates = Season::SeasonDates($i_mid_season);
         $season_start_month = gmdate('n', $season_dates[0]);
         $season_end_month = gmdate('n', $season_dates[1]);
         if ($season_start_month) {
             $o_date->SetMonthStart($season_start_month);
         }
         if ($season_end_month) {
             $o_date->SetMonthEnd($season_end_month);
         }
         $season_start_year = $this->context_season->GetStartYear();
         $season_end_year = $this->context_season->GetEndYear();
         if ($season_start_year) {
             $o_date->SetYearStart($season_start_year);
         }
         if ($season_end_year) {
             $o_date->SetYearEnd($season_end_year);
         }
     }
     $o_date_part = new FormPart('When?', $o_date);
     $o_date_part->SetIsFieldset(true);
     $match_box->AddControl($o_date_part);
     # Where?
     $o_ground_list = new XhtmlSelect($this->GetNamingPrefix() . 'Ground');
     $o_ground_list->AddControl(new XhtmlOption("Don't know", -1));
     $o_ground_list->AddControl(new XhtmlOption('Not listed (type the address in the notes field)', -2));
     # Promote the most likely grounds to the top of the list
     $likely_ground_ids = array();
     if ($match->GetGroundId()) {
         $likely_ground_ids[] = $match->GetGroundId();
     }
     foreach ($this->probable_teams as $o_team) {
         $likely_ground_ids[] = $o_team->GetGround()->GetId();
     }
     if (isset($this->context_season)) {
         foreach ($this->context_season->GetTeams() as $o_team) {
             $likely_ground_ids[] = $o_team->GetGround()->GetId();
         }
     }
     if (isset($this->context_team) and is_object($this->context_team->GetGround())) {
         $likely_ground_ids[] = $this->context_team->GetGround()->GetId();
     }
     $likely_grounds = array();
     $a_other_grounds = array();
     /* @var $o_ground Ground */
     foreach ($this->grounds->GetItems() as $o_ground) {
         if (array_search($o_ground->GetId(), $likely_ground_ids) > -1) {
             $likely_grounds[] = $o_ground;
         } else {
             $a_other_grounds[] = $o_ground;
         }
     }
     # Add home grounds
     foreach ($likely_grounds as $o_ground) {
         $option = new XhtmlOption($o_ground->GetNameAndTown(), $o_ground->GetId());
         $option->SetGroupName('Likely grounds');
         $o_ground_list->AddControl($option);
     }
     # Add away grounds
     foreach ($a_other_grounds as $o_ground) {
         $option = new XhtmlOption($o_ground->GetNameAndTown(), $o_ground->GetId());
         $option->SetGroupName('Other grounds');
         $o_ground_list->AddControl($option);
     }
     # Select ground
     if ($match->GetGroundId()) {
         $o_ground_list->SelectOption($match->GetGroundId());
     } elseif (isset($this->context_team)) {
         $o_ground_list->SelectOption($this->context_team->GetGround()->GetId());
     }
     $o_ground_part = new FormPart('Where?', $o_ground_list);
     $match_box->AddControl($o_ground_part);
     # Notes
     $o_notes = new TextBox($this->GetNamingPrefix() . 'Notes', $match->GetNotes());
     $o_notes->SetMode(TextBoxMode::MultiLine());
     $o_notes_part = new FormPart('Notes<br />(remember to include contact details)', $o_notes);
     $match_box->AddControl($o_notes_part);
     # Remember short URL
     $o_short_url = new TextBox($this->GetNamingPrefix() . 'ShortUrl', $match->GetShortUrl());
     $o_short_url->SetMode(TextBoxMode::Hidden());
     $match_box->AddControl($o_short_url);
     # Note the context team to be added to the tournament by default
     if (isset($this->context_team)) {
         $context_team_box = new TextBox($this->GetNamingPrefix() . 'ContextTeam', $this->context_team->GetId());
         $context_team_box->SetMode(TextBoxMode::Hidden());
         $match_box->AddControl($context_team_box);
     }
     # Change Save button to "Next" button
     if ($this->show_step_number) {
         $this->SetButtonText('Next &raquo;');
     }
 }
 function CreateControls()
 {
     $this->AddCssClass('form');
     /* @var $club Club */
     /* @var $competition Competition */
     /* @var $season Season */
     /* @var $ground Ground */
     require_once 'xhtml/forms/textbox.class.php';
     require_once 'xhtml/forms/checkbox.class.php';
     require_once 'stoolball/season-select.class.php';
     $team = $this->GetDataObject();
     $this->SetButtonText('Save team');
     /* @var $team Team */
     $is_once_only = $team->GetTeamType() == Team::ONCE;
     if ($this->is_admin) {
         # add club
         $club_list = new XhtmlSelect('club', null, $this->IsValidSubmit());
         $club_list->SetBlankFirst(true);
         foreach ($this->a_clubs as $club) {
             if ($club instanceof Club) {
                 $opt = new XhtmlOption($club->GetName(), $club->GetId());
                 $club_list->AddControl($opt);
                 unset($opt);
             }
         }
         if (!is_null($team->GetClub()) and $this->IsValidSubmit()) {
             $club_list->SelectOption($team->GetClub()->GetId());
         }
         $club_label = new XhtmlElement('label', 'Club');
         $club_label->AddAttribute('for', $club_list->GetXhtmlId());
         $this->AddControl($club_label);
         $this->AddControl($club_list);
     }
     if ($this->is_admin or $is_once_only) {
         # add name
         $name_box = new TextBox('name', $team->GetName(), $this->IsValidSubmit());
         $name_box->AddAttribute('maxlength', 100);
         $name = new XhtmlElement('label', 'Team name');
         $name->AddAttribute('for', $name_box->GetXhtmlId());
         $this->AddControl($name);
         $this->AddControl($name_box);
     }
     if ($this->is_admin) {
         # add player type
         $type_list = new XhtmlSelect('playerType', null, $this->IsValidSubmit());
         $type_list->AddControl(new XhtmlOption(PlayerType::Text(PlayerType::MIXED), PlayerType::MIXED));
         $type_list->AddControl(new XhtmlOption(PlayerType::Text(PlayerType::LADIES), PlayerType::LADIES));
         $type_list->AddControl(new XhtmlOption(PlayerType::Text(PlayerType::JUNIOR_MIXED), PlayerType::JUNIOR_MIXED));
         $type_list->AddControl(new XhtmlOption(PlayerType::Text(PlayerType::GIRLS), PlayerType::GIRLS));
         $type_list->AddControl(new XhtmlOption(PlayerType::Text(PlayerType::MEN), PlayerType::MEN));
         $type_list->AddControl(new XhtmlOption(PlayerType::Text(PlayerType::BOYS), PlayerType::BOYS));
         if (!is_null($team->GetPlayerType()) and $this->IsValidSubmit()) {
             $type_list->SelectOption($team->GetPlayerType());
         }
         $type_part = new XhtmlElement('label', 'Player type');
         $type_part->AddAttribute('for', $type_list->GetXhtmlId());
         $this->AddControl($type_part);
         $this->AddControl($type_list);
         # Remember short URL
         $short_url = new TextBox($this->GetNamingPrefix() . 'ShortUrl', $team->GetShortUrl(), $this->IsValidSubmit());
         $short_url_label = new XhtmlElement('label', 'Short URL');
         $short_url_label->AddAttribute('for', $short_url->GetXhtmlId());
         $this->AddControl($short_url_label);
         $this->AddControl($short_url);
     }
     # add intro
     $intro_box = new TextBox('intro', $team->GetIntro(), $this->IsValidSubmit());
     $intro_box->SetMode(TextBoxMode::MultiLine());
     $intro = new XhtmlElement('label', 'Introduction');
     $intro->AddAttribute('for', $intro_box->GetXhtmlId());
     $this->AddControl($intro);
     $this->AddControl('<p class="label-hint">If you need to change your team name, please email us.</p>');
     $this->AddControl($intro_box);
     if (!$is_once_only) {
         # Can we join in?
         $team_type = new XhtmlSelect('team_type', null, $this->IsValidSubmit());
         $team_type->AddControl(new XhtmlOption("plays regularly", Team::REGULAR, $team->GetTeamType() == Team::REGULAR));
         $team_type->AddControl(new XhtmlOption("represents a league or group", Team::REPRESENTATIVE, $team->GetTeamType() == Team::REPRESENTATIVE));
         $team_type->AddControl(new XhtmlOption("closed group (example: only staff can join a work team)", Team::CLOSED_GROUP, $team->GetTeamType() == Team::CLOSED_GROUP));
         $team_type->AddControl(new XhtmlOption("plays occasionally", Team::OCCASIONAL, $team->GetTeamType() == Team::OCCASIONAL));
         $team_type->AddControl(new XhtmlOption("school year group(s)", Team::SCHOOL_YEARS, $team->GetTeamType() == Team::SCHOOL_YEARS));
         $team_type->AddControl(new XhtmlOption("school club (eg after school)", Team::SCHOOL_CLUB, $team->GetTeamType() == Team::SCHOOL_CLUB));
         $team_type->AddControl(new XhtmlOption("other school team", Team::SCHOOL_OTHER, $team->GetTeamType() == Team::SCHOOL_OTHER));
         $type_label = new XhtmlElement('label', "Type of team");
         $type_label->AddAttribute('for', $team_type->GetXhtmlId());
         $this->AddControl($type_label);
         $this->AddControl('<p class="label-hint">We use this to decide when to list your team.</p>');
         $this->AddControl($team_type);
         $school_years_data = $this->GetDataObject()->GetSchoolYears();
         $school_years = new XhtmlElement("fieldset", null, "school-years");
         $school_years->AddControl(new XhtmlElement("legend", "Select the school year(s) this team represents"));
         $school_years->AddControl(new XhtmlElement("p", "For example, if Years 7 and 8 play together, select both. If Year 9 also plays, but separately, create a separate Year 9 team."));
         $school_years->AddControl(new CheckBox('year1', 'Year 1', 1, array_key_exists(1, $school_years_data) and $school_years_data[1], $this->IsValidSubmit()));
         $school_years->AddControl(new CheckBox('year2', 'Year 2', 1, array_key_exists(2, $school_years_data) and $school_years_data[2], $this->IsValidSubmit()));
         $school_years->AddControl(new CheckBox('year3', 'Year 3', 1, array_key_exists(3, $school_years_data) and $school_years_data[3], $this->IsValidSubmit()));
         $school_years->AddControl(new CheckBox('year4', 'Year 4', 1, array_key_exists(4, $school_years_data) and $school_years_data[4], $this->IsValidSubmit()));
         $school_years->AddControl(new CheckBox('year5', 'Year 5', 1, array_key_exists(5, $school_years_data) and $school_years_data[5], $this->IsValidSubmit()));
         $school_years->AddControl(new CheckBox('year6', 'Year 6', 1, array_key_exists(6, $school_years_data) and $school_years_data[6], $this->IsValidSubmit()));
         $school_years->AddControl(new CheckBox('year7', 'Year 7', 1, array_key_exists(7, $school_years_data) and $school_years_data[7], $this->IsValidSubmit()));
         $school_years->AddControl(new CheckBox('year8', 'Year 8', 1, array_key_exists(8, $school_years_data) and $school_years_data[8], $this->IsValidSubmit()));
         $school_years->AddControl(new CheckBox('year9', 'Year 9', 1, array_key_exists(9, $school_years_data) and $school_years_data[9], $this->IsValidSubmit()));
         $school_years->AddControl(new CheckBox('year10', 'Year 10', 1, array_key_exists(10, $school_years_data) and $school_years_data[10], $this->IsValidSubmit()));
         $school_years->AddControl(new CheckBox('year11', 'Year 11', 1, array_key_exists(11, $school_years_data) and $school_years_data[11], $this->IsValidSubmit()));
         $school_years->AddControl(new CheckBox('year11', 'Year 12', 1, array_key_exists(12, $school_years_data) and $school_years_data[12], $this->IsValidSubmit()));
         $this->AddControl($school_years);
         $this->AddControl(new CheckBox('playing', 'This team still plays matches', 1, $team->GetIsActive(), $this->IsValidSubmit()));
         # add ground
         $ground_list = new XhtmlSelect('ground', null, $this->IsValidSubmit());
         foreach ($this->a_grounds as $ground) {
             if ($ground instanceof Ground) {
                 $opt = new XhtmlOption($ground->GetNameAndTown(), $ground->GetId());
                 $ground_list->AddControl($opt);
                 unset($opt);
             }
         }
         $ground = $team->GetGround();
         if (is_numeric($ground->GetId()) and $this->IsValidSubmit()) {
             $ground_list->SelectOption($ground->GetId());
         }
         $ground_label = new XhtmlElement('label', 'Where do you play?');
         $ground_label->AddAttribute('for', $ground_list->GetXhtmlId());
         $this->AddControl($ground_label);
         $this->AddControl('<p class="label-hint">If your ground isn\'t listed, please email us the address.</p>');
         $this->AddControl($ground_list);
     }
     # Add seasons
     $this->AddControl(new XhtmlElement('label', 'Leagues and competitions'));
     $this->AddControl('<p class="label-hint">We manage the leagues and competitions you\'re listed in. Please email us with any changes.</p>');
     if (!$is_once_only) {
         # add times
         $times_box = new TextBox('times', $team->GetPlayingTimes(), $this->IsValidSubmit());
         $times_box->SetMode(TextBoxMode::MultiLine());
         $times = new XhtmlElement("label", 'Which days of the week do you play, and at what time?');
         $times->AddAttribute('for', $times_box->GetXhtmlId());
         $this->AddControl($times);
         $this->AddControl($times_box);
     }
     # add cost
     $year_box = new TextBox('yearCost', $team->GetCost(), $this->IsValidSubmit());
     $year_box->SetMode(TextBoxMode::MultiLine());
     $year = new XhtmlElement('label', 'Cost to play');
     $year->AddAttribute('for', $year_box->GetXhtmlId());
     $this->AddControl($year);
     $this->AddControl('<p class="label-hint">Do you have an annual membership fee? Match fees? Special rates for juniors?</p>');
     $this->AddControl($year_box);
     # add contact info
     $contact_box = new TextBox('contact', $team->GetContact(), $this->IsValidSubmit());
     $contact_box->SetMode(TextBoxMode::MultiLine());
     $contact = new XhtmlElement('label', 'Contact details for the public');
     $contact->AddAttribute('for', $contact_box->GetXhtmlId());
     $this->AddControl($contact);
     $this->AddControl('<p class="label-hint">We recommend you publish a phone number and email so new players can get in touch.</p>');
     $this->AddControl($contact_box);
     $private_box = new TextBox('private', $team->GetPrivateContact(), $this->IsValidSubmit());
     $private_box->SetMode(TextBoxMode::MultiLine());
     $private = new XhtmlElement('label', 'Contact details for Stoolball England (if different)');
     $private->AddAttribute('for', $private_box->GetXhtmlId());
     $this->AddControl($private);
     $this->AddControl('<p class="label-hint">We won\'t share this with anyone else.</p>');
     $this->AddControl($private_box);
     # add website url
     $website_url_box = new TextBox('websiteUrl', $team->GetWebsiteUrl(), $this->IsValidSubmit());
     $website_url_box->AddAttribute('maxlength', 250);
     $website_url = new XhtmlElement('label', 'Team website');
     $website_url->AddAttribute('for', $website_url_box->GetXhtmlId());
     $this->AddControl($website_url);
     $this->AddControl($website_url_box);
 }
 /**
  * Adds controls to edit a team score
  *
  * @param XhtmlElement $o_container
  * @param string $s_id_prefix
  * @param Match $o_match
  * @param Team $o_team
  * @param int $i_runs
  * @param int $i_wickets
  */
 private function CreateTeamScoreControls($o_container, $s_team_role, Match $o_match, Team $o_team = null, $i_runs, $i_wickets)
 {
     $o_box = new XhtmlElement('div');
     $o_runs = new TextBox($this->GetNamingPrefix() . $s_team_role . 'Runs', $i_runs);
     $o_runs->SetCssClass("numeric");
     if ($i_runs == null) {
         $o_runs->PopulateData();
     }
     $s_runs_label = (is_null($o_team) ? $s_team_role : $o_team->GetName()) . ' score';
     $o_part = new FormPart($s_runs_label, $o_box);
     $o_box->AddControl($o_runs);
     $o_part->GetLabel()->AddAttribute('for', $o_runs->GetXhtmlId());
     $o_wickets = new XhtmlSelect($this->GetNamingPrefix() . $s_team_role . 'Wickets', ' for ');
     $o_wickets->SetBlankFirst(true);
     $max_wickets = $o_match->GetMaximumPlayersPerTeam() - 2;
     $season_dates = Season::SeasonDates($o_match->GetStartTime());
     # working with GMT
     if (Date::Year($season_dates[0]) != Date::Year($season_dates[1])) {
         # outdoor needs maximum-2, but indoor needs maximum-1 cos last batter can play on.
         # if there's any chance it's indoor use maximum-1
         $max_wickets = $o_match->GetMaximumPlayersPerTeam() - 1;
     }
     for ($i = 0; $i <= $max_wickets; $i++) {
         $o_wickets->AddControl(new XhtmlOption($i));
     }
     $o_wickets->AddControl(new XhtmlOption('all out', -1));
     $o_wickets->SelectOption($i_wickets);
     $o_box->AddControl($o_wickets);
     $o_container->AddControl($o_part);
 }
 private function CreateWicketsRow(Match $match, $wickets_taken)
 {
     $wickets_header = new XhtmlCell(true, "Wickets");
     $wickets_header->SetColumnSpan(4);
     $wickets = new XhtmlSelect("batWickets", null, $this->IsValidSubmit());
     $wickets->SetBlankFirst(true);
     $max_wickets = $match->GetMaximumPlayersPerTeam() - 2;
     $season_dates = Season::SeasonDates($match->GetStartTime());
     # working with GMT
     if (Date::Year($season_dates[0]) != Date::Year($season_dates[1])) {
         # outdoor needs maximum-2, but indoor needs maximum-1 cos last batter can play on.
         # if there's any chance it's indoor use maximum-1
         $max_wickets = $match->GetMaximumPlayersPerTeam() - 1;
     }
     for ($i = 0; $i <= $max_wickets; $i++) {
         $wickets->AddControl(new XhtmlOption($i));
     }
     $wickets->AddControl(new XhtmlOption('all out', -1));
     if ($this->IsValidSubmit() and !is_null($wickets_taken)) {
         $wickets->SelectOption($wickets_taken);
     }
     $balls_column = new XhtmlCell(false, null);
     $wickets_row = new XhtmlRow(array($wickets_header, $wickets, $balls_column));
     $wickets_row->SetCssClass("totals");
     return $wickets_row;
 }
 /**
  * Configures, and repopulates on postback, a dropdown list to manage one property of a related data item
  *
  * @param XhtmlSelect $select
  * @param string $s_validated_value
  * @param string $s_name
  * @param int $i_row_count
  * @param int $i_total_rows
  * @param bool $b_required
  * @param string $s_default_value
  * @return XhtmlSelect
  */
 protected function ConfigureSelect($select, $s_validated_value, $s_name, $i_row_count, $i_total_rows, $b_required = false, $s_default_value = '')
 {
     # Establish current status
     $b_is_add_row = is_null($i_row_count);
     $b_repopulate_add_row = (!$this->IsValid() or $this->DeleteClicked() or $this->IsUnrelatedInternalPostback());
     $select->SetXhtmlId($this->GetNamingPrefix() . $s_name . $i_row_count);
     if ($b_required) {
         $select->SetCssClass('required');
     }
     # If this is the row used to add a new related item...
     # Add a blank option only if data is not required, or there's no obvious default
     if ($b_is_add_row and (!$b_required or !strlen($s_default_value))) {
         $select->SetBlankFirst(true);
     }
     # If there is a default, set it
     if ($b_is_add_row and !$this->IsPostback() and strlen($s_default_value)) {
         $select->SelectOption($s_default_value);
     }
     # But if it's an existing row and data is required, there's no blank option...
     if (!$b_is_add_row and !$b_required) {
         $select->SetBlankFirst(true);
     }
     # If this is the row used to add a new related item...
     if ($b_is_add_row) {
         # ...if we repopulate, it'll be with the exact value posted,
         # as validation has either failed or not occurred
         if ($b_repopulate_add_row and isset($_POST[$select->GetXhtmlId()])) {
             $select->SelectOption($_POST[$select->GetXhtmlId()]);
         }
     } else {
         if ($this->IsValid()) {
             if ($this->AddClicked() and $i_row_count == $this->i_row_added) {
                 # If a new row was posted, is valid, and is now displayed here, need to get the posted value from the add row
                 $s_select_in_add_row = substr($select->GetXhtmlId(), 0, strlen($select->GetXhtmlId()) - strlen($i_row_count));
                 $select->SelectOption($_POST[$s_select_in_add_row]);
             } else {
                 # Even though the editor as a whole is valid, this row wasn't validated
                 # so just restore the previous value
                 if (isset($_POST[$select->GetXhtmlId()])) {
                     $select->SelectOption($_POST[$select->GetXhtmlId()]);
                 } else {
                     # Won't be in $_POST when page is first loaded
                     $select->SelectOption($s_validated_value);
                 }
             }
         } else {
             # Repopulate with the exact value posted, as validation has failed
             $select->SelectOption($_POST[$select->GetXhtmlId()]);
         }
     }
     # Return dropdown so that other things can be done to it - eg add a CSS class
     return $select;
 }