/** * Create a table row to add or edit a permission * * @param object $data_object * @param int $i_row_count * @param int $i_total_rows */ protected function AddItemToTable($data_object = null, $i_row_count = null, $i_total_rows = null) { /* @var $data_object IdValue */ $b_has_data_object = !is_null($data_object); // Which permission? $permission_select = new XhtmlSelect(); foreach ($this->permissions as $permission) { $permission_select->AddControl(new XhtmlOption($permission->GetValue(), $permission->GetId())); } $permission_select = $this->ConfigureSelect($permission_select, $b_has_data_object ? $data_object->GetId() : '', 'Permission', $i_row_count, $i_total_rows, true); // For a particular resource? $resource_box = $this->CreateTextBox($b_has_data_object ? $data_object->GetValue() : '', 'Resource', $i_row_count, $i_total_rows, true); $resource_box->SetMaxLength(250); # Add controls to table $this->AddRowToTable(array($permission_select, $resource_box)); }
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'); }
/** * 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() { $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 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 OnPreRender() { if ($this->b_show_date) { # create dropdown menu for day of month $o_day = new XhtmlSelect($this->GetXhtmlId() . '_day', '', $this->b_page_valid); if (!$this->GetRequireDate()) { $o_day->AddControl(new XhtmlOption()); } for ($i = 1; $i <= 31; $i++) { $o_day->AddControl(new XhtmlOption($i, $i)); } if ($this->i_timestamp != null and !($this->b_page_valid === false)) { $o_day->SelectOption(date('j', $this->i_timestamp)); } # create label, and add controls $o_day_label = new XhtmlElement('label', 'Day'); $o_day_label->AddAttribute('for', $o_day->GetXhtmlId()); $o_day_label->SetCssClass('aural'); $this->AddControl($o_day_label); $this->AddControl($o_day); # create dropdown menu for month $o_month = new XhtmlSelect($this->GetXhtmlId() . '_month', '', $this->b_page_valid); if (!$this->GetRequireDate()) { $o_month->AddControl(new XhtmlOption()); } if ($this->month_end > $this->month_start) { for ($i = $this->month_start; $i <= $this->month_end; $i++) { $s_monthname = date('F', gmmktime(0, 0, 0, $i, 1, 0)); $o_month->AddControl(new XhtmlOption($s_monthname, $i)); } } else { # Support order of Oct, Nov, Dec, Jan, Feb Mar for ($i = $this->month_start; $i <= 12; $i++) { $s_monthname = date('F', gmmktime(0, 0, 0, $i, 1, 0)); $o_month->AddControl(new XhtmlOption($s_monthname, $i)); } for ($i = 1; $i <= $this->month_end; $i++) { $s_monthname = date('F', gmmktime(0, 0, 0, $i, 1, 0)); $o_month->AddControl(new XhtmlOption($s_monthname, $i)); } } if ($this->i_timestamp != null and !($this->b_page_valid === false)) { $o_month->SelectOption(date('n', $this->i_timestamp)); } # create label, and add controls $o_month_label = new XhtmlElement('label', 'Month'); $o_month_label->AddAttribute('for', $o_month->GetXhtmlId()); $o_month_label->SetCssClass('aural'); $this->AddControl($o_month_label); $this->AddControl($o_month); # create dropdown for year if ($this->GetRequireDate() and $this->year_start == $this->year_end) { # If there's only one possible value for year and it's required, just hard-code it $o_year = new TextBox($this->GetXhtmlId() . '_year', $this->year_start, $this->b_page_valid); $o_year->SetMode(TextBoxMode::Hidden()); $this->AddControl($o_year); $this->AddControl(' ' . $this->year_start); } else { $o_year = new XhtmlSelect($this->GetXhtmlId() . '_year', '', $this->b_page_valid); if (!$this->GetRequireDate()) { $o_year->AddControl(new XhtmlOption()); } for ($i = $this->year_start; $i <= $this->year_end; $i++) { $o_option = new XhtmlOption($i, $i); $o_year->AddControl($o_option); } if ($this->i_timestamp != null and !($this->b_page_valid === false)) { $o_year->SelectOption(date('Y', $this->i_timestamp)); } # create label, and add controls $o_year_label = new XhtmlElement('label', 'Year'); $o_year_label->AddAttribute('for', $o_year->GetXhtmlId()); $o_year_label->SetCssClass('aural'); $this->AddControl($o_year_label); $this->AddControl($o_year); } } else { $o_day = new TextBox($this->GetXhtmlId() . '_day'); $o_day->SetMode(TextBoxMode::Hidden()); $o_day->SetText(date('j', $this->i_timestamp)); $this->AddControl($o_day); $o_month = new TextBox($this->GetXhtmlId() . '_month'); $o_month->SetMode(TextBoxMode::Hidden()); $o_month->SetText(date('n', $this->i_timestamp)); $this->AddControl($o_month); $o_year = new TextBox($this->GetXhtmlId() . '_year'); $o_year->SetMode(TextBoxMode::Hidden()); $o_year->SetText(date('Y', $this->i_timestamp)); $this->AddControl($o_year); } if ($this->b_show_time) { if ($this->b_show_date) { $this->AddControl(' '); } $this->AddControl('<span class="time">'); if ($this->b_show_date) { $this->AddControl('at '); } # create dropdown menu for hour $o_hour = new XhtmlSelect($this->GetXhtmlId() . '_hour', '', $this->b_page_valid); if (!$this->GetRequireTime()) { $o_hour->AddControl(new XhtmlOption()); } for ($i = 1; $i <= 12; $i++) { $o_hour->AddControl(new XhtmlOption($i, $i)); } if ($this->i_timestamp != null and $this->b_time_known and !($this->b_page_valid === false)) { $o_hour->SelectOption(date('g', $this->i_timestamp)); } # create label, and add controls $o_hour_label = new XhtmlElement('label', 'Hour'); $o_hour_label->AddAttribute('for', $o_hour->GetXhtmlId()); $o_hour_label->SetCssClass('aural'); $this->AddControl($o_hour_label); $this->AddControl($o_hour); # create dropdown menu for minute $o_minute = new XhtmlSelect($this->GetXhtmlId() . '_minute', '', $this->b_page_valid); if (!$this->GetRequireTime()) { $o_minute->AddControl(new XhtmlOption()); } for ($i = 0; $i <= 59; $i++) { if ($i % $this->i_minute_interval == 0) { $s_minute = $i > 9 ? (string) $i : "0" . (string) $i; $o_minute->AddControl(new XhtmlOption($s_minute, $s_minute)); } } if ($this->i_timestamp != null and $this->b_time_known and !($this->b_page_valid === false)) { $o_minute->SelectOption(date('i', $this->i_timestamp)); } # create label, and add controls $o_min_label = new XhtmlElement('label', 'Minutes'); $o_min_label->AddAttribute('for', $o_minute->GetXhtmlId()); $o_min_label->SetCssClass('aural'); $this->AddControl($o_min_label); $this->AddControl($o_minute); # create dropdown menu for am/pm $o_ampm = new XhtmlSelect($this->GetXhtmlId() . '_ampm', '', $this->b_page_valid); if (!$this->GetRequireTime()) { $o_ampm->AddControl(new XhtmlOption()); } $o_ampm->AddControl(new XhtmlOption('am', 'am')); $o_ampm->AddControl(new XhtmlOption('pm', 'pm')); if ($this->i_timestamp != null and $this->b_time_known and !($this->b_page_valid === false)) { $o_ampm->SelectOption(date('a', $this->i_timestamp)); } # create label, and add controls $o_ampm_label = new XhtmlElement('label', 'AM or PM'); $o_ampm_label->AddAttribute('for', $o_ampm->GetXhtmlId()); $o_ampm_label->SetCssClass('aural'); $this->AddControl($o_ampm_label); $this->AddControl($o_ampm); $this->AddControl('</span>'); } else { $o_hour = new TextBox($this->GetXhtmlId() . '_hour'); $o_hour->SetMode(TextBoxMode::Hidden()); if ($this->b_time_known) { $o_hour->SetText(date('g', $this->i_timestamp)); } $this->AddControl($o_hour); $o_minute = new TextBox($this->GetXhtmlId() . '_minute'); $o_minute->SetMode(TextBoxMode::Hidden()); if ($this->b_time_known) { $o_minute->SetText(date('i', $this->i_timestamp)); } $this->AddControl($o_minute); $o_ampm = new TextBox($this->GetXhtmlId() . '_ampm'); $o_ampm->SetMode(TextBoxMode::Hidden()); if ($this->b_time_known) { $o_ampm->SetText(date('a', $this->i_timestamp)); } $this->AddControl($o_ampm); } }
private function CreateWicketsRow(Match $match, $wickets_taken) { $wickets_header = new XhtmlCell(true, "Wickets"); $wickets_header->SetColumnSpan(4); $wickets = new XhtmlSelect("batWickets", null, $this->IsValidSubmit()); $wickets->SetBlankFirst(true); $max_wickets = $match->GetMaximumPlayersPerTeam() - 2; $season_dates = Season::SeasonDates($match->GetStartTime()); # working with GMT if (Date::Year($season_dates[0]) != Date::Year($season_dates[1])) { # outdoor needs maximum-2, but indoor needs maximum-1 cos last batter can play on. # if there's any chance it's indoor use maximum-1 $max_wickets = $match->GetMaximumPlayersPerTeam() - 1; } for ($i = 0; $i <= $max_wickets; $i++) { $wickets->AddControl(new XhtmlOption($i)); } $wickets->AddControl(new XhtmlOption('all out', -1)); if ($this->IsValidSubmit() and !is_null($wickets_taken)) { $wickets->SelectOption($wickets_taken); } $balls_column = new XhtmlCell(false, null); $wickets_row = new XhtmlRow(array($wickets_header, $wickets, $balls_column)); $wickets_row->SetCssClass("totals"); return $wickets_row; }
/** * Creates a dropdown list to select either "don't know" or one of the two playing teams */ private function SelectOneOfTwoTeams($list_id, Match $match, $select_home_if, $select_away_if) { $list = new XhtmlSelect($list_id); $list->AddControl(new XhtmlOption("Don't know", '')); $list->AddControl(new XhtmlOption(!is_null($match->GetHomeTeam()) ? $match->GetHomeTeam()->GetName() : 'Home team', TeamRole::Home(), $select_home_if)); $list->AddControl(new XhtmlOption(!is_null($match->GetAwayTeam()) ? $match->GetAwayTeam()->GetName() : 'Away team', TeamRole::Away(), $select_away_if)); return $list; }
protected function CreateControls() { $o_match = $this->GetDataObject(); if (is_null($o_match)) { $o_match = new Match($this->GetSettings()); } /* @var $o_match Match */ /* @var $o_team Team */ $b_got_home = !is_null($o_match->GetHomeTeam()); $b_got_away = !is_null($o_match->GetAwayTeam()); $b_is_new_match = !(bool) $o_match->GetId(); $b_is_tournament_match = false; if ($this->i_match_type == MatchType::TOURNAMENT_MATCH) { $b_is_tournament_match = $this->tournament instanceof Match; } else { if ($o_match->GetMatchType() == MatchType::TOURNAMENT_MATCH and $o_match->GetTournament() instanceof Match) { $this->SetTournament($o_match->GetTournament()); $this->SetMatchType($o_match->GetMatchType()); $b_is_tournament_match = true; } } $o_match_outer_1 = new XhtmlElement('div'); $o_match_outer_1->SetCssClass('MatchFixtureEdit'); $o_match_outer_1->AddCssClass($this->GetCssClass()); $this->SetCssClass(''); $o_match_outer_1->SetXhtmlId($this->GetNamingPrefix()); $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}', MatchType::Text($this->i_match_type), $this->GetHeading()); # Add match type if required $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_match_box->AddControl(new XhtmlElement('h2', $o_title_inner_3, "medium large")); } # Offer choice of season if appropriate $season_count = $this->seasons->GetCount(); if ($season_count == 1 and $this->i_match_type != MatchType::PRACTICE) { $o_season_id = new TextBox($this->GetNamingPrefix() . 'Season', $this->seasons->GetFirst()->GetId()); $o_season_id->SetMode(TextBoxMode::Hidden()); $o_match_box->AddControl($o_season_id); } elseif ($season_count > 1 and $this->i_match_type != MatchType::PRACTICE) { $o_season_id = new XhtmlSelect($this->GetNamingPrefix() . 'Season', '', $this->IsValidSubmit()); foreach ($this->Seasons()->GetItems() as $season) { $o_season_id->AddControl(new XhtmlOption($season->GetCompetitionName(), $season->GetId())); } $o_match_box->AddControl(new FormPart('Competition', $o_season_id)); } # Start date and time $match_time_known = (bool) $o_match->GetStartTime(); if (!$match_time_known) { # if no date set, use specified default if ($this->i_default_time) { $o_match->SetStartTime($this->i_default_time); if ($b_is_tournament_match) { $o_match->SetIsStartTimeKnown(false); } } else { # if no date set and no default, default to today at 6.30pm BST $i_now = gmdate('U'); $o_match->SetStartTime(gmmktime(17, 30, 00, (int) gmdate('n', $i_now), (int) gmdate('d', $i_now), (int) gmdate('Y', $i_now))); } } $o_date = new DateControl($this->GetNamingPrefix() . 'Start', $o_match->GetStartTime(), $o_match->GetIsStartTimeKnown(), $this->IsValidSubmit()); $o_date->SetShowTime(true); $o_date->SetRequireTime(false); $o_date->SetMinuteInterval(5); # if no date set and only one season to choose from, limit available dates to the length of that season if (!$match_time_known and $season_count == 1) { if ($this->Seasons()->GetFirst()->GetStartYear() == $this->Seasons()->GetFirst()->GetEndYear()) { $i_mid_season = gmmktime(0, 0, 0, 6, 30, $this->Seasons()->GetFirst()->GetStartYear()); } else { $i_mid_season = gmmktime(0, 0, 0, 12, 31, $this->Seasons()->GetFirst()->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 + 1); } // TODO: need a better way to handle this, allowing overlap. Shirley has indoor matches until early April. $season_start_year = $this->Seasons()->GetFirst()->GetStartYear(); $season_end_year = $this->Seasons()->GetFirst()->GetEndYear(); if ($season_start_year) { $o_date->SetYearStart($season_start_year); } if ($season_end_year) { $o_date->SetYearEnd($season_end_year); } } if ($b_is_tournament_match) { $o_date->SetShowDate(false); $o_date->SetShowTime(false); $o_match_box->AddControl($o_date); } else { $o_date_part = new FormPart('When?', $o_date); $o_date_part->SetIsFieldset(true); $o_match_box->AddControl($o_date_part); } # Who's playing? if ($this->i_match_type == MatchType::PRACTICE and isset($this->context_team)) { $home_id = new TextBox($this->GetNamingPrefix() . 'Home', $this->context_team->GetId()); $home_id->SetMode(TextBoxMode::Hidden()); $away_id = new TextBox($this->GetNamingPrefix() . 'Away', $this->context_team->GetId()); $away_id->SetMode(TextBoxMode::Hidden()); $o_match_box->AddControl($home_id); $o_match_box->AddControl($away_id); } else { $o_home_list = new XhtmlSelect($this->GetNamingPrefix() . 'Home'); $o_away_list = new XhtmlSelect($this->GetNamingPrefix() . 'Away'); $first_real_team_index = 0; if ($this->b_user_is_admin) { # Option of not specifying teams is currently admin-only # Value of 0 is important because PHP sees it as boolean negative, but it can be used as the indexer of an array in JavaScript $o_home_list->AddControl(new XhtmlOption("Don't know yet", '0')); $o_away_list->AddControl(new XhtmlOption("Don't know yet", '0')); $first_real_team_index = 1; } foreach ($this->a_teams as $group_name => $teams) { foreach ($teams as $o_team) { $home_option = new XhtmlOption($o_team->GetName(), $o_team->GetId()); if (is_string($group_name) and $group_name) { $home_option->SetGroupName($group_name); } $o_home_list->AddControl($home_option); $away_option = new XhtmlOption($o_team->GetName(), $o_team->GetId()); if (is_string($group_name) and $group_name) { $away_option->SetGroupName($group_name); } $o_away_list->AddControl($away_option); } } $o_home_part = new FormPart('Home team', $o_home_list); $o_away_part = new FormPart('Away team', $o_away_list); $o_match_box->AddControl($o_home_part); $o_match_box->AddControl($o_away_part); if ($b_got_home) { $o_home_list->SelectOption($o_match->GetHomeTeamId()); } if (!$b_got_home and $b_is_new_match) { // if no home team data, select the first team by default // unless editing a match, in which case it may be correct to have no teams (eg cup final) $o_home_list->SelectIndex($first_real_team_index); } if (!$b_got_away and $b_is_new_match) { // if no away team data, select the second team as the away team so that it's not the same as the first // unless editing a match, in which case it may be correct to have no teams (eg cup final). $o_away_list->SelectIndex($first_real_team_index + 1); // if there was a home team but not an away team, make sure we don't select the home team against itself if ($b_got_home and $o_away_list->GetSelectedValue() == (string) $o_match->GetHomeTeamId()) { $o_away_list->SelectIndex($first_real_team_index); } } else { if ($b_got_away) { $o_away_list->SelectOption($o_match->GetAwayTeamId()); } if (!$b_is_new_match) { # Note which away team was previously saved, even if it's "not known" - this is for JavaScript to know it shouldn't auto-change the away team $away_saved = new TextBox($this->GetNamingPrefix() . 'SavedAway', $o_match->GetAwayTeamId()); $away_saved->SetMode(TextBoxMode::Hidden()); $o_match_box->AddControl($away_saved); unset($away_saved); } } } # Where? # If tournament match, assume same ground as tournament. Otherwise ask the user for ground. if ($b_is_tournament_match) { $ground = new TextBox($this->GetNamingPrefix() . 'Ground', $this->tournament->GetGroundId() ? $this->tournament->GetGroundId() : $o_match->GetGroundId()); $ground->SetMode(TextBoxMode::Hidden()); $o_match_box->AddControl($ground); } else { $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 home grounds for this season to the top of the list $a_home_ground_ids = array(); foreach ($this->a_teams as $teams) { foreach ($teams as $o_team) { $a_home_ground_ids[$o_team->GetId()] = $o_team->GetGround()->GetId(); } } $a_home_grounds = array(); $a_other_grounds = array(); /* @var $o_ground Ground */ foreach ($this->a_grounds as $o_ground) { if (array_search($o_ground->GetId(), $a_home_ground_ids) > -1) { $a_home_grounds[] = $o_ground; } else { $a_other_grounds[] = $o_ground; } } # Add home grounds foreach ($a_home_grounds as $o_ground) { $option = new XhtmlOption($o_ground->GetNameAndTown(), $o_ground->GetId()); $option->SetGroupName('Home 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('Away grounds'); $o_ground_list->AddControl($option); } # Select ground if ($o_match->GetGroundId()) { $o_ground_list->SelectOption($o_match->GetGroundId()); } elseif ($this->i_match_type == MatchType::PRACTICE and isset($this->context_team)) { $o_ground_list->SelectOption($this->context_team->GetGround()->GetId()); } $o_ground_part = new FormPart('Where?', $o_ground_list); $o_match_box->AddControl($o_ground_part); # Note which grounds belong to which teams, for use by match-fixture-edit-control.js to select a ground when the home team is changed # Format is 1,2;2,3;4,5 # where ; separates each team, and for each team the first number identifies the team and the second is the ground $s_team_ground = ''; foreach ($a_home_ground_ids as $i_team => $i_ground) { if ($s_team_ground) { $s_team_ground .= ';'; } $s_team_ground .= $i_team . ',' . $i_ground; } $o_hidden = new TextBox($this->GetNamingPrefix() . 'TeamGround', $s_team_ground); $o_hidden->SetMode(TextBoxMode::Hidden()); $o_match_box->AddControl($o_hidden); unset($o_hidden); # Note which ground was previously saved - this is for JavaScript to know it shouldn't auto-change the ground if (!$b_is_new_match) { $o_hidden = new TextBox($this->GetNamingPrefix() . 'SavedGround', $o_match->GetGroundId()); $o_hidden->SetMode(TextBoxMode::Hidden()); $o_match_box->AddControl($o_hidden); unset($o_hidden); } } # Notes $o_notes = new TextBox($this->GetNamingPrefix() . 'Notes', $o_match->GetNotes()); $o_notes->SetMode(TextBoxMode::MultiLine()); $o_notes_part = new FormPart('Notes', $o_notes); $o_match_box->AddControl($o_notes_part); # Remember match type, tournament and short URL $o_type = new TextBox($this->GetNamingPrefix() . 'MatchType', $this->GetMatchType()); $o_type->SetMode(TextBoxMode::Hidden()); $o_match_box->AddControl($o_type); if ($b_is_tournament_match) { $tourn_box = new TextBox($this->GetNamingPrefix() . 'Tournament', $this->tournament->GetId()); $tourn_box->SetMode(TextBoxMode::Hidden()); $o_match_box->AddControl($tourn_box); } $o_short_url = new TextBox($this->GetNamingPrefix() . 'ShortUrl', $o_match->GetShortUrl()); $o_short_url->SetMode(TextBoxMode::Hidden()); $o_match_box->AddControl($o_short_url); # Note the context team - to be picked up by JavaScript to enable auto-changing of away team if # context team is not selected as home team if (isset($this->context_team)) { $context_team_box = new TextBox($this->GetNamingPrefix() . 'ContextTeam', $this->context_team->GetId()); $context_team_box->SetMode(TextBoxMode::Hidden()); $o_match_box->AddControl($context_team_box); } }
/** * Adds objects as options in a dropdown list * * @param XhtmlSelect $select * @param object[] $a_objects_to_add * @param int[] $a_objects_to_disable * @return XhtmlSelect */ protected function AddOptions(XhtmlSelect $select, $a_objects_to_add, $a_objects_to_disable) { foreach ($a_objects_to_add as $i_id => $obj) { $opt = $this->CreateOption($i_id, $obj); if (in_array($i_id, $a_objects_to_disable, true)) { $this->DisableOption($opt); } $select->AddControl($opt); } return $select; }
/** * Build the form */ protected function OnPreRender() { $this->AddControl('<div id="statisticsFilter" class="panel"><div><div><h2><span><span><span>Filter these statistics</span></span></span></h2>'); # Track whether to show or hide this filter $filter = '<input type="hidden" id="filter" name="filter" value="'; $filter .= (isset($_GET["filter"]) and $_GET["filter"] == "1") ? 1 : 0; $filter .= '" />'; $this->AddControl($filter); $type_filters = array(); # Support player type filter if (is_array($this->player_type_filter)) { require_once "stoolball/player-type.enum.php"; $player_type_list = new XhtmlSelect("player-type"); $blank = new XhtmlOption("any players", ""); $player_type_list->AddControl($blank); foreach ($this->player_type_filter[0] as $player_type) { $player_type_list->AddControl(new XhtmlOption(strtolower(PlayerType::Text($player_type)), $player_type, $player_type === $this->player_type_filter[1])); } $label = new XhtmlElement("label", "Type of players", "aural"); $label->AddAttribute("for", $player_type_list->GetXhtmlId()); $type_filters[] = $label; $type_filters[] = $player_type_list; } # Support match type filter if (is_array($this->match_type_filter)) { require_once "stoolball/match-type.enum.php"; $match_type_list = new XhtmlSelect("match-type"); $blank = new XhtmlOption("any match", ""); $match_type_list->AddControl($blank); foreach ($this->match_type_filter[0] as $match_type) { $match_type_list->AddControl(new XhtmlOption(str_replace(" match", "", MatchType::Text($match_type)), $match_type, $match_type === $this->match_type_filter[1])); } $label = new XhtmlElement("label", "Type of competition", "aural"); $label->AddAttribute("for", $match_type_list->GetXhtmlId()); $type_filters[] = $label; $type_filters[] = $match_type_list; } if (count($type_filters)) { $type = new XhtmlElement("fieldset", new XhtmlElement("legend", "Match type", "formLabel"), "formPart"); $controls = new XhtmlElement("div", null, "formControl"); foreach ($type_filters as $control) { $controls->AddControl($control); } $type->AddControl($controls); $this->AddControl($type); } # Support team filter if (is_array($this->team_filter)) { $team_list = new XhtmlSelect("team"); $blank = new XhtmlOption("any team", ""); $team_list->AddControl($blank); foreach ($this->team_filter[0] as $team) { $team_list->AddControl(new XhtmlOption($team->GetName(), $team->GetId(), $team->GetId() == $this->team_filter[1])); } $this->AddControl(new FormPart("Team", $team_list)); } # Support opposition team filter if (is_array($this->opposition_filter)) { $opposition_list = new XhtmlSelect("opposition"); $blank = new XhtmlOption("any team", ""); $opposition_list->AddControl($blank); foreach ($this->opposition_filter[0] as $team) { $opposition_list->AddControl(new XhtmlOption($team->GetName(), $team->GetId(), $team->GetId() == $this->opposition_filter[1])); } $this->AddControl(new FormPart("Against", $opposition_list)); } # Support ground filter if (is_array($this->ground_filter)) { $ground_list = new XhtmlSelect("ground"); $blank = new XhtmlOption("any ground", ""); $ground_list->AddControl($blank); foreach ($this->ground_filter[0] as $ground) { $ground_list->AddControl(new XhtmlOption($ground->GetNameAndTown(), $ground->GetId(), $ground->GetId() == $this->ground_filter[1])); } $this->AddControl(new FormPart("Ground", $ground_list)); } # Support competition filter if (is_array($this->competition_filter)) { $competition_list = new XhtmlSelect("competition"); $blank = new XhtmlOption("any competition", ""); $competition_list->AddControl($blank); foreach ($this->competition_filter[0] as $competition) { $competition_list->AddControl(new XhtmlOption($competition->GetName(), $competition->GetId(), $competition->GetId() == $this->competition_filter[1])); } $this->AddControl(new FormPart("Competition", $competition_list)); } # Support date filter # Use text fields rather than HTML 5 date fields because then we can accept dates like "last Tuesday" # which PHP will understand. Jquery calendar is at least as good as native date pickers anyway. $date_fields = '<div class="formPart"> <label for="from" class="formLabel">From date</label> <div class="formControl twoFields"> <input type="text" class="date firstField" id="from" name="from" placeholder="any date" autocomplete="off"'; if (!$this->IsValid()) { $date_fields .= ' value="' . (isset($_GET["from"]) ? $_GET["from"] : "") . '"'; } else { if ($this->after_date_filter) { $date_fields .= ' value="' . Date::BritishDate($this->after_date_filter, false, true, false) . '"'; } } $date_fields .= ' /> <label for="to">Up to date <input type="text" class="date" id="to" name="to" placeholder="any date" autocomplete="off"'; if (!$this->IsValid()) { $date_fields .= ' value="' . (isset($_GET["to"]) ? $_GET["to"] : "") . '"'; } else { if ($this->before_date_filter) { $date_fields .= ' value="' . Date::BritishDate($this->before_date_filter, false, true, false) . '"'; } } $date_fields .= ' /></label> </div> </div>'; $this->AddControl($date_fields); # Support innings filter $innings_list = new XhtmlSelect("innings"); $innings_list->AddControl(new XhtmlOption("either innings", "")); $innings_list->AddControl(new XhtmlOption("first innings", 1, 1 == $this->innings_filter)); $innings_list->AddControl(new XhtmlOption("second innings", 2, 2 == $this->innings_filter)); $this->AddControl('<div class="formPart"> <label for="innings" class="formLabel">Innings</label> <div class="formControl">' . $innings_list . '</div>' . '</div>'); # Support batting position filter if (is_array($this->batting_position_filter)) { $batting_position_list = new XhtmlSelect("batpos"); $blank = new XhtmlOption("any position", ""); $batting_position_list->AddControl($blank); foreach ($this->batting_position_filter[0] as $batting_position) { $batting_position_list->AddControl(new XhtmlOption($batting_position == 1 ? "opening" : $batting_position, $batting_position, $batting_position == $this->batting_position_filter[1])); } $this->AddControl('<div class="formPart"> <label for="batpos" class="formLabel">Batting at</label> <div class="formControl">' . $batting_position_list . '</div>' . '</div>'); } # Support match result filter $result_list = new XhtmlSelect("result"); $result_list->AddControl(new XhtmlOption("any result", "")); $result_list->AddControl(new XhtmlOption("win", 1, 1 === $this->match_result_filter)); $result_list->AddControl(new XhtmlOption("tie", 0, 0 === $this->match_result_filter)); $result_list->AddControl(new XhtmlOption("lose", -1, -1 === $this->match_result_filter)); $this->AddControl('<div class="formPart"> <label for="result" class="formLabel">Match result</label> <div class="formControl">' . $result_list . '</div>' . '</div>'); # Preserve the player filter if applied if (isset($_GET["player"]) and is_numeric($_GET["player"])) { $this->AddControl('<input type="hidden" name="player" id="player" value="' . $_GET["player"] . '" />'); } $this->AddControl('<p class="actions"><input type="submit" value="Apply filter" /></p>'); $this->AddControl('</div></div></div>'); }
/** * Create a table row to add or edit a points adjustment * * @param object $data_object * @param int $i_row_count * @param int $i_total_rows */ protected function AddItemToTable($data_object = null, $i_row_count = null, $i_total_rows = null) { /* @var $data_object PointsAdjustment */ $b_has_data_object = !is_null($data_object); // Number of points $i_positive_points = $b_has_data_object ? (int) str_replace('-', '', $data_object->GetPoints()) : null; $o_point_value = $this->CreateTextBox($i_positive_points, 'Points', $i_row_count, $i_total_rows, true); $o_point_value->AddAttribute('class', trim($o_point_value->GetAttribute('class') . ' numeric pointsBox')); // Awarded or deducted? $award = new XhtmlSelect(); $award->AddControl(new XhtmlOption('Awarded', 1)); $award->AddControl(new XhtmlOption('Deducted', 2)); $o_points_award = $this->ConfigureSelect($award, $b_has_data_object ? $data_object->GetPoints() > 0 ? 1 : 2 : '', 'Awarded', $i_row_count, $i_total_rows, true, 1); // For which team? $team = new XhtmlSelect(); foreach ($this->a_teams as $o_team) { $team->AddControl(new XhtmlOption($o_team->GetName(), $o_team->GetId())); } $o_points_team = $this->ConfigureSelect($team, $b_has_data_object ? $data_object->GetTeam()->GetId() : '', 'PointsTeam', $i_row_count, $i_total_rows, true); // For what reason? $o_points_reason = $this->CreateTextBox($b_has_data_object ? $data_object->GetReason() : '', 'Reason', $i_row_count, $i_total_rows, true); $o_points_reason->SetMaxLength(200); # Add controls to table $this->AddRowToTable(array($o_point_value, $o_points_award, $o_points_team, $o_points_reason)); }
function OnPageLoad() { echo "<h1>Stoolball matches</h1>"; # Filter controls $filter_box = new XhtmlForm(); $filter_box->SetCssClass('dataFilter'); $filter_box->AddAttribute('method', 'get'); $filter_box->AddControl(new XhtmlElement('p', 'Show me: ', "follow-on large")); $filter_inner = new XhtmlElement('div'); $filter_box->AddControl($filter_inner); $gender = new XhtmlSelect('player', 'Player type'); $gender->SetHideLabel(true); $gender->AddControl(new XhtmlOption("mixed and ladies", '')); $gender->AddControl(new XhtmlOption('mixed', 1)); $gender->AddControl(new XhtmlOption("ladies", 2)); if (isset($_GET['player'])) { $gender->SelectOption($_GET['player']); } $filter_inner->AddControl($gender); $type = new XhtmlSelect('type', 'Match type'); $type->SetHideLabel(true); $type->AddControl(new XhtmlOption('all matches', '')); $type->AddControl(new XhtmlOption('league matches', MatchType::LEAGUE)); $type->AddControl(new XhtmlOption('cup matches', MatchType::CUP)); $type->AddControl(new XhtmlOption('friendlies', MatchType::FRIENDLY)); $type->AddControl(new XhtmlOption('tournaments', MatchType::TOURNAMENT)); $type->AddControl(new XhtmlOption('practices', MatchType::PRACTICE)); if (isset($_GET['type'])) { $type->SelectOption($_GET['type']); } $filter_inner->AddControl($type); $filter_inner->AddControl(' in '); $month = new XhtmlSelect('month', 'Month'); $month->SetHideLabel(true); $month->AddControl(new XhtmlOption('next few matches', '')); foreach ($this->a_months as $i_month => $i_matches) { $opt = new XhtmlOption(Date::MonthAndYear($i_month), $i_month); if (isset($_GET['month']) and $_GET['month'] == $i_month) { $opt->AddAttribute('selected', 'selected'); } $month->AddControl($opt); unset($opt); } $filter_inner->AddControl($month); $update = new XhtmlElement('input'); $update->AddAttribute('type', 'submit'); $update->AddAttribute('value', 'Update'); $filter_inner->AddControl($update); # Content container $container = new XhtmlElement('div', $filter_box, "box"); $content = new XhtmlElement("div", null, "box-content"); $container->AddControl($content); # Display the matches if (count($this->a_matches)) { $list = new MatchListControl($this->a_matches); $content->AddControl($list); } else { $content->AddControl(new XhtmlElement('p', 'Sorry, there are no matches to show you.')); $content->AddControl(new XhtmlElement('p', 'If you know of a match which should be listed, please <a href="/play/manage/website/">add the match to the website</a>.')); } echo $container; }
/** * Adds controls to edit a team score * * @param XhtmlElement $o_container * @param string $s_id_prefix * @param Match $o_match * @param Team $o_team * @param int $i_runs * @param int $i_wickets */ private function CreateTeamScoreControls($o_container, $s_team_role, Match $o_match, Team $o_team = null, $i_runs, $i_wickets) { $o_box = new XhtmlElement('div'); $o_runs = new TextBox($this->GetNamingPrefix() . $s_team_role . 'Runs', $i_runs); $o_runs->SetCssClass("numeric"); if ($i_runs == null) { $o_runs->PopulateData(); } $s_runs_label = (is_null($o_team) ? $s_team_role : $o_team->GetName()) . ' score'; $o_part = new FormPart($s_runs_label, $o_box); $o_box->AddControl($o_runs); $o_part->GetLabel()->AddAttribute('for', $o_runs->GetXhtmlId()); $o_wickets = new XhtmlSelect($this->GetNamingPrefix() . $s_team_role . 'Wickets', ' for '); $o_wickets->SetBlankFirst(true); $max_wickets = $o_match->GetMaximumPlayersPerTeam() - 2; $season_dates = Season::SeasonDates($o_match->GetStartTime()); # working with GMT if (Date::Year($season_dates[0]) != Date::Year($season_dates[1])) { # outdoor needs maximum-2, but indoor needs maximum-1 cos last batter can play on. # if there's any chance it's indoor use maximum-1 $max_wickets = $o_match->GetMaximumPlayersPerTeam() - 1; } for ($i = 0; $i <= $max_wickets; $i++) { $o_wickets->AddControl(new XhtmlOption($i)); } $o_wickets->AddControl(new XhtmlOption('all out', -1)); $o_wickets->SelectOption($i_wickets); $o_box->AddControl($o_wickets); $o_container->AddControl($o_part); }
/** * Create a table row to add or edit a team registration * * @param object $data_object * @param int $i_row_count * @param int $i_total_rows */ protected function AddItemToTable($data_object = null, $i_row_count = null, $i_total_rows = null) { /* @var $data_object TeamInSeason */ $b_has_data_object = !is_null($data_object); // Which team? if (is_null($i_row_count)) { $team = new XhtmlSelect(); foreach ($this->a_teams as $o_team) { // For each team, check that it's not already selected before offering it as a choice $is_current_team = false; foreach ($this->DataObjects() as $team_in_season) { /* @var $team_in_season TeamInSeason */ if ($team_in_season->GetTeamId() == $o_team->GetId()) { $is_current_team = true; break; } } if (!$is_current_team) { $team->AddControl(new XhtmlOption($o_team->GetName(), $o_team->GetId())); } } $team_control = $this->ConfigureSelect($team, $b_has_data_object ? $data_object->GetTeam()->GetId() : '', 'Team', $i_row_count, $i_total_rows, true); } else { if (!$data_object->GetTeamName()) { foreach ($this->a_teams as $o_team) { if ($o_team->GetId() == $data_object->GetTeamId()) { $data_object->SetTeam($o_team); break; } } } $team_control = $this->CreateNonEditableText($b_has_data_object ? $data_object->GetTeamId() : null, $b_has_data_object ? $data_object->GetTeamName() : '', 'Team', $i_row_count, $i_total_rows); } // Withdrawn from league? $withdrawn_league = $this->CreateCheckbox($b_has_data_object ? $data_object->GetWithdrawnFromLeague() : '', 'WithdrawnLeague', $i_row_count, $i_total_rows); # Add controls to table $this->AddRowToTable(array($team_control, $withdrawn_league)); }
private function AddTeamList($list_id, $value, $i_total_rows) { $list = new XhtmlSelect(); foreach ($this->teams as $team) { $list->AddControl(new XhtmlOption($team->GetName(), $team->GetId())); } return $this->ConfigureSelect($list, $value, $list_id, null, $i_total_rows, true); }