function OnPreRender() { /* @var $o_team Team */ $a_teams = $this->teams; if (count($a_teams)) { $o_list = new XhtmlElement('ul'); if ($this->is_navigation_list) { $o_list->SetCssClass('teamList nav'); $nav = new XhtmlElement("nav", $o_list); $this->AddControl($nav); } else { $o_list->SetCssClass('teamList'); $this->AddControl($o_list); } $i_count = 0; foreach ($a_teams as $o_team) { if (strtolower(get_class($o_team)) == 'team') { $li = new XhtmlElement('li'); $li->AddAttribute("typeof", "schema:SportsTeam"); $li->AddAttribute("about", $o_team->GetLinkedDataUri()); if ($this->b_show_type) { $link = new TeamNameControl($o_team, "a"); } else { $link = new XhtmlElement('a', Html::Encode($o_team->GetName())); $link->AddAttribute("property", "schema:name"); } $link->AddAttribute('href', $o_team->GetNavigateUrl()); $link->AddAttribute("rel", "schema:url"); $li->AddControl($link); # Add not playing, if relevant if (!$o_team->GetIsActive()) { $li->AddControl(' (doesn\'t play any more)'); } $o_list->AddControl($li); $i_count++; } } } else { # Display no teams message if ($this->s_no_teams_message) { $this->AddControl(new XhtmlElement('p', $this->s_no_teams_message)); } } }
function GetActionCell($o_sub) { # delete link $o_link = new XhtmlElement('a', 'Unsubscribe'); $o_link->AddAttribute('href', $_SERVER['PHP_SELF'] . '?delete=' . $o_sub->GetSubscribedItemId() . '&type=' . $o_sub->GetType()); $o_link->AddAttribute('onclick', "return confirm('Unsubscribe from \\'" . addslashes($o_sub->GetTitle()) . "\\'" . '?\\n\\nAre you sure?\');'); # create cell $o_td = new XhtmlElement('td', $o_link); $o_td->SetCssClass('action'); return $o_td; }
function OnPageLoad() { # display intro if (isset($_GET['action']) and $_GET['action'] == 'request') { $o_message = new XhtmlElement('div'); $o_message->SetCssClass('activateMessage'); if (isset($_GET['email']) and $_GET['email'] == 'no') { echo '<h1>Confirm your registration</h1>'; $s_message = 'There was a <strong>problem sending you an email</strong>.'; $s_message .= "You need to get an email to register with " . Html::Encode($this->GetSettings()->GetSiteName()) . '. ' . 'Please check your email address and try again.'; $o_message->AddControl(new XhtmlElement('p', $s_message)); } else { echo '<h1>Check your email to confirm your registration</h1>'; $o_message->AddControl(new XhtmlElement('p', 'Thanks for registering with ' . Html::Encode($this->GetSettings()->GetSiteName()) . '.')); $s_message = "We've sent you an email. Please check your inbox now, and click on the link in the email to confirm your registration."; $o_message->AddControl(new XhtmlElement('p', $s_message)); } echo $o_message; } else { if ($this->b_success) { ?> <h1>Confirmation successful</h1> <p>Welcome to <?php echo Html::Encode($this->GetSettings()->GetSiteName()); ?> !</p> <p>We've activated your account, and sent you an email confirming your sign in details.</p> <p><strong>Please <a href="/you">sign in</a> using your email address and your new password.</strong></p> <?php } else { echo new XhtmlElement('h1', 'Confirmation failed'); echo new XhtmlElement('p', 'Sorry, your registration for ' . Html::Encode($this->GetSettings()->GetSiteName()) . ' could not be confirmed.'); echo new XhtmlElement('p', 'Please check that you used the exact address in the email you received, or try to <a href="' . Html::Encode($this->GetSettings()->GetUrl('AccountCreate')) . '">register again</a>.'); } } }
function OnPreRender() { # Add required asterisk if ($this->b_required) { $o_label = $this->GetLabel(); if (is_object($o_label)) { $o_req = new XhtmlElement('span', '*'); $o_req->SetCssClass('requiredField'); $o_label->AddControl($o_req); } } # Change to fieldset if needed if ($this->b_fieldset) { $this->SetElementName('fieldset'); $o_label = $this->GetLabel(); if (is_object($o_label)) { $o_label->SetElementName('legend'); $o_label->RemoveAttribute('for'); } } }
/** * Creates the controls when the editor is in its season view * */ private function CreateSeasonControls(Match $match, XhtmlElement $match_box) { /* @var $season Season */ $css_class = 'TournamentEdit checkBoxList'; 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); $heading = 'Select seasons'; if ($this->show_step_number) { $heading .= ' – step 3 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")); # Preserve match title, because we need it to send the email when the seasons are saved $title = new TextBox($this->GetNamingPrefix() . 'Title', $match->GetTitle(), $this->IsValidSubmit()); $title->SetMode(TextBoxMode::Hidden()); $match_box->AddControl($title); # If the list of seasons includes ones in which the only match type is tournament, then # they're annual tournaments like Expo and Seaford. Although those tournaments can be listed # in other seasons (they're of interest to the league teams), we don't want other tournaments # listed on pages which are supposed to be just about those annual tournaments. So exclude them # from the collection of possible seasons. Next bit of code will add them back in for any # tournaments which actually are meant to be in those seasons. $seasons = $this->seasons->GetItems(); $len = count($seasons); for ($i = 0; $i < $len; $i++) { # Make sure only seasons which contain tournaments are listed. Necessary to include all match types # in the Seasons() collection from the database so that we can test what other match types seasons support. if (!$seasons[$i]->MatchTypes()->Contains(MatchType::TOURNAMENT)) { unset($seasons[$i]); continue; } if ($seasons[$i]->MatchTypes()->GetCount() == 1 and $seasons[$i]->MatchTypes()->GetFirst() == MatchType::TOURNAMENT) { unset($seasons[$i]); } } $this->seasons->SetItems($seasons); # If the list of possible seasons doesn't include the one(s) the match is already in, # or the ones the context team plays in, add those to the list of possibles $a_season_ids = array(); foreach ($this->seasons as $season) { $a_season_ids[] = $season->GetId(); } foreach ($match->Seasons() as $season) { if (!in_array($season->GetId(), $a_season_ids, true)) { $this->seasons->Insert($season); $a_season_ids[] = $season->GetId(); } } if (isset($this->context_team)) { $match_year = Date::Year($match->GetStartTime()); foreach ($this->context_team->Seasons() as $team_in_season) { /* @var $team_in_season TeamInSeason */ if (!in_array($team_in_season->GetSeasonId(), $a_season_ids, true) and ($team_in_season->GetSeason()->GetStartYear() == $match_year or $team_in_season->GetSeason()->GetEndYear() == $match_year)) { $this->seasons->Insert($team_in_season->GetSeason()); $a_season_ids[] = $team_in_season->GetSeasonId(); } } } require_once 'xhtml/forms/checkbox.class.php'; $seasons_list = ''; if ($this->seasons->GetCount()) { # Sort the seasons by name, because they've been messed up by the code above $this->seasons->SortByProperty('GetCompetitionName'); $match_box->AddControl(new XhtmlElement('p', 'Tick all the places we should list your tournament:')); $match_box->AddControl('<div class="radioButtonList">'); foreach ($this->seasons as $season) { # Select season if it's one of the seasons the match is already in $b_season_selected = false; foreach ($match->Seasons() as $match_season) { $b_season_selected = ($b_season_selected or $match_season->GetId() == $season->GetId()); } /* @var $season Season */ $box = new CheckBox($this->GetNamingPrefix() . 'Season' . $season->GetId(), $season->GetCompetitionName(), $season->GetId(), $b_season_selected, $this->IsValidSubmit()); $seasons_list .= $season->GetId() . ';'; $match_box->AddControl($box); } $match_box->AddControl('</div>'); # Remember all the season ids to make it much easier to find the data on postback $seasons = new TextBox($this->GetNamingPrefix() . 'Seasons', $seasons_list, $this->IsValidSubmit()); $seasons->SetMode(TextBoxMode::Hidden()); $match_box->AddControl($seasons); } else { $match_month = 'in ' . Date::MonthAndYear($match->GetStartTime()); $type = strtolower(PlayerType::Text($match->GetPlayerType())); $match_box->AddControl(new XhtmlElement('p', "Unfortunately we don't have details of any {$type} competitions {$match_month} to list your tournament in.")); $match_box->AddControl(new XhtmlElement('p', 'Please click \'Save tournament\' to continue.')); } }
function CreateControls() { $this->AddCssClass('legacy-form'); /* @var $team Team */ /* @var $comp Competition */ $season = $this->GetDataObject(); /* @var $season Season */ require_once 'xhtml/forms/form-part.class.php'; require_once 'xhtml/forms/textbox.class.php'; require_once 'xhtml/forms/radio-button.class.php'; require_once 'xhtml/forms/checkbox.class.php'; # Show fewer options for a new season than when editing, beacause a new season gets settings copied from last year to save time $b_is_new_season = !(bool) $season->GetId(); # Add competition $comp = $season->GetCompetition(); $competition = new TextBox($this->GetNamingPrefix() . 'competition', $comp->GetId()); $competition->SetMode(TextBoxMode::Hidden()); $this->AddControl($competition); # Make current short URL available, because then it can match the suggested one and be left alone $short_url = new TextBox($this->GetNamingPrefix() . 'ShortUrl', $season->GetShortUrl()); $short_url->SetMode(TextBoxMode::Hidden()); $this->AddControl($short_url); # add years $start_box = new TextBox('start', is_null($season->GetStartYear()) ? Date::Year(gmdate('U')) : $season->GetStartYear(), $this->IsValidSubmit()); $start_box->AddAttribute('maxlength', 4); $start = new FormPart('Year season starts', $start_box); $this->AddControl($start); $summer = new RadioButton('summer', 'when', 'Summer season', 0); $winter = new RadioButton('winter', 'when', 'Winter season', 1); if ($season->GetEndYear() > $season->GetStartYear()) { $winter->SetChecked(true); } else { $summer->SetChecked(true); } $when = new XhtmlElement('div', $summer); $when->AddControl($winter); $when->SetCssClass('formControl'); $when_legend = new XhtmlElement('legend', 'Time of year'); $when_legend->SetCssClass('formLabel'); $when_fs = new XhtmlElement('fieldset', $when_legend); $when_fs->SetCssClass('formPart'); $when_fs->AddControl($when); $this->AddControl($when_fs); # add intro $intro_box = new TextBox('intro', $season->GetIntro(), $this->IsValidSubmit()); $intro_box->SetMode(TextBoxMode::MultiLine()); $intro = new FormPart('Introduction', $intro_box); $this->AddControl($intro); if (!$b_is_new_season) { # add types of matches if (!$this->IsPostback() or $this->b_saving_new and $this->IsValidSubmit()) { foreach ($season->MatchTypes()->GetItems() as $i_type) { $this->match_types_editor->DataObjects()->Add(new IdValue($i_type, ucfirst(MatchType::Text($i_type)))); } } $this->AddControl(new FormPart('Match types', $this->match_types_editor)); # add results $result_container = new XhtmlElement('div'); $result_box = new TextBox('results', $season->GetResults(), $this->IsValidSubmit()); $result_box->SetMode(TextBoxMode::MultiLine()); $result_container->AddControl($result_box); $result = new FormPart('Results', $result_container); $result->GetLabel()->AddAttribute('for', $result_box->GetXhtmlId()); $this->AddControl($result); # Add rules table $rules = new XhtmlTable(); $rules->SetCaption('Points for each result'); $header = new XhtmlRow(array('Result', 'Points for home team', 'Points for away team')); $header->SetIsHeader(true); $rules->AddRow($header); foreach ($this->result_types as $result) { /* @var $result MatchResult */ # Shouldn't ever need to assign points to a postponed match if ($result->GetResultType() == MatchResult::POSTPONED) { continue; } # Populate result with points from season rule $season->PossibleResults()->ResetCounter(); while ($season->PossibleResults()->MoveNext()) { if ($season->PossibleResults()->GetItem()->GetResultType() == $result->GetResultType()) { $result->SetHomePoints($season->PossibleResults()->GetItem()->GetHomePoints()); $result->SetAwayPoints($season->PossibleResults()->GetItem()->GetAwayPoints()); break; } } # Create table row $home_box = new TextBox($this->GetNamingPrefix() . 'Result' . $result->GetResultType() . 'Home', $result->GetHomePoints(), $this->IsValidSubmit()); $away_box = new TextBox($this->GetNamingPrefix() . 'Result' . $result->GetResultType() . 'Away', $result->GetAwayPoints(), $this->IsValidSubmit()); $home_box->AddAttribute('class', 'pointsBox'); $away_box->AddAttribute('class', 'pointsBox'); $result_row = new XhtmlRow(array(MatchResult::Text($result->GetResultType()), $home_box, $away_box)); $rules->AddRow($result_row); } $result_container->AddControl($rules); # Add points adjustments $this->adjustments_editor->SetTeams($season->GetTeams()); if (!$this->IsPostback() or $this->b_saving_new and $this->IsValidSubmit()) { $this->adjustments_editor->DataObjects()->SetItems($season->PointsAdjustments()->GetItems()); } $result_container->AddControl($this->adjustments_editor); # Show league table? $table = new CheckBox('showTable', 'Show results table', 1, $season->GetShowTable()); $this->AddControl($table); $this->AddControl(new CheckBox('runsScored', 'Include runs scored', 1, $season->GetShowTableRunsScored())); $this->AddControl(new CheckBox('runsConceded', 'Include runs conceded', 1, $season->GetShowTableRunsConceded())); # add teams if (!$this->IsPostback() or $this->b_saving_new and $this->IsValidSubmit()) { $teams_in_season = array(); foreach ($season->GetTeams() as $team) { $teams_in_season[] = new TeamInSeason($team, $season, is_object($season->TeamsWithdrawnFromLeague()->GetItemByProperty('GetId', $team->GetId()))); } $this->teams_editor->DataObjects()->SetItems($teams_in_season); } $this->AddControl(new FormPart('Teams', $this->teams_editor)); } }
/** * 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 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); } }
/** * Creates standard controls used by most data edit forms * */ protected function OnPreRender() { require_once 'xhtml/forms/textbox.class.php'; require_once 'xhtml/forms/checkbox.class.php'; require_once 'xhtml/forms/xhtml-select.class.php'; # add id if (is_object($this->o_data_object) and method_exists($this->o_data_object, 'GetId') and $this->o_data_object->GetId()) { $o_id_box = new TextBox($this->s_naming_prefix . 'item', (string) $this->o_data_object->GetId()); $o_id_box->SetMode(TextBoxMode::Hidden()); $this->AddControl($o_id_box); } # Add save button if building the form # Add at top of form to trap enter key if ($this->b_render_base_element) { $o_buttons = new XhtmlElement('div'); $o_buttons->AddCssClass($this->show_buttons_at_top ? 'buttonGroup buttonGroupTop' : 'buttonGroup aural'); $o_save = new XhtmlElement('input'); $o_save->SetEmpty(true); $o_save->AddAttribute('type', 'submit'); $o_save->SetXhtmlId($this->GetNamingPrefix() . 'DataEditSave'); $o_save->AddAttribute('name', $o_save->GetXhtmlId()); $o_buttons->AddControl($o_save); if ($this->show_buttons_at_top and $this->GetAllowCancel()) { require_once 'xhtml/forms/button.class.php'; $o_buttons->AddControl(new Button($this->GetNamingPrefix() . 'DataEditCancel', 'Cancel')); } $this->AddControl($o_buttons); } # fire event for child class to create its controls $this->CreateControls(); # Add a second save button if ($this->b_render_base_element) { $o_save->AddAttribute('value', $this->GetButtonText()); # Allow button text to be set late $o_save2 = clone $o_save; $o_save2->SetXhtmlId($this->GetNamingPrefix() . 'DataEditSave2'); $o_save2->AddAttribute('name', $o_save2->GetXhtmlId()); $o_save2->AddCssClass('primary'); $o_buttons2 = new XhtmlElement('div'); $o_buttons2->SetCssClass('buttonGroup'); $o_buttons2->AddControl($o_save2); if ($this->GetAllowCancel()) { if (!$this->show_buttons_at_top) { require_once 'xhtml/forms/button.class.php'; } $cancel = new Button($this->GetNamingPrefix() . 'DataEditCancel2', 'Cancel'); $cancel->SetCssClass('cancel'); $o_buttons2->AddControl($cancel); } $this->AddControl($o_buttons2); } # Add page number if it's not the default if ($this->current_page != 1) { $page = new TextBox($this->GetNamingPrefix() . 'Page', $this->GetCurrentPage(), $this->IsValidSubmit()); $page->SetMode(TextBoxMode::Hidden()); $this->AddControl($page); } # to be valid, should all be in a div $o_container = new XhtmlElement('div'); $o_container->SetControls($this->GetControls()); if (!$this->b_render_base_element) { $o_container->SetCssClass($this->GetCssClass()); $o_container->SetXhtmlId($this->GetXhtmlId()); } $a_controls = array(); $a_controls[] = $o_container; $this->SetControls($a_controls); }
private function AddMetadata(Match $match, XhtmlElement $li) { $li->AddCssClass('vevent'); # hCalendar $li->AddAttribute("typeof", "schema:SportsEvent"); $li->AddAttribute("about", $match->GetLinkedDataUri()); $meta = new XhtmlElement('span'); $meta->SetCssClass('metadata'); # hCalendar end date if ($match->GetStartTime() and $match->GetIsStartTimeKnown()) { $end_date = $this->CreateEndDate($match); $meta->AddControl($end_date); } # hCalendar location if (!is_null($match->GetGround())) { $ground = new XhtmlElement('span', htmlentities($match->GetGround()->GetNameAndTown(), ENT_QUOTES, "UTF-8", false)); $ground->SetCssClass('location'); $meta->AddControl(' at '); $meta->AddControl($ground); } # hCalendar description $hcal_desc = new XhtmlElement('span'); $hcal_desc->SetCssClass('description'); $i_seasons = $match->Seasons()->GetCount(); if ($i_seasons) { $meta->AddControl(' in '); $seasons = $match->Seasons()->GetItems(); for ($i = 0; $i < $i_seasons; $i++) { $b_last = ($i > 0 and $i == $i_seasons - 1); if ($i > 0 and !$b_last) { $hcal_desc->AddControl(', '); } elseif ($b_last) { $hcal_desc->AddControl(' and '); } $hcal_desc->AddControl(htmlentities($seasons[$i]->GetCompetitionName(), ENT_QUOTES, "UTF-8", false)); } } if (!$match->GetIsStartTimeKnown()) { $hcal_desc->AddControl('. Start time not known'); } if ($hcal_desc->CountControls()) { $meta->AddControl($hcal_desc); } # hCalendar timestamp $meta->AddControl('. At '); $hcal_stamp = new XhtmlElement('abbr', htmlentities(Date::Time(gmdate('U')), ENT_QUOTES, "UTF-8", false)); $hcal_stamp->SetTitle(Date::Microformat()); $hcal_stamp->SetCssClass('dtstamp'); $meta->AddControl($hcal_stamp); # hCalendar GUID $meta->AddControl(' match '); $hcal_guid = new XhtmlElement('span', htmlentities($match->GetLinkedDataUri(), ENT_QUOTES, "UTF-8", false)); $hcal_guid->SetCssClass('uid'); $meta->AddControl($hcal_guid); # hCalendar status $s_status = 'CONFIRMED'; switch ($match->Result()->GetResultType()) { case MatchResult::CANCELLED: case MatchResult::POSTPONED: case MatchResult::AWAY_WIN_BY_FORFEIT: case MatchResult::HOME_WIN_BY_FORFEIT: $s_status = 'CANCELLED'; } $meta->AddControl(' is '); $status = new XhtmlElement('span', $s_status); $status->SetCssClass('status'); $meta->AddControl($status); $meta->AddControl('.'); $li->AddControl($meta); }
/** * Fires immediately after the body element is opened * */ protected function OnBodyOpened() { $mobile_logo = '<img src="' . $this->resource_root . '/images/logos/138x40-trans.png" width="138" height="40" alt="Go to the Stoolball England home page" class="small screen logo-small" /> <img src="' . $this->resource_root . '/images/logos/210x61-trans.png" width="210" height="61" alt="Go to the Stoolball England home page" class="print logo" />'; if (SiteContext::IsWordPress() and is_home()) { echo $mobile_logo; } else { echo '<a href="/">' . $mobile_logo . '</a>'; } ?> <form id="handle" action="/search/" method="get" class="large"><div><input id="search" type="search" name="q" value="<?php if (isset($_GET['q'])) { echo htmlentities($_GET['q'], ENT_QUOTES, "UTF-8", false); } ?> " /> <input type="submit" value="Search" id="go" /></div> </form> <div id="bat1"></div> <?php if ($this->GetContentCssClass()) { echo '<div id="board" class="' . $this->GetContentCssClass() . '">'; } else { echo '<div id="board">'; } ?> <div id="boardLeft"> <div id="boardRight"> <?php # build navbar and add to control tree $o_current = $this->GetContext()->GetByHierarchyLevel(2); $b_got_category = is_object($o_current); $b_section_home = ($this->GetContext()->GetDepth() == 2 and str_replace("/", "", $_SERVER['REQUEST_URI']) == $o_current->GetUrl()); $o_news = new XhtmlElement('a', 'News'); $o_rules = new XhtmlElement('a', 'Rules'); $o_play = new XhtmlElement('a', 'Play!'); $schools = new XhtmlElement('a', 'Schools'); $o_about = new XhtmlElement('a', 'About <span class="large"> Us</span>'); $search = new XhtmlElement('a', 'Search'); if ($b_got_category and $o_current->GetUrl() == 'news' or SiteContext::IsWordPress() and (is_single() or is_archive() and !is_category())) { if (!$b_section_home) { $o_news->AddAttribute('href', '/news'); $o_news->AddAttribute('role', 'menuitem'); $o_news->SetCssClass('current'); } else { $o_news->SetElementName('em'); } } else { $o_news->AddAttribute('href', '/news'); } if ($b_got_category and $o_current->GetUrl() == 'rules') { if (!$b_section_home) { $o_rules->AddAttribute('href', '/rules'); $o_rules->AddAttribute('role', 'menuitem'); $o_rules->SetCssClass('current'); } else { $o_rules->SetElementName('em'); } } else { $o_rules->AddAttribute('href', '/rules'); } if ($b_got_category and $o_current->GetUrl() == 'play') { if (!$b_section_home) { $o_play->AddAttribute('href', '/play'); $o_play->AddAttribute('role', 'menuitem'); $o_play->SetCssClass('current'); } else { $o_play->SetElementName('em'); } } else { $o_play->AddAttribute('href', '/play'); } if ($b_got_category and $o_current->GetUrl() == 'schools') { if (!$b_section_home) { $schools->AddAttribute('href', '/schools'); $schools->AddAttribute('role', 'menuitem'); $schools->SetCssClass('current'); } else { $schools->SetElementName('em'); } } else { $schools->AddAttribute('href', '/schools'); } if ($b_got_category and $o_current->GetUrl() == 'about') { if (!$b_section_home) { $o_about->AddAttribute('href', '/about'); $o_about->AddAttribute('role', 'menuitem'); $o_about->SetCssClass('current'); } else { $o_about->SetElementName('em'); } } else { $o_about->AddAttribute('href', '/about'); } if ($b_got_category and $o_current->GetUrl() == 'search') { if (!$b_section_home) { $search->AddAttribute('href', '/search'); $search->AddAttribute('role', 'menuitem'); $search->SetCssClass('current'); } else { $search->SetElementName('em'); } } else { $search->AddAttribute('href', '/search'); } ?> <nav> <ul class="menu screen" role="menubar"> <?php echo ''; echo '<li id="news">' . $o_news . '</li>'; echo '<li id="rules">' . $o_rules . '</li>'; echo '<li id="play">' . $o_play . '</li>'; echo '<li id="schools">' . $schools . '</li>'; echo '<li id="about">' . $o_about . '</li>'; echo '<li class="search small">' . $search . '</li>'; echo ''; ?> </ul> </nav> <div id="bat2" class="large"> <div id="involved"></div> <ul> <li><a href="/rules/what-is-stoolball">What is stoolball?</a></li> <li><a href="/rules">Learn the rules</a></li> <li><a href="/teams/map">Map of teams</a></li> </ul> </div> <div id="content" class="content"> <?php # add content if ($this->i_constraint_type != StoolballPage::ConstrainNone()) { switch ($this->i_constraint_type) { case StoolballPage::ConstrainText(): echo '<div id="constraint" class="constrainText">'; break; case StoolballPage::ConstrainColumns(): case StoolballPage::ConstrainBox(): echo '<div id="constraint" class="constrainColumns">'; break; } } if ($this->i_constraint_type == StoolballPage::ConstrainColumns()) { echo '<div class="supportedContentContainer"><div class="supportedContent">'; $this->b_col1_open = true; } $this->Render(); }
protected function OnPreRender() { /* @var $o_home Team */ /* @var $o_away Team */ /* @var $o_tourney Match */ # Date and tournament $o_date_para = new XhtmlElement('p'); $o_date = new XhtmlElement('abbr', htmlentities($this->o_match->GetStartTimeFormatted(), ENT_QUOTES, "UTF-8", false)); $o_date->SetTitle(Date::Microformat($this->o_match->GetStartTime())); # hCalendar $o_date->SetCssClass('dtstart'); # hCalendar $o_date->AddAttribute("property", "schema:startDate"); $o_date->AddAttribute("datatype", "xsd:date"); $o_date->AddAttribute("content", Date::Microformat($this->o_match->GetStartTime())); $o_date_para->AddControl('When: '); $o_date_para->AddControl($o_date); # hCalendar end date if ($this->o_match->GetIsStartTimeKnown()) { $i_end_time = $this->o_match->GetStartTime() + 60 * 90; $o_hcal_end = new XhtmlElement('abbr', ' until around ' . htmlentities(Date::Time($i_end_time), ENT_QUOTES, "UTF-8", false)); $o_hcal_end->SetTitle(Date::Microformat($i_end_time)); $o_hcal_end->SetCssClass('metadata dtend'); $o_date_para->AddControl($o_hcal_end); } # If we know the time and place, show when the sun sets # TODO: Assumes UK if ($this->o_match->GetGround() instanceof Ground and $this->o_match->GetGround()->GetAddress()->GetLatitude() and $this->o_match->GetGround()->GetAddress()->GetLongitude()) { $o_date_para->AddControl(' <span class="sunset">sunset ' . htmlentities(Date::Time(date_sunset($this->o_match->GetStartTime(), SUNFUNCS_RET_TIMESTAMP, $this->o_match->GetGround()->GetAddress()->GetLatitude(), $this->o_match->GetGround()->GetAddress()->GetLongitude())), ENT_QUOTES, "UTF-8", false) . '</span>'); } # Display match type/season/tournament if ($this->o_match->GetMatchType() == MatchType::TOURNAMENT_MATCH) { $o_date_para->SetCssClass('description'); # hCal $o_tourney = $this->o_match->GetTournament(); if (is_object($o_tourney)) { $tournament_link = new XhtmlAnchor(htmlentities($o_tourney->GetTitle(), ENT_QUOTES, "UTF-8", false), $o_tourney->GetNavigateUrl()); $tournament_link->AddAttribute("typeof", "schema:SportsEvent"); $tournament_link->AddAttribute("about", $o_tourney->GetLinkedDataUri()); $tournament_link->AddAttribute("rel", "schema:url"); $tournament_link->AddAttribute("property", "schema:name"); $tournament_container = new XhtmlElement("span", $tournament_link); $tournament_container->AddAttribute("rel", "schema:superEvent"); # Check for 'the' to get the grammar right $s_title = strtolower($o_tourney->GetTitle()); if (strlen($s_title) >= 4 and substr($s_title, 0, 4) == 'the ') { $o_date_para->AddControl(', in '); } else { $o_date_para->AddControl(', in the '); } $o_date_para->AddControl($tournament_container); $o_date_para->AddControl('.'); } else { $o_date_para->AddControl(', in a tournament.'); } } else { # hCalendar desc, built up at the same time as the date and league/tournament $hcal_desc = new XhtmlElement('div', null, 'description'); $this->AddControl($hcal_desc); $s_detail_xhtml = ucfirst(MatchType::Text($this->o_match->GetMatchType())); $season_list_xhtml = null; if ($this->o_match->Seasons()->GetCount() == 1) { $season = $this->o_match->Seasons()->GetFirst(); $season_name = new XhtmlAnchor(htmlentities($season->GetCompetitionName(), ENT_QUOTES, "UTF-8", false), $season->GetNavigateUrl()); $b_the = !(stristr($season->GetCompetitionName(), 'the ') === 0); $s_detail_xhtml .= ' in ' . ($b_the ? 'the ' : '') . $season_name->__toString() . '.'; } elseif ($this->o_match->Seasons()->GetCount() > 1) { $s_detail_xhtml .= ' in the following seasons: '; $season_list_xhtml = new XhtmlElement('ul'); $seasons = $this->o_match->Seasons()->GetItems(); $total_seasons = count($seasons); for ($i = 0; $i < $total_seasons; $i++) { $season = $seasons[$i]; /* @var $season Season */ $season_name = new XhtmlAnchor(htmlentities($season->GetCompetitionName(), ENT_QUOTES, "UTF-8", false), $season->GetNavigateUrl()); $li = new XhtmlElement('li', $season_name); if ($i < $total_seasons - 2) { $li->AddControl(new XhtmlElement('span', ', ', 'metadata')); } else { if ($i < $total_seasons - 1) { $li->AddControl(new XhtmlElement('span', ' and ', 'metadata')); } } $season_list_xhtml->AddControl($li); } } else { $s_detail_xhtml .= '.'; } $hcal_desc->AddControl(new XhtmlElement('p', $s_detail_xhtml)); if (!is_null($season_list_xhtml)) { $hcal_desc->AddControl($season_list_xhtml); } } # Who $o_home = $this->o_match->GetHomeTeam(); $o_away = $this->o_match->GetAwayTeam(); $has_home = $o_home instanceof Team; $has_away = $o_away instanceof Team; if ($has_home or $has_away) { $who = new XhtmlElement("p", "Who: "); if ($has_home) { $who->AddControl($this->CreateTeamLink($o_home)); } if ($has_home and $has_away) { $who->AddControl(" and "); } if ($has_away) { $who->AddControl($this->CreateTeamLink($o_away)); } $this->AddControl($who); } # When $this->AddControl($o_date_para); # Ground $o_ground = $this->o_match->GetGround(); if (is_object($o_ground)) { $o_ground_link = new XhtmlElement('a', htmlentities($o_ground->GetNameAndTown(), ENT_QUOTES, "UTF-8", false)); $o_ground_link->AddAttribute('href', $o_ground->GetNavigateUrl()); $o_ground_link->SetCssClass('location'); # hCalendar $o_ground_link->AddAttribute("typeof", "schema:Place"); $o_ground_link->AddAttribute("about", $o_ground->GetLinkedDataUri()); $o_ground_link->AddAttribute("rel", "schema:url"); $o_ground_link->AddAttribute("property", "schema:name"); $o_ground_control = new XhtmlElement('p', 'Where: '); $o_ground_control->AddAttribute("rel", "schema:location"); $o_ground_control->AddControl($o_ground_link); $this->AddControl($o_ground_control); } # Add result $o_result = $this->o_match->Result(); $b_result_known = !$o_result->GetResultType() == MatchResult::UNKNOWN; $toss_known = !is_null($this->o_match->Result()->GetTossWonBy()); $b_batting_order_known = !is_null($this->o_match->Result()->GetHomeBattedFirst()); $has_scorecard_data = ($o_result->HomeBatting()->GetCount() or $o_result->HomeBowling()->GetCount() or $o_result->AwayBatting()->GetCount() or $o_result->AwayBowling()->GetCount() or $o_result->GetHomeRuns() or $o_result->GetHomeWickets() or $o_result->GetAwayRuns() or $o_result->GetAwayWickets()); $has_player_of_match = $this->o_match->Result()->GetPlayerOfTheMatch() instanceof Player and $this->o_match->Result()->GetPlayerOfTheMatch()->GetName(); $has_player_of_match_home = $this->o_match->Result()->GetPlayerOfTheMatchHome() instanceof Player and $this->o_match->Result()->GetPlayerOfTheMatchHome()->GetName(); $has_player_of_match_away = $this->o_match->Result()->GetPlayerOfTheMatchAway() instanceof Player and $this->o_match->Result()->GetPlayerOfTheMatchAway()->GetName(); if ($b_result_known or $b_batting_order_known or $has_scorecard_data) { # Put result in header, so long as we have something to put after it. Otherwise put the result after it. $result_header = "Result"; if ($b_result_known and ($b_batting_order_known or $has_scorecard_data)) { $result_header .= ": " . $this->o_match->GetResultDescription(); } $result_header = new XhtmlElement('h2', htmlentities($result_header, ENT_QUOTES, "UTF-8", false)); if ($has_scorecard_data) { $result_header->AddCssClass("hasScorecard"); } $this->AddControl($result_header); } if ($toss_known) { $toss_team = $this->o_match->Result()->GetTossWonBy() === TeamRole::Home() ? $this->o_match->GetHomeTeam() : $this->o_match->GetAwayTeam(); if ($toss_team instanceof Team) { $toss_text = $toss_team->GetName() . " won the toss"; if ($b_batting_order_known) { $chose_to = ($this->o_match->Result()->GetTossWonBy() === TeamRole::Home()) == $this->o_match->Result()->GetHomeBattedFirst() ? "bat" : "bowl"; $toss_text .= " and chose to " . $chose_to; } $this->AddControl("<p>" . Html::Encode($toss_text) . '.</p>'); } } # If at least one player recorded, create a container for the schema.org metadata if ($has_scorecard_data or $has_player_of_match or $has_player_of_match_home or $has_player_of_match_away) { $this->AddControl('<div rel="schema:performers">'); } if ($has_scorecard_data) { $this->CreateScorecard($this->o_match); } else { # Got to be just result and batting order now. Only include result if batting order's not there, otherwise result will already be in header. if ($b_result_known and !$b_batting_order_known) { $this->AddControl(new XhtmlElement('p', htmlentities($this->o_match->GetResultDescription(), ENT_QUOTES, "UTF-8", false) . '.')); } if ($b_batting_order_known) { $this->AddControl(new XhtmlElement('p', htmlentities(($this->o_match->Result()->GetHomeBattedFirst() ? $o_home->GetName() : $o_away->GetName()) . ' batted first.'), ENT_QUOTES, "UTF-8", false)); } } # Player of the match if ($has_player_of_match) { $player = $this->o_match->Result()->GetPlayerOfTheMatch(); $team = $player->Team()->GetId() == $o_home->GetId() ? $o_home->GetName() : $o_away->GetName(); $player_of_match = new XhtmlElement('p', 'Player of the match: <a property="schema:name" rel="schema:url" href="' . htmlentities($player->GetPlayerUrl(), ENT_QUOTES, "UTF-8", false) . '">' . htmlentities($player->GetName(), ENT_QUOTES, "UTF-8", false) . "</a> ({$team})"); $player_of_match->AddAttribute("typeof", "schema:Person"); $player_of_match->AddAttribute("about", $player->GetLinkedDataUri()); $this->AddControl($player_of_match); } if ($has_player_of_match_home) { $player = $this->o_match->Result()->GetPlayerOfTheMatchHome(); $player_of_match = new XhtmlElement('p', $o_home->GetName() . ' player of the match: <a property="schema:name" rel="schema:url" href="' . htmlentities($player->GetPlayerUrl(), ENT_QUOTES, "UTF-8", false) . '">' . htmlentities($player->GetName(), ENT_QUOTES, "UTF-8", false) . "</a>"); $player_of_match->AddAttribute("typeof", "schema:Person"); $player_of_match->AddAttribute("about", $player->GetLinkedDataUri()); $this->AddControl($player_of_match); } if ($has_player_of_match_away) { $player = $this->o_match->Result()->GetPlayerOfTheMatchAway(); $player_of_match = new XhtmlElement('p', $o_away->GetName() . ' player of the match: <a property="schema:name" rel="schema:url" href="' . htmlentities($player->GetPlayerUrl(), ENT_QUOTES, "UTF-8", false) . '">' . htmlentities($player->GetName(), ENT_QUOTES, "UTF-8", false) . "</a>"); $player_of_match->AddAttribute("typeof", "schema:Person"); $player_of_match->AddAttribute("about", $player->GetLinkedDataUri()); $this->AddControl($player_of_match); } # End container for the schema.org metadata if ($has_scorecard_data or $has_player_of_match or $has_player_of_match_home or $has_player_of_match_away) { $this->AddControl('</div>'); } # Add notes if ($this->o_match->GetNotes()) { $this->AddControl(new XhtmlElement('h2', 'Notes')); $s_notes = htmlentities($this->o_match->GetNotes(), ENT_QUOTES, "UTF-8", false); $s_notes = XhtmlMarkup::ApplyCharacterEntities($s_notes); require_once 'email/email-address-protector.class.php'; $protector = new EmailAddressProtector($this->o_settings); $s_notes = $protector->ApplyEmailProtection($s_notes, AuthenticationManager::GetUser()->IsSignedIn()); $s_notes = XhtmlMarkup::ApplyHeadings($s_notes); $s_notes = XhtmlMarkup::ApplyParagraphs($s_notes); $s_notes = XhtmlMarkup::ApplyLists($s_notes); $s_notes = XhtmlMarkup::ApplySimpleTags($s_notes); $s_notes = XhtmlMarkup::ApplyLinks($s_notes); if (strpos($s_notes, '<p>') > -1) { $this->AddControl($s_notes); } else { $this->AddControl(new XhtmlElement('p', $s_notes)); } } # hCalendar metadata $o_hcal_para = new XhtmlElement('p'); $o_hcal_para->SetCssClass('metadata'); $this->AddControl($o_hcal_para); # hCalendar timestamp $o_hcal_para->AddControl('Status: At '); $o_hcal_stamp = new XhtmlElement('abbr', htmlentities(Date::Time(gmdate('U')), ENT_QUOTES, "UTF-8", false)); $o_hcal_stamp->SetTitle(Date::Microformat()); $o_hcal_stamp->SetCssClass('dtstamp'); $o_hcal_para->AddControl($o_hcal_stamp); # hCalendar GUID $o_hcal_para->AddControl(' match '); $o_hcal_guid = new XhtmlElement('span', htmlentities($this->o_match->GetLinkedDataUri(), ENT_QUOTES, "UTF-8", false)); $o_hcal_guid->SetCssClass('uid'); $o_hcal_para->AddControl($o_hcal_guid); # work out hCalendar status $s_status = 'CONFIRMED'; switch ($this->o_match->Result()->GetResultType()) { case MatchResult::CANCELLED: case MatchResult::POSTPONED: case MatchResult::AWAY_WIN_BY_FORFEIT: case MatchResult::HOME_WIN_BY_FORFEIT: $s_status = 'CANCELLED'; } # hCalendar URL and status $o_hcal_para->AddControl(' is '); $o_hcal_url = new XhtmlAnchor($s_status, 'http://' . $_SERVER['HTTP_HOST'] . $this->o_match->GetNavigateUrl()); $o_hcal_url->SetCssClass('url status'); $o_hcal_para->AddControl($o_hcal_url); }
function OnPageLoad() { echo '<h1>' . htmlentities($this->GetPageTitle(), ENT_QUOTES, "UTF-8", false) . '</h1>'; if (is_object($this->match)) { echo "<p>Thank you. You have added the following match:</p>"; echo new MatchListControl(array($this->match)); echo "<p>Don't worry if you made a mistake, just <a href=\"" . htmlentities($this->match->GetEditNavigateUrl(), ENT_QUOTES, "UTF-8", false) . '">edit this match</a> or <a href="' . htmlentities($this->match->GetDeleteNavigateUrl(), ENT_QUOTES, "UTF-8", false) . '">delete this match</a>.</p>'; $this->edit->SetHeading('Add another {0}'); # Configure edit control $this->edit->SetCssClass('panel addAnotherPanel'); } else { /* Create instruction panel */ $o_panel = new XhtmlElement('div'); $o_panel->SetCssClass('panel instructionPanel large'); $o_title_inner1 = new XhtmlElement('div', 'Add your matches quickly:'); $o_title = new XhtmlElement('h2', $o_title_inner1); $o_panel->AddControl($o_title); $o_tab_tip = new XhtmlElement('ul'); $o_tab_tip->AddControl(new XhtmlElement('li', 'Use the <span class="tab">tab</span> key on your keyboard to move through the form')); $o_tab_tip->AddControl(new XhtmlElement('li', 'Type the first letter or number to select from a dropdown list')); if ($this->i_match_type != MatchType::TOURNAMENT_MATCH) { $o_tab_tip->AddControl(new XhtmlElement('li', 'If you\'re not sure when the match starts, leave the time blank')); } $o_panel->AddControl($o_tab_tip); echo $o_panel; # Configure edit control $this->edit->SetCssClass('panel'); } # display the match to edit echo $this->edit; parent::OnPageLoad(); }
function OnPageLoad() { $is_tournament = $this->match->GetMatchType() == MatchType::TOURNAMENT; $class = $is_tournament ? "match" : "match vevent"; ?> <div class="$class" typeof="schema:SportsEvent" about="<?php echo Html::Encode($this->match->GetLinkedDataUri()); ?> "> <?php require_once 'xhtml/navigation/tabs.class.php'; $tabs = array('Summary' => ''); if ($is_tournament) { $tabs['Tournament statistics'] = $this->match->GetNavigateUrl() . '/statistics'; # Make sure the reader knows this is a tournament, and the player type $says_tournament = strpos(strtolower($this->match->GetTitle()), 'tournament') !== false; $player_type = PlayerType::Text($this->match->GetPlayerType()); $says_player_type = strpos(strtolower($this->match->GetTitle()), strtolower(rtrim($player_type, '\''))) !== false; $page_title = $this->match->GetTitle() . ", " . Date::BritishDate($this->match->GetStartTime(), false); if (!$says_tournament and !$says_player_type) { $page_title .= ' (' . $player_type . ' stoolball tournament)'; } else { if (!$says_tournament) { $page_title .= ' stoolball tournament'; } else { if (!$says_player_type) { $page_title .= ' (' . $player_type . ')'; } } } $heading = new XhtmlElement('h1', $page_title); $heading->AddAttribute("property", "schema:name"); echo $heading; } else { if ($this->match->GetMatchType() == MatchType::TOURNAMENT_MATCH) { $tabs['Match statistics'] = $this->match->GetNavigateUrl() . '/statistics'; $tabs['Tournament statistics'] = $this->match->GetTournament()->GetNavigateUrl() . '/statistics'; $page_title = $this->match->GetTitle() . " in the " . $this->match->GetTournament()->GetTitle(); } else { $tabs['Statistics'] = $this->match->GetNavigateUrl() . '/statistics'; $page_title = $this->match->GetTitle(); } $o_title = new XhtmlElement('h1', Html::Encode($page_title)); $o_title->AddAttribute("property", "schema:name"); # hCalendar $o_title->SetCssClass('summary'); $o_title_meta = new XhtmlElement('span', ' (stoolball)'); $o_title_meta->SetCssClass('metadata'); $o_title->AddControl($o_title_meta); if ($this->match->GetMatchType() !== MatchType::TOURNAMENT_MATCH) { $o_title->AddControl(", " . Date::BritishDate($this->match->GetStartTime(), false)); } echo $o_title; } echo new Tabs($tabs); ?> <div class="box tab-box"> <div class="dataFilter"></div> <div class="box-content"> <?php if ($is_tournament) { require_once 'stoolball/tournaments/tournament-control.class.php'; echo new TournamentControl($this->GetSettings(), $this->match); } else { require_once 'stoolball/matches/match-control.class.php'; echo new MatchControl($this->GetSettings(), $this->match); } $this->DisplayComments(); $this->ShowSocial(); ?> </div> </div> </div> <?php $this->AddSeparator(); # add/edit/delete options $user_is_admin = AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_MATCHES); $user_is_owner = AuthenticationManager::GetUser()->GetId() == $this->match->GetAddedBy()->GetId(); $panel = new UserEditPanel($this->GetSettings(), 'this match'); $panel->AddCssClass("with-tabs"); if ($user_is_admin or $user_is_owner) { $link_text = $is_tournament ? 'tournament' : 'match'; $panel->AddLink('edit this ' . $link_text, $this->match->GetEditNavigateUrl()); } else { if ($this->match->GetMatchType() != MatchType::PRACTICE and !$is_tournament) { $panel->AddLink('update result', $this->match->GetEditNavigateUrl()); } } if ($is_tournament) { $panel->AddCssClass("with-tabs"); if ($user_is_admin or $user_is_owner) { $panel->AddLink('add or remove teams', $this->match->EditTournamentTeamsUrl()); } $panel->AddLink('add or remove matches', $this->match->GetEditTournamentMatchesUrl()); if (count($this->match->GetMatchesInTournament())) { $panel->AddLink('update results', $this->match->GetNavigateUrl() . "/matches/results"); } } if ($user_is_admin or $user_is_owner) { if ($is_tournament) { $panel->AddLink('edit where to list this tournament', $this->match->EditTournamentCompetitionsUrl()); } $link_text = $is_tournament ? 'tournament' : 'match'; $panel->AddLink('delete this ' . $link_text, $this->match->GetDeleteNavigateUrl()); } if ($this->match->GetMatchType() != MatchType::TOURNAMENT_MATCH and $this->match->GetStartTime() > time()) { $link_text = $is_tournament ? 'tournament' : 'match'; $panel->AddLink("add {$link_text} to your calendar", $this->match->GetCalendarNavigateUrl()); } echo $panel; if ($this->has_player_stats) { $tournament = $is_tournament ? $this->match : $this->match->GetTournament(); require_once 'stoolball/statistics-highlight-table.class.php'; echo new StatisticsHighlightTable($this->best_batting, $this->most_runs, $this->best_bowling, $this->most_wickets, $this->most_catches, "tournament"); echo '<p class="playerSummaryMore"><a href="' . $tournament->GetNavigateUrl() . '/statistics">Tournament statistics</a></p>'; } }
protected function CreateControls() { $o_match = $this->GetDataObject(); /* @var $o_match Match */ $b_got_teams = !(is_null($o_match->GetHomeTeam()) || is_null($o_match->GetAwayTeam())); $b_future = ($o_match->GetId() and $o_match->GetStartTime() > gmdate('U')); // Move CSS class to div element $o_match_outer_1 = new XhtmlElement('div'); if ($this->GetCssClass()) { $o_match_outer_1->SetCssClass('matchResultEdit ' . $this->GetCssClass()); } else { $o_match_outer_1->SetCssClass('matchResultEdit'); } $this->SetCssClass(''); $o_match_outer_2 = new XhtmlElement('div'); $o_match_box = new XhtmlElement('div'); $this->AddControl($o_match_outer_1); $o_match_outer_1->AddControl($o_match_outer_2); $o_match_outer_2->AddControl($o_match_box); if ($this->GetShowHeading()) { $s_heading = str_replace('{0}', $o_match->GetTitle(), $this->GetHeading()); $s_heading = str_replace('{1}', Date::BritishDate($o_match->GetStartTime(), false), $s_heading); $o_title_inner_1 = new XhtmlElement('span', htmlentities($s_heading, ENT_QUOTES, "UTF-8", false)); $o_title_inner_2 = new XhtmlElement('span', $o_title_inner_1); $o_title_inner_3 = new XhtmlElement('span', $o_title_inner_2); $o_heading = new XhtmlElement($this->b_in_section ? 'h3' : 'h2', $o_title_inner_3); $o_match_box->AddControl($o_heading); } # Who's playing? $o_home_name = new TextBox($this->GetNamingPrefix() . 'Home'); $o_away_name = new TextBox($this->GetNamingPrefix() . 'Away'); $o_home_name->SetMode(TextBoxMode::Hidden()); $o_away_name->SetMode(TextBoxMode::Hidden()); if (!is_null($o_match->GetHomeTeam())) { $o_home_name->SetText($o_match->GetHomeTeam()->GetId() . ";" . $o_match->GetHomeTeam()->GetName()); } if (!is_null($o_match->GetAwayTeam())) { $o_away_name->SetText($o_match->GetAwayTeam()->GetId() . ";" . $o_match->GetAwayTeam()->GetName()); } $this->AddControl($o_home_name); $this->AddControl($o_away_name); # When? (for validator message only) $when = new TextBox($this->GetNamingPrefix() . 'Date', $o_match->GetStartTime()); $when->SetMode(TextBoxMode::Hidden()); $this->AddControl($when); # Who batted first? if (!$b_future) { $o_bat_first = new XhtmlSelect($this->GetNamingPrefix() . 'BatFirst'); $o_bat_first->AddControl(new XhtmlOption("Don't know", '')); if ($b_got_teams) { $o_bat_first->AddControl(new XhtmlOption($o_match->GetHomeTeam()->GetName(), 'home')); $o_bat_first->AddControl(new XhtmlOption($o_match->GetAwayTeam()->GetName(), 'away')); } else { $o_bat_first->AddControl(new XhtmlOption('Home team', 'home')); $o_bat_first->AddControl(new XhtmlOption('Away team', 'away')); } if (!is_null($o_match->Result()->GetHomeBattedFirst())) { if ($o_match->Result()->GetHomeBattedFirst()) { $o_bat_first->SelectOption('home'); } else { $o_bat_first->SelectOption('away'); } } $o_bat_part = new FormPart('Who batted first?', $o_bat_first); $o_match_box->AddControl($o_bat_part); } # Who won? $o_winner = new XhtmlSelect($this->GetNamingPrefix() . 'Result'); $o_winner->AddControl(new XhtmlOption($b_future ? 'The match will go ahead' : "Don't know", '')); $result_types = array(MatchResult::HOME_WIN, MatchResult::AWAY_WIN, MatchResult::HOME_WIN_BY_FORFEIT, MatchResult::AWAY_WIN_BY_FORFEIT, MatchResult::TIE, MatchResult::POSTPONED, MatchResult::CANCELLED, MatchResult::ABANDONED); if ($o_match->GetMatchType() == MatchType::TOURNAMENT_MATCH) { # You don't postpone a match in a tournament for another day unset($result_types[array_search(MatchResult::POSTPONED, $result_types, true)]); } foreach ($result_types as $result_type) { if (!$b_future or MatchResult::PossibleInAdvance($result_type)) { if ($b_got_teams) { $o_winner->AddControl(new XhtmlOption($this->NameTeams(MatchResult::Text($result_type), $o_match->GetHomeTeam(), $o_match->GetAwayTeam()), $result_type)); } else { $o_winner->AddControl(new XhtmlOption(MatchResult::Text($result_type), $result_type)); } } } $o_winner->SelectOption($o_match->Result()->GetResultType()); $o_win_part = new FormPart($b_future ? 'Will it happen?' : 'Who won?', $o_winner); $o_match_box->AddControl($o_win_part); # If the match has already happened if (!$b_future) { # What did each team score? $this->CreateTeamScoreControls($o_match_box, 'Home', $o_match, $o_match->GetHomeTeam(), $o_match->Result()->GetHomeRuns(), $o_match->Result()->GetHomeWickets()); $this->CreateTeamScoreControls($o_match_box, 'Away', $o_match, $o_match->GetAwayTeam(), $o_match->Result()->GetAwayRuns(), $o_match->Result()->GetAwayWickets()); # Any comments? $comments = new TextBox($this->GetNamingPrefix() . 'Comments', '', $this->IsValidSubmit()); $comments->SetMode(TextBoxMode::MultiLine()); $comments->AddAttribute('class', 'matchReport'); $comments_label = new XhtmlElement('label'); $comments_label->AddAttribute('for', $comments->GetXhtmlId()); $comments_label->AddCssClass('matchReport'); $comments_label->AddControl('Add a match report:'); $o_match_box->AddControl($comments_label); $o_match_box->AddControl($comments); } # Show audit data if ($o_match->GetLastAudit() != null) { require_once "data/audit-control.class.php"; $o_match_box->AddControl(new AuditControl($o_match->GetLastAudit(), "match")); } }
public function OnPageLoad() { # Matches this page shouldn't edit are page not found if ($this->page_not_found) { require_once $_SERVER['DOCUMENT_ROOT'] . "/wp-content/themes/stoolball/section-404.php"; return; } $edit_or_update = ($this->b_user_is_match_admin or $this->b_user_is_match_owner) ? "Edit" : "Update"; if ($this->match->GetStartTime() > gmdate('U') and !$this->b_user_is_match_admin and !$this->b_user_is_match_owner) { $step = ""; # definitely only this step because match in future and can't change date } else { $step = " – step 1 of 4"; } echo new XhtmlElement('h1', "{$edit_or_update} " . htmlentities($this->match->GetTitle(), ENT_QUOTES, "UTF-8", false) . $step); # If result only there's room for a little help if (!$this->b_user_is_match_admin and !$this->b_user_is_match_owner) { /* Create instruction panel */ $o_panel = new XhtmlElement('div'); $o_panel->SetCssClass('panel instructionPanel'); $o_title_inner1 = new XhtmlElement('div', 'Add your matches quickly:'); $o_title = new XhtmlElement('h2', $o_title_inner1); $o_panel->AddControl($o_title); $o_tab_tip = new XhtmlElement('ul'); $o_tab_tip->AddControl(new XhtmlElement('li', 'You can add runs, wickets and the winning team on the next few pages')); $o_tab_tip->AddControl(new XhtmlElement('li', 'Don\'t worry if you don\'t know – fill in what you can and leave the rest blank.')); $o_panel->AddControl($o_tab_tip); echo $o_panel; } # OK to edit the match $this->editor->SetDataObject($this->match); echo $this->editor; }
function OnPreRender() { /* @var $match Match */ /* @var $o_home Team */ /* @var $o_away Team */ $match = $this->match; $player_type = PlayerType::Text($match->GetPlayerType()); # Show time and place $date = new XhtmlElement('p', 'When: ' . $match->GetStartTimeFormatted()); $date->AddAttribute("property", "schema:startDate"); $date->AddAttribute("datatype", "xsd:date"); $date->AddAttribute("content", Date::Microformat($match->GetStartTime())); $this->AddControl($date); # If we know the time and place, show when the sun sets # TODO: assumes UK if ($match->GetGround() instanceof Ground and $match->GetGround()->GetAddress()->GetLatitude() and $match->GetGround()->GetAddress()->GetLongitude()) { $date->AddControl(' <span class="sunset">sunset ' . Date::Time(date_sunset($match->GetStartTime(), SUNFUNCS_RET_TIMESTAMP, $match->GetGround()->GetAddress()->GetLatitude(), $match->GetGround()->GetAddress()->GetLongitude())) . '</span>'); } $ground = $match->GetGround(); if (is_object($ground)) { $ground_link = new XhtmlElement('a', $ground->GetNameAndTown()); $ground_link->AddAttribute('href', $ground->GetNavigateUrl()); $ground_link->SetCssClass('location'); # hCalendar $ground_link->AddAttribute("typeof", "schema:Place"); $ground_link->AddAttribute("about", $ground->GetLinkedDataUri()); $ground_link->AddAttribute("rel", "schema:url"); $ground_link->AddAttribute("property", "schema:name"); $ground_control = new XhtmlElement('p', 'Where: '); $ground_control->AddAttribute("rel", "schema:location"); $ground_control->AddControl($ground_link); $this->AddControl($ground_control); } # Format if ($match->GetIsOversKnown()) { $this->AddControl(new XhtmlElement("p", "Matches are " . $match->GetOvers() . " overs.")); } # Add teams $a_teams = $match->GetAwayTeams(); if (!is_array($a_teams)) { $a_teams = array(); } if (!is_null($match->GetHomeTeam())) { array_unshift($a_teams, $match->GetHomeTeam()); } # shouldn't be home teams any more, but doesn't hurt! $how_many_teams = count($a_teams); $qualification = $match->GetQualificationType(); if ($qualification === MatchQualification::OPEN_TOURNAMENT) { $qualification = "Any " . strtolower($player_type) . " team may enter this tournament. "; } else { if ($qualification === MatchQualification::CLOSED_TOURNAMENT) { $qualification = "Only invited or qualifying teams may enter this tournament. "; } else { $qualification = ""; } } $show_spaces_left = ($match->GetMaximumTeamsInTournament() and gmdate('U') < $match->GetStartTime() and $match->GetQualificationType() !== MatchQualification::CLOSED_TOURNAMENT); if ($match->GetIsMaximumPlayersPerTeamKnown() or $show_spaces_left or $how_many_teams or $qualification) { $this->AddControl(new XhtmlElement('h2', 'Teams')); } $who_can_play = ""; if ($match->GetIsMaximumPlayersPerTeamKnown()) { $who_can_play = Html::Encode($match->GetMaximumPlayersPerTeam() . " players per team. "); } $who_can_play .= Html::Encode($qualification); if ($show_spaces_left) { $who_can_play .= '<strong class="spaces-left">' . $match->GetSpacesLeftInTournament() . " spaces left.</strong>"; } if ($who_can_play) { $this->AddControl("<p>" . trim($who_can_play) . "</p>"); } if ($how_many_teams) { $teams = new TeamListControl($a_teams); $this->AddControl('<div rel="schema:performers">' . $teams . '</div>'); } # Add matches $a_matches = $match->GetMatchesInTournament(); if (is_array($a_matches) && count($a_matches)) { $o_hmatches = new XhtmlElement('h2', 'Matches'); $matches = new MatchListControl($a_matches); $matches->AddAttribute("rel", "schema:subEvents"); $this->AddControl($o_hmatches); $this->AddControl($matches); } # Add notes if ($match->GetNotes() or $match->Seasons()->GetCount() > 0) { $this->AddControl(new XhtmlElement('h2', 'Notes')); } if ($match->GetNotes()) { $s_notes = XhtmlMarkup::ApplyCharacterEntities($match->GetNotes()); require_once 'email/email-address-protector.class.php'; $protector = new EmailAddressProtector($this->settings); $s_notes = $protector->ApplyEmailProtection($s_notes, AuthenticationManager::GetUser()->IsSignedIn()); $s_notes = XhtmlMarkup::ApplyHeadings($s_notes); $s_notes = XhtmlMarkup::ApplyParagraphs($s_notes); $s_notes = XhtmlMarkup::ApplyLists($s_notes); $s_notes = XhtmlMarkup::ApplySimpleTags($s_notes); $s_notes = XhtmlMarkup::ApplyLinks($s_notes); if (strpos($s_notes, '<p>') > -1) { $this->AddControl($s_notes); } else { $this->AddControl(new XhtmlElement('p', $s_notes)); } } # Show details of the seasons if ($match->Seasons()->GetCount() == 1) { $season = $match->Seasons()->GetFirst(); $season_name = new XhtmlAnchor($season->GetCompetitionName(), $season->GetNavigateUrl()); $b_the = !(stristr($season->GetCompetitionName(), 'the ') === 0); $this->AddControl(new XhtmlElement('p', 'This tournament is listed in ' . ($b_the ? 'the ' : '') . $season_name->__toString() . '.')); } elseif ($match->Seasons()->GetCount() > 1) { $this->AddControl(new XhtmlElement('p', 'This tournament is listed in the following seasons: ')); $season_list = new XhtmlElement('ul'); $this->AddControl($season_list); $seasons = $match->Seasons()->GetItems(); $total_seasons = count($seasons); for ($i = 0; $i < $total_seasons; $i++) { $season = $seasons[$i]; /* @var $season Season */ $season_name = new XhtmlAnchor($season->GetCompetitionName(), $season->GetNavigateUrl()); $li = new XhtmlElement('li', $season_name); if ($i < $total_seasons - 2) { $li->AddControl(new XhtmlElement('span', ', ', 'metadata')); } else { if ($i < $total_seasons - 1) { $li->AddControl(new XhtmlElement('span', ' and ', 'metadata')); } } $season_list->AddControl($li); } } }
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 OnPageLoad() { /* @var $season Season */ echo new XhtmlElement('h1', htmlentities($this->GetPageTitle(), ENT_QUOTES, "UTF-8", false)); # display the season if (!is_object($this->season)) { $this->season = new Season($this->GetSettings()); if (isset($_GET['competition'])) { $comp = new Competition($this->GetSettings()); $comp->SetId($_GET['competition']); $this->season->SetCompetition($comp); } /* Create instruction panel */ $panel = new XhtmlElement('div'); $panel->SetCssClass('panel instructionPanel'); $title_inner1 = new XhtmlElement('div', 'Tips for adding seasons'); $title = new XhtmlElement('h2', $title_inner1); $panel->AddControl($title); $tab_tip = new XhtmlElement('ul'); $tab_tip->AddControl(new XhtmlElement('li', "You'll be able to edit more details after you click 'Save'")); $panel->AddControl($tab_tip); echo $panel; } $this->edit->SetDataObject($this->season); echo $this->edit; parent::OnPageLoad(); }
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())); }
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); } }
function OnPageLoad() { echo '<div class="ground vcard" typeof="schema:Place" about="' . $this->ground->GetLinkedDataUri() . '">'; $o_fn = new XhtmlElement('h1', htmlentities($this->ground->GetNameAndTown(), ENT_QUOTES, "UTF-8", false)); $o_fn->SetCssClass('fn'); $o_fn->AddAttribute("property", "schema:name"); echo $o_fn; require_once 'xhtml/navigation/tabs.class.php'; $tabs = array('Summary' => '', 'Statistics' => $this->ground->GetStatsNavigateUrl()); echo new Tabs($tabs); ?> <div class="box tab-box"> <div class="dataFilter"></div> <div class="box-content"> <?php $address = new XhtmlElement("div"); $address->AddAttribute("rel", "schema:address"); $address->AddAttribute("resource", $this->ground->GetLinkedDataUri() . "#PostalAddress"); $postal = new PostalAddressControl($this->ground->GetAddress()); $postal->AddAttribute("about", $this->ground->GetLinkedDataUri() . "#PostalAddress"); $address->AddControl($postal); echo $address; # Show teams based at this ground if ($this->ground->Teams()->GetCount()) { require_once "stoolball/team-list-control.class.php"; echo "<h2>Teams based at this ground</h2>" . new TeamListControl($this->ground->Teams()->GetItems()); } if (!is_null($this->ground->GetAddress()->GetLatitude()) and !is_null($this->ground->GetAddress()->GetLongitude())) { $o_geo = new XhtmlElement('div'); $o_geo->SetXhtmlId('geoGround'); $o_geo->AddAttribute("rel", "schema:geo"); $o_geo->AddAttribute("resource", $this->ground->GetLinkedDataUri() . "#geo"); $o_latlong = new XhtmlElement('p'); $o_latlong->SetCssClass('geo'); # geo microformat $o_latlong->AddAttribute("about", $this->ground->GetLinkedDataUri() . "#geo"); $o_latlong->AddAttribute("typeof", "schema:GeoCoordinates"); $o_latlong->AddControl('Latitude '); $o_lat = new XhtmlElement('span', (string) $this->ground->GetAddress()->GetLatitude()); $o_lat->SetCssClass('latitude'); # geo microformat $o_lat->AddAttribute("property", "schema:latitude"); $o_latlong->AddControl($o_lat); $o_latlong->AddControl('; longitude '); $o_long = new XhtmlElement('span', (string) $this->ground->GetAddress()->GetLongitude()); $o_long->SetCssClass('longitude'); # geo microformat $o_long->AddAttribute("property", "schema:longitude"); $o_latlong->AddControl($o_long); $o_geo->AddControl($o_latlong); $s_place = ''; $s_class = ''; switch ($this->ground->GetAddress()->GetGeoPrecision()) { case GeoPrecision::Exact(): $s_place = $this->ground->GetNameAndTown(); $s_class = 'exact'; break; case GeoPrecision::Postcode(): $s_place = $this->ground->GetAddress()->GetPostcode(); $s_class = 'postcode'; break; case GeoPrecision::StreetDescriptor(): $s_place = $this->ground->GetAddress()->GetStreetDescriptor() . ', ' . $this->ground->GetAddress()->GetTown(); $s_class = 'street'; break; case GeoPrecision::Town(): $s_place = $this->ground->GetAddress()->GetTown(); $s_class = 'town'; break; } $o_map_link = new XhtmlAnchor('Map of <span class="' . $s_class . '">' . htmlentities($s_place, ENT_QUOTES, "UTF-8", false) . '</span> on Google Maps', 'http://maps.google.co.uk/?z=16&q=' . urlencode($this->ground->GetNameAndTown()) . '@' . $this->ground->GetAddress()->GetLatitude() . ',' . $this->ground->GetAddress()->GetLongitude() . '&ll=' . $this->ground->GetAddress()->GetLatitude() . ',' . $this->ground->GetAddress()->GetLongitude()); $o_map = new XhtmlElement('div', $o_map_link); $o_geo->AddControl($o_map); echo $o_geo; } if ($this->ground->GetDirections()) { echo new XhtmlElement('h2', 'Directions'); $s_directions = htmlentities($this->ground->GetDirections(), ENT_QUOTES, "UTF-8", false); $s_directions = XhtmlMarkup::ApplyCharacterEntities($s_directions); $s_directions = XhtmlMarkup::ApplyParagraphs($s_directions); $s_directions = XhtmlMarkup::ApplySimpleTags($s_directions); echo $s_directions; } if ($this->ground->GetParking()) { echo new XhtmlElement('h2', 'Parking'); $s_parking = htmlentities($this->ground->GetParking(), ENT_QUOTES, "UTF-8", false); $s_parking = XhtmlMarkup::ApplyCharacterEntities($s_parking); $s_parking = XhtmlMarkup::ApplyParagraphs($s_parking); $s_parking = XhtmlMarkup::ApplySimpleTags($s_parking); $s_parking = XhtmlMarkup::ApplyLinks($s_parking); echo $s_parking; } if ($this->ground->GetFacilities()) { echo new XhtmlElement('h2', 'Facilities'); $s_facilities = htmlentities($this->ground->GetFacilities(), ENT_QUOTES, "UTF-8", false); $s_facilities = XhtmlMarkup::ApplyCharacterEntities($s_facilities); $s_facilities = XhtmlMarkup::ApplyParagraphs($s_facilities); $s_facilities = XhtmlMarkup::ApplySimpleTags($s_facilities); $s_facilities = XhtmlMarkup::ApplyLinks($s_facilities); echo $s_facilities; } $o_meta = new XhtmlElement('p'); $o_meta->SetCssClass('metadata'); $o_meta->AddControl('Status: '); $o_uid = new XhtmlElement('span', $this->ground->GetLinkedDataUri()); $o_uid->SetCssClass('uid'); $o_meta->AddControl($o_uid); $o_meta->AddControl(' last updated at '); $o_rev = new XhtmlElement('abbr', Date::BritishDateAndTime($this->ground->GetDateUpdated())); $o_rev->SetTitle(Date::Microformat($this->ground->GetDateUpdated())); $o_rev->SetCssClass('rev'); $o_meta->AddControl($o_rev); $o_meta->AddControl(', sort as '); $o_url = new XhtmlAnchor(htmlentities($this->ground->GetAddress()->GenerateSortName(), ENT_QUOTES, "UTF-8", false), $this->ground->GetNavigateUrl()); $o_url->SetCssClass('url sort-string'); $o_meta->AddControl($o_url); echo $o_meta; echo "</div>"; ?> </div> </div> <?php $this->AddSeparator(); $o_user = new UserEditPanel($this->GetSettings(), 'this ground'); $o_user->AddCssClass("with-tabs"); if (AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_GROUNDS)) { $o_user->AddLink("edit this ground", $this->ground->GetEditGroundUrl()); $o_user->AddLink("delete this ground", $this->ground->GetDeleteGroundUrl()); } echo $o_user; # Show top players if ($this->has_player_stats) { require_once 'stoolball/statistics-highlight-table.class.php'; echo new StatisticsHighlightTable($this->best_batting, $this->most_runs, $this->best_bowling, $this->most_wickets, $this->most_catches, "All seasons"); } }
/** * Creates the default action buttons for the repeated group of controls * @return XhtmlElement */ private function CreateDefaultButtons() { $o_buttons = new XhtmlElement('div'); $o_buttons->SetCssClass('buttonGroup'); $o_button = new XhtmlElement('input'); $o_button->SetEmpty(true); $o_button->AddAttribute('type', 'submit'); $o_button->AddAttribute('value', $this->GetButtonText()); $o_buttons->AddControl($o_button); return $o_buttons; }
/** * Sets up controls for page 4 of the wizard * @param Match $match * @return void */ private function CreateHighlightsControls(Match $match) { $b_got_teams = !(is_null($match->GetHomeTeam()) || is_null($match->GetAwayTeam())); // Move CSS class to div element $match_outer_1 = new XhtmlElement('div'); $match_outer_1->SetCssClass('matchResultEdit panel'); $match_outer_2 = new XhtmlElement('div'); $match_box = new XhtmlElement('div'); $this->AddControl($match_outer_1); $match_outer_1->AddControl($match_outer_2); $match_outer_2->AddControl($match_box); $o_title_inner_1 = new XhtmlElement('span', "Match highlights"); $o_title_inner_2 = new XhtmlElement('span', $o_title_inner_1); $o_title_inner_3 = new XhtmlElement('span', $o_title_inner_2); $o_heading = new XhtmlElement('h2', $o_title_inner_3); $match_box->AddControl($o_heading); # Who's playing? $o_home_name = new TextBox($this->GetNamingPrefix() . 'Home'); $o_away_name = new TextBox($this->GetNamingPrefix() . 'Away'); $o_home_name->SetMode(TextBoxMode::Hidden()); $o_away_name->SetMode(TextBoxMode::Hidden()); if (!is_null($match->GetHomeTeam())) { $o_home_name->SetText($match->GetHomeTeam()->GetId() . MatchHighlightsEditControl::DATA_SEPARATOR . $match->GetHomeTeam()->GetName()); } if (!is_null($match->GetAwayTeam())) { $o_away_name->SetText($match->GetAwayTeam()->GetId() . MatchHighlightsEditControl::DATA_SEPARATOR . $match->GetAwayTeam()->GetName()); } $this->AddControl($o_home_name); $this->AddControl($o_away_name); # When? (for validator message only) $when = new TextBox($this->GetNamingPrefix() . 'Date', $match->GetStartTime()); $when->SetMode(TextBoxMode::Hidden()); $this->AddControl($when); # Who won? $o_winner = new XhtmlSelect($this->GetNamingPrefix() . 'Result'); $o_winner->AddControl(new XhtmlOption("Don't know", '')); $result_types = array(MatchResult::HOME_WIN, MatchResult::AWAY_WIN, MatchResult::TIE, MatchResult::ABANDONED); foreach ($result_types as $result_type) { if ($b_got_teams) { $o_winner->AddControl(new XhtmlOption($this->NameTeams(MatchResult::Text($result_type), $match->GetHomeTeam(), $match->GetAwayTeam()), $result_type)); } else { $o_winner->AddControl(new XhtmlOption(MatchResult::Text($result_type), $result_type)); } } if ($this->IsValidSubmit()) { if ($match->Result()->GetResultType() == MatchResult::UNKNOWN and !is_null($match->Result()->GetHomeRuns()) and !is_null($match->Result()->GetAwayRuns())) { # If match result is not known but we can guess from the entered scores, select it if ($match->Result()->GetHomeRuns() > $match->Result()->GetAwayRuns()) { $o_winner->SelectOption(MatchResult::HOME_WIN); } else { if ($match->Result()->GetHomeRuns() < $match->Result()->GetAwayRuns()) { $o_winner->SelectOption(MatchResult::AWAY_WIN); } else { if ($match->Result()->GetHomeRuns() == $match->Result()->GetAwayRuns()) { $o_winner->SelectOption(MatchResult::TIE); } } } } else { $o_winner->SelectOption($match->Result()->GetResultType()); } } $o_win_part = new FormPart('Who won?', $o_winner); $match_box->AddControl($o_win_part); # Get current player of match $player = $match->Result()->GetPlayerOfTheMatch(); $home_player = $match->Result()->GetPlayerOfTheMatchHome(); $away_player = $match->Result()->GetPlayerOfTheMatchAway(); $current_pom = MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_NONE; if ($player instanceof Player) { $current_pom = MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_OVERALL; } else { if ($home_player instanceof Player or $away_player instanceof Player) { $current_pom = MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_HOME_AND_AWAY; } } # Choose from different types of player of the match require_once 'xhtml/forms/radio-button.class.php'; $pom_container = new XhtmlElement('fieldset', new XhtmlElement('legend', 'Player of the match', 'formLabel')); $pom_container->SetCssClass('formPart'); $pom_options = new XhtmlElement('div', null, 'formControl radioButtonList'); $pom_options->SetXhtmlId($this->GetNamingPrefix() . "PlayerOptions"); $pom_container->AddControl($pom_options); $match_box->AddControl($pom_container); $pom_options->AddControl(new RadioButton($this->GetNamingPrefix() . 'POM' . MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_NONE, $this->GetNamingPrefix() . 'POM', "none chosen", MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_NONE, $current_pom == MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_NONE, $this->IsValidSubmit())); $pom_options->AddControl(new RadioButton($this->GetNamingPrefix() . 'POM' . MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_OVERALL, $this->GetNamingPrefix() . 'POM', "yes, one chosen", MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_OVERALL, $current_pom == MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_OVERALL, $this->IsValidSubmit())); $pom_options->AddControl(new RadioButton($this->GetNamingPrefix() . 'POM' . MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_HOME_AND_AWAY, $this->GetNamingPrefix() . 'POM', "yes, one from each team", MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_HOME_AND_AWAY, $current_pom == MatchHighlightsEditControl::PLAYER_OF_THE_MATCH_HOME_AND_AWAY, $this->IsValidSubmit())); # Controls for entering a single player of the match $player_name = new TextBox($this->GetNamingPrefix() . 'Player', $player instanceof Player ? $player->GetName() : '', $this->IsValidSubmit()); $player_name->SetMaxLength(100); $player_name->AddCssClass("player"); $player_name->AddCssClass("team" . $match->GetHomeTeamId()); $player_name->AddCssClass("team" . $match->GetAwayTeamId()); $player_name->AddAttribute("autocomplete", "off"); $player_box = new XhtmlElement("div", $player_name); $player_team = new XhtmlSelect($this->GetNamingPrefix() . "PlayerTeam", " playing for", $this->IsValidSubmit()); $player_team->SetCssClass("playerTeam"); # for JS $player_team->AddControl(new XhtmlOption("Don't know", "")); $player_team->AddControl(new XhtmlOption($match->GetHomeTeam()->GetName(), $match->GetHomeTeamId())); $player_team->AddControl(new XhtmlOption($match->GetAwayTeam()->GetName(), $match->GetAwayTeamId())); if ($player instanceof Player) { $player_team->SelectOption($player->Team()->GetId()); } $player_box->AddControl($player_team); $player_part = new FormPart("Player's name", $player_box); $player_part->SetXhtmlId($this->GetNamingPrefix() . "OnePlayer"); $player_part->GetLabel()->AddAttribute("for", $player_name->GetXhtmlId()); $match_box->AddControl($player_part); # Controls for entering home and away players of the match $home_box = new TextBox($this->GetNamingPrefix() . 'PlayerHome', $home_player instanceof Player ? $home_player->GetName() : '', $this->IsValidSubmit()); $home_box->SetMaxLength(100); $home_box->AddCssClass("player"); $home_box->AddCssClass("team" . $match->GetHomeTeamId()); $home_box->AddAttribute("autocomplete", "off"); $home_part = new FormPart($this->NameTeams('Home player', $match->GetHomeTeam(), $match->GetAwayTeam()), $home_box); $home_part->SetCssClass("formPart multiPlayer"); $match_box->AddControl($home_part); $away_box = new TextBox($this->GetNamingPrefix() . 'PlayerAway', $away_player instanceof Player ? $away_player->GetName() : '', $this->IsValidSubmit()); $away_box->SetMaxLength(100); $away_box->AddCssClass("player"); $away_box->AddCssClass("team" . $match->GetAwayTeamId()); $away_box->AddAttribute("autocomplete", "off"); $away_part = new FormPart($this->NameTeams('Away player', $match->GetHomeTeam(), $match->GetAwayTeam()), $away_box); $away_part->SetCssClass("formPart multiPlayer"); $match_box->AddControl($away_part); # Any comments? $comments = new TextBox($this->GetNamingPrefix() . 'Comments', '', $this->IsValidSubmit()); $comments->SetMode(TextBoxMode::MultiLine()); $comments->AddAttribute('class', 'matchReport'); $comments_label = new XhtmlElement('label'); $comments_label->AddAttribute('for', $comments->GetXhtmlId()); $comments_label->AddCssClass('matchReport'); $comments_label->AddControl('Add a match report:'); $match_box->AddControl($comments_label); $match_box->AddControl($comments); if ($match->GetLastAudit() != null) { require_once "data/audit-control.class.php"; $match_box->AddControl(new AuditControl($match->GetLastAudit(), "match")); } $this->SetButtonText('Save match'); }
function OnPageLoad() { echo '<h1>' . Html::Encode($this->GetPageTitle()) . '</h1>'; if (!is_object($this->tournament)) { /* Create instruction panel */ $o_panel = new XhtmlElement('div'); $o_panel->SetCssClass('panel instructionPanel large'); $o_title_inner1 = new XhtmlElement('div', 'Add your tournament quickly:'); $o_title = new XhtmlElement('h2', $o_title_inner1); $o_panel->AddControl($o_title); $o_tab_tip = new XhtmlElement('ul'); $o_tab_tip->AddControl(new XhtmlElement('li', 'Use the <span class="tab">tab</span> key on your keyboard to move through the form')); $o_tab_tip->AddControl(new XhtmlElement('li', 'Type the first letter or number to select from a dropdown list')); $o_tab_tip->AddControl(new XhtmlElement('li', 'If you\'re not sure of any details, leave them blank')); $o_panel->AddControl($o_tab_tip); echo $o_panel; } # Configure edit control $this->editor->SetCssClass('panel'); # remember the page the user came from, in case they click cancel require_once 'xhtml/forms/textbox.class.php'; $cancel_url = new TextBox('page', $this->destination_url_if_cancelled); $cancel_url->SetMode(TextBoxMode::Hidden()); $this->editor->AddControl($cancel_url); # display the match to edit echo $this->editor; }
/** * Creates the controls to edit the matches * */ private function CreateMatchControls(Match $tournament, XhtmlElement $box) { $css_class = 'TournamentEdit'; $box->SetCssClass($css_class); $this->SetCssClass(''); $box->SetXhtmlId($this->GetNamingPrefix()); $this->AddControl($box); # Preserve tournament title and date, because we need them for the page title when "add" is clicked $title = new TextBox($this->GetNamingPrefix() . 'Title', $tournament->GetTitle(), $this->IsValidSubmit()); $title->SetMode(TextBoxMode::Hidden()); $box->AddControl($title); $date = new TextBox($this->GetNamingPrefix() . 'Start', $tournament->GetStartTime(), $this->IsValidSubmit()); $date->SetMode(TextBoxMode::Hidden()); $box->AddControl($date); # Matches editor $this->EnsureAggregatedEditors(); $this->matches_editor->DataObjects()->SetItems($tournament->GetMatchesInTournament()); $this->matches_editor->SetTeams($tournament->GetAwayTeams()); $box->AddControl($this->matches_editor); }
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"); } }
public function OnPageLoad() { # Matches this page shouldn't edit are page not found if ($this->page_not_found) { require_once $_SERVER['DOCUMENT_ROOT'] . "/wp-content/themes/stoolball/section-404.php"; return; } $edit_or_update = ($this->b_user_is_match_admin or $this->b_user_is_match_owner) ? "Edit" : "Update"; $step = " – step " . $this->editor->GetCurrentPage() . " of 4"; echo new XhtmlElement('h1', "{$edit_or_update} " . htmlentities($this->match->GetTitle(), ENT_QUOTES, "UTF-8", false) . $step); if ($this->IsValid()) { /* Create instruction panel */ $panel = new XhtmlElement('div'); $panel->SetCssClass('panel instructionPanel'); $title_inner1 = new XhtmlElement('div', 'Fill in scorecards quickly:'); $title = new XhtmlElement('h2', $title_inner1, "large"); $panel->AddControl($title); $tab_tip = new XhtmlElement('ul'); $tab_tip->AddControl(new XhtmlElement('li', 'Use the <span class="tab">tab</span> and up and down keys to move through the form', "large")); $tab_tip->AddControl(new XhtmlElement('li', 'Use the <span class="tab">tab</span> key to select a player\'s name from the suggestions', "large")); $tab_tip->AddControl(new XhtmlElement('li', "List everyone on the batting card, even if they didn't bat, so we know who played.")); $tab_tip->AddControl(new XhtmlElement('li', 'Don\'t worry if you don\'t know – fill in what you can and leave the rest blank.')); $panel->AddControl($tab_tip); echo $panel; } # OK to edit the match $this->editor->SetDataObject($this->match); echo $this->editor; }
function OnPageLoad() { echo '<h1>' . htmlentities($this->GetPageTitle(), ENT_QUOTES, "UTF-8", false) . '</h1>'; /* Create instruction panel */ $o_panel = new XhtmlElement('div'); $o_panel->SetCssClass('panel instructionPanel'); $o_title_inner1 = new XhtmlElement('div', 'Add your results quickly:'); $o_title = new XhtmlElement('h2', $o_title_inner1, "large"); $o_panel->AddControl($o_title); $o_tab_tip = new XhtmlElement('ul'); $o_tab_tip->AddControl(new XhtmlElement('li', 'Use the <span class="tab">tab</span> key on your keyboard to move through the form', "large")); $o_tab_tip->AddControl(new XhtmlElement('li', 'Type the first letter or number to select from a dropdown list', "large")); $o_tab_tip->AddControl(new XhtmlElement('li', 'Don\'t worry if you don\'t know – fill in what you can and leave the rest blank.')); $o_panel->AddControl($o_tab_tip); echo $o_panel; # display the matches to edit, with some filtering and sorting for teams and seasons if (is_null($this->tournament_id)) { $i_user_now = gmdate('U'); $i_tonight = gmmktime(11, 59, 59, gmdate('m', $i_user_now), gmdate('d', $i_user_now), gmdate('Y', $i_user_now)); $i_week_ago = $i_user_now - 60 * 60 * 24 * 7; $i_matches = count($this->a_matches); $a_this_week = array(); for ($i = 0; $i < $i_matches; $i++) { /* @var $o_match Match */ $o_match = $this->a_matches[$i]; # If it's a practice, there's no result so don't show it # If it's a tournament, we're not handling those yet so don't show if ($o_match->GetMatchType() == MatchType::PRACTICE or $o_match->GetMatchType() == MatchType::TOURNAMENT) { unset($this->a_matches[$i]); continue; } # If it's a tournament match, only show if it's being specifically edited, not as part of season if ($o_match->GetMatchType() == MatchType::TOURNAMENT_MATCH and $o_match->GetId() != $this->i_match_id) { unset($this->a_matches[$i]); continue; } # If match was in the last week, promote it to top of list if ($o_match->GetStartTime() >= $i_week_ago and $o_match->GetStartTime() <= $i_tonight) { unset($this->a_matches[$i]); $a_this_week[] = $o_match; } } foreach ($a_this_week as $o_match) { $this->repeater->AddDataObject($o_match, 1); } } foreach ($this->a_matches as $o_match) { $this->repeater->AddDataObject($o_match, 2); } if (isset($a_this_week) and count($a_this_week) and count($this->a_matches)) { $this->repeater->SetSectionHeading(1, 'This week\'s matches'); $this->repeater->SetSectionHeading(2, 'Other matches'); } else { $this->repeater->SetShowSections(false); } echo $this->repeater; }