public function CreateControls()
 {
     $this->AddCssClass('form');
     require_once 'xhtml/forms/textbox.class.php';
     $this->SetButtonText('Add new school');
     $school = new Club($this->GetSettings());
     /* @var $school Club */
     # add name
     $name_box = new TextBox('school-name', '', $this->IsValidSubmit());
     $name_box->AddAttribute('maxlength', 100);
     $name_box->AddAttribute('autocomplete', "off");
     $name_box->AddCssClass("searchable");
     $name = new XhtmlElement('label', 'School name');
     $name->AddAttribute('for', $name_box->GetXhtmlId());
     $this->AddControl($name);
     $this->AddControl($name_box);
     # add town
     $town_box = new TextBox('town', '', $this->IsValidSubmit());
     $town_box->AddAttribute('maxlength', 100);
     $town_box->AddAttribute('autocomplete', "off");
     $town_box->AddCssClass("searchable town");
     $town = new XhtmlElement('label', 'Town or village');
     $town->AddAttribute('for', $town_box->GetXhtmlId());
     $this->AddControl($town);
     $this->AddControl($town_box);
     # add hook for suggestions
     $this->AddControl('<div class="suggestions"></div>');
 }
 function CreateControls()
 {
     require_once 'xhtml/forms/form-part.class.php';
     require_once 'xhtml/forms/textbox.class.php';
     $role = $this->GetDataObject();
     # add id
     $id_box = new TextBox('item', (string) $role->getRoleId());
     $id_box->SetMode(TextBoxMode::Hidden());
     $this->AddControl($id_box);
     # add name
     $name_box = new TextBox('name', $role->getRoleName(), $this->IsValidSubmit());
     $name_box->AddAttribute('maxlength', 100);
     $name = new FormPart('Role name', $name_box);
     $this->AddControl($name);
     # Permissions
     if (!$this->IsPostback() or $this->IsValidSubmit()) {
         $permissions = $role->Permissions()->ToArray();
         foreach ($permissions as $permission => $scopes) {
             foreach ($scopes as $scope => $ignore) {
                 if ($scope == PermissionType::GLOBAL_PERMISSION_SCOPE) {
                     $scope = "";
                 }
                 $this->permissions_editor->DataObjects()->Add(new IdValue($permission, $scope));
             }
         }
     }
     $this->AddControl(new FormPart("Permissions", $this->permissions_editor));
 }
 public function CreateControls()
 {
     $this->AddCssClass('form');
     $this->SetButtonText("Save player");
     # get player to edit
     $player = $this->GetDataObject();
     if (!$player instanceof Player) {
         $player = new Player($this->GetSettings());
     }
     require_once "xhtml/forms/radio-button.class.php";
     if ($this->GetCurrentPage() == PlayerEditor::MERGE_PLAYER) {
         $this->AddControl("<p>There's another player named '" . htmlentities($player->GetName(), ENT_QUOTES, "UTF-8", false) . "' in this team. What would you like to do?</p>");
         $this->AddControl("<dl class=\"decision\"><dt>");
         $this->AddControl(new RadioButton($this->GetNamingPrefix() . "Merge", $this->GetNamingPrefix() . "MergeOptions", htmlentities("Merge with the other " . $player->GetName(), ENT_QUOTES, "UTF-8", false), 1, false, $this->IsValid()));
         $this->AddControl("</dt><dd>If they're the same person you can merge the records so there's only one " . htmlentities($player->GetName(), ENT_QUOTES, "UTF-8", false) . ". Don't choose this for a player who's got married and changed their name though.</dd>");
         $this->AddControl("<dt>");
         $this->AddControl(new RadioButton($this->GetNamingPrefix() . "Rename", $this->GetNamingPrefix() . "MergeOptions", "Choose a new name for this player", 2, false, $this->IsValid()));
         $this->AddControl("</dt><dd>If they're different people you need to pick a different name. For example, if you have two players called 'Jane Smith',\n\t\t\t\tchange one to 'Jane A Smith'.</dd></dl>");
     }
     # Container for form elements, useful for JavaScript to hide them
     $container = new XhtmlElement("div", null, "#playerEditorFields");
     $this->AddControl($container);
     # add name
     $name = new XhtmlElement("label", "Name");
     $name->AddAttribute("for", $this->GetNamingPrefix() . 'Name');
     $container->AddControl($name);
     $name_box = new TextBox($this->GetNamingPrefix() . 'Name', $player->GetName(), $this->IsValid());
     $name_box->AddAttribute('maxlength', 100);
     #$name = new FormPart('Name', $name_box);
     $container->AddControl($name_box);
 }
 function CreateControls()
 {
     /* @var $email Zend_Mail */
     $email = $this->GetDataObject();
     if (!is_object($email)) {
         $email = new Zend_Mail('UTF-8');
     }
     # Your details
     $name = new TextBox('fromName', '', $this->IsValidSubmit());
     $name->SetMaxLength(100);
     $name_part = new FormPart('Your name', $name);
     $this->AddControl($name_part);
     $from = new TextBox('from', '', $this->IsValidSubmit());
     $from->AddAttribute("type", "email");
     $from->SetMaxLength(250);
     $from_part = new FormPart('Your email address', $from);
     $this->AddControl($from_part);
     # Your email
     $subj = new TextBox('subject', '', $this->IsValidSubmit());
     $subj->SetMaxLength(250);
     $subj_part = new FormPart('Subject', $subj);
     $this->AddControl($subj_part);
     $body = new TextBox('body', '', $this->IsValidSubmit());
     $body->SetMode(TextBoxMode::MultiLine());
     $body_part = new FormPart('Your message', $body);
     $this->AddControl($body_part);
 }
 function CreateControls()
 {
     $club = $this->GetDataObject();
     /* @var $club Club */
     $this->AddControl(new FormPart('', new CheckBox('school', 'This is a school', 1, $this->GetDataObject()->GetTypeOfClub() === Club::SCHOOL, $this->IsValidSubmit())));
     $o_name_box = new TextBox('name', $this->GetDataObject()->GetName(), $this->IsValidSubmit());
     $o_name_box->AddAttribute('maxlength', 250);
     $o_name = new FormPart('Name', $o_name_box);
     $this->AddControl($o_name);
     $how_many_box = new TextBox('how_many_players', $club->GetHowManyPlayers(), $this->IsValidSubmit());
     $how_many_box->SetMaxLength(4);
     $how_many_box->AddAttribute("type", "number");
     $how_many = new FormPart('How many players?', new XhtmlElement('div', $how_many_box));
     $this->AddControl($how_many);
     $age_range_lower_box = new TextBox('age_range_lower', $club->GetAgeRangeLower(), $this->IsValidSubmit());
     $age_range_lower_box->SetMaxLength(2);
     $age_range_lower_box->AddAttribute("type", "number");
     $age_range_lower = new FormPart('Age range (from)', new XhtmlElement('div', $age_range_lower_box));
     $this->AddControl($age_range_lower);
     $age_range_upper_box = new TextBox('age_range_upper', $club->GetAgeRangeUpper(), $this->IsValidSubmit());
     $age_range_upper_box->SetMaxLength(2);
     $age_range_upper_box->AddAttribute("type", "number");
     $age_range_upper = new FormPart('Age range (to)', new XhtmlElement('div', $age_range_upper_box));
     $this->AddControl($age_range_upper);
     $twitter_box = new TextBox('twitter', $this->GetDataObject()->GetTwitterAccount(), $this->IsValidSubmit());
     $twitter_box->AddAttribute('maxlength', 16);
     $twitter = new FormPart('Twitter account', $twitter_box);
     $this->AddControl($twitter);
     $facebook_box = new TextBox('facebook', $this->GetDataObject()->GetFacebookUrl(), $this->IsValidSubmit());
     $facebook_box->AddAttribute('maxlength', 250);
     $facebook = new FormPart('Facebook URL', $facebook_box);
     $this->AddControl($facebook);
     $instagram_box = new TextBox('instagram', $this->GetDataObject()->GetInstagramAccount(), $this->IsValidSubmit());
     $instagram_box->AddAttribute('maxlength', 50);
     $instagram = new FormPart('Instagram account', $instagram_box);
     $this->AddControl($instagram);
     $this->AddControl(new FormPart('', new CheckBox('outdoors', 'Plays outdoors', 1, $this->GetDataObject()->GetPlaysOutdoors(), $this->IsValidSubmit())));
     $this->AddControl(new FormPart('', new CheckBox('indoors', 'Plays indoors', 1, $this->GetDataObject()->GetPlaysIndoors(), $this->IsValidSubmit())));
     $this->AddControl(new FormPart('', new CheckBox('clubmark', 'Clubmark accredited', 1, $this->GetDataObject()->GetClubmarkAccredited(), $this->IsValidSubmit())));
     # Remember short URL
     $o_short_url = new TextBox($this->GetNamingPrefix() . 'ShortUrl', $this->GetDataObject()->GetShortUrl());
     $this->AddControl(new FormPart('Short URL', $o_short_url));
 }
 function CreateControls()
 {
     require_once 'xhtml/forms/form-part.class.php';
     require_once 'xhtml/forms/checkbox.class.php';
     require_once 'xhtml/forms/textbox.class.php';
     $this->AddCssClass('legacy-form');
     $user = $this->GetDataObject();
     # add id
     $id_box = new TextBox('item', (string) $user->GetId());
     $id_box->SetMode(TextBoxMode::Hidden());
     $this->AddControl($id_box);
     # add name
     $name_box = new TextBox('known_as', $user->GetName(), $this->IsValidSubmit());
     $name_box->AddAttribute('maxlength', 210);
     $name = new FormPart('Nickname', $name_box);
     $this->AddControl($name);
     # add first name
     $fname_box = new TextBox('name_first', $user->GetFirstName(), $this->IsValidSubmit());
     $fname_box->AddAttribute('maxlength', 100);
     $fname = new FormPart('First name', $fname_box);
     $this->AddControl($fname);
     # add last name
     $lname_box = new TextBox('name_last', $user->GetLastName(), $this->IsValidSubmit());
     $lname_box->AddAttribute('maxlength', 100);
     $lname = new FormPart('Last name', $lname_box);
     $this->AddControl($lname);
     # add email
     $email_box = new TextBox('email', $user->GetEmail(), $this->IsValidSubmit());
     $email_box->AddAttribute('maxlength', 100);
     $email = new FormPart('Email', $email_box);
     $this->AddControl($email);
     # Is account disabled?
     $this->AddControl(new CheckBox("disabled", "Account disabled", 1, $user->GetAccountDisabled(), $this->IsValidSubmit()));
     # Permissions
     if (!$this->IsPostback() or $this->IsValidSubmit()) {
         foreach ($user->Roles() as $role) {
             /* @var $role Role */
             $this->roles_editor->DataObjects()->Add($role);
         }
     }
     $this->AddControl(new FormPart("Roles", $this->roles_editor));
 }
 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);
 }
 /**
  * Sets up controls for page 4 of the wizard
  * @param Match $match
  * @return void
  */
 private function CreateHighlightsControls(Match $match)
 {
     $b_got_teams = !(is_null($match->GetHomeTeam()) || is_null($match->GetAwayTeam()));
     // Move CSS class to div element
     $match_outer_1 = new XhtmlElement('div');
     $match_outer_1->SetCssClass('matchResultEdit panel');
     $match_outer_2 = new XhtmlElement('div');
     $match_box = new XhtmlElement('div');
     $this->AddControl($match_outer_1);
     $match_outer_1->AddControl($match_outer_2);
     $match_outer_2->AddControl($match_box);
     $o_title_inner_1 = new XhtmlElement('span', "Match highlights");
     $o_title_inner_2 = new XhtmlElement('span', $o_title_inner_1);
     $o_title_inner_3 = new XhtmlElement('span', $o_title_inner_2);
     $o_heading = new XhtmlElement('h2', $o_title_inner_3);
     $match_box->AddControl($o_heading);
     # Who's playing?
     $o_home_name = new TextBox($this->GetNamingPrefix() . 'Home');
     $o_away_name = new TextBox($this->GetNamingPrefix() . 'Away');
     $o_home_name->SetMode(TextBoxMode::Hidden());
     $o_away_name->SetMode(TextBoxMode::Hidden());
     if (!is_null($match->GetHomeTeam())) {
         $o_home_name->SetText($match->GetHomeTeam()->GetId() . MatchHighlightsEditControl::DATA_SEPARATOR . $match->GetHomeTeam()->GetName());
     }
     if (!is_null($match->GetAwayTeam())) {
         $o_away_name->SetText($match->GetAwayTeam()->GetId() . MatchHighlightsEditControl::DATA_SEPARATOR . $match->GetAwayTeam()->GetName());
     }
     $this->AddControl($o_home_name);
     $this->AddControl($o_away_name);
     # When? (for validator message only)
     $when = new TextBox($this->GetNamingPrefix() . 'Date', $match->GetStartTime());
     $when->SetMode(TextBoxMode::Hidden());
     $this->AddControl($when);
     # Who won?
     $o_winner = new XhtmlSelect($this->GetNamingPrefix() . 'Result');
     $o_winner->AddControl(new XhtmlOption("Don't know", ''));
     $result_types = array(MatchResult::HOME_WIN, MatchResult::AWAY_WIN, MatchResult::TIE, MatchResult::ABANDONED);
     foreach ($result_types as $result_type) {
         if ($b_got_teams) {
             $o_winner->AddControl(new XhtmlOption($this->NameTeams(MatchResult::Text($result_type), $match->GetHomeTeam(), $match->GetAwayTeam()), $result_type));
         } else {
             $o_winner->AddControl(new XhtmlOption(MatchResult::Text($result_type), $result_type));
         }
     }
     if ($this->IsValidSubmit()) {
         if ($match->Result()->GetResultType() == MatchResult::UNKNOWN and !is_null($match->Result()->GetHomeRuns()) and !is_null($match->Result()->GetAwayRuns())) {
             # If match result is not known but we can guess from the entered scores, select it
             if ($match->Result()->GetHomeRuns() > $match->Result()->GetAwayRuns()) {
                 $o_winner->SelectOption(MatchResult::HOME_WIN);
             } else {
                 if ($match->Result()->GetHomeRuns() < $match->Result()->GetAwayRuns()) {
                     $o_winner->SelectOption(MatchResult::AWAY_WIN);
                 } else {
                     if ($match->Result()->GetHomeRuns() == $match->Result()->GetAwayRuns()) {
                         $o_winner->SelectOption(MatchResult::TIE);
                     }
                 }
             }
         } else {
             $o_winner->SelectOption($match->Result()->GetResultType());
         }
     }
     $o_win_part = new FormPart('Who won?', $o_winner);
     $match_box->AddControl($o_win_part);
     # Get current player of match
     $player = $match->Result()->GetPlayerOfTheMatch();
     $home_player = $match->Result()->GetPlayerOfTheMatchHome();
     $away_player = $match->Result()->GetPlayerOfTheMatchAway();
     $current_pom = MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_NONE;
     if ($player instanceof Player) {
         $current_pom = MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_OVERALL;
     } else {
         if ($home_player instanceof Player or $away_player instanceof Player) {
             $current_pom = MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_HOME_AND_AWAY;
         }
     }
     # Choose from different types of player of the match
     require_once 'xhtml/forms/radio-button.class.php';
     $pom_container = new XhtmlElement('fieldset', new XhtmlElement('legend', 'Player of the match', 'formLabel'));
     $pom_container->SetCssClass('formPart');
     $pom_options = new XhtmlElement('div', null, 'formControl radioButtonList');
     $pom_options->SetXhtmlId($this->GetNamingPrefix() . "PlayerOptions");
     $pom_container->AddControl($pom_options);
     $match_box->AddControl($pom_container);
     $pom_options->AddControl(new RadioButton($this->GetNamingPrefix() . 'POM' . MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_NONE, $this->GetNamingPrefix() . 'POM', "none chosen", MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_NONE, $current_pom == MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_NONE, $this->IsValidSubmit()));
     $pom_options->AddControl(new RadioButton($this->GetNamingPrefix() . 'POM' . MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_OVERALL, $this->GetNamingPrefix() . 'POM', "yes, one chosen", MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_OVERALL, $current_pom == MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_OVERALL, $this->IsValidSubmit()));
     $pom_options->AddControl(new RadioButton($this->GetNamingPrefix() . 'POM' . MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_HOME_AND_AWAY, $this->GetNamingPrefix() . 'POM', "yes, one from each team", MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_HOME_AND_AWAY, $current_pom == MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_HOME_AND_AWAY, $this->IsValidSubmit()));
     # Controls for entering a single player of the match
     $player_name = new TextBox($this->GetNamingPrefix() . 'Player', $player instanceof Player ? $player->GetName() : '', $this->IsValidSubmit());
     $player_name->SetMaxLength(100);
     $player_name->AddCssClass("player");
     $player_name->AddCssClass("team" . $match->GetHomeTeamId());
     $player_name->AddCssClass("team" . $match->GetAwayTeamId());
     $player_name->AddAttribute("autocomplete", "off");
     $player_box = new XhtmlElement("div", $player_name);
     $player_team = new XhtmlSelect($this->GetNamingPrefix() . "PlayerTeam", " playing for", $this->IsValidSubmit());
     $player_team->SetCssClass("playerTeam");
     # for JS
     $player_team->AddControl(new XhtmlOption("Don't know", ""));
     $player_team->AddControl(new XhtmlOption($match->GetHomeTeam()->GetName(), $match->GetHomeTeamId()));
     $player_team->AddControl(new XhtmlOption($match->GetAwayTeam()->GetName(), $match->GetAwayTeamId()));
     if ($player instanceof Player) {
         $player_team->SelectOption($player->Team()->GetId());
     }
     $player_box->AddControl($player_team);
     $player_part = new FormPart("Player's name", $player_box);
     $player_part->SetXhtmlId($this->GetNamingPrefix() . "OnePlayer");
     $player_part->GetLabel()->AddAttribute("for", $player_name->GetXhtmlId());
     $match_box->AddControl($player_part);
     # Controls for entering home and away players of the match
     $home_box = new TextBox($this->GetNamingPrefix() . 'PlayerHome', $home_player instanceof Player ? $home_player->GetName() : '', $this->IsValidSubmit());
     $home_box->SetMaxLength(100);
     $home_box->AddCssClass("player");
     $home_box->AddCssClass("team" . $match->GetHomeTeamId());
     $home_box->AddAttribute("autocomplete", "off");
     $home_part = new FormPart($this->NameTeams('Home player', $match->GetHomeTeam(), $match->GetAwayTeam()), $home_box);
     $home_part->SetCssClass("formPart multiPlayer");
     $match_box->AddControl($home_part);
     $away_box = new TextBox($this->GetNamingPrefix() . 'PlayerAway', $away_player instanceof Player ? $away_player->GetName() : '', $this->IsValidSubmit());
     $away_box->SetMaxLength(100);
     $away_box->AddCssClass("player");
     $away_box->AddCssClass("team" . $match->GetAwayTeamId());
     $away_box->AddAttribute("autocomplete", "off");
     $away_part = new FormPart($this->NameTeams('Away player', $match->GetHomeTeam(), $match->GetAwayTeam()), $away_box);
     $away_part->SetCssClass("formPart multiPlayer");
     $match_box->AddControl($away_part);
     # Any comments?
     $comments = new TextBox($this->GetNamingPrefix() . 'Comments', '', $this->IsValidSubmit());
     $comments->SetMode(TextBoxMode::MultiLine());
     $comments->AddAttribute('class', 'matchReport');
     $comments_label = new XhtmlElement('label');
     $comments_label->AddAttribute('for', $comments->GetXhtmlId());
     $comments_label->AddCssClass('matchReport');
     $comments_label->AddControl('Add a match report:');
     $match_box->AddControl($comments_label);
     $match_box->AddControl($comments);
     if ($match->GetLastAudit() != null) {
         require_once "data/audit-control.class.php";
         $match_box->AddControl(new AuditControl($match->GetLastAudit(), "match"));
     }
     $this->SetButtonText('Save match');
 }
 function CreateControls()
 {
     require_once 'xhtml/xhtml-element.class.php';
     require_once 'xhtml/forms/form-part.class.php';
     require_once 'xhtml/forms/textbox.class.php';
     $this->AddCssClass('legacy-form');
     $o_comp = $this->GetDataObject();
     /* @var $o_type IdValue */
     /* @var $o_comp Competition */
     /* @var $o_season Season */
     # add name
     $o_name_box = new TextBox('name', $o_comp->GetName(), $this->IsValidSubmit());
     $o_name_box->AddAttribute('maxlength', 100);
     $o_name = new FormPart('Competition name', $o_name_box);
     $this->AddControl($o_name);
     # Add seasons once competition saved
     if ($o_comp->GetId()) {
         $a_seasons = $o_comp->GetSeasons();
         $o_season_part = new FormPart('Seasons');
         $o_season_control = new Placeholder();
         # List exisiting seasons
         if (is_array($a_seasons) and count($a_seasons)) {
             $o_seasons = new XhtmlElement('ul');
             foreach ($a_seasons as $o_season) {
                 $o_season_link = new XhtmlAnchor(Html::Encode($o_season->GetName()), $o_season->GetEditSeasonUrl());
                 $o_seasons->AddControl(new XhtmlElement('li', $o_season_link));
             }
             $o_season_control->AddControl($o_seasons);
         }
         $o_new_season = new XhtmlAnchor('Add season', '/play/competitions/seasonedit.php?competition=' . $o_comp->GetId());
         $o_season_control->AddControl($o_new_season);
         $o_season_part->SetControl($o_season_control);
         $this->AddControl($o_season_part);
     }
     # Still going?
     $this->AddControl(new CheckBox('active', 'This competition is still played', 1, $o_comp->GetIsActive(), $this->IsValidSubmit()));
     # add player type
     $o_type_list = new XhtmlSelect('playerType', null, $this->IsValidSubmit());
     $o_type_list->AddControl(new XhtmlOption(PlayerType::Text(PlayerType::MIXED), PlayerType::MIXED));
     $o_type_list->AddControl(new XhtmlOption(PlayerType::Text(PlayerType::LADIES), PlayerType::LADIES));
     $o_type_list->AddControl(new XhtmlOption(PlayerType::Text(PlayerType::JUNIOR_MIXED), PlayerType::JUNIOR_MIXED));
     $o_type_list->AddControl(new XhtmlOption(PlayerType::Text(PlayerType::GIRLS), PlayerType::GIRLS));
     $o_type_list->AddControl(new XhtmlOption(PlayerType::Text(PlayerType::MEN), PlayerType::MEN));
     $o_type_list->AddControl(new XhtmlOption(PlayerType::Text(PlayerType::BOYS), PlayerType::BOYS));
     if (!is_null($o_comp->GetPlayerType()) and $this->IsValidSubmit()) {
         $o_type_list->SelectOption($o_comp->GetPlayerType());
     }
     $o_type_part = new FormPart('Player type', $o_type_list);
     $this->AddControl($o_type_part);
     # add players per team
     $players_box = new TextBox('players', $o_comp->GetMaximumPlayersPerTeam(), $this->IsValidSubmit());
     $players_box->SetMaxLength(2);
     $players = new FormPart('Max players in league/cup team', $players_box);
     $this->AddControl($players);
     # add overs
     $overs_box = new TextBox('overs', $o_comp->GetOvers(), $this->IsValidSubmit());
     $overs_box->SetMaxLength(2);
     $overs = new FormPart('Overs per innings', $overs_box);
     $this->AddControl($overs);
     # category
     $cat_select = new CategorySelectControl($this->categories, $this->IsValidSubmit());
     $cat_select->SetXhtmlId($this->GetNamingPrefix() . 'category');
     if (!is_null($o_comp->GetCategory()) and $this->IsValidSubmit()) {
         $cat_select->SelectOption($o_comp->GetCategory()->GetId());
     }
     $this->AddControl(new FormPart('Category', $cat_select));
     # add intro
     $o_intro_box = new TextBox('intro', $o_comp->GetIntro(), $this->IsValidSubmit());
     $o_intro_box->SetMode(TextBoxMode::MultiLine());
     $o_intro = new FormPart('Introduction', $o_intro_box);
     $this->AddControl($o_intro);
     # add contact info
     $o_contact_box = new TextBox('contact', $o_comp->GetContact(), $this->IsValidSubmit());
     $o_contact_box->SetMode(TextBoxMode::MultiLine());
     $o_contact = new FormPart('Contact details', $o_contact_box);
     $this->AddControl($o_contact);
     # Add notification email
     $o_notify_box = new TextBox('notification', $o_comp->GetNotificationEmail(), $this->IsValidSubmit());
     $o_notify_box->SetMaxLength(200);
     $o_notify = new FormPart('Notification email', $o_notify_box);
     $this->AddControl($o_notify);
     # add website
     $o_website_box = new TextBox('website', $o_comp->GetWebsiteUrl(), $this->IsValidSubmit());
     $o_website_box->SetMaxLength(250);
     $o_website = new FormPart('Website', $o_website_box);
     $this->AddControl($o_website);
     # Remember short URL
     $o_short_url = new TextBox($this->GetNamingPrefix() . 'ShortUrl', $o_comp->GetShortUrl(), $this->IsValidSubmit());
     $this->AddControl(new FormPart('Short URL', $o_short_url));
 }
 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);
 }
 function CreateControls()
 {
     /* @var $o_email Zend_Mail */
     $this->AddCssClass('legacy-form');
     $o_email = $this->GetDataObject();
     if (!is_object($o_email)) {
         $o_email = new Zend_Mail('UTF-8');
     }
     # Who to send to
     $i_address_count = count($this->a_addresses);
     if ($i_address_count > 1) {
         $o_who = new XhtmlElement('fieldset', new XhtmlElement('legend', 'Why are you contacting us?'));
         $o_who->SetCssClass('radioButtonList');
         $i = 0;
         foreach ($this->a_addresses as $s_addr => $s_reason) {
             $o_radio = new XhtmlElement('input');
             $o_radio->SetEmpty(true);
             $o_radio->AddAttribute('type', 'radio');
             $o_radio->AddAttribute('name', 'to');
             $o_radio->AddAttribute('value', md5($s_addr));
             $o_radio->SetXhtmlId('to' . $i);
             if ($this->IsPostback()) {
                 if (isset($_POST['to']) and $_POST['to'] == md5($s_addr)) {
                     $o_radio->AddAttribute('checked', 'checked');
                 }
             } else {
                 if (!$i) {
                     $o_radio->AddAttribute('checked', 'checked');
                 }
             }
             $o_label = new XhtmlElement('label', $o_radio);
             $o_label->AddAttribute('for', $o_radio->GetXhtmlId());
             $o_label->AddControl($s_reason);
             $o_who->AddControl($o_label);
             $i++;
         }
         $this->AddControl($o_who);
     }
     # Your details
     $o_details = new XhtmlElement('fieldset');
     $o_details->AddControl(new XhtmlElement('legend', 'Your details'));
     $this->AddControl($o_details);
     $o_name = new TextBox('fromName', '', $this->IsValidSubmit());
     $o_name->SetMaxLength(100);
     $o_name_part = new FormPart('Name', $o_name);
     $o_details->AddControl($o_name_part);
     $o_from = new TextBox('from', '', $this->IsValidSubmit());
     $o_from->AddAttribute("type", "email");
     $o_from->SetMaxLength(250);
     $o_from_part = new FormPart('Email address', $o_from);
     $o_from_part->SetIsRequired(true);
     $o_details->AddControl($o_from_part);
     # Your email
     $o_message = new XhtmlElement('fieldset');
     $o_message->AddControl(new XhtmlElement('legend', 'Your email'));
     $this->AddControl($o_message);
     $o_subj = new TextBox('subject', '', $this->IsValidSubmit());
     $o_subj->SetMaxLength(250);
     $o_subj_part = new FormPart('Subject', $o_subj);
     $o_message->AddControl($o_subj_part);
     $o_body = new TextBox('body', '', $this->IsValidSubmit());
     $o_body->SetMode(TextBoxMode::MultiLine());
     $o_body_part = new FormPart('Your message', $o_body);
     $o_body_part->SetIsRequired(true);
     $o_message->AddControl($o_body_part);
     # Options
     $o_opt = new XhtmlElement('fieldset', null, "radioButtonList");
     $o_opt->AddControl(new XhtmlElement('legend', 'Options', "aural"));
     $this->AddControl($o_opt);
     $o_opt->AddControl(new CheckBox('cc', 'Send me a copy', 1, false, $this->IsValidSubmit()));
     $o_opt->AddControl(new CheckBox('reply', "I'd like a reply", 1, true, $this->IsValidSubmit()));
 }
 /**
  * Creates an extras/totals row at the bottom of the batting card
  * @param string $id
  * @param string $label
  * @param string $row_class
  * @param string $box_class
  * @param int $value
  * @return void
  */
 private function CreateExtrasRow($id, $label, $row_class, $box_class, $value)
 {
     $extras_header = new XhtmlCell(true, $label);
     $extras_header->SetColumnSpan(4);
     $extras = new TextBox($id, $value, $this->IsValidSubmit());
     $extras->AddAttribute("autocomplete", "off");
     $extras->SetCssClass($box_class);
     $extras->AddAttribute("type", "number");
     $balls_column = new XhtmlCell(false, null);
     $extras_row = new XhtmlRow(array($extras_header, $extras, $balls_column));
     $extras_row->SetCssClass($row_class);
     return $extras_row;
 }
 protected function CreateControls()
 {
     $o_match = $this->GetDataObject();
     /* @var $o_match Match */
     $b_got_teams = !(is_null($o_match->GetHomeTeam()) || is_null($o_match->GetAwayTeam()));
     $b_future = ($o_match->GetId() and $o_match->GetStartTime() > gmdate('U'));
     // Move CSS class to div element
     $o_match_outer_1 = new XhtmlElement('div');
     if ($this->GetCssClass()) {
         $o_match_outer_1->SetCssClass('matchResultEdit ' . $this->GetCssClass());
     } else {
         $o_match_outer_1->SetCssClass('matchResultEdit');
     }
     $this->SetCssClass('');
     $o_match_outer_2 = new XhtmlElement('div');
     $o_match_box = new XhtmlElement('div');
     $this->AddControl($o_match_outer_1);
     $o_match_outer_1->AddControl($o_match_outer_2);
     $o_match_outer_2->AddControl($o_match_box);
     if ($this->GetShowHeading()) {
         $s_heading = str_replace('{0}', $o_match->GetTitle(), $this->GetHeading());
         $s_heading = str_replace('{1}', Date::BritishDate($o_match->GetStartTime(), false), $s_heading);
         $o_title_inner_1 = new XhtmlElement('span', htmlentities($s_heading, ENT_QUOTES, "UTF-8", false));
         $o_title_inner_2 = new XhtmlElement('span', $o_title_inner_1);
         $o_title_inner_3 = new XhtmlElement('span', $o_title_inner_2);
         $o_heading = new XhtmlElement($this->b_in_section ? 'h3' : 'h2', $o_title_inner_3);
         $o_match_box->AddControl($o_heading);
     }
     # Who's playing?
     $o_home_name = new TextBox($this->GetNamingPrefix() . 'Home');
     $o_away_name = new TextBox($this->GetNamingPrefix() . 'Away');
     $o_home_name->SetMode(TextBoxMode::Hidden());
     $o_away_name->SetMode(TextBoxMode::Hidden());
     if (!is_null($o_match->GetHomeTeam())) {
         $o_home_name->SetText($o_match->GetHomeTeam()->GetId() . ";" . $o_match->GetHomeTeam()->GetName());
     }
     if (!is_null($o_match->GetAwayTeam())) {
         $o_away_name->SetText($o_match->GetAwayTeam()->GetId() . ";" . $o_match->GetAwayTeam()->GetName());
     }
     $this->AddControl($o_home_name);
     $this->AddControl($o_away_name);
     # When? (for validator message only)
     $when = new TextBox($this->GetNamingPrefix() . 'Date', $o_match->GetStartTime());
     $when->SetMode(TextBoxMode::Hidden());
     $this->AddControl($when);
     # Who batted first?
     if (!$b_future) {
         $o_bat_first = new XhtmlSelect($this->GetNamingPrefix() . 'BatFirst');
         $o_bat_first->AddControl(new XhtmlOption("Don't know", ''));
         if ($b_got_teams) {
             $o_bat_first->AddControl(new XhtmlOption($o_match->GetHomeTeam()->GetName(), 'home'));
             $o_bat_first->AddControl(new XhtmlOption($o_match->GetAwayTeam()->GetName(), 'away'));
         } else {
             $o_bat_first->AddControl(new XhtmlOption('Home team', 'home'));
             $o_bat_first->AddControl(new XhtmlOption('Away team', 'away'));
         }
         if (!is_null($o_match->Result()->GetHomeBattedFirst())) {
             if ($o_match->Result()->GetHomeBattedFirst()) {
                 $o_bat_first->SelectOption('home');
             } else {
                 $o_bat_first->SelectOption('away');
             }
         }
         $o_bat_part = new FormPart('Who batted first?', $o_bat_first);
         $o_match_box->AddControl($o_bat_part);
     }
     # Who won?
     $o_winner = new XhtmlSelect($this->GetNamingPrefix() . 'Result');
     $o_winner->AddControl(new XhtmlOption($b_future ? 'The match will go ahead' : "Don't know", ''));
     $result_types = array(MatchResult::HOME_WIN, MatchResult::AWAY_WIN, MatchResult::HOME_WIN_BY_FORFEIT, MatchResult::AWAY_WIN_BY_FORFEIT, MatchResult::TIE, MatchResult::POSTPONED, MatchResult::CANCELLED, MatchResult::ABANDONED);
     if ($o_match->GetMatchType() == MatchType::TOURNAMENT_MATCH) {
         # You don't postpone a match in a tournament for another day
         unset($result_types[array_search(MatchResult::POSTPONED, $result_types, true)]);
     }
     foreach ($result_types as $result_type) {
         if (!$b_future or MatchResult::PossibleInAdvance($result_type)) {
             if ($b_got_teams) {
                 $o_winner->AddControl(new XhtmlOption($this->NameTeams(MatchResult::Text($result_type), $o_match->GetHomeTeam(), $o_match->GetAwayTeam()), $result_type));
             } else {
                 $o_winner->AddControl(new XhtmlOption(MatchResult::Text($result_type), $result_type));
             }
         }
     }
     $o_winner->SelectOption($o_match->Result()->GetResultType());
     $o_win_part = new FormPart($b_future ? 'Will it happen?' : 'Who won?', $o_winner);
     $o_match_box->AddControl($o_win_part);
     # If the match has already happened
     if (!$b_future) {
         # What did each team score?
         $this->CreateTeamScoreControls($o_match_box, 'Home', $o_match, $o_match->GetHomeTeam(), $o_match->Result()->GetHomeRuns(), $o_match->Result()->GetHomeWickets());
         $this->CreateTeamScoreControls($o_match_box, 'Away', $o_match, $o_match->GetAwayTeam(), $o_match->Result()->GetAwayRuns(), $o_match->Result()->GetAwayWickets());
         # Any comments?
         $comments = new TextBox($this->GetNamingPrefix() . 'Comments', '', $this->IsValidSubmit());
         $comments->SetMode(TextBoxMode::MultiLine());
         $comments->AddAttribute('class', 'matchReport');
         $comments_label = new XhtmlElement('label');
         $comments_label->AddAttribute('for', $comments->GetXhtmlId());
         $comments_label->AddCssClass('matchReport');
         $comments_label->AddControl('Add a match report:');
         $o_match_box->AddControl($comments_label);
         $o_match_box->AddControl($comments);
     }
     # Show audit data
     if ($o_match->GetLastAudit() != null) {
         require_once "data/audit-control.class.php";
         $o_match_box->AddControl(new AuditControl($o_match->GetLastAudit(), "match"));
     }
 }
 public function CreateControls()
 {
     $this->AddCssClass('form');
     require_once 'xhtml/forms/textbox.class.php';
     $this->SetButtonText('Save school');
     $school = $this->GetDataObject();
     /* @var $school School */
     # Get ground id
     $ground_id = new TextBox('ground-id', $school->Ground()->GetId(), $this->IsValidSubmit());
     $ground_id->SetMode(TextBoxMode::Hidden());
     $this->AddControl($ground_id);
     # add name
     $name_box = new TextBox('school-name', $school->Ground()->GetAddress()->GetPaon(), $this->IsValidSubmit());
     $name_box->AddAttribute('maxlength', 100);
     $name_box->AddAttribute('autocomplete', "off");
     $name = new XhtmlElement('label', 'School name');
     $name->AddAttribute('for', $name_box->GetXhtmlId());
     $this->AddControl($name);
     $this->AddControl($name_box);
     # add street
     $street_box = new TextBox('street', $school->Ground()->GetAddress()->GetStreetDescriptor(), $this->IsValidSubmit());
     $street_box->AddAttribute('maxlength', 250);
     $street_box->AddAttribute('autocomplete', "off");
     $street_box->AddCssClass("street");
     $street = new XhtmlElement('label', 'Road');
     $street->AddAttribute('for', $street_box->GetXhtmlId());
     $this->AddControl($street);
     $this->AddControl($street_box);
     # add locality
     $locality_box = new TextBox('locality', $school->Ground()->GetAddress()->GetLocality(), $this->IsValidSubmit());
     $locality_box->AddAttribute('maxlength', 250);
     $locality_box->AddAttribute('autocomplete', "off");
     $locality_box->AddCssClass("town");
     $locality = new XhtmlElement('label', 'Part of town');
     $locality->AddAttribute('for', $locality_box->GetXhtmlId());
     $this->AddControl($locality);
     $this->AddControl($locality_box);
     # add town
     $town_box = new TextBox('town', $school->Ground()->GetAddress()->GetTown(), $this->IsValidSubmit());
     $town_box->AddAttribute('maxlength', 100);
     $town_box->AddAttribute('autocomplete', "off");
     $town_box->AddCssClass("town");
     $town = new XhtmlElement('label', 'Town or village');
     $town->AddAttribute('for', $town_box->GetXhtmlId());
     $this->AddControl($town);
     $this->AddControl($town_box);
     # add administrative area
     $county_box = new TextBox('county', $school->Ground()->GetAddress()->GetAdministrativeArea(), $this->IsValidSubmit());
     $county_box->AddAttribute('maxlength', 100);
     $county_box->AddAttribute('autocomplete', "off");
     $county_box->AddCssClass("county");
     $county = new XhtmlElement('label', 'County');
     $county->AddAttribute('for', $county_box->GetXhtmlId());
     $this->AddControl($county);
     $this->AddControl($county_box);
     # add postcode
     $postcode_box = new TextBox('postcode', $school->Ground()->GetAddress()->GetPostcode(), $this->IsValidSubmit());
     $postcode_box->AddAttribute('maxlength', 8);
     $postcode_box->AddAttribute('autocomplete', "off");
     $postcode_box->AddCssClass("postcode");
     $postcode = new XhtmlElement('label', 'Postcode');
     $postcode->AddAttribute('for', $postcode_box->GetXhtmlId());
     $this->AddControl($postcode);
     $this->AddControl($postcode_box);
     # add lat/long
     $latitude = new TextBox('latitude', $school->Ground()->GetAddress()->GetLatitude(), $this->IsValidSubmit());
     $latitude->SetMode(TextBoxMode::Hidden());
     $this->AddControl($latitude);
     $longitude = new TextBox('longitude', $school->Ground()->GetAddress()->GetLongitude(), $this->IsValidSubmit());
     $longitude->SetMode(TextBoxMode::Hidden());
     $this->AddControl($longitude);
     $geoprecision = new TextBox('geoprecision', $school->Ground()->GetAddress()->GetGeoPrecision(), $this->IsValidSubmit());
     $geoprecision->SetMode(TextBoxMode::Hidden());
     $this->AddControl($geoprecision);
     # placeholder for client-side map
     $map = new XhtmlElement('div', null, "#map");
     $map->AddCssClass("map");
     $this->AddControl($map);
 }
 function CreateControls()
 {
     $this->AddCssClass('legacy-form');
     /* @var $team Team */
     /* @var $comp Competition */
     $season = $this->GetDataObject();
     /* @var $season Season */
     require_once 'xhtml/forms/form-part.class.php';
     require_once 'xhtml/forms/textbox.class.php';
     require_once 'xhtml/forms/radio-button.class.php';
     require_once 'xhtml/forms/checkbox.class.php';
     # Show fewer options for a new season than when editing, beacause a new season gets settings copied from last year to save time
     $b_is_new_season = !(bool) $season->GetId();
     # Add competition
     $comp = $season->GetCompetition();
     $competition = new TextBox($this->GetNamingPrefix() . 'competition', $comp->GetId());
     $competition->SetMode(TextBoxMode::Hidden());
     $this->AddControl($competition);
     # Make current short URL available, because then it can match the suggested one and be left alone
     $short_url = new TextBox($this->GetNamingPrefix() . 'ShortUrl', $season->GetShortUrl());
     $short_url->SetMode(TextBoxMode::Hidden());
     $this->AddControl($short_url);
     # add years
     $start_box = new TextBox('start', is_null($season->GetStartYear()) ? Date::Year(gmdate('U')) : $season->GetStartYear(), $this->IsValidSubmit());
     $start_box->AddAttribute('maxlength', 4);
     $start = new FormPart('Year season starts', $start_box);
     $this->AddControl($start);
     $summer = new RadioButton('summer', 'when', 'Summer season', 0);
     $winter = new RadioButton('winter', 'when', 'Winter season', 1);
     if ($season->GetEndYear() > $season->GetStartYear()) {
         $winter->SetChecked(true);
     } else {
         $summer->SetChecked(true);
     }
     $when = new XhtmlElement('div', $summer);
     $when->AddControl($winter);
     $when->SetCssClass('formControl');
     $when_legend = new XhtmlElement('legend', 'Time of year');
     $when_legend->SetCssClass('formLabel');
     $when_fs = new XhtmlElement('fieldset', $when_legend);
     $when_fs->SetCssClass('formPart');
     $when_fs->AddControl($when);
     $this->AddControl($when_fs);
     # add intro
     $intro_box = new TextBox('intro', $season->GetIntro(), $this->IsValidSubmit());
     $intro_box->SetMode(TextBoxMode::MultiLine());
     $intro = new FormPart('Introduction', $intro_box);
     $this->AddControl($intro);
     if (!$b_is_new_season) {
         # add types of matches
         if (!$this->IsPostback() or $this->b_saving_new and $this->IsValidSubmit()) {
             foreach ($season->MatchTypes()->GetItems() as $i_type) {
                 $this->match_types_editor->DataObjects()->Add(new IdValue($i_type, ucfirst(MatchType::Text($i_type))));
             }
         }
         $this->AddControl(new FormPart('Match types', $this->match_types_editor));
         # add results
         $result_container = new XhtmlElement('div');
         $result_box = new TextBox('results', $season->GetResults(), $this->IsValidSubmit());
         $result_box->SetMode(TextBoxMode::MultiLine());
         $result_container->AddControl($result_box);
         $result = new FormPart('Results', $result_container);
         $result->GetLabel()->AddAttribute('for', $result_box->GetXhtmlId());
         $this->AddControl($result);
         # Add rules table
         $rules = new XhtmlTable();
         $rules->SetCaption('Points for each result');
         $header = new XhtmlRow(array('Result', 'Points for home team', 'Points for away team'));
         $header->SetIsHeader(true);
         $rules->AddRow($header);
         foreach ($this->result_types as $result) {
             /* @var $result MatchResult */
             # Shouldn't ever need to assign points to a postponed match
             if ($result->GetResultType() == MatchResult::POSTPONED) {
                 continue;
             }
             # Populate result with points from season rule
             $season->PossibleResults()->ResetCounter();
             while ($season->PossibleResults()->MoveNext()) {
                 if ($season->PossibleResults()->GetItem()->GetResultType() == $result->GetResultType()) {
                     $result->SetHomePoints($season->PossibleResults()->GetItem()->GetHomePoints());
                     $result->SetAwayPoints($season->PossibleResults()->GetItem()->GetAwayPoints());
                     break;
                 }
             }
             # Create table row
             $home_box = new TextBox($this->GetNamingPrefix() . 'Result' . $result->GetResultType() . 'Home', $result->GetHomePoints(), $this->IsValidSubmit());
             $away_box = new TextBox($this->GetNamingPrefix() . 'Result' . $result->GetResultType() . 'Away', $result->GetAwayPoints(), $this->IsValidSubmit());
             $home_box->AddAttribute('class', 'pointsBox');
             $away_box->AddAttribute('class', 'pointsBox');
             $result_row = new XhtmlRow(array(MatchResult::Text($result->GetResultType()), $home_box, $away_box));
             $rules->AddRow($result_row);
         }
         $result_container->AddControl($rules);
         # Add points adjustments
         $this->adjustments_editor->SetTeams($season->GetTeams());
         if (!$this->IsPostback() or $this->b_saving_new and $this->IsValidSubmit()) {
             $this->adjustments_editor->DataObjects()->SetItems($season->PointsAdjustments()->GetItems());
         }
         $result_container->AddControl($this->adjustments_editor);
         # Show league table?
         $table = new CheckBox('showTable', 'Show results table', 1, $season->GetShowTable());
         $this->AddControl($table);
         $this->AddControl(new CheckBox('runsScored', 'Include runs scored', 1, $season->GetShowTableRunsScored()));
         $this->AddControl(new CheckBox('runsConceded', 'Include runs conceded', 1, $season->GetShowTableRunsConceded()));
         # add teams
         if (!$this->IsPostback() or $this->b_saving_new and $this->IsValidSubmit()) {
             $teams_in_season = array();
             foreach ($season->GetTeams() as $team) {
                 $teams_in_season[] = new TeamInSeason($team, $season, is_object($season->TeamsWithdrawnFromLeague()->GetItemByProperty('GetId', $team->GetId())));
             }
             $this->teams_editor->DataObjects()->SetItems($teams_in_season);
         }
         $this->AddControl(new FormPart('Teams', $this->teams_editor));
     }
 }
 function OnPreRender()
 {
     require_once 'xhtml/forms/form-part.class.php';
     require_once 'xhtml/forms/textbox.class.php';
     # add lines
     $o_saon_box = new TextBox('saon', $this->o_data_object->GetSaon());
     $o_saon_box->AddAttribute('maxlength', 250);
     $o_saon = new FormPart('Address within building', $o_saon_box);
     $this->AddControl($o_saon);
     $o_line1_box = new TextBox('paon', $this->o_data_object->GetPaon());
     $o_line1_box->AddAttribute('maxlength', 250);
     $o_line1 = new FormPart('Building name or number', $o_line1_box);
     $this->AddControl($o_line1);
     $o_line2_box = new TextBox('streetDescriptor', $this->o_data_object->GetStreetDescriptor());
     $o_line2_box->AddAttribute('maxlength', 250);
     $o_line2 = new FormPart('Street name', $o_line2_box);
     $this->AddControl($o_line2);
     $o_line3_box = new TextBox('locality', $this->o_data_object->GetLocality());
     $o_line3_box->AddAttribute('maxlength', 250);
     $o_line3 = new FormPart('Village or part of town', $o_line3_box);
     $this->AddControl($o_line3);
     # add town
     $o_town_box = new TextBox('town', $this->o_data_object->GetTown());
     $o_town_box->AddAttribute('maxlength', 100);
     $o_town = new FormPart('Town', $o_town_box);
     $this->AddControl($o_town);
     # add county
     $o_county_box = new TextBox('county', $this->o_data_object->GetAdministrativeArea());
     $o_county_box->AddAttribute('maxlength', 100);
     $o_county = new FormPart('County', $o_county_box);
     $this->AddControl($o_county);
     # add postcode
     $o_postcode_box = new TextBox('postcode', $this->o_data_object->GetPostcode());
     $o_postcode_box->AddAttribute('maxlength', 8);
     $o_postcode = new FormPart('Postcode', $o_postcode_box);
     $this->AddControl($o_postcode);
     # add geolocation
     $o_lat_box = new TextBox('lat', $this->o_data_object->GetLatitude());
     $o_lat_box->SetMaxLength(20);
     $o_lat = new FormPart('Latitude', $o_lat_box);
     $this->AddControl($o_lat);
     $o_long_box = new TextBox('long', $this->o_data_object->GetLongitude());
     $o_long_box->SetMaxLength(20);
     $o_long = new FormPart('Longitude', $o_long_box);
     $this->AddControl($o_long);
     $o_precision = new XhtmlSelect('geoprecision');
     $o_precision->AddControl(new XhtmlOption("Don't know", ''));
     $o_precision->AddControl(new XhtmlOption('Exact', GeoPrecision::Exact()));
     $o_precision->AddControl(new XhtmlOption('Postcode', GeoPrecision::Postcode()));
     $o_precision->AddControl(new XhtmlOption('Street', GeoPrecision::StreetDescriptor()));
     $o_precision->AddControl(new XhtmlOption('Town', GeoPrecision::Town()));
     $o_precision->SelectOption($this->o_data_object->GetGeoPrecision());
     $o_precision_part = new FormPart('How accurate is lat/long?', $o_precision);
     $this->AddControl($o_precision_part);
     $o_map = new XhtmlElement('div');
     $o_map->SetXhtmlId('map');
     $o_map->SetCssClass('formControl');
     $o_map_container = new XhtmlElement('div', $o_map);
     $o_map_container->SetCssClass('formPart');
     $this->AddControl($o_map_container);
 }
 /**
  * Creates, and re-populates on postback, a textbox to manage one property of a related data item
  *
  * @param string $s_validated_value
  * @param string $s_name
  * @param int $i_row_count
  * @param int $i_total_rows
  * @param bool $b_required
  * @return TextBox
  */
 protected function CreateTextBox($s_validated_value, $s_name, $i_row_count, $i_total_rows, $b_required = false)
 {
     # Establish current status
     $b_is_add_row = is_null($i_row_count);
     $b_repopulate_add_row = (!$this->IsValid() or $this->DeleteClicked() or $this->IsUnrelatedInternalPostback());
     # Create text box
     $textbox = new TextBox($this->GetNamingPrefix() . $s_name . $i_row_count);
     if ($b_required) {
         $textbox->AddAttribute('class', 'required');
     }
     # Repopulate the previous value
     # 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[$textbox->GetXhtmlId()])) {
             $textbox->SetText($_POST[$textbox->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_textbox_in_add_row = substr($textbox->GetXhtmlId(), 0, strlen($textbox->GetXhtmlId()) - strlen($i_row_count));
                 $textbox->SetText($_POST[$s_textbox_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[$textbox->GetXhtmlId()])) {
                     $textbox->SetText($_POST[$textbox->GetXhtmlId()]);
                 } else {
                     # Won't be in $_POST when page is first loaded
                     $textbox->SetText($s_validated_value);
                 }
             }
         } else {
             # Repopulate with the exact value posted, as validation has failed
             $textbox->SetText($_POST[$textbox->GetXhtmlId()]);
         }
     }
     # Return textbox so that other things can be done to it - eg add a CSS class or maxlength
     return $textbox;
 }