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>'); }
/** * 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() { $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); }
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); }
/** * Creates, and re-populates on postback, non-editable text with an associated id * * @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 CreateNonEditableText($i_validated_id, $s_validated_value, $s_name, $i_row_count, $i_total_rows) { # 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 boxes $textbox_id = new TextBox($this->GetNamingPrefix() . $s_name . $i_row_count); $textbox_id->SetMode(TextBoxMode::Hidden()); $textbox_value = new TextBox($this->GetNamingPrefix() . $s_name . 'Value' . $i_row_count); $textbox_value->SetMode(TextBoxMode::Hidden()); # 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_id->GetXhtmlId()])) { $textbox_id->SetText($_POST[$textbox_id->GetXhtmlId()]); } if ($b_repopulate_add_row and isset($_POST[$textbox_value->GetXhtmlId()])) { $textbox_value->SetText($_POST[$textbox_value->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_id_in_add_row = substr($textbox_id->GetXhtmlId(), 0, strlen($textbox_id->GetXhtmlId()) - strlen($i_row_count)); if (isset($_POST[$s_textbox_id_in_add_row])) { $textbox_id->SetText($_POST[$s_textbox_id_in_add_row]); } $s_textbox_value_in_add_row = substr($textbox_value->GetXhtmlId(), 0, strlen($textbox_value->GetXhtmlId()) - strlen($i_row_count)); if (isset($_POST[$s_textbox_value_in_add_row])) { $textbox_value->SetText($_POST[$s_textbox_value_in_add_row]); } else { # If the add row doesn't populate the item name as well as the item id, it can be passed in as the validated value $textbox_value->SetText($s_validated_value); } } 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_id->GetXhtmlId()])) { $textbox_id->SetText($_POST[$textbox_id->GetXhtmlId()]); } else { # Won't be in $_POST when page is first loaded $textbox_id->SetText($i_validated_id); } # Even though the editor as a whole is valid, this row wasn't validated # so just restore the previous value if (isset($_POST[$textbox_value->GetXhtmlId()])) { $textbox_value->SetText($_POST[$textbox_value->GetXhtmlId()]); } else { # Won't be in $_POST when page is first loaded $textbox_value->SetText($s_validated_value); } } } else { # Repopulate with the exact value posted, as validation has failed $textbox_id->SetText($_POST[$textbox_id->GetXhtmlId()]); $textbox_value->SetText($_POST[$textbox_value->GetXhtmlId()]); } } # Return textboxes so that other things can be done to them - eg add a CSS class or maxlength $placeholder = new Placeholder(); $placeholder->AddControl($textbox_id); $placeholder->AddControl($textbox_value); $placeholder->AddControl($textbox_value->GetText()); return $placeholder; }