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)); }
/** * 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'); }
/** * Creates the controls when the editor is in its fixture view * */ private function CreateFixtureControls(Match $match, XhtmlElement $match_box) { $css_class = 'TournamentEdit'; if ($this->GetCssClass()) { $css_class .= ' ' . $this->GetCssClass(); } $match_outer_1 = new XhtmlElement('div'); $match_outer_1->SetCssClass($css_class); $this->SetCssClass(''); $match_outer_1->SetXhtmlId($this->GetNamingPrefix()); $match_outer_2 = new XhtmlElement('div'); $this->AddControl($match_outer_1); $match_outer_1->AddControl($match_outer_2); $match_outer_2->AddControl($match_box); if ($match->GetId()) { $heading = "Edit tournament"; } else { $heading = "Add your tournament"; } if ($this->show_step_number) { $heading .= ' – step 1 of 3'; } $o_title_inner_1 = new XhtmlElement('span', $heading); $o_title_inner_2 = new XhtmlElement('span', $o_title_inner_1); $o_title_inner_3 = new XhtmlElement('span', $o_title_inner_2); $match_box->AddControl(new XhtmlElement('h2', $o_title_inner_3, "large")); # Tournament title $suggested_title = $match->GetTitle(); if (isset($this->context_season)) { $suggested_title = $this->GetContextSeason()->GetCompetition()->GetName(); if (strpos(strtolower($suggested_title), 'tournament') === false) { $suggested_title .= ' tournament'; } } else { if (isset($this->context_team)) { $suggested_title = $this->GetContextTeam()->GetName(); if (strpos(strtolower($suggested_title), 'tournament') === false) { $suggested_title .= ' tournament'; } } } if ($suggested_title == "To be confirmed tournament") { $suggested_title = ""; } if ($suggested_title == "To be confirmed v To be confirmed") { $suggested_title = ""; } $title = new TextBox($this->GetNamingPrefix() . 'Title', $suggested_title, $this->IsValidSubmit()); $title->SetMaxLength(200); $match_box->AddControl(new FormPart('Tournament name', $title)); # Open or invite? require_once 'xhtml/forms/radio-button.class.php'; $qualify_set = new XhtmlElement('fieldset'); $qualify_set->SetCssClass('formPart radioButtonList'); $qualify_set->AddControl(new XhtmlElement('legend', 'Who can play?', 'formLabel')); $qualify_radios = new XhtmlElement('div', null, 'formControl'); $qualify_set->AddControl($qualify_radios); $qualify_radios->AddControl(new RadioButton($this->GetNamingPrefix() . 'Open', $this->GetNamingPrefix() . 'Qualify', 'any team may enter', MatchQualification::OPEN_TOURNAMENT, $match->GetQualificationType() === MatchQualification::OPEN_TOURNAMENT or !$match->GetId(), $this->IsValidSubmit())); $qualify_radios->AddControl(new RadioButton($this->GetNamingPrefix() . 'Qualify', $this->GetNamingPrefix() . 'Qualify', 'only invited or qualifying teams can enter', MatchQualification::CLOSED_TOURNAMENT, $match->GetQualificationType() === MatchQualification::CLOSED_TOURNAMENT, $this->IsValidSubmit())); $match_box->AddControl($qualify_set); # Player type $suggested_type = 2; if (isset($this->context_season)) { $suggested_type = $this->context_season->GetCompetition()->GetPlayerType(); } elseif (isset($this->context_team)) { $suggested_type = $this->context_team->GetPlayerType(); } if (!is_null($match->GetPlayerType())) { $suggested_type = $match->GetPlayerType(); } # Saved value overrides suggestion $player_set = new XhtmlElement('fieldset'); $player_set->SetCssClass('formPart radioButtonList'); $player_set->AddControl(new XhtmlElement('legend', 'Type of teams', 'formLabel')); $player_radios = new XhtmlElement('div', null, 'formControl'); $player_set->AddControl($player_radios); $player_radios_1 = new XhtmlElement('div', null, 'column'); $player_radios_2 = new XhtmlElement('div', null, 'column'); $player_radios->AddControl($player_radios_1); $player_radios->AddControl($player_radios_2); $player_radios_1->AddControl(new RadioButton($this->GetNamingPrefix() . 'Ladies', $this->GetNamingPrefix() . 'PlayerType', 'Ladies', 2, $suggested_type === 2, $this->IsValidSubmit())); $player_radios_1->AddControl(new RadioButton($this->GetNamingPrefix() . 'Mixed', $this->GetNamingPrefix() . 'PlayerType', 'Mixed', 1, $suggested_type === 1, $this->IsValidSubmit())); $player_radios_2->AddControl(new RadioButton($this->GetNamingPrefix() . 'Girls', $this->GetNamingPrefix() . 'PlayerType', 'Junior girls', 5, $suggested_type === 5, $this->IsValidSubmit())); $player_radios_2->AddControl(new RadioButton($this->GetNamingPrefix() . 'Children', $this->GetNamingPrefix() . 'PlayerType', 'Junior mixed', 4, $suggested_type === 6, $this->IsValidSubmit())); $match_box->AddControl($player_set); # How many? $per_side_box = new XhtmlSelect($this->GetNamingPrefix() . "Players", null, $this->IsValid()); $per_side_box->SetBlankFirst(true); for ($i = 6; $i <= 16; $i++) { $per_side_box->AddControl(new XhtmlOption($i)); } if ($match->GetIsMaximumPlayersPerTeamKnown()) { $per_side_box->SelectOption($match->GetMaximumPlayersPerTeam()); } else { if (!$match->GetId()) { # Use eight as sensible default for new tournaments $per_side_box->SelectOption(8); } } $players_per_team = new XhtmlElement("label", $per_side_box); $players_per_team->AddAttribute("for", $this->GetNamingPrefix() . "Players"); $players_per_team->AddControl(" players per team"); $players_part = new FormPart("How many players?", $players_per_team); $players_part->AddCssClass("playersPerTeam"); $match_box->AddControl($players_part); # Overs $overs_box = new XhtmlSelect($this->GetNamingPrefix() . "Overs", null, $this->IsValid()); $overs_box->SetBlankFirst(true); for ($i = 2; $i <= 8; $i++) { $overs_box->AddControl(new XhtmlOption($i)); } if ($match->GetIsOversKnown()) { $overs_box->SelectOption($match->GetOvers()); } $overs_label = new XhtmlElement("label", "Overs per innings"); $overs_label->AddAttribute("for", $overs_box->GetXhtmlId()); $overs_part = new FormPart($overs_label, new XhtmlElement("div", $overs_box)); $overs_part->AddCssClass("overs"); $match_box->AddControl($overs_part); # Start date and time if (!$match->GetStartTime()) { # if no date set, use specified default if ($this->i_default_time) { $match->SetStartTime($this->i_default_time); } else { # if no date set and no default, default to today at 10.30am BST # NOTE that if this is a new tournament in an old season, this date won't be selected because the available # dates will be limited below and won't include today. It'll be the same day in the relevant year though. $i_now = gmdate('U'); $match->SetStartTime(gmmktime(9, 30, 00, (int) gmdate('n', $i_now), (int) gmdate('d', $i_now), (int) gmdate('Y', $i_now))); $match->SetIsStartTimeKnown(true); } } $o_date = new DateControl($this->GetNamingPrefix() . 'Start', $match->GetStartTime(), $match->GetIsStartTimeKnown(), $this->IsValidSubmit()); $o_date->SetShowTime(true); $o_date->SetRequireTime(false); $o_date->SetMinuteInterval(5); # if only one season to choose from, limit available dates to the length of that season if ($this->context_season instanceof Season) { if ($this->context_season->GetStartYear() == $this->context_season->GetEndYear()) { $i_mid_season = gmmktime(0, 0, 0, 6, 30, $this->context_season->GetStartYear()); } else { $i_mid_season = gmmktime(0, 0, 0, 12, 31, $this->context_season->GetStartYear()); } $season_dates = Season::SeasonDates($i_mid_season); $season_start_month = gmdate('n', $season_dates[0]); $season_end_month = gmdate('n', $season_dates[1]); if ($season_start_month) { $o_date->SetMonthStart($season_start_month); } if ($season_end_month) { $o_date->SetMonthEnd($season_end_month); } $season_start_year = $this->context_season->GetStartYear(); $season_end_year = $this->context_season->GetEndYear(); if ($season_start_year) { $o_date->SetYearStart($season_start_year); } if ($season_end_year) { $o_date->SetYearEnd($season_end_year); } } $o_date_part = new FormPart('When?', $o_date); $o_date_part->SetIsFieldset(true); $match_box->AddControl($o_date_part); # Where? $o_ground_list = new XhtmlSelect($this->GetNamingPrefix() . 'Ground'); $o_ground_list->AddControl(new XhtmlOption("Don't know", -1)); $o_ground_list->AddControl(new XhtmlOption('Not listed (type the address in the notes field)', -2)); # Promote the most likely grounds to the top of the list $likely_ground_ids = array(); if ($match->GetGroundId()) { $likely_ground_ids[] = $match->GetGroundId(); } foreach ($this->probable_teams as $o_team) { $likely_ground_ids[] = $o_team->GetGround()->GetId(); } if (isset($this->context_season)) { foreach ($this->context_season->GetTeams() as $o_team) { $likely_ground_ids[] = $o_team->GetGround()->GetId(); } } if (isset($this->context_team) and is_object($this->context_team->GetGround())) { $likely_ground_ids[] = $this->context_team->GetGround()->GetId(); } $likely_grounds = array(); $a_other_grounds = array(); /* @var $o_ground Ground */ foreach ($this->grounds->GetItems() as $o_ground) { if (array_search($o_ground->GetId(), $likely_ground_ids) > -1) { $likely_grounds[] = $o_ground; } else { $a_other_grounds[] = $o_ground; } } # Add home grounds foreach ($likely_grounds as $o_ground) { $option = new XhtmlOption($o_ground->GetNameAndTown(), $o_ground->GetId()); $option->SetGroupName('Likely grounds'); $o_ground_list->AddControl($option); } # Add away grounds foreach ($a_other_grounds as $o_ground) { $option = new XhtmlOption($o_ground->GetNameAndTown(), $o_ground->GetId()); $option->SetGroupName('Other grounds'); $o_ground_list->AddControl($option); } # Select ground if ($match->GetGroundId()) { $o_ground_list->SelectOption($match->GetGroundId()); } elseif (isset($this->context_team)) { $o_ground_list->SelectOption($this->context_team->GetGround()->GetId()); } $o_ground_part = new FormPart('Where?', $o_ground_list); $match_box->AddControl($o_ground_part); # Notes $o_notes = new TextBox($this->GetNamingPrefix() . 'Notes', $match->GetNotes()); $o_notes->SetMode(TextBoxMode::MultiLine()); $o_notes_part = new FormPart('Notes<br />(remember to include contact details)', $o_notes); $match_box->AddControl($o_notes_part); # Remember short URL $o_short_url = new TextBox($this->GetNamingPrefix() . 'ShortUrl', $match->GetShortUrl()); $o_short_url->SetMode(TextBoxMode::Hidden()); $match_box->AddControl($o_short_url); # Note the context team to be added to the tournament by default if (isset($this->context_team)) { $context_team_box = new TextBox($this->GetNamingPrefix() . 'ContextTeam', $this->context_team->GetId()); $context_team_box->SetMode(TextBoxMode::Hidden()); $match_box->AddControl($context_team_box); } # Change Save button to "Next" button if ($this->show_step_number) { $this->SetButtonText('Next »'); } }
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() { /* @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())); }
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); }
function OnPageInit() { parent::OnPageInit(); # Set up form, which must exist to be validated $this->form = new XhtmlForm(); $fs1 = new XhtmlElement('fieldset', new XhtmlElement('legend', 'Your team name')); $this->form->AddControl($fs1); $o_team = new TextBox('team', isset($_POST['team']) ? $_POST['team'] : ''); $o_team->SetMaxLength(200); $o_team_part = new FormPart('Team name', $o_team); $o_team_part->SetIsRequired(true); $fs1->AddControl($o_team_part); $o_club = new TextBox('club', isset($_POST['club']) ? $_POST['club'] : ''); $o_club->SetMaxLength(200); $o_club_part = new FormPart('Club (if different)', $o_club); $fs1->AddControl($o_club_part); $fs2 = new XhtmlElement('fieldset', new XhtmlElement('legend', 'Where and when you play')); $this->form->AddControl($fs2); $o_ground = new TextBox('ground', isset($_POST['ground']) ? $_POST['ground'] : ''); $o_ground->SetMode(TextBoxMode::MultiLine()); $o_ground_part = new FormPart('Address of playing field', $o_ground); $o_ground_part->SetIsRequired(true); $fs2->AddControl($o_ground_part); $o_prac = new TextBox('pracNight', isset($_POST['pracNight']) ? $_POST['pracNight'] : ''); $o_prac->SetMaxLength(50); $o_prac_part = new FormPart('Practice night', $o_prac); $fs2->AddControl($o_prac_part); $o_match = new TextBox('matchNight', isset($_POST['matchNight']) ? $_POST['matchNight'] : ''); $o_match->SetMaxLength(100); $o_match_part = new FormPart('Match nights', $o_match); $fs2->AddControl($o_match_part); $o_league = new TextBox('leagues', isset($_POST['leagues']) ? $_POST['leagues'] : ''); $o_league->SetMode(TextBoxMode::MultiLine()); $o_league_part = new FormPart('League(s) or friendlies you play in', $o_league); $fs2->AddControl($o_league_part); $fs3 = new XhtmlElement('fieldset', new XhtmlElement('legend', 'Contact details for Stoolball England to use')); $this->form->AddControl($fs3); $o_contact = new TextBox('contact', isset($_POST['contact']) ? $_POST['contact'] : ''); $o_contact->SetMaxLength(150); $o_contact_part = new FormPart('Contact name', $o_contact); $o_contact_part->SetIsRequired(true); $fs3->AddControl($o_contact_part); $o_contact_addr = new TextBox('address', isset($_POST['address']) ? $_POST['address'] : ''); $o_contact_addr->SetMode(TextBoxMode::MultiLine()); $o_contact_addr_part = new FormPart('Contact address', $o_contact_addr); $fs3->AddControl($o_contact_addr_part); $o_contact_phone = new TextBox('contactPhone', isset($_POST['contactPhone']) ? $_POST['contactPhone'] : ''); $o_contact_phone->SetMaxLength(50); $o_contact_phone_part = new FormPart('Contact phone number', $o_contact_phone); $fs3->AddControl($o_contact_phone_part); $o_contact_e = new TextBox('email', isset($_POST['email']) ? $_POST['email'] : ''); $o_contact_e_part = new FormPart('Contact email', $o_contact_e); $o_contact_e_part->SetIsRequired(true); $fs3->AddControl($o_contact_e_part); $fs4 = new XhtmlElement('fieldset', new XhtmlElement('legend', 'Contact details for the website'), '#publicContact'); $fs4->SetCssClass("radioButtonList"); $this->form->AddControl($fs4); $public1 = new RadioButton('publicAbove', 'public', 'Same as above', 'Same', $this->IsPostback() ? isset($_POST['public']) and $_POST['public'] == 'Same' : true); $public3 = new RadioButton('publicDiff', 'public', 'Display different contact details on the website', 'Different', $this->IsPostback() ? isset($_POST['public']) and $_POST['public'] == 'Different' : false); $public2 = new RadioButton('publicNone', 'public', 'Don\'t display any contact details (not recommended)', 'None', $this->IsPostback() ? isset($_POST['public']) and $_POST['public'] == 'None' : false); $fs4->AddControl($public1); $fs4->AddControl($public3); $fs4->AddControl($public2); $public_contact = new TextBox('publicContact', isset($_POST['publicContact']) ? $_POST['publicContact'] : ''); $public_contact->SetMode(TextBoxMode::MultiLine()); $public_contact_part = new FormPart('Contact details for the website', $public_contact); $public_contact_part->SetXhtmlId('publicContactPart'); $fs4->AddControl($public_contact_part); $fs5 = new XhtmlElement('fieldset', new XhtmlElement('legend', 'Anything else you\'d like on your team\'s page')); $this->form->AddControl($fs5); $o_notes = new TextBox('notes', isset($_POST['notes']) ? $_POST['notes'] : ''); $o_notes->SetMode(TextBoxMode::MultiLine()); $o_notes_part = new FormPart('Other details', $o_notes); $fs5->AddControl($o_notes_part); $o_buttons = new XhtmlElement('div'); $o_buttons->SetCssClass('buttonGroup'); $o_submit = new Button('send', 'Send email'); $o_buttons->AddControl($o_submit); $this->form->AddControl($o_buttons); # Set up validation require_once 'data/validation/required-field-validator.class.php'; require_once 'data/validation/length-validator.class.php'; require_once 'data/validation/email-validator.class.php'; $a_validators = array(); $a_validators[] = new RequiredFieldValidator(array('team'), 'A team name is required'); $a_validators[] = new LengthValidator(array('team'), 'Your team name is too long', 0, 200); $a_validators[] = new LengthValidator(array('club'), 'Your club name is too long', 0, 200); $a_validators[] = new RequiredFieldValidator(array('ground'), 'A playing field address is required'); $a_validators[] = new LengthValidator(array('ground'), 'The playing field address is too long', 0, 2000); $a_validators[] = new RequiredFieldValidator(array('contact'), 'A contact name for the team is required'); $a_validators[] = new LengthValidator(array('pracNight'), 'Practice night must be 50 characters or less', 0, 50); $a_validators[] = new LengthValidator(array('matchNight'), 'Match nights must be 100 characters or less', 0, 100); $a_validators[] = new LengthValidator(array('leagues'), 'Your league or friendly group(s) must be 2000 characters or less', 0, 2000); $a_validators[] = new LengthValidator(array('contact'), 'Your contact name is too long', 0, 150); $a_validators[] = new LengthValidator(array('address'), 'The contact address is too long', 0, 2000); $a_validators[] = new LengthValidator(array('contactPhone'), 'The contact phone number is too long', 0, 50); $a_validators[] = new RequiredFieldValidator(array('email'), 'A contact email for the team is required'); $a_validators[] = new EmailValidator('email', 'Please enter a valid email address'); $a_validators[] = new LengthValidator('publicContact', 'You\'ve put too much in the "website contact details" box. Please make the text shorter.', 0, 10000); $a_validators[] = new LengthValidator('notes', 'You\'ve put too much in the "other details" box. Please make the text shorter.', 0, 10000); foreach ($a_validators as $o_v) { $this->form->AddValidator($o_v); unset($o_v); } $this->RegisterControlForValidation($this->form); }
function CreateControls() { $match = $this->GetDataObject(); /* @var $match Match */ $this->b_user_is_match_owner = ($match->GetAddedBy() instanceof User and AuthenticationManager::GetUser()->GetId() == $match->GetAddedBy()->GetId()); $this->AddCssClass('legacy-form'); if ($this->b_user_is_match_admin) { # Add match title editing $b_new = !$match->GetId(); $title = new TextBox('title', $b_new ? '' : $match->GetTitle()); $title->SetMaxLength(100); $this->AddControl(new FormPart('Match title', $title)); $o_generate = new CheckBox('defaultTitle', 'Use default title', 1); if ($b_new) { $o_generate->SetChecked(true); } else { $o_generate->SetChecked(!$match->GetUseCustomTitle()); } $this->AddControl($o_generate); # Add match type if ($match->GetMatchType() != MatchType::TOURNAMENT_MATCH) { $o_type_list = new XhtmlSelect('type'); $o_type_list->AddControl(new XhtmlOption(MatchType::Text(MatchType::LEAGUE), MatchType::LEAGUE)); $o_type_list->AddControl(new XhtmlOption(MatchType::Text(MatchType::PRACTICE), MatchType::PRACTICE)); $o_type_list->AddControl(new XhtmlOption(MatchType::Text(MatchType::FRIENDLY), MatchType::FRIENDLY)); $o_type_list->AddControl(new XhtmlOption(MatchType::Text(MatchType::CUP), MatchType::CUP)); $o_type_list->SelectOption($match->GetMatchType()); $this->AddControl(new FormPart('Type of match', $o_type_list)); } } if ($this->b_user_is_match_owner or $this->b_user_is_match_admin) { $this->EnsureAggregatedEditors(); $this->fixture_editor->SetDataObject($match); $this->AddControl($this->fixture_editor); } if ($this->b_user_is_match_admin) { # add season if (!$this->IsPostback()) { $this->season_editor->DataObjects()->SetItems($match->Seasons()->GetItems()); } $this->AddControl($this->season_editor); # Hidden data on teams, for use by match-fixture-edit-control.js to re-sort teams when the season is changed # Format is 1,2,3,4,5;2,3,4,5,6 # where ; separates each team, and for each team the first number identifies the team and subsequent numbers identify the season /* @var $o_team Team */ /* @var $o_comp Competition */ $s_team_season = ''; # Build a list of all seasons, so that the "Not known yet" option can be added to all seasons $all_seasons = array(); foreach ($this->fixture_editor->GetTeams() as $group) { foreach ($group as $o_team) { if (!$o_team instanceof Team) { continue; } # Add team id if ($s_team_season) { $s_team_season .= ';'; } $s_team_season .= $o_team->GetId(); # add team seasons foreach ($o_team->Seasons() as $team_in_season) { $s_team_season .= ',' . $team_in_season->GetSeasonId(); $all_seasons[] = $team_in_season->GetSeasonId(); } } } # Add the "Don't know yet" option with all seasons $all_seasons = array_unique($all_seasons); $s_team_season = "0," . implode(",", $all_seasons) . ";{$s_team_season}"; # Put it in a hidden field accessible to JavaScript. $o_ts = new TextBox($this->GetNamingPrefix() . 'TeamSeason', $s_team_season); $o_ts->SetMode(TextBoxMode::Hidden()); $this->AddControl($o_ts); } $got_home_team = !is_null($match->GetHomeTeam()); $got_away_team = !is_null($match->GetAwayTeam()); $b_got_teams = ($got_home_team and $got_away_team); $b_future = ($match->GetId() and $match->GetStartTime() > gmdate('U')); // 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', "Result of this match"); $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 batted first? if (!$b_future) { $match_box->AddControl('<h3>If the match went ahead:</h3>'); $toss = $this->SelectOneOfTwoTeams($this->GetNamingPrefix() . 'Toss', $match, $match->Result()->GetTossWonBy() === TeamRole::Home(), $match->Result()->GetTossWonBy() === TeamRole::Away()); $toss_part = new FormPart('Who won the toss?', $toss); $match_box->AddControl($toss_part); $bat_first = $this->SelectOneOfTwoTeams($this->GetNamingPrefix() . 'BatFirst', $match, $match->Result()->GetHomeBattedFirst() === true, $match->Result()->GetHomeBattedFirst() === false); $bat_part = new FormPart('Who batted first?', $bat_first); $match_box->AddControl($bat_part); } # Who won? $o_winner = new XhtmlSelect($this->GetNamingPrefix() . 'Result'); if ($b_future) { $o_winner->AddControl(new XhtmlOption('The match will go ahead', '')); } else { # This option means "no change", therefore it has to have the current value for the match result even though that's # a different value from match to match. If it's not there the submitted match doesn't have result info, so when admin # saves fixture it regenerates its title as "Team A v Team B", which doesn't match the existing title so gets saved to db. # Can't be exactly the current value though, because otherwise a cancelled match has two options with the same value, # so re-selecting the option doesn't work. Instead change it to a negative number, which can be converted back when submitted. $o_winner->AddControl(new XhtmlOption('Not applicable – match went ahead', $match->Result()->GetResultType() * -1)); } $result_types = array(MatchResult::HOME_WIN_BY_FORFEIT, MatchResult::AWAY_WIN_BY_FORFEIT, MatchResult::POSTPONED, MatchResult::CANCELLED, MatchResult::ABANDONED); 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), $match->GetHomeTeam(), $match->GetAwayTeam()), $result_type)); } else { $o_winner->AddControl(new XhtmlOption(MatchResult::Text($result_type), $result_type)); } } } $o_winner->SelectOption($match->Result()->GetResultType()); if (!$b_future) { $match_box->AddControl('<h3 class="ifNotPlayed">Or, if the match was not played:</h3>'); } $o_win_part = new FormPart($b_future ? 'Will it happen?' : 'Why not?', $o_winner); $match_box->AddControl($o_win_part); # Show audit data if ($match->GetLastAudit() != null) { require_once "data/audit-control.class.php"; $match_box->AddControl(new AuditControl($match->GetLastAudit(), "match")); } # Remember short URL $o_short_url = new TextBox($this->GetNamingPrefix() . 'ShortUrl', $match->GetShortUrl()); if ($this->b_user_is_match_admin) { $o_url_part = new FormPart('Short URL', $o_short_url); $this->AddControl($o_url_part); $this->AddControl(new CheckBox($this->GetNamingPrefix() . 'RegenerateUrl', 'Regenerate short URL', 1, !$match->GetUseCustomShortUrl(), $this->IsValidSubmit())); } else { $o_short_url->SetMode(TextBoxMode::Hidden()); $this->AddControl($o_short_url); } if ($b_future and !$this->b_user_is_match_admin and !$this->b_user_is_match_owner) { $this->SetButtonText("Save result"); } }
/** * Sets up controls for pages 2/3 of the wizard * @param Match $match * @param Team $batting_team * @param Collection $batting_data * @param Team $bowling_team * @param Collection $bowling_data * @param int $total * @param int $wickets_taken * @return void */ private function CreateScorecardControls(Match $match, Team $batting_team, Collection $batting_data, Team $bowling_team, Collection $bowling_data, $total, $wickets_taken) { require_once "xhtml/tables/xhtml-table.class.php"; $batting_table = new XhtmlTable(); $batting_table->SetCaption($batting_team->GetName() . "'s batting"); $batting_table->SetCssClass("scorecard scorecardEditor batting"); $out_by_header = new XhtmlCell(true, '<span class="small">Fielder</span><span class="large">Caught<span class="wrapping-hair-space"> </span>/<span class="wrapping-hair-space"> </span><span class="nowrap">run-out by</span></span>'); $out_by_header->SetCssClass("dismissedBy"); $bowler_header = new XhtmlCell(true, "Bowler"); $bowler_header->SetCssClass("bowler"); $score_header = new XhtmlCell(true, "Runs"); $score_header->SetCssClass("numeric"); $balls_header = new XhtmlCell(true, "Balls"); $balls_header->SetCssClass("numeric"); $batting_headings = new XhtmlRow(array("Batsman", "How out", $out_by_header, $bowler_header, $score_header, $balls_header)); $batting_headings->SetIsHeader(true); $batting_table->AddRow($batting_headings); $batting_data->ResetCounter(); $byes = null; $wides = null; $no_balls = null; $bonus = null; # Loop = max players + 4, because if you have a full scorecard you have to keep looping to get the 4 extras players for ($i = 1; $i <= $match->GetMaximumPlayersPerTeam() + 4; $i++) { $batting = $batting_data->MoveNext() ? $batting_data->GetItem() : null; /* @var $batting Batting */ # Grab the scores for extras players to use later if (!is_null($batting)) { switch ($batting->GetPlayer()->GetPlayerRole()) { case Player::BYES: $byes = $batting->GetRuns(); break; case Player::WIDES: $wides = $batting->GetRuns(); break; case Player::NO_BALLS: $no_balls = $batting->GetRuns(); break; case Player::BONUS_RUNS: $bonus = $batting->GetRuns(); break; } } # Don't write a table row for the last four loops, we'll do that next because they're different if ($i <= $match->GetMaximumPlayersPerTeam()) { $player = new TextBox("batName{$i}", (is_null($batting) or !$batting->GetPlayer()->GetPlayerRole() == Player::PLAYER) ? "" : $batting->GetPlayer()->GetName(), $this->IsValidSubmit()); $player->SetMaxLength(100); $player->AddAttribute("autocomplete", "off"); $player->AddCssClass("player batsman team" . $batting_team->GetId()); $how = new XhtmlSelect("batHowOut{$i}", null, $this->IsValidSubmit()); $how->SetCssClass("howOut"); $how->AddOptions(array(Batting::DID_NOT_BAT => Batting::Text(Batting::DID_NOT_BAT), Batting::NOT_OUT => Batting::Text(Batting::NOT_OUT), Batting::CAUGHT => Batting::Text(Batting::CAUGHT), Batting::BOWLED => Batting::Text(Batting::BOWLED), Batting::CAUGHT_AND_BOWLED => str_replace(" and ", "/", Batting::Text(Batting::CAUGHT_AND_BOWLED)), Batting::RUN_OUT => Batting::Text(Batting::RUN_OUT), Batting::BODY_BEFORE_WICKET => "bbw", Batting::HIT_BALL_TWICE => Batting::Text(Batting::HIT_BALL_TWICE), Batting::TIMED_OUT => Batting::Text(Batting::TIMED_OUT), Batting::RETIRED_HURT => Batting::Text(Batting::RETIRED_HURT), Batting::RETIRED => Batting::Text(Batting::RETIRED), Batting::UNKNOWN_DISMISSAL => Batting::Text(Batting::UNKNOWN_DISMISSAL)), null); if (!is_null($batting) and $batting->GetPlayer()->GetPlayerRole() == Player::PLAYER and $this->IsValidSubmit()) { $how->SelectOption($batting->GetHowOut()); } $out_by = new TextBox("batOutBy{$i}", (is_null($batting) or is_null($batting->GetDismissedBy()) or !$batting->GetDismissedBy()->GetPlayerRole() == Player::PLAYER) ? "" : $batting->GetDismissedBy()->GetName(), $this->IsValidSubmit()); $out_by->SetMaxLength(100); $out_by->AddAttribute("autocomplete", "off"); $out_by->AddCssClass("player team" . $bowling_team->GetId()); $bowled_by = new TextBox("batBowledBy{$i}", (is_null($batting) or is_null($batting->GetBowler()) or !$batting->GetBowler()->GetPlayerRole() == Player::PLAYER) ? "" : $batting->GetBowler()->GetName(), $this->IsValidSubmit()); $bowled_by->SetMaxLength(100); $bowled_by->AddAttribute("autocomplete", "off"); $bowled_by->AddCssClass("player team" . $bowling_team->GetId()); $runs = new TextBox("batRuns{$i}", (is_null($batting) or $batting->GetPlayer()->GetPlayerRole() != Player::PLAYER) ? "" : $batting->GetRuns(), $this->IsValidSubmit()); $runs->SetCssClass("numeric runs"); $runs->AddAttribute("type", "number"); $runs->AddAttribute("min", "0"); $runs->AddAttribute("autocomplete", "off"); $balls = new TextBox("batBalls{$i}", (is_null($batting) or $batting->GetPlayer()->GetPlayerRole() != Player::PLAYER) ? "" : $batting->GetBallsFaced(), $this->IsValidSubmit()); $balls->SetCssClass("numeric balls"); $balls->AddAttribute("type", "number"); $balls->AddAttribute("min", "0"); $balls->AddAttribute("autocomplete", "off"); $batting_row = new XhtmlRow(array($player, $how, $out_by, $bowled_by, $runs, $balls)); $batting_row->GetFirstCell()->SetCssClass("batsman"); $batting_table->AddRow($batting_row); } } $batting_table->AddRow($this->CreateExtrasRow("batByes", "Byes", "extras", "numeric runs", $byes)); $batting_table->AddRow($this->CreateExtrasRow("batWides", "Wides", "extras", "numeric runs", $wides)); $batting_table->AddRow($this->CreateExtrasRow("batNoBalls", "No balls", "extras", "numeric runs", $no_balls)); $batting_table->AddRow($this->CreateExtrasRow("batBonus", "Bonus or penalty runs", "extras", "numeric runs", $bonus)); $batting_table->AddRow($this->CreateExtrasRow("batTotal", "Total", "totals", "numeric", $total)); $batting_table->AddRow($this->CreateWicketsRow($match, $wickets_taken)); $this->AddControl($batting_table); $total_batsmen = new TextBox("batRows", $match->GetMaximumPlayersPerTeam(), $this->IsValidSubmit()); $total_batsmen->SetMode(TextBoxMode::Hidden()); $this->AddControl($total_batsmen); $bowling_table = new XhtmlTable(); $bowling_table->SetCaption($bowling_team->GetName() . "'s bowling, over-by-over"); $bowling_table->SetCssClass("scorecard scorecardEditor bowling-scorecard bowling"); $over_header = new XhtmlCell(true, 'Balls bowled <span class="qualifier">(excluding extras)</span>'); $over_header->SetCssClass("numeric balls"); $wides_header = new XhtmlCell(true, "Wides"); $wides_header->SetCssClass("numeric"); $no_balls_header = new XhtmlCell(true, "No balls"); $no_balls_header->SetCssClass("numeric"); $runs_header = new XhtmlCell(true, "Over total"); $runs_header->SetCssClass("numeric"); $bowling_headings = new XhtmlRow(array("Bowler", $over_header, $wides_header, $no_balls_header, $runs_header)); $bowling_headings->SetIsHeader(true); $bowling_table->AddRow($bowling_headings); $bowling_data->ResetCounter(); for ($i = 1; $i <= $match->GetOvers(); $i++) { $bowling = $bowling_data->MoveNext() ? $bowling_data->GetItem() : null; /* @var $bowling Over */ $blank_row = (is_null($bowling) or is_null($bowling->GetOverNumber())); // don't list records generated from batting card to record wickets taken $player = new TextBox("bowlerName{$i}", $blank_row ? "" : $bowling->GetPlayer()->GetName(), $this->IsValidSubmit()); $player->SetMaxLength(100); $player->AddAttribute("autocomplete", "off"); $player->AddCssClass("player team" . $bowling_team->GetId()); $balls = new TextBox("bowlerBalls{$i}", $blank_row ? "" : $bowling->GetBalls(), $this->IsValidSubmit()); $balls->AddAttribute("autocomplete", "off"); $balls->AddAttribute("type", "number"); $balls->AddAttribute("min", "0"); $balls->AddAttribute("max", "10"); $balls->SetCssClass("numeric balls"); $wides = new TextBox("bowlerWides{$i}", $blank_row ? "" : $bowling->GetWides(), $this->IsValidSubmit()); $wides->AddAttribute("autocomplete", "off"); $wides->AddAttribute("type", "number"); $wides->AddAttribute("min", "0"); $wides->SetCssClass("numeric wides"); $no_balls = new TextBox("bowlerNoBalls{$i}", $blank_row ? "" : $bowling->GetNoBalls(), $this->IsValidSubmit()); $no_balls->AddAttribute("autocomplete", "off"); $no_balls->AddAttribute("type", "number"); $no_balls->AddAttribute("min", "0"); $no_balls->SetCssClass("numeric no-balls"); $runs = new TextBox("bowlerRuns{$i}", $blank_row ? "" : $bowling->GetRunsInOver(), $this->IsValidSubmit()); $runs->AddAttribute("autocomplete", "off"); $runs->AddAttribute("type", "number"); $runs->AddAttribute("min", "0"); $runs->SetCssClass("numeric runs"); $bowling_row = new XhtmlRow(array($player, $balls, $wides, $no_balls, $runs)); $bowling_row->GetFirstCell()->SetCssClass("bowler"); $bowling_table->AddRow($bowling_row); } $this->AddControl($bowling_table); $total_overs = new TextBox("bowlerRows", $match->GetOvers(), $this->IsValidSubmit()); $total_overs->SetMode(TextBoxMode::Hidden()); $this->AddControl($total_overs); if ($match->GetLastAudit() != null) { require_once "data/audit-control.class.php"; $this->AddControl(new AuditControl($match->GetLastAudit(), "match")); } $home_batted_first = ""; if (!is_null($match->Result()->GetHomeBattedFirst())) { $home_batted_first = (int) $match->Result()->GetHomeBattedFirst(); } $teams = new TextBox("teams", $home_batted_first . ScorecardEditControl::DATA_SEPARATOR . $match->GetHomeTeamId() . ScorecardEditControl::DATA_SEPARATOR . $match->GetHomeTeam()->GetName() . ScorecardEditControl::DATA_SEPARATOR . $match->GetAwayTeamId() . ScorecardEditControl::DATA_SEPARATOR . $match->GetAwayTeam()->GetName() . ScorecardEditControl::DATA_SEPARATOR . $match->GetTitle()); $teams->SetMode(TextBoxMode::Hidden()); $this->AddControl($teams); }