private function DisplayCompetitions(XhtmlElement $container) { /* @var $o_competition Competition */ /* @var $o_season Season */ $b_list_open = false; $i_current_category = null; $category_limit = isset($_GET["category"]) ? $_GET["category"] : null; $male_image = '<img src="/images/play/catcher.jpg" alt="" width="280" height="170" />'; $female_image = '<img src="/images/play/winterfold.jpg" alt="" width="238" height="195" />'; $category = ""; if (!$category_limit) { $container->AddControl($male_image . '<nav><ul class="nav">'); $b_list_open = true; } foreach ($this->competitions as $o_competition) { $comp_name = $o_competition->GetNameAndType(); if ($o_competition->GetCategory() != null) { if ($o_competition->GetCategory()->GetId() != $i_current_category) { if (!$category_limit) { $container->AddControl('<li><a href="/competitions/' . htmlentities($o_competition->GetCategory()->GetUrl(), ENT_QUOTES, "UTF-8", false) . '">' . htmlentities($o_competition->GetCategory()->GetName(), ENT_QUOTES, "UTF-8", false) . '</a></li>'); } else { if ($b_list_open) { $container->AddControl('</ul></nav>'); $b_list_open = false; } if ($o_competition->GetCategory()->GetUrl() == $category_limit) { $category = $o_competition->GetCategory()->GetName(); if (strpos(strtolower($category), "mixed") !== false) { $container->AddControl($male_image); } else { $container->AddControl($female_image); } } } $i_current_category = $o_competition->GetCategory()->GetId(); } $comp_name = trim(str_replace($o_competition->GetCategory()->GetName(), '', $comp_name)); # If not initial view, link to the competition if ($o_competition->GetCategory()->GetUrl() == $category_limit) { if (!$b_list_open) { $container->AddControl('<nav><ul class="nav">'); $b_list_open = true; } $o_link = new XhtmlElement('a', htmlentities($comp_name, ENT_QUOTES, "UTF-8", false)); $o_link->AddAttribute('href', $o_competition->GetLatestSeason()->GetNavigateUrl()); $o_li = new XhtmlElement('li'); $o_li->AddControl($o_link); if (!$o_competition->GetIsActive()) { $o_li->AddControl(' (not played any more)'); } $container->AddControl($o_li); } } } if ($b_list_open) { $container->AddControl('</ul></nav>'); } return $category; }
function OnPageLoad() { echo new XhtmlElement('h1', "Contact us"); $o_message = new XhtmlElement('p'); if ($this->b_send_attempted) { $o_message->AddControl($this->b_send_succeeded ? 'Thank you. Your email has been sent.' : 'Sorry, there was a problem sending your email. Please try again later.'); echo $o_message; } else { $o_message->AddControl('You can also contact us via <a href="http://Facebook.com/stoolball">Facebook</a> or <a href="http://twitter.com/stoolball">Twitter</a>.'); echo $o_message; } echo $this->o_form; }
function OnPreRender() { # list subscriptions to pages (which may not yet be topics) $this->SetCssClass('subscriptions'); if (is_array($this->a_subs) and count($this->a_subs)) { # build table $o_table = new XhtmlElement('table'); # build header row $o_row = new XhtmlElement('tr'); $o_row->AddControl(new XhtmlElement('th', 'What you subscribed to')); $o_row->AddControl(new XhtmlElement('th', 'Date subscribed')); $o_row->AddControl(new XhtmlElement('th', 'Unsubscribe')); $o_thead = new XhtmlElement('thead', $o_row); $o_table->AddControl($o_thead); # build table body $o_tbody = new XhtmlElement('tbody'); foreach ($this->a_subs as $o_sub) { $o_item = null; # build table row for each subscription if ($o_sub->GetType() == ContentType::STOOLBALL_MATCH) { $o_item = new Match($this->o_settings); $o_item->SetShortUrl($o_sub->GetSubscribedItemUrl()); } if (is_object($o_item)) { $o_row = new XhtmlElement('tr'); $o_link = new XhtmlElement('a', Html::Encode($o_sub->GetTitle())); $o_link->AddAttribute('href', $o_item->GetNavigateUrl()); $o_td_item = new XhtmlElement('td', $o_link); if ($o_sub->GetContentDate()) { $o_qualifier = new XhtmlElement('span', ' on ' . Html::Encode($o_sub->GetContentDate())); $o_qualifier->SetCssClass('subscriptionQualifier'); $o_td_item->AddControl($o_qualifier); } $o_row->AddControl($o_td_item); # admin cells $o_row->AddControl($this->GetSubscribeDateCell($o_sub)); $o_row->AddControl($this->GetActionCell($o_sub)); $o_tbody->AddControl($o_row); unset($o_item); } } $o_table->AddControl($o_tbody); $this->AddControl($o_table); } else { $o_p = new XhtmlElement('p', 'You have not subscribed to any email alerts.'); $o_p->SetCssClass('subscriptionNone'); $this->AddControl($o_p); } }
function OnPageLoad() { echo '<h1>Subscribed to ' . Html::Encode($this->o_review_item->GetTitle() ? $this->o_review_item->GetTitle() : ' page') . '</h1>'; # Confirm subscription to user $b_title = (bool) $this->o_review_item->GetTitle(); echo new XhtmlElement('p', 'You have subscribed to ' . Html::Encode($b_title ? "'" . $this->o_review_item->GetTitle() . "'" : 'the page you selected') . '. You will get an email alert every time someone adds a comment.'); echo new XhtmlElement('p', 'If you want to stop getting these email alerts, sign in to ' . Html::Encode($this->GetSettings()->GetSiteName()) . ' and delete your subscription from the email alerts page.'); # Links suggesting what to do next $o_whatnext = new XhtmlElement('ul'); if ($this->o_review_item->GetNavigateUrl()) { $o_whatnext->AddControl(new XhtmlElement('li', new XhtmlAnchor('Go back to ' . Html::Encode($b_title ? $this->o_review_item->GetTitle() : 'the page you came from'), $this->o_review_item->GetNavigateUrl()))); } $o_whatnext->AddControl(new XhtmlElement('li', new XhtmlAnchor("Email alerts", $this->GetSettings()->GetUrl('EmailAlerts')))); echo $o_whatnext; }
/** * Synchronise the internal column objects with the column count * */ private function GenerateColumns() { $i_controls = $this->CountControls(); $i_cols = $this->GetColumnCount(); if (!$i_controls) { # If none, generate them all for ($i = 0; $i < $i_cols; $i++) { parent::AddControl(new XhtmlColumn()); } } else { if ($i_controls < $i_cols) { # If some missing, make up the difference $i_missing = $i_cols - $i_controls; for ($i = 0; $i < $i_missing; $i++) { parent::AddControl(new XhtmlColumn()); } } else { if ($i_controls > $i_cols) { # If too many, remove from end $i_extra = $i_controls - $i_cols; $a_controls = $this->GetControls(); while ($i_extra > 0) { $i_key = count($a_controls) - 1; if (array_key_exists($i_key, $a_controls)) { unset($a_controls[$i_key]); } $i_extra--; } $this->SetControls($a_controls); } } } }
function OnPreRender() { /* @var $o_validator DataValidator */ $a_validators = array(); $a_controls_to_validate =& $this->a_controls_to_validate; foreach ($a_controls_to_validate as $o_control) { $a_validators = array_merge($a_validators, $o_control->GetValidators()); } if (count($a_validators)) { $o_list = new XhtmlElement('ul'); foreach ($a_validators as $o_validator) { if (!$o_validator->IsValid()) { $o_item = new XhtmlElement('li', $o_validator->GetMessage()); $o_list->AddControl($o_item); } } if ($o_list->CountControls()) { if ($this->s_header_text) { $this->AddControl(new XhtmlElement('span', $this->s_header_text)); } $this->AddControl($o_list); $this->SetVisible(true); } else { $this->SetVisible(false); } } }
function OnPreRender() { /* @var $o_ground Ground */ foreach ($this->a_grounds as $o_ground) { if ($o_ground instanceof Ground) { $o_link = new XhtmlElement('a', Html::Encode($o_ground->GetNameAndTown())); $o_link->AddAttribute('href', $o_ground->GetNavigateUrl()); $o_li = new XhtmlElement('li'); $o_li->AddControl($o_link); $precision = array(GeoPrecision::Unknown() => 'No map', GeoPrecision::Exact() => 'Exact', GeoPrecision::Postcode() => 'Postcode', GeoPrecision::StreetDescriptor() => 'Street', GeoPrecision::Town() => 'Town'); if (!is_null($o_ground->GetAddress()->GetGeoPrecision())) { $o_li->AddControl(' (Map: ' . Html::Encode($precision[$o_ground->GetAddress()->GetGeoPrecision()]) . ')'); } $this->AddControl($o_li); } } }
function OnPostback() { # new list for validation $this->o_error_list = new XhtmlElement('ul'); $this->o_error_list->AddAttribute('class', 'validationSummary'); # check we've got email if (isset($_POST['email']) and !trim($_POST['email']) or !isset($_POST['email'])) { $this->o_error_list->AddControl(new XhtmlElement('li', 'Please enter your email address')); } # check for request to resend activation email if (isset($_POST['resend']) and !$this->o_error_list->CountControls()) { # Get the person's name and id. Only checking email at this point creates the possibility that someone could # fake this request for another user, but the worst they can do is send a new activation request to that other # user; they can't gain any information themselves or disable anyone's account. Don't try to check password because # browser security means we can't be sure it'll be repopulated and reposted. $authentication = $this->GetAuthenticationManager(); $authentication->ReadByEmail($_POST['email']); $account = $authentication->GetFirst(); if (is_object($account)) { # send a new email $s_hash = $authentication->SaveRequest($account->GetId()); $email_success = $authentication->SendActivationEmail($account, $s_hash); # redirect to activation message $s_email_status = $email_success ? '' : '&email=no'; $this->Redirect($this->GetSettings()->GetUrl('AccountActivate') . '?action=request&name=' . urlencode($account->GetName()) . '&address=' . urlencode($account->GetEmail()) . $s_email_status); } } # check we've got password if (isset($_POST['password']) and !trim($_POST['password']) or !isset($_POST['password'])) { $this->o_error_list->AddControl(new XhtmlElement('li', 'Please enter your password')); } # no message so form OK if (!$this->o_error_list->CountControls()) { # try to sign in $sign_in_result = $this->GetAuthenticationManager()->SignIn($_POST['email'], $_POST['password'], isset($_POST['remember_me'])); switch ($sign_in_result) { case SignInResult::Success(): if (isset($_POST['page'])) { header('Location: ' . str_replace('&', '&', str_replace('&', '&', $_POST['page']))); } else { header('location: ' . $this->GetSettings()->GetClientRoot()); } exit; case SignInResult::AccountDisabled(): $this->o_error_list->AddControl(new XhtmlElement('li', 'Sorry, your account has been disabled due to misuse.')); break; case SignInResult::NotActivated(): $not_activated = new XhtmlElement('li', 'You need to activate your account. Check your email inbox.'); $not_activated->AddControl('<input type="submit" name="resend" value="Send a new email" class="inlineButton" />'); $this->o_error_list->AddControl($not_activated); break; case SignInResult::NotFound(): $this->o_error_list->AddControl(new XhtmlElement('li', 'You tried to sign in with an incorrect email address and/or password. Please sign in again.')); break; } } }
/** * Adds a cell to the end of the row * * @param XhtmlCell $m_cell_or_data */ function AddCell($m_cell_or_data) { if ($m_cell_or_data instanceof XhtmlCell) { parent::AddControl($m_cell_or_data); } else { $o_cell = new XhtmlCell(false, $m_cell_or_data); $o_cell->SetElementName($this->b_is_header ? 'th' : 'td'); parent::AddControl($o_cell); } $this->i_columns = -1; }
public function OnPreRender() { # Create panel $o_sidebar = new XhtmlElement('div'); $o_outer_panel = new XhtmlElement('div', $o_sidebar); $this->AddControl($o_outer_panel); $this->AddCssClass('panel supportingPanel screen'); # Add heading $o_sidebar->AddControl(new XhtmlElement('h2', '<span><span><span>You can<span class="aural"> take these actions</span>:</span></span></span>')); # Create list for links $o_ul = new XhtmlElement('ul'); $o_sidebar->AddControl($o_ul); # Add custom links foreach ($this->a_links as $item) { $o_ul->AddControl($item); } # Link to contact us $text = '<a href="' . $this->o_settings->GetFolder('Contact') . '">contact Stoolball England</a>'; $o_contact = new XhtmlElement('li', $text, "large"); $o_ul->AddControl($o_contact); }
function OnPreRender() { foreach ($this->a_clubs as $o_club) { if ($o_club instanceof Club) { $o_link = new XhtmlElement('a', Html::Encode($o_club->GetName())); $o_link->AddAttribute('href', $o_club->GetNavigateUrl()); $o_li = new XhtmlElement('li'); $o_li->AddControl($o_link); $this->AddControl($o_li); } } }
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>.'); } } }
/** * @return bool * @param XhtmlElement/string $m_label * @desc Add a text label to associate with the form control */ function SetLabel(&$m_label) { /* @var $m_label XhtmlElement */ if ($m_label instanceof XhtmlElement) { $m_label->SetCssClass('formLabel'); if (count($this->a_controls) > 0 and $this->a_controls[1] instanceof XhtmlElement) { $m_label->AddAttribute('for', $this->a_controls[1]->GetId()); } $this->a_controls[0] =& $m_label; return true; } else { if (is_string($m_label)) { $o_new_label = new XhtmlElement('label'); $o_new_label->AddControl($m_label); return $this->SetLabel($o_new_label); } else { return false; } } }
function CreateControls() { $this->AddCssClass('legacy-form'); /* @var $team Team */ /* @var $comp Competition */ $season = $this->GetDataObject(); /* @var $season Season */ require_once 'xhtml/forms/form-part.class.php'; require_once 'xhtml/forms/textbox.class.php'; require_once 'xhtml/forms/radio-button.class.php'; require_once 'xhtml/forms/checkbox.class.php'; # Show fewer options for a new season than when editing, beacause a new season gets settings copied from last year to save time $b_is_new_season = !(bool) $season->GetId(); # Add competition $comp = $season->GetCompetition(); $competition = new TextBox($this->GetNamingPrefix() . 'competition', $comp->GetId()); $competition->SetMode(TextBoxMode::Hidden()); $this->AddControl($competition); # Make current short URL available, because then it can match the suggested one and be left alone $short_url = new TextBox($this->GetNamingPrefix() . 'ShortUrl', $season->GetShortUrl()); $short_url->SetMode(TextBoxMode::Hidden()); $this->AddControl($short_url); # add years $start_box = new TextBox('start', is_null($season->GetStartYear()) ? Date::Year(gmdate('U')) : $season->GetStartYear(), $this->IsValidSubmit()); $start_box->AddAttribute('maxlength', 4); $start = new FormPart('Year season starts', $start_box); $this->AddControl($start); $summer = new RadioButton('summer', 'when', 'Summer season', 0); $winter = new RadioButton('winter', 'when', 'Winter season', 1); if ($season->GetEndYear() > $season->GetStartYear()) { $winter->SetChecked(true); } else { $summer->SetChecked(true); } $when = new XhtmlElement('div', $summer); $when->AddControl($winter); $when->SetCssClass('formControl'); $when_legend = new XhtmlElement('legend', 'Time of year'); $when_legend->SetCssClass('formLabel'); $when_fs = new XhtmlElement('fieldset', $when_legend); $when_fs->SetCssClass('formPart'); $when_fs->AddControl($when); $this->AddControl($when_fs); # add intro $intro_box = new TextBox('intro', $season->GetIntro(), $this->IsValidSubmit()); $intro_box->SetMode(TextBoxMode::MultiLine()); $intro = new FormPart('Introduction', $intro_box); $this->AddControl($intro); if (!$b_is_new_season) { # add types of matches if (!$this->IsPostback() or $this->b_saving_new and $this->IsValidSubmit()) { foreach ($season->MatchTypes()->GetItems() as $i_type) { $this->match_types_editor->DataObjects()->Add(new IdValue($i_type, ucfirst(MatchType::Text($i_type)))); } } $this->AddControl(new FormPart('Match types', $this->match_types_editor)); # add results $result_container = new XhtmlElement('div'); $result_box = new TextBox('results', $season->GetResults(), $this->IsValidSubmit()); $result_box->SetMode(TextBoxMode::MultiLine()); $result_container->AddControl($result_box); $result = new FormPart('Results', $result_container); $result->GetLabel()->AddAttribute('for', $result_box->GetXhtmlId()); $this->AddControl($result); # Add rules table $rules = new XhtmlTable(); $rules->SetCaption('Points for each result'); $header = new XhtmlRow(array('Result', 'Points for home team', 'Points for away team')); $header->SetIsHeader(true); $rules->AddRow($header); foreach ($this->result_types as $result) { /* @var $result MatchResult */ # Shouldn't ever need to assign points to a postponed match if ($result->GetResultType() == MatchResult::POSTPONED) { continue; } # Populate result with points from season rule $season->PossibleResults()->ResetCounter(); while ($season->PossibleResults()->MoveNext()) { if ($season->PossibleResults()->GetItem()->GetResultType() == $result->GetResultType()) { $result->SetHomePoints($season->PossibleResults()->GetItem()->GetHomePoints()); $result->SetAwayPoints($season->PossibleResults()->GetItem()->GetAwayPoints()); break; } } # Create table row $home_box = new TextBox($this->GetNamingPrefix() . 'Result' . $result->GetResultType() . 'Home', $result->GetHomePoints(), $this->IsValidSubmit()); $away_box = new TextBox($this->GetNamingPrefix() . 'Result' . $result->GetResultType() . 'Away', $result->GetAwayPoints(), $this->IsValidSubmit()); $home_box->AddAttribute('class', 'pointsBox'); $away_box->AddAttribute('class', 'pointsBox'); $result_row = new XhtmlRow(array(MatchResult::Text($result->GetResultType()), $home_box, $away_box)); $rules->AddRow($result_row); } $result_container->AddControl($rules); # Add points adjustments $this->adjustments_editor->SetTeams($season->GetTeams()); if (!$this->IsPostback() or $this->b_saving_new and $this->IsValidSubmit()) { $this->adjustments_editor->DataObjects()->SetItems($season->PointsAdjustments()->GetItems()); } $result_container->AddControl($this->adjustments_editor); # Show league table? $table = new CheckBox('showTable', 'Show results table', 1, $season->GetShowTable()); $this->AddControl($table); $this->AddControl(new CheckBox('runsScored', 'Include runs scored', 1, $season->GetShowTableRunsScored())); $this->AddControl(new CheckBox('runsConceded', 'Include runs conceded', 1, $season->GetShowTableRunsConceded())); # add teams if (!$this->IsPostback() or $this->b_saving_new and $this->IsValidSubmit()) { $teams_in_season = array(); foreach ($season->GetTeams() as $team) { $teams_in_season[] = new TeamInSeason($team, $season, is_object($season->TeamsWithdrawnFromLeague()->GetItemByProperty('GetId', $team->GetId()))); } $this->teams_editor->DataObjects()->SetItems($teams_in_season); } $this->AddControl(new FormPart('Teams', $this->teams_editor)); } }
function OnPreRender() { /* @var $o_season Season */ /* @var $o_excluded Season */ $current_competition = null; $single_list_open = false; foreach ($this->a_seasons as $o_season) { if ($o_season instanceof Season) { $b_excluded = false; foreach ($this->a_excluded as $o_excluded) { if ($o_excluded->GetId() == $o_season->GetId()) { $b_excluded = true; break; } } if (!$b_excluded) { if (method_exists($o_season, $this->url_method)) { $url_method = $this->url_method; $url = $o_season->{$url_method}(); } else { $url = $o_season->GetNavigateUrl(); } if (!$this->show_competition and !$single_list_open) { $this->AddControl('<ul>'); $single_list_open = true; } else { if ($this->show_competition and $current_competition != $o_season->GetCompetition()->GetId()) { if ($current_competition != null) { $this->AddControl("</ul>"); } $this->AddControl("<h2>" . htmlentities($o_season->GetCompetition()->GetName(), ENT_QUOTES, "UTF-8", false) . '</h2><ul>'); $current_competition = $o_season->GetCompetition()->GetId(); } } $o_link = new XhtmlElement('a', htmlentities($o_season->GetName(), ENT_QUOTES, "UTF-8", false) . " season"); $o_link->AddAttribute('href', $url); $o_li = new XhtmlElement('li'); $o_li->AddControl($o_link); $this->AddControl($o_li); } } } if ($current_competition != null or $single_list_open) { $this->AddControl("</ul>"); } }
/** * Build the form */ protected function OnPreRender() { $this->AddControl('<div id="statisticsFilter" class="panel"><div><div><h2><span><span><span>Filter these statistics</span></span></span></h2>'); # Track whether to show or hide this filter $filter = '<input type="hidden" id="filter" name="filter" value="'; $filter .= (isset($_GET["filter"]) and $_GET["filter"] == "1") ? 1 : 0; $filter .= '" />'; $this->AddControl($filter); $type_filters = array(); # Support player type filter if (is_array($this->player_type_filter)) { require_once "stoolball/player-type.enum.php"; $player_type_list = new XhtmlSelect("player-type"); $blank = new XhtmlOption("any players", ""); $player_type_list->AddControl($blank); foreach ($this->player_type_filter[0] as $player_type) { $player_type_list->AddControl(new XhtmlOption(strtolower(PlayerType::Text($player_type)), $player_type, $player_type === $this->player_type_filter[1])); } $label = new XhtmlElement("label", "Type of players", "aural"); $label->AddAttribute("for", $player_type_list->GetXhtmlId()); $type_filters[] = $label; $type_filters[] = $player_type_list; } # Support match type filter if (is_array($this->match_type_filter)) { require_once "stoolball/match-type.enum.php"; $match_type_list = new XhtmlSelect("match-type"); $blank = new XhtmlOption("any match", ""); $match_type_list->AddControl($blank); foreach ($this->match_type_filter[0] as $match_type) { $match_type_list->AddControl(new XhtmlOption(str_replace(" match", "", MatchType::Text($match_type)), $match_type, $match_type === $this->match_type_filter[1])); } $label = new XhtmlElement("label", "Type of competition", "aural"); $label->AddAttribute("for", $match_type_list->GetXhtmlId()); $type_filters[] = $label; $type_filters[] = $match_type_list; } if (count($type_filters)) { $type = new XhtmlElement("fieldset", new XhtmlElement("legend", "Match type", "formLabel"), "formPart"); $controls = new XhtmlElement("div", null, "formControl"); foreach ($type_filters as $control) { $controls->AddControl($control); } $type->AddControl($controls); $this->AddControl($type); } # Support team filter if (is_array($this->team_filter)) { $team_list = new XhtmlSelect("team"); $blank = new XhtmlOption("any team", ""); $team_list->AddControl($blank); foreach ($this->team_filter[0] as $team) { $team_list->AddControl(new XhtmlOption($team->GetName(), $team->GetId(), $team->GetId() == $this->team_filter[1])); } $this->AddControl(new FormPart("Team", $team_list)); } # Support opposition team filter if (is_array($this->opposition_filter)) { $opposition_list = new XhtmlSelect("opposition"); $blank = new XhtmlOption("any team", ""); $opposition_list->AddControl($blank); foreach ($this->opposition_filter[0] as $team) { $opposition_list->AddControl(new XhtmlOption($team->GetName(), $team->GetId(), $team->GetId() == $this->opposition_filter[1])); } $this->AddControl(new FormPart("Against", $opposition_list)); } # Support ground filter if (is_array($this->ground_filter)) { $ground_list = new XhtmlSelect("ground"); $blank = new XhtmlOption("any ground", ""); $ground_list->AddControl($blank); foreach ($this->ground_filter[0] as $ground) { $ground_list->AddControl(new XhtmlOption($ground->GetNameAndTown(), $ground->GetId(), $ground->GetId() == $this->ground_filter[1])); } $this->AddControl(new FormPart("Ground", $ground_list)); } # Support competition filter if (is_array($this->competition_filter)) { $competition_list = new XhtmlSelect("competition"); $blank = new XhtmlOption("any competition", ""); $competition_list->AddControl($blank); foreach ($this->competition_filter[0] as $competition) { $competition_list->AddControl(new XhtmlOption($competition->GetName(), $competition->GetId(), $competition->GetId() == $this->competition_filter[1])); } $this->AddControl(new FormPart("Competition", $competition_list)); } # Support date filter # Use text fields rather than HTML 5 date fields because then we can accept dates like "last Tuesday" # which PHP will understand. Jquery calendar is at least as good as native date pickers anyway. $date_fields = '<div class="formPart"> <label for="from" class="formLabel">From date</label> <div class="formControl twoFields"> <input type="text" class="date firstField" id="from" name="from" placeholder="any date" autocomplete="off"'; if (!$this->IsValid()) { $date_fields .= ' value="' . (isset($_GET["from"]) ? $_GET["from"] : "") . '"'; } else { if ($this->after_date_filter) { $date_fields .= ' value="' . Date::BritishDate($this->after_date_filter, false, true, false) . '"'; } } $date_fields .= ' /> <label for="to">Up to date <input type="text" class="date" id="to" name="to" placeholder="any date" autocomplete="off"'; if (!$this->IsValid()) { $date_fields .= ' value="' . (isset($_GET["to"]) ? $_GET["to"] : "") . '"'; } else { if ($this->before_date_filter) { $date_fields .= ' value="' . Date::BritishDate($this->before_date_filter, false, true, false) . '"'; } } $date_fields .= ' /></label> </div> </div>'; $this->AddControl($date_fields); # Support innings filter $innings_list = new XhtmlSelect("innings"); $innings_list->AddControl(new XhtmlOption("either innings", "")); $innings_list->AddControl(new XhtmlOption("first innings", 1, 1 == $this->innings_filter)); $innings_list->AddControl(new XhtmlOption("second innings", 2, 2 == $this->innings_filter)); $this->AddControl('<div class="formPart"> <label for="innings" class="formLabel">Innings</label> <div class="formControl">' . $innings_list . '</div>' . '</div>'); # Support batting position filter if (is_array($this->batting_position_filter)) { $batting_position_list = new XhtmlSelect("batpos"); $blank = new XhtmlOption("any position", ""); $batting_position_list->AddControl($blank); foreach ($this->batting_position_filter[0] as $batting_position) { $batting_position_list->AddControl(new XhtmlOption($batting_position == 1 ? "opening" : $batting_position, $batting_position, $batting_position == $this->batting_position_filter[1])); } $this->AddControl('<div class="formPart"> <label for="batpos" class="formLabel">Batting at</label> <div class="formControl">' . $batting_position_list . '</div>' . '</div>'); } # Support match result filter $result_list = new XhtmlSelect("result"); $result_list->AddControl(new XhtmlOption("any result", "")); $result_list->AddControl(new XhtmlOption("win", 1, 1 === $this->match_result_filter)); $result_list->AddControl(new XhtmlOption("tie", 0, 0 === $this->match_result_filter)); $result_list->AddControl(new XhtmlOption("lose", -1, -1 === $this->match_result_filter)); $this->AddControl('<div class="formPart"> <label for="result" class="formLabel">Match result</label> <div class="formControl">' . $result_list . '</div>' . '</div>'); # Preserve the player filter if applied if (isset($_GET["player"]) and is_numeric($_GET["player"])) { $this->AddControl('<input type="hidden" name="player" id="player" value="' . $_GET["player"] . '" />'); } $this->AddControl('<p class="actions"><input type="submit" value="Apply filter" /></p>'); $this->AddControl('</div></div></div>'); }
/** * 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 '<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"); } }
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); } } }
/** * 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 »'); } }
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 CreateControls() { $this->AddCssClass('form'); /* @var $club Club */ /* @var $competition Competition */ /* @var $season Season */ /* @var $ground Ground */ require_once 'xhtml/forms/textbox.class.php'; require_once 'xhtml/forms/checkbox.class.php'; require_once 'stoolball/season-select.class.php'; $team = $this->GetDataObject(); $this->SetButtonText('Save team'); /* @var $team Team */ $is_once_only = $team->GetTeamType() == Team::ONCE; if ($this->is_admin) { # add club $club_list = new XhtmlSelect('club', null, $this->IsValidSubmit()); $club_list->SetBlankFirst(true); foreach ($this->a_clubs as $club) { if ($club instanceof Club) { $opt = new XhtmlOption($club->GetName(), $club->GetId()); $club_list->AddControl($opt); unset($opt); } } if (!is_null($team->GetClub()) and $this->IsValidSubmit()) { $club_list->SelectOption($team->GetClub()->GetId()); } $club_label = new XhtmlElement('label', 'Club'); $club_label->AddAttribute('for', $club_list->GetXhtmlId()); $this->AddControl($club_label); $this->AddControl($club_list); } if ($this->is_admin or $is_once_only) { # add name $name_box = new TextBox('name', $team->GetName(), $this->IsValidSubmit()); $name_box->AddAttribute('maxlength', 100); $name = new XhtmlElement('label', 'Team name'); $name->AddAttribute('for', $name_box->GetXhtmlId()); $this->AddControl($name); $this->AddControl($name_box); } if ($this->is_admin) { # add player type $type_list = new XhtmlSelect('playerType', null, $this->IsValidSubmit()); $type_list->AddControl(new XhtmlOption(PlayerType::Text(PlayerType::MIXED), PlayerType::MIXED)); $type_list->AddControl(new XhtmlOption(PlayerType::Text(PlayerType::LADIES), PlayerType::LADIES)); $type_list->AddControl(new XhtmlOption(PlayerType::Text(PlayerType::JUNIOR_MIXED), PlayerType::JUNIOR_MIXED)); $type_list->AddControl(new XhtmlOption(PlayerType::Text(PlayerType::GIRLS), PlayerType::GIRLS)); $type_list->AddControl(new XhtmlOption(PlayerType::Text(PlayerType::MEN), PlayerType::MEN)); $type_list->AddControl(new XhtmlOption(PlayerType::Text(PlayerType::BOYS), PlayerType::BOYS)); if (!is_null($team->GetPlayerType()) and $this->IsValidSubmit()) { $type_list->SelectOption($team->GetPlayerType()); } $type_part = new XhtmlElement('label', 'Player type'); $type_part->AddAttribute('for', $type_list->GetXhtmlId()); $this->AddControl($type_part); $this->AddControl($type_list); # Remember short URL $short_url = new TextBox($this->GetNamingPrefix() . 'ShortUrl', $team->GetShortUrl(), $this->IsValidSubmit()); $short_url_label = new XhtmlElement('label', 'Short URL'); $short_url_label->AddAttribute('for', $short_url->GetXhtmlId()); $this->AddControl($short_url_label); $this->AddControl($short_url); } # add intro $intro_box = new TextBox('intro', $team->GetIntro(), $this->IsValidSubmit()); $intro_box->SetMode(TextBoxMode::MultiLine()); $intro = new XhtmlElement('label', 'Introduction'); $intro->AddAttribute('for', $intro_box->GetXhtmlId()); $this->AddControl($intro); $this->AddControl('<p class="label-hint">If you need to change your team name, please email us.</p>'); $this->AddControl($intro_box); if (!$is_once_only) { # Can we join in? $team_type = new XhtmlSelect('team_type', null, $this->IsValidSubmit()); $team_type->AddControl(new XhtmlOption("plays regularly", Team::REGULAR, $team->GetTeamType() == Team::REGULAR)); $team_type->AddControl(new XhtmlOption("represents a league or group", Team::REPRESENTATIVE, $team->GetTeamType() == Team::REPRESENTATIVE)); $team_type->AddControl(new XhtmlOption("closed group (example: only staff can join a work team)", Team::CLOSED_GROUP, $team->GetTeamType() == Team::CLOSED_GROUP)); $team_type->AddControl(new XhtmlOption("plays occasionally", Team::OCCASIONAL, $team->GetTeamType() == Team::OCCASIONAL)); $team_type->AddControl(new XhtmlOption("school year group(s)", Team::SCHOOL_YEARS, $team->GetTeamType() == Team::SCHOOL_YEARS)); $team_type->AddControl(new XhtmlOption("school club (eg after school)", Team::SCHOOL_CLUB, $team->GetTeamType() == Team::SCHOOL_CLUB)); $team_type->AddControl(new XhtmlOption("other school team", Team::SCHOOL_OTHER, $team->GetTeamType() == Team::SCHOOL_OTHER)); $type_label = new XhtmlElement('label', "Type of team"); $type_label->AddAttribute('for', $team_type->GetXhtmlId()); $this->AddControl($type_label); $this->AddControl('<p class="label-hint">We use this to decide when to list your team.</p>'); $this->AddControl($team_type); $school_years_data = $this->GetDataObject()->GetSchoolYears(); $school_years = new XhtmlElement("fieldset", null, "school-years"); $school_years->AddControl(new XhtmlElement("legend", "Select the school year(s) this team represents")); $school_years->AddControl(new XhtmlElement("p", "For example, if Years 7 and 8 play together, select both. If Year 9 also plays, but separately, create a separate Year 9 team.")); $school_years->AddControl(new CheckBox('year1', 'Year 1', 1, array_key_exists(1, $school_years_data) and $school_years_data[1], $this->IsValidSubmit())); $school_years->AddControl(new CheckBox('year2', 'Year 2', 1, array_key_exists(2, $school_years_data) and $school_years_data[2], $this->IsValidSubmit())); $school_years->AddControl(new CheckBox('year3', 'Year 3', 1, array_key_exists(3, $school_years_data) and $school_years_data[3], $this->IsValidSubmit())); $school_years->AddControl(new CheckBox('year4', 'Year 4', 1, array_key_exists(4, $school_years_data) and $school_years_data[4], $this->IsValidSubmit())); $school_years->AddControl(new CheckBox('year5', 'Year 5', 1, array_key_exists(5, $school_years_data) and $school_years_data[5], $this->IsValidSubmit())); $school_years->AddControl(new CheckBox('year6', 'Year 6', 1, array_key_exists(6, $school_years_data) and $school_years_data[6], $this->IsValidSubmit())); $school_years->AddControl(new CheckBox('year7', 'Year 7', 1, array_key_exists(7, $school_years_data) and $school_years_data[7], $this->IsValidSubmit())); $school_years->AddControl(new CheckBox('year8', 'Year 8', 1, array_key_exists(8, $school_years_data) and $school_years_data[8], $this->IsValidSubmit())); $school_years->AddControl(new CheckBox('year9', 'Year 9', 1, array_key_exists(9, $school_years_data) and $school_years_data[9], $this->IsValidSubmit())); $school_years->AddControl(new CheckBox('year10', 'Year 10', 1, array_key_exists(10, $school_years_data) and $school_years_data[10], $this->IsValidSubmit())); $school_years->AddControl(new CheckBox('year11', 'Year 11', 1, array_key_exists(11, $school_years_data) and $school_years_data[11], $this->IsValidSubmit())); $school_years->AddControl(new CheckBox('year11', 'Year 12', 1, array_key_exists(12, $school_years_data) and $school_years_data[12], $this->IsValidSubmit())); $this->AddControl($school_years); $this->AddControl(new CheckBox('playing', 'This team still plays matches', 1, $team->GetIsActive(), $this->IsValidSubmit())); # add ground $ground_list = new XhtmlSelect('ground', null, $this->IsValidSubmit()); foreach ($this->a_grounds as $ground) { if ($ground instanceof Ground) { $opt = new XhtmlOption($ground->GetNameAndTown(), $ground->GetId()); $ground_list->AddControl($opt); unset($opt); } } $ground = $team->GetGround(); if (is_numeric($ground->GetId()) and $this->IsValidSubmit()) { $ground_list->SelectOption($ground->GetId()); } $ground_label = new XhtmlElement('label', 'Where do you play?'); $ground_label->AddAttribute('for', $ground_list->GetXhtmlId()); $this->AddControl($ground_label); $this->AddControl('<p class="label-hint">If your ground isn\'t listed, please email us the address.</p>'); $this->AddControl($ground_list); } # Add seasons $this->AddControl(new XhtmlElement('label', 'Leagues and competitions')); $this->AddControl('<p class="label-hint">We manage the leagues and competitions you\'re listed in. Please email us with any changes.</p>'); if (!$is_once_only) { # add times $times_box = new TextBox('times', $team->GetPlayingTimes(), $this->IsValidSubmit()); $times_box->SetMode(TextBoxMode::MultiLine()); $times = new XhtmlElement("label", 'Which days of the week do you play, and at what time?'); $times->AddAttribute('for', $times_box->GetXhtmlId()); $this->AddControl($times); $this->AddControl($times_box); } # add cost $year_box = new TextBox('yearCost', $team->GetCost(), $this->IsValidSubmit()); $year_box->SetMode(TextBoxMode::MultiLine()); $year = new XhtmlElement('label', 'Cost to play'); $year->AddAttribute('for', $year_box->GetXhtmlId()); $this->AddControl($year); $this->AddControl('<p class="label-hint">Do you have an annual membership fee? Match fees? Special rates for juniors?</p>'); $this->AddControl($year_box); # add contact info $contact_box = new TextBox('contact', $team->GetContact(), $this->IsValidSubmit()); $contact_box->SetMode(TextBoxMode::MultiLine()); $contact = new XhtmlElement('label', 'Contact details for the public'); $contact->AddAttribute('for', $contact_box->GetXhtmlId()); $this->AddControl($contact); $this->AddControl('<p class="label-hint">We recommend you publish a phone number and email so new players can get in touch.</p>'); $this->AddControl($contact_box); $private_box = new TextBox('private', $team->GetPrivateContact(), $this->IsValidSubmit()); $private_box->SetMode(TextBoxMode::MultiLine()); $private = new XhtmlElement('label', 'Contact details for Stoolball England (if different)'); $private->AddAttribute('for', $private_box->GetXhtmlId()); $this->AddControl($private); $this->AddControl('<p class="label-hint">We won\'t share this with anyone else.</p>'); $this->AddControl($private_box); # add website url $website_url_box = new TextBox('websiteUrl', $team->GetWebsiteUrl(), $this->IsValidSubmit()); $website_url_box->AddAttribute('maxlength', 250); $website_url = new XhtmlElement('label', 'Team website'); $website_url->AddAttribute('for', $website_url_box->GetXhtmlId()); $this->AddControl($website_url); $this->AddControl($website_url_box); }
function CreateControls() { require_once 'xhtml/xhtml-element.class.php'; require_once 'xhtml/forms/form-part.class.php'; require_once 'xhtml/forms/textbox.class.php'; $this->AddCssClass('legacy-form'); $o_comp = $this->GetDataObject(); /* @var $o_type IdValue */ /* @var $o_comp Competition */ /* @var $o_season Season */ # add name $o_name_box = new TextBox('name', $o_comp->GetName(), $this->IsValidSubmit()); $o_name_box->AddAttribute('maxlength', 100); $o_name = new FormPart('Competition name', $o_name_box); $this->AddControl($o_name); # Add seasons once competition saved if ($o_comp->GetId()) { $a_seasons = $o_comp->GetSeasons(); $o_season_part = new FormPart('Seasons'); $o_season_control = new Placeholder(); # List exisiting seasons if (is_array($a_seasons) and count($a_seasons)) { $o_seasons = new XhtmlElement('ul'); foreach ($a_seasons as $o_season) { $o_season_link = new XhtmlAnchor(Html::Encode($o_season->GetName()), $o_season->GetEditSeasonUrl()); $o_seasons->AddControl(new XhtmlElement('li', $o_season_link)); } $o_season_control->AddControl($o_seasons); } $o_new_season = new XhtmlAnchor('Add season', '/play/competitions/seasonedit.php?competition=' . $o_comp->GetId()); $o_season_control->AddControl($o_new_season); $o_season_part->SetControl($o_season_control); $this->AddControl($o_season_part); } # Still going? $this->AddControl(new CheckBox('active', 'This competition is still played', 1, $o_comp->GetIsActive(), $this->IsValidSubmit())); # add player type $o_type_list = new XhtmlSelect('playerType', null, $this->IsValidSubmit()); $o_type_list->AddControl(new XhtmlOption(PlayerType::Text(PlayerType::MIXED), PlayerType::MIXED)); $o_type_list->AddControl(new XhtmlOption(PlayerType::Text(PlayerType::LADIES), PlayerType::LADIES)); $o_type_list->AddControl(new XhtmlOption(PlayerType::Text(PlayerType::JUNIOR_MIXED), PlayerType::JUNIOR_MIXED)); $o_type_list->AddControl(new XhtmlOption(PlayerType::Text(PlayerType::GIRLS), PlayerType::GIRLS)); $o_type_list->AddControl(new XhtmlOption(PlayerType::Text(PlayerType::MEN), PlayerType::MEN)); $o_type_list->AddControl(new XhtmlOption(PlayerType::Text(PlayerType::BOYS), PlayerType::BOYS)); if (!is_null($o_comp->GetPlayerType()) and $this->IsValidSubmit()) { $o_type_list->SelectOption($o_comp->GetPlayerType()); } $o_type_part = new FormPart('Player type', $o_type_list); $this->AddControl($o_type_part); # add players per team $players_box = new TextBox('players', $o_comp->GetMaximumPlayersPerTeam(), $this->IsValidSubmit()); $players_box->SetMaxLength(2); $players = new FormPart('Max players in league/cup team', $players_box); $this->AddControl($players); # add overs $overs_box = new TextBox('overs', $o_comp->GetOvers(), $this->IsValidSubmit()); $overs_box->SetMaxLength(2); $overs = new FormPart('Overs per innings', $overs_box); $this->AddControl($overs); # category $cat_select = new CategorySelectControl($this->categories, $this->IsValidSubmit()); $cat_select->SetXhtmlId($this->GetNamingPrefix() . 'category'); if (!is_null($o_comp->GetCategory()) and $this->IsValidSubmit()) { $cat_select->SelectOption($o_comp->GetCategory()->GetId()); } $this->AddControl(new FormPart('Category', $cat_select)); # add intro $o_intro_box = new TextBox('intro', $o_comp->GetIntro(), $this->IsValidSubmit()); $o_intro_box->SetMode(TextBoxMode::MultiLine()); $o_intro = new FormPart('Introduction', $o_intro_box); $this->AddControl($o_intro); # add contact info $o_contact_box = new TextBox('contact', $o_comp->GetContact(), $this->IsValidSubmit()); $o_contact_box->SetMode(TextBoxMode::MultiLine()); $o_contact = new FormPart('Contact details', $o_contact_box); $this->AddControl($o_contact); # Add notification email $o_notify_box = new TextBox('notification', $o_comp->GetNotificationEmail(), $this->IsValidSubmit()); $o_notify_box->SetMaxLength(200); $o_notify = new FormPart('Notification email', $o_notify_box); $this->AddControl($o_notify); # add website $o_website_box = new TextBox('website', $o_comp->GetWebsiteUrl(), $this->IsValidSubmit()); $o_website_box->SetMaxLength(250); $o_website = new FormPart('Website', $o_website_box); $this->AddControl($o_website); # Remember short URL $o_short_url = new TextBox($this->GetNamingPrefix() . 'ShortUrl', $o_comp->GetShortUrl(), $this->IsValidSubmit()); $this->AddControl(new FormPart('Short URL', $o_short_url)); }
function CreateControls() { /* @var $o_email Zend_Mail */ $this->AddCssClass('legacy-form'); $o_email = $this->GetDataObject(); if (!is_object($o_email)) { $o_email = new Zend_Mail('UTF-8'); } # Who to send to $i_address_count = count($this->a_addresses); if ($i_address_count > 1) { $o_who = new XhtmlElement('fieldset', new XhtmlElement('legend', 'Why are you contacting us?')); $o_who->SetCssClass('radioButtonList'); $i = 0; foreach ($this->a_addresses as $s_addr => $s_reason) { $o_radio = new XhtmlElement('input'); $o_radio->SetEmpty(true); $o_radio->AddAttribute('type', 'radio'); $o_radio->AddAttribute('name', 'to'); $o_radio->AddAttribute('value', md5($s_addr)); $o_radio->SetXhtmlId('to' . $i); if ($this->IsPostback()) { if (isset($_POST['to']) and $_POST['to'] == md5($s_addr)) { $o_radio->AddAttribute('checked', 'checked'); } } else { if (!$i) { $o_radio->AddAttribute('checked', 'checked'); } } $o_label = new XhtmlElement('label', $o_radio); $o_label->AddAttribute('for', $o_radio->GetXhtmlId()); $o_label->AddControl($s_reason); $o_who->AddControl($o_label); $i++; } $this->AddControl($o_who); } # Your details $o_details = new XhtmlElement('fieldset'); $o_details->AddControl(new XhtmlElement('legend', 'Your details')); $this->AddControl($o_details); $o_name = new TextBox('fromName', '', $this->IsValidSubmit()); $o_name->SetMaxLength(100); $o_name_part = new FormPart('Name', $o_name); $o_details->AddControl($o_name_part); $o_from = new TextBox('from', '', $this->IsValidSubmit()); $o_from->AddAttribute("type", "email"); $o_from->SetMaxLength(250); $o_from_part = new FormPart('Email address', $o_from); $o_from_part->SetIsRequired(true); $o_details->AddControl($o_from_part); # Your email $o_message = new XhtmlElement('fieldset'); $o_message->AddControl(new XhtmlElement('legend', 'Your email')); $this->AddControl($o_message); $o_subj = new TextBox('subject', '', $this->IsValidSubmit()); $o_subj->SetMaxLength(250); $o_subj_part = new FormPart('Subject', $o_subj); $o_message->AddControl($o_subj_part); $o_body = new TextBox('body', '', $this->IsValidSubmit()); $o_body->SetMode(TextBoxMode::MultiLine()); $o_body_part = new FormPart('Your message', $o_body); $o_body_part->SetIsRequired(true); $o_message->AddControl($o_body_part); # Options $o_opt = new XhtmlElement('fieldset', null, "radioButtonList"); $o_opt->AddControl(new XhtmlElement('legend', 'Options', "aural")); $this->AddControl($o_opt); $o_opt->AddControl(new CheckBox('cc', 'Send me a copy', 1, false, $this->IsValidSubmit())); $o_opt->AddControl(new CheckBox('reply', "I'd like a reply", 1, true, $this->IsValidSubmit())); }
/** * 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; }
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; }
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() { /* @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 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); }
/** * Adds controls to edit a team score * * @param XhtmlElement $o_container * @param string $s_id_prefix * @param Match $o_match * @param Team $o_team * @param int $i_runs * @param int $i_wickets */ private function CreateTeamScoreControls($o_container, $s_team_role, Match $o_match, Team $o_team = null, $i_runs, $i_wickets) { $o_box = new XhtmlElement('div'); $o_runs = new TextBox($this->GetNamingPrefix() . $s_team_role . 'Runs', $i_runs); $o_runs->SetCssClass("numeric"); if ($i_runs == null) { $o_runs->PopulateData(); } $s_runs_label = (is_null($o_team) ? $s_team_role : $o_team->GetName()) . ' score'; $o_part = new FormPart($s_runs_label, $o_box); $o_box->AddControl($o_runs); $o_part->GetLabel()->AddAttribute('for', $o_runs->GetXhtmlId()); $o_wickets = new XhtmlSelect($this->GetNamingPrefix() . $s_team_role . 'Wickets', ' for '); $o_wickets->SetBlankFirst(true); $max_wickets = $o_match->GetMaximumPlayersPerTeam() - 2; $season_dates = Season::SeasonDates($o_match->GetStartTime()); # working with GMT if (Date::Year($season_dates[0]) != Date::Year($season_dates[1])) { # outdoor needs maximum-2, but indoor needs maximum-1 cos last batter can play on. # if there's any chance it's indoor use maximum-1 $max_wickets = $o_match->GetMaximumPlayersPerTeam() - 1; } for ($i = 0; $i <= $max_wickets; $i++) { $o_wickets->AddControl(new XhtmlOption($i)); } $o_wickets->AddControl(new XhtmlOption('all out', -1)); $o_wickets->SelectOption($i_wickets); $o_box->AddControl($o_wickets); $o_container->AddControl($o_part); }