public function CreateControls() { $this->AddCssClass('form'); $this->SetButtonText("Save player"); # get player to edit $player = $this->GetDataObject(); if (!$player instanceof Player) { $player = new Player($this->GetSettings()); } require_once "xhtml/forms/radio-button.class.php"; if ($this->GetCurrentPage() == PlayerEditor::MERGE_PLAYER) { $this->AddControl("<p>There's another player named '" . htmlentities($player->GetName(), ENT_QUOTES, "UTF-8", false) . "' in this team. What would you like to do?</p>"); $this->AddControl("<dl class=\"decision\"><dt>"); $this->AddControl(new RadioButton($this->GetNamingPrefix() . "Merge", $this->GetNamingPrefix() . "MergeOptions", htmlentities("Merge with the other " . $player->GetName(), ENT_QUOTES, "UTF-8", false), 1, false, $this->IsValid())); $this->AddControl("</dt><dd>If they're the same person you can merge the records so there's only one " . htmlentities($player->GetName(), ENT_QUOTES, "UTF-8", false) . ". Don't choose this for a player who's got married and changed their name though.</dd>"); $this->AddControl("<dt>"); $this->AddControl(new RadioButton($this->GetNamingPrefix() . "Rename", $this->GetNamingPrefix() . "MergeOptions", "Choose a new name for this player", 2, false, $this->IsValid())); $this->AddControl("</dt><dd>If they're different people you need to pick a different name. For example, if you have two players called 'Jane Smith',\n\t\t\t\tchange one to 'Jane A Smith'.</dd></dl>"); } # Container for form elements, useful for JavaScript to hide them $container = new XhtmlElement("div", null, "#playerEditorFields"); $this->AddControl($container); # add name $name = new XhtmlElement("label", "Name"); $name->AddAttribute("for", $this->GetNamingPrefix() . 'Name'); $container->AddControl($name); $name_box = new TextBox($this->GetNamingPrefix() . 'Name', $player->GetName(), $this->IsValid()); $name_box->AddAttribute('maxlength', 100); #$name = new FormPart('Name', $name_box); $container->AddControl($name_box); }
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); } } }
public function CreateControls() { $this->AddCssClass('form'); require_once 'xhtml/forms/textbox.class.php'; $this->SetButtonText('Add new school'); $school = new Club($this->GetSettings()); /* @var $school Club */ # add name $name_box = new TextBox('school-name', '', $this->IsValidSubmit()); $name_box->AddAttribute('maxlength', 100); $name_box->AddAttribute('autocomplete', "off"); $name_box->AddCssClass("searchable"); $name = new XhtmlElement('label', 'School name'); $name->AddAttribute('for', $name_box->GetXhtmlId()); $this->AddControl($name); $this->AddControl($name_box); # add town $town_box = new TextBox('town', '', $this->IsValidSubmit()); $town_box->AddAttribute('maxlength', 100); $town_box->AddAttribute('autocomplete', "off"); $town_box->AddCssClass("searchable town"); $town = new XhtmlElement('label', 'Town or village'); $town->AddAttribute('for', $town_box->GetXhtmlId()); $this->AddControl($town); $this->AddControl($town_box); # add hook for suggestions $this->AddControl('<div class="suggestions"></div>'); }
/** * Instantiates a SupportedContentControl * * @param XhtmlElement $o_all_content */ public function __construct(XhtmlElement $o_all_content) { parent::XhtmlElement('div'); $this->SetCssClass('supportedContentContainer'); $o_all_content->AddCssClass('supportedContent'); $this->AddControl($o_all_content); }
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; } } }
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 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() { 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 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; }
/** * Create new TeamNameControl * @param Team $team * @param string $container_element */ public function __construct(Team $team, $container_element) { parent::XhtmlElement($container_element); $name = $team->GetName(); $type = is_null($team->GetPlayerType()) ? '' : PlayerType::Text($team->GetPlayerType()); if ($type and strpos(strtolower(str_replace("'", '', $name)), strtolower(str_replace("'", '', $type))) !== false) { $type = ""; } $town = (is_null($team->GetGround()) or is_null($team->GetGround()->GetAddress())) ? "" : $team->GetGround()->GetAddress()->GetTown(); if ($town and strpos(strtolower($name), strtolower($town)) !== false) { $town = ""; } if ($type or $town) { $html = '<span property="schema:name">' . htmlentities($name, ENT_QUOTES, "UTF-8", false) . '</span>'; if ($town) { $html .= htmlentities(", {$town}", ENT_QUOTES, "UTF-8", false); } if ($type) { $html .= htmlentities(" ({$type})", ENT_QUOTES, "UTF-8", false); } $this->AddControl($html); } else { $this->AddAttribute("property", "schema:name"); $this->AddControl(htmlentities($name, ENT_QUOTES, "UTF-8", false)); } }
public function __construct(ForumTopic $o_topic, AuthenticationManager $authentication_manager) { $this->o_topic = $o_topic; $this->authentication_manager = $authentication_manager; parent::XhtmlElement('div'); $this->SetCssClass('forumNavbar'); }
function XhtmlTable() { parent::XhtmlElement('table'); $this->a_rowgroups = array(); $this->a_rowgroups[] = new XhtmlRowGroup(); $this->a_colgroups = array(); }
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 PostalAddressControl(PostalAddress $o_address) { # set up element parent::XhtmlElement('p'); $this->SetCssClass('adr'); $this->AddAttribute("typeof", "schema:PostalAddress"); $this->SetAddress($o_address); }
function OnPageLoad() { ?> <h1>Manage users</h1> <ul> <?php foreach ($this->a_people as $o_person) { if ($o_person instanceof User) { $o_link = new XhtmlElement('a', Html::Encode($o_person->GetName())); $o_link->AddAttribute('href', 'personedit.php?item=' . $o_person->GetId()); echo "<li>" . $o_link . "</li>"; } } ?> </ul> <?php }
function Button($id, $text) { parent::XhtmlElement('input'); $this->SetXhtmlId($id); $this->AddAttribute('name', $this->GetXhtmlId()); $this->AddAttribute('type', 'submit'); $this->SetEmpty(true); $this->AddAttribute('value', $text); }
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)); } } }
public function __construct($s_text = null, $s_value = null, $selected = false) { parent::XhtmlElement('option'); # store text $this->AddControl(Html::Encode((string) $s_text)); # use text as value if no value supplied $this->AddAttribute('value', is_null($s_value) ? $s_text : $s_value); if ($selected) { $this->AddAttribute('selected', 'selected'); } }
/** * 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); }
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() { # 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>.'); } } }
public function OnPreRender() { $a_items = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'); $querystring = QueryStringBuilder::RemoveParameter('az'); foreach ($a_items as $s_item) { if ($s_item == $this->s_current) { $o_li = new XhtmlElement('li', new XhtmlElement('strong', $s_item)); $this->AddControl($o_li); unset($o_li); } else { if (in_array($s_item, $this->disabled, true)) { $this->AddControl(new XhtmlElement('li', $s_item)); } else { $o_link = new XhtmlElement('a', $s_item); # $o_link->AddAttribute('href', $this->s_page . $querystring . 'az=' . strtolower($s_item)); $o_link->AddAttribute('href', $this->s_page . '?az=' . strtolower($s_item)); $o_li = new XhtmlElement('li', $o_link); $this->AddControl($o_li); unset($o_link); unset($o_li); } } } }
private function CreateItem(Category $category) { $o_link = new XhtmlElement('a', Html::Encode($category->GetName())); $o_link->AddAttribute('href', 'categoryedit.php?item=' . $category->GetId()); return new XhtmlElement('li', $o_link); }
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; }
/** * 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.')); } }
/** * 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 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>"); } }
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)); } }
/** * 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'); }