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;
 }
 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>');
 }
 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_team Team */
     $a_teams = $this->teams;
     if (count($a_teams)) {
         $o_list = new XhtmlElement('ul');
         if ($this->is_navigation_list) {
             $o_list->SetCssClass('teamList nav');
             $nav = new XhtmlElement("nav", $o_list);
             $this->AddControl($nav);
         } else {
             $o_list->SetCssClass('teamList');
             $this->AddControl($o_list);
         }
         $i_count = 0;
         foreach ($a_teams as $o_team) {
             if (strtolower(get_class($o_team)) == 'team') {
                 $li = new XhtmlElement('li');
                 $li->AddAttribute("typeof", "schema:SportsTeam");
                 $li->AddAttribute("about", $o_team->GetLinkedDataUri());
                 if ($this->b_show_type) {
                     $link = new TeamNameControl($o_team, "a");
                 } else {
                     $link = new XhtmlElement('a', Html::Encode($o_team->GetName()));
                     $link->AddAttribute("property", "schema:name");
                 }
                 $link->AddAttribute('href', $o_team->GetNavigateUrl());
                 $link->AddAttribute("rel", "schema:url");
                 $li->AddControl($link);
                 # Add not playing, if relevant
                 if (!$o_team->GetIsActive()) {
                     $li->AddControl(' (doesn\'t play any more)');
                 }
                 $o_list->AddControl($li);
                 $i_count++;
             }
         }
     } else {
         # Display no teams message
         if ($this->s_no_teams_message) {
             $this->AddControl(new XhtmlElement('p', $this->s_no_teams_message));
         }
     }
 }
 function 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);
         }
     }
 }
 /**
  * Creates a new RadioButton
  *
  * @param string $s_id
  * @param string $s_group_name
  * @param string $s_label
  * @param string $s_value
  * @param bool $b_checked
  * @param bool $page_valid
  * @return RadioButton
  */
 function RadioButton($s_id, $s_group_name, $s_label, $s_value = '', $b_checked = false, $page_valid = null)
 {
     # this element is the label for the radio button
     parent::XhtmlElement('label');
     $this->AddAttribute('for', $s_id);
     $this->SetCssClass('radioButton');
     # create radio button as child control
     $o_radio = new XhtmlElement('input');
     $o_radio->SetEmpty(true);
     $o_radio->AddAttribute('type', 'radio');
     $o_radio->AddAttribute('value', $s_value);
     $this->a_controls[0] =& $o_radio;
     $this->SetGroupName($s_group_name);
     # wait to set id, because it'll set both controls at once
     $this->SetXhtmlId($s_id);
     # wait to set label so that it comes after radio button
     $this->a_controls[1] = htmlentities($s_label, ENT_QUOTES, "UTF-8", false);
     if ($page_valid === false) {
         $this->b_checked = (isset($_POST[$s_group_name]) and $_POST[$s_group_name] == $s_value);
     } else {
         $this->b_checked = (bool) $b_checked;
     }
 }
 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 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 
    }
 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);
             }
         }
     }
 }
 /**
  * @access public
  * @return void
  * @param string $s_id
  * @desc Set the id and name attributes of the TextBox together
  */
 function SetXhtmlId($s_id)
 {
     $s_id = (string) $s_id;
     parent::SetXhtmlId($s_id);
     parent::AddAttribute('name', $s_id);
 }
 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()
 {
     /* @var $o_email Zend_Mail */
     $this->AddCssClass('legacy-form');
     $o_email = $this->GetDataObject();
     if (!is_object($o_email)) {
         $o_email = new Zend_Mail('UTF-8');
     }
     # Who to send to
     $i_address_count = count($this->a_addresses);
     if ($i_address_count > 1) {
         $o_who = new XhtmlElement('fieldset', new XhtmlElement('legend', 'Why are you contacting us?'));
         $o_who->SetCssClass('radioButtonList');
         $i = 0;
         foreach ($this->a_addresses as $s_addr => $s_reason) {
             $o_radio = new XhtmlElement('input');
             $o_radio->SetEmpty(true);
             $o_radio->AddAttribute('type', 'radio');
             $o_radio->AddAttribute('name', 'to');
             $o_radio->AddAttribute('value', md5($s_addr));
             $o_radio->SetXhtmlId('to' . $i);
             if ($this->IsPostback()) {
                 if (isset($_POST['to']) and $_POST['to'] == md5($s_addr)) {
                     $o_radio->AddAttribute('checked', 'checked');
                 }
             } else {
                 if (!$i) {
                     $o_radio->AddAttribute('checked', 'checked');
                 }
             }
             $o_label = new XhtmlElement('label', $o_radio);
             $o_label->AddAttribute('for', $o_radio->GetXhtmlId());
             $o_label->AddControl($s_reason);
             $o_who->AddControl($o_label);
             $i++;
         }
         $this->AddControl($o_who);
     }
     # Your details
     $o_details = new XhtmlElement('fieldset');
     $o_details->AddControl(new XhtmlElement('legend', 'Your details'));
     $this->AddControl($o_details);
     $o_name = new TextBox('fromName', '', $this->IsValidSubmit());
     $o_name->SetMaxLength(100);
     $o_name_part = new FormPart('Name', $o_name);
     $o_details->AddControl($o_name_part);
     $o_from = new TextBox('from', '', $this->IsValidSubmit());
     $o_from->AddAttribute("type", "email");
     $o_from->SetMaxLength(250);
     $o_from_part = new FormPart('Email address', $o_from);
     $o_from_part->SetIsRequired(true);
     $o_details->AddControl($o_from_part);
     # Your email
     $o_message = new XhtmlElement('fieldset');
     $o_message->AddControl(new XhtmlElement('legend', 'Your email'));
     $this->AddControl($o_message);
     $o_subj = new TextBox('subject', '', $this->IsValidSubmit());
     $o_subj->SetMaxLength(250);
     $o_subj_part = new FormPart('Subject', $o_subj);
     $o_message->AddControl($o_subj_part);
     $o_body = new TextBox('body', '', $this->IsValidSubmit());
     $o_body->SetMode(TextBoxMode::MultiLine());
     $o_body_part = new FormPart('Your message', $o_body);
     $o_body_part->SetIsRequired(true);
     $o_message->AddControl($o_body_part);
     # Options
     $o_opt = new XhtmlElement('fieldset', null, "radioButtonList");
     $o_opt->AddControl(new XhtmlElement('legend', 'Options', "aural"));
     $this->AddControl($o_opt);
     $o_opt->AddControl(new CheckBox('cc', 'Send me a copy', 1, false, $this->IsValidSubmit()));
     $o_opt->AddControl(new CheckBox('reply', "I'd like a reply", 1, true, $this->IsValidSubmit()));
 }
    function OnPageLoad()
    {
        /* @var $team Team */
        $team = $this->team;
        # display the team
        echo '<div class="team" typeof="schema:SportsTeam" about="' . htmlentities($this->team->GetLinkedDataUri(), ENT_QUOTES, "UTF-8", false) . '">';
        echo new TeamNameControl($this->team, 'h1');
        require_once 'xhtml/navigation/tabs.class.php';
        $tabs = array('Summary' => '');
        if ($this->has_player_stats) {
            $tabs['Players'] = $this->team->GetPlayersNavigateUrl();
        }
        $tabs['Statistics'] = $this->team->GetStatsNavigateUrl();
        echo new Tabs($tabs);
        ?>
        <div class="box tab-box">
            <div class="dataFilter"></div>
            <div class="box-content">
        <?php 
        if (!$this->is_one_time_team) {
            # add club name
            if ($team->GetClub()->GetId()) {
                $o_club_para = new XhtmlElement('p');
                $o_club_para->AddControl('Part of ');
                $o_club_link = new XhtmlElement('a', htmlentities($team->GetClub()->GetName(), ENT_QUOTES, "UTF-8", false));
                $o_club_link->AddAttribute('href', $team->GetClub()->GetNavigateUrl());
                $o_club_para->AddControl($o_club_link);
                $o_club_para->AddControl('.');
                echo $o_club_para;
            }
        }
        # Add intro
        if ($team->GetIntro()) {
            $s_intro = htmlentities($team->GetIntro(), ENT_QUOTES, "UTF-8", false);
            $s_intro = XhtmlMarkup::ApplyParagraphs($s_intro);
            $s_intro = XhtmlMarkup::ApplyLists($s_intro);
            $s_intro = XhtmlMarkup::ApplySimpleXhtmlTags($s_intro, false);
            $s_intro = XhtmlMarkup::ApplyLinks($s_intro);
            if (strpos($s_intro, '<p>') > -1) {
                echo '<div property="schema:description">' . $s_intro . '</div>';
            } else {
                echo '<p property="schema:description">' . $s_intro . '</p>';
            }
        }
        ######################
        ### When and where ###
        ######################
        echo new XhtmlElement('h2', 'When and where');
        if (!$this->is_one_time_team) {
            # Add not playing, if relevant
            if (!$team->GetIsActive()) {
                echo new XhtmlElement('p', new XhtmlElement('strong', 'This team doesn\'t play any more.'));
            }
        }
        # add ground
        $ground = $team->GetGround();
        if ($ground->GetId() and $ground->GetName()) {
            echo '<p rel="schema:location">This team plays at <a typeof="schema:Place" about="' . htmlentities($ground->GetLinkedDataUri(), ENT_QUOTES, "UTF-8", false) . '" property="schema:name" rel="schema:url" href="' . htmlentities($ground->GetNavigateUrl(), ENT_QUOTES, "UTF-8", false) . '">' . htmlentities($ground->GetNameAndTown(), ENT_QUOTES, "UTF-8", false) . '</a>.</p>';
        }
        if (!$this->is_one_time_team) {
            # Add playing times
            if ($team->GetPlayingTimes()) {
                $s_times = htmlentities($team->GetPlayingTimes(), ENT_QUOTES, "UTF-8", false);
                $s_times = XhtmlMarkup::ApplyParagraphs($s_times);
                $s_times = XhtmlMarkup::ApplyLists($s_times);
                $s_times = XhtmlMarkup::ApplySimpleXhtmlTags($s_times, false);
                $s_times = XhtmlMarkup::ApplyLinks($s_times);
                echo $s_times;
            }
        }
        # Match list
        if (count($this->a_matches)) {
            if ($this->is_one_time_team) {
                $came = "came";
                if (count($this->a_matches) == 1 and $this->a_matches[0]->GetStartTime() > gmdate("U")) {
                    $came = "will come";
                }
                echo "<p>This team {$came} together once to play in a tournament.</p>";
            } else {
                echo new XhtmlElement('h2', 'Matches this season');
            }
            echo new MatchListControl($this->a_matches);
        }
        if (!$this->is_one_time_team) {
            #################
            ###  Seasons  ###
            #################
            $seasons = array();
            foreach ($team->Seasons() as $team_in_season) {
                $seasons[] = $team_in_season->GetSeason();
            }
            if (count($seasons)) {
                $season_list = new SeasonListControl($seasons);
                $season_list->SetShowCompetition(true);
                echo $season_list;
            }
        }
        #################
        ###   Cost    ###
        #################
        if ($team->GetCost()) {
            echo new XhtmlElement('h2', 'How much does it cost?');
            $cost = XhtmlMarkup::ApplyParagraphs(htmlentities($team->GetCost(), ENT_QUOTES, "UTF-8", false));
            $cost = XhtmlMarkup::ApplyLists($cost);
            $cost = XhtmlMarkup::ApplySimpleXhtmlTags($cost, false);
            $cost = XhtmlMarkup::ApplyLinks($cost);
            echo $cost;
        }
        #####################
        ### Find out more ###
        #####################
        if ($team->GetContact() or $team->GetWebsiteUrl()) {
            echo new XhtmlElement('h2', 'Contact details');
        }
        # Add contact details
        $s_contact = $team->GetContact();
        if ($s_contact) {
            # protect emails before escaping HTML, because it's trying to recognise the actual HTML tags
            require_once 'email/email-address-protector.class.php';
            $protector = new EmailAddressProtector($this->GetSettings());
            $s_contact = $protector->ApplyEmailProtection($s_contact, AuthenticationManager::GetUser()->IsSignedIn());
            $s_contact = htmlentities($s_contact, ENT_QUOTES, "UTF-8", false);
            $s_contact = XhtmlMarkup::ApplyParagraphs($s_contact);
            $s_contact = XhtmlMarkup::ApplyLists($s_contact);
            $s_contact = XhtmlMarkup::ApplySimpleXhtmlTags($s_contact, false);
            $s_contact = XhtmlMarkup::ApplyLinks($s_contact);
            echo $s_contact;
        }
        # Add website
        $s_website = $team->GetWebsiteUrl();
        if ($s_website) {
            echo new XhtmlElement('p', new XhtmlAnchor("Visit " . htmlentities($team->GetName(), ENT_QUOTES, "UTF-8", false) . "'s website", $s_website));
        }
        if ($team->GetClub() instanceof Club and $team->GetClub()->GetClubmarkAccredited()) {
            ?>
            <p><img src="/images/logos/clubmark.png" alt="Clubmark accredited" width="150" height="29" /></p>
            <p>This is a <a href="http://www.sportenglandclubmatters.com/club-mark/">Clubmark accredited</a> stoolball club.</p>
            <?php 
        }
        if (!$this->is_one_time_team) {
            # Prompt for more contact information, unless it's a repreaentative team when we don't expect it
            if (!$s_contact and !$s_website and $team->GetTeamType() !== Team::REPRESENTATIVE) {
                if ($team->GetPrivateContact()) {
                    ?>
    <p>We may be able to contact this team, but we don't have permission to publish their details. If you'd like to play for them, <a href="/contact">contact us</a> and we'll pass your details on.</p>
    				<?php 
                } else {
                    ?>
    <p>This team hasn't given us any contact details. If you'd like to play for them, try contacting their opposition teams or the secretary of their league, and ask them to pass on your details.</p>
    				<?php 
                }
                ?>
    <p>If you play for this team, please <a href="<?php 
                echo $this->GetSettings()->GetUrl('TeamAdd');
                ?>
">help us to improve this page</a>.</p>
    			<?php 
            }
        }
        $club = $this->team->GetClub();
        if ($club and ($club->GetFacebookUrl() or $club->GetTwitterAccount() or $club->GetInstagramAccount())) {
            ?>
            <div class="social screen">
            <?php 
            if ($club->GetFacebookUrl()) {
                ?>
                <a href="<?php 
                echo Html::Encode($club->GetFacebookUrl());
                ?>
" class="facebook-group"><img src="/images/play/find-us-on-facebook.png" alt="Find us on Facebook" width="137" height="22" /></a>
            <?php 
            }
            if ($club->GetTwitterAccount()) {
                ?>
                <a href="https://twitter.com/<?php 
                echo Html::Encode(substr($club->GetTwitterAccount(), 1));
                ?>
" class="twitter-follow-button">Follow <?php 
                echo Html::Encode($this->team->GetClub()->GetTwitterAccount());
                ?>
</a>
                <script src="https://platform.twitter.com/widgets.js"></script>
                <?php 
            }
            if ($club->GetInstagramAccount()) {
                ?>
                <a href="https://www.instagram.com/<?php 
                echo Html::Encode(trim($club->GetInstagramAccount(), '@'));
                ?>
/?ref=badge" class="instagram"><img src="//badges.instagram.com/static/images/ig-badge-view-24.png" alt="Instagram" /></a>
                <?php 
            }
            ?>
            </div>
            <?php 
        } else {
            $this->ShowSocial();
        }
        ?>
        </div>
        </div>
        </div>
        <?php 
        $this->AddSeparator();
        $o_panel = new TeamEditPanel($this->GetSettings(), $this->team, $this->seasons, $this->a_matches);
        $o_panel->AddCssClass("with-tabs");
        echo $o_panel;
        $this->Render();
        ### Build charts ###
        if ($this->has_facebook_page_url) {
            $this->ShowFacebookPage($club->GetFacebookUrl(), $club->GetName());
        }
        # Show top players, except for once-only teams which have a very short page for this to sit alongside
        if ($this->has_player_stats and !$this->is_one_time_team) {
            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");
        }
        // Show graphs of results, except for once-only teams which have a very short page for this to sit alongside
        if (!$this->is_one_time_team) {
            ?>
             <span class="chart-js-template supporting-chart" id="all-results-chart"></span>
            <?php 
        }
    }
 /**
  * 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&amp;q=' . urlencode($this->ground->GetNameAndTown()) . '@' . $this->ground->GetAddress()->GetLatitude() . ',' . $this->ground->GetAddress()->GetLongitude() . '&amp;ll=' . $this->ground->GetAddress()->GetLatitude() . ',' . $this->ground->GetAddress()->GetLongitude());
         $o_map = new XhtmlElement('div', $o_map_link);
         $o_geo->AddControl($o_map);
         echo $o_geo;
     }
     if ($this->ground->GetDirections()) {
         echo new XhtmlElement('h2', 'Directions');
         $s_directions = htmlentities($this->ground->GetDirections(), ENT_QUOTES, "UTF-8", false);
         $s_directions = XhtmlMarkup::ApplyCharacterEntities($s_directions);
         $s_directions = XhtmlMarkup::ApplyParagraphs($s_directions);
         $s_directions = XhtmlMarkup::ApplySimpleTags($s_directions);
         echo $s_directions;
     }
     if ($this->ground->GetParking()) {
         echo new XhtmlElement('h2', 'Parking');
         $s_parking = htmlentities($this->ground->GetParking(), ENT_QUOTES, "UTF-8", false);
         $s_parking = XhtmlMarkup::ApplyCharacterEntities($s_parking);
         $s_parking = XhtmlMarkup::ApplyParagraphs($s_parking);
         $s_parking = XhtmlMarkup::ApplySimpleTags($s_parking);
         $s_parking = XhtmlMarkup::ApplyLinks($s_parking);
         echo $s_parking;
     }
     if ($this->ground->GetFacilities()) {
         echo new XhtmlElement('h2', 'Facilities');
         $s_facilities = htmlentities($this->ground->GetFacilities(), ENT_QUOTES, "UTF-8", false);
         $s_facilities = XhtmlMarkup::ApplyCharacterEntities($s_facilities);
         $s_facilities = XhtmlMarkup::ApplyParagraphs($s_facilities);
         $s_facilities = XhtmlMarkup::ApplySimpleTags($s_facilities);
         $s_facilities = XhtmlMarkup::ApplyLinks($s_facilities);
         echo $s_facilities;
     }
     $o_meta = new XhtmlElement('p');
     $o_meta->SetCssClass('metadata');
     $o_meta->AddControl('Status: ');
     $o_uid = new XhtmlElement('span', $this->ground->GetLinkedDataUri());
     $o_uid->SetCssClass('uid');
     $o_meta->AddControl($o_uid);
     $o_meta->AddControl(' last updated at ');
     $o_rev = new XhtmlElement('abbr', Date::BritishDateAndTime($this->ground->GetDateUpdated()));
     $o_rev->SetTitle(Date::Microformat($this->ground->GetDateUpdated()));
     $o_rev->SetCssClass('rev');
     $o_meta->AddControl($o_rev);
     $o_meta->AddControl(', sort as ');
     $o_url = new XhtmlAnchor(htmlentities($this->ground->GetAddress()->GenerateSortName(), ENT_QUOTES, "UTF-8", false), $this->ground->GetNavigateUrl());
     $o_url->SetCssClass('url sort-string');
     $o_meta->AddControl($o_url);
     echo $o_meta;
     echo "</div>";
     ?>
     </div>
     </div>
     <?php 
     $this->AddSeparator();
     $o_user = new UserEditPanel($this->GetSettings(), 'this ground');
     $o_user->AddCssClass("with-tabs");
     if (AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_GROUNDS)) {
         $o_user->AddLink("edit this ground", $this->ground->GetEditGroundUrl());
         $o_user->AddLink("delete this ground", $this->ground->GetDeleteGroundUrl());
     }
     echo $o_user;
     # Show top players
     if ($this->has_player_stats) {
         require_once 'stoolball/statistics-highlight-table.class.php';
         echo new StatisticsHighlightTable($this->best_batting, $this->most_runs, $this->best_bowling, $this->most_wickets, $this->most_catches, "All seasons");
     }
 }
 /**
  * Creates the default action buttons for the repeated group of controls
  * @return XhtmlElement
  */
 private function CreateDefaultButtons()
 {
     $o_buttons = new XhtmlElement('div');
     $o_buttons->SetCssClass('buttonGroup');
     $o_button = new XhtmlElement('input');
     $o_button->SetEmpty(true);
     $o_button->AddAttribute('type', 'submit');
     $o_button->AddAttribute('value', $this->GetButtonText());
     $o_buttons->AddControl($o_button);
     return $o_buttons;
 }
 function OnPageLoad()
 {
     echo "<h1>Stoolball matches</h1>";
     # Filter controls
     $filter_box = new XhtmlForm();
     $filter_box->SetCssClass('dataFilter');
     $filter_box->AddAttribute('method', 'get');
     $filter_box->AddControl(new XhtmlElement('p', 'Show me: ', "follow-on large"));
     $filter_inner = new XhtmlElement('div');
     $filter_box->AddControl($filter_inner);
     $gender = new XhtmlSelect('player', 'Player type');
     $gender->SetHideLabel(true);
     $gender->AddControl(new XhtmlOption("mixed and ladies", ''));
     $gender->AddControl(new XhtmlOption('mixed', 1));
     $gender->AddControl(new XhtmlOption("ladies", 2));
     if (isset($_GET['player'])) {
         $gender->SelectOption($_GET['player']);
     }
     $filter_inner->AddControl($gender);
     $type = new XhtmlSelect('type', 'Match type');
     $type->SetHideLabel(true);
     $type->AddControl(new XhtmlOption('all matches', ''));
     $type->AddControl(new XhtmlOption('league matches', MatchType::LEAGUE));
     $type->AddControl(new XhtmlOption('cup matches', MatchType::CUP));
     $type->AddControl(new XhtmlOption('friendlies', MatchType::FRIENDLY));
     $type->AddControl(new XhtmlOption('tournaments', MatchType::TOURNAMENT));
     $type->AddControl(new XhtmlOption('practices', MatchType::PRACTICE));
     if (isset($_GET['type'])) {
         $type->SelectOption($_GET['type']);
     }
     $filter_inner->AddControl($type);
     $filter_inner->AddControl(' in ');
     $month = new XhtmlSelect('month', 'Month');
     $month->SetHideLabel(true);
     $month->AddControl(new XhtmlOption('next few matches', ''));
     foreach ($this->a_months as $i_month => $i_matches) {
         $opt = new XhtmlOption(Date::MonthAndYear($i_month), $i_month);
         if (isset($_GET['month']) and $_GET['month'] == $i_month) {
             $opt->AddAttribute('selected', 'selected');
         }
         $month->AddControl($opt);
         unset($opt);
     }
     $filter_inner->AddControl($month);
     $update = new XhtmlElement('input');
     $update->AddAttribute('type', 'submit');
     $update->AddAttribute('value', 'Update');
     $filter_inner->AddControl($update);
     # Content container
     $container = new XhtmlElement('div', $filter_box, "box");
     $content = new XhtmlElement("div", null, "box-content");
     $container->AddControl($content);
     # Display the matches
     if (count($this->a_matches)) {
         $list = new MatchListControl($this->a_matches);
         $content->AddControl($list);
     } else {
         $content->AddControl(new XhtmlElement('p', 'Sorry, there are no matches to show you.'));
         $content->AddControl(new XhtmlElement('p', 'If you know of a match which should be listed, please <a href="/play/manage/website/">add the match to the website</a>.'));
     }
     echo $container;
 }
 private function AddMetadata(Match $match, XhtmlElement $li)
 {
     $li->AddCssClass('vevent');
     # hCalendar
     $li->AddAttribute("typeof", "schema:SportsEvent");
     $li->AddAttribute("about", $match->GetLinkedDataUri());
     $meta = new XhtmlElement('span');
     $meta->SetCssClass('metadata');
     # hCalendar end date
     if ($match->GetStartTime() and $match->GetIsStartTimeKnown()) {
         $end_date = $this->CreateEndDate($match);
         $meta->AddControl($end_date);
     }
     # hCalendar location
     if (!is_null($match->GetGround())) {
         $ground = new XhtmlElement('span', htmlentities($match->GetGround()->GetNameAndTown(), ENT_QUOTES, "UTF-8", false));
         $ground->SetCssClass('location');
         $meta->AddControl(' at ');
         $meta->AddControl($ground);
     }
     # hCalendar description
     $hcal_desc = new XhtmlElement('span');
     $hcal_desc->SetCssClass('description');
     $i_seasons = $match->Seasons()->GetCount();
     if ($i_seasons) {
         $meta->AddControl(' in ');
         $seasons = $match->Seasons()->GetItems();
         for ($i = 0; $i < $i_seasons; $i++) {
             $b_last = ($i > 0 and $i == $i_seasons - 1);
             if ($i > 0 and !$b_last) {
                 $hcal_desc->AddControl(', ');
             } elseif ($b_last) {
                 $hcal_desc->AddControl(' and ');
             }
             $hcal_desc->AddControl(htmlentities($seasons[$i]->GetCompetitionName(), ENT_QUOTES, "UTF-8", false));
         }
     }
     if (!$match->GetIsStartTimeKnown()) {
         $hcal_desc->AddControl('. Start time not known');
     }
     if ($hcal_desc->CountControls()) {
         $meta->AddControl($hcal_desc);
     }
     # hCalendar timestamp
     $meta->AddControl('. At ');
     $hcal_stamp = new XhtmlElement('abbr', htmlentities(Date::Time(gmdate('U')), ENT_QUOTES, "UTF-8", false));
     $hcal_stamp->SetTitle(Date::Microformat());
     $hcal_stamp->SetCssClass('dtstamp');
     $meta->AddControl($hcal_stamp);
     # hCalendar GUID
     $meta->AddControl(' match ');
     $hcal_guid = new XhtmlElement('span', htmlentities($match->GetLinkedDataUri(), ENT_QUOTES, "UTF-8", false));
     $hcal_guid->SetCssClass('uid');
     $meta->AddControl($hcal_guid);
     # hCalendar status
     $s_status = 'CONFIRMED';
     switch ($match->Result()->GetResultType()) {
         case MatchResult::CANCELLED:
         case MatchResult::POSTPONED:
         case MatchResult::AWAY_WIN_BY_FORFEIT:
         case MatchResult::HOME_WIN_BY_FORFEIT:
             $s_status = 'CANCELLED';
     }
     $meta->AddControl(' is ');
     $status = new XhtmlElement('span', $s_status);
     $status->SetCssClass('status');
     $meta->AddControl($status);
     $meta->AddControl('.');
     $li->AddControl($meta);
 }
 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);
         }
     }
 }
    /**
     * 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>');
    }
 /**
  * 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 .= ' &#8211; 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 &raquo;');
     }
 }
    /**
     * @return void
     * @desc Fires before closing the body element of the page
     */
    protected function OnBodyClosing()
    {
        # Close open divs
        if ($this->b_col1_open) {
            echo '</div></div>';
        }
        if ($this->b_col2_open) {
            echo '</div>';
        }
        if ($this->i_constraint_type != StoolballPage::ConstrainNone()) {
            echo '</div>';
        }
        # Close <div id="constraint">
        ?>
	</div>
	<div id="sidebar">
	<?php 
        if (AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::VIEW_ADMINISTRATION_PAGE)) {
            $o_menu_link = new XhtmlElement('a', 'Menu');
            $o_menu_link->AddAttribute('href', '/yesnosorry/');
            echo new XhtmlElement('p', $o_menu_link, "screen");
        }
        # Add WordPress edit page link if relevant
        if (SiteContext::IsWordPress() and AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::VIEW_WORDPRESS_LOGIN)) {
            global $post;
            $b_wordpress_edit_allowed = true;
            echo '<ul>';
            if ($post->post_type == 'page') {
                if (!current_user_can('edit_page', $post->ID)) {
                    $b_wordpress_edit_allowed = false;
                }
            } else {
                if (!current_user_can('edit_post', $post->ID)) {
                    $b_wordpress_edit_allowed = false;
                }
            }
            if ($b_wordpress_edit_allowed) {
                echo '<li><a href="' . apply_filters('edit_post_link', get_edit_post_link($post->ID), $post->ID) . '">Edit page</a></li>';
            }
            if (function_exists('wp_register')) {
                wp_register();
                echo '<li>';
                wp_loginout();
                echo '</li>';
                wp_meta();
            }
            echo '</ul>';
        }
        echo '<h2 id="your" class="large">Your stoolball.org.uk</h2>';
        $authentication = new AuthenticationControl($this->GetSettings(), AuthenticationManager::GetUser());
        $authentication->SetXhtmlId('authControl');
        echo $authentication;
        # Add admin options
        $this->Render();
        # Add next matches
        $num_matches = count($this->a_next_matches);
        if ($num_matches) {
            $next_alt = $num_matches > 1 ? "Next {$num_matches} matches" : 'Next match';
            echo '<h2 id="next' . $num_matches . '" class="large"><span></span>' . $next_alt . '</h2>';
            $o_match_list = new MatchListControl($this->a_next_matches);
            $o_match_list->UseMicroformats(false);
            # Because parse should look at other match lists on page
            $o_match_list->AddCssClass("large");
            echo $o_match_list;
            echo '<p class="large"><a href="/matches">All matches and tournaments</a></p>';
        }
        $this->Render();
        ?>
	</div>
	<div id="boardBottom">
		<div>
			<div></div>
		</div>
	</div>
</div></div></div>
<div id="post"></div>
	<?php 
        if (!SiteContext::IsDevelopment() and !AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::EXCLUDE_FROM_ANALYTICS)) {
            ?>
<script>
var _gaq=[['_setAccount','UA-1597472-1'],['_trackPageview'],['_setDomainName','.stoolball.org.uk'],['_trackPageLoadTime']];
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.async=1;
g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
s.parentNode.insertBefore(g,s)}(document,'script'));
</script>
		<?php 
        }
        if ($this->GetHasGoogleMap()) {
            // Load Google AJAX Search API for geocoding (Google Maps API v3 Geocoding is still rubbish 29 Oct 2009)
            $s_key = SiteContext::IsDevelopment() ? 'ABQIAAAA1HxejNRwsLuCM4npXmWXVRRQNEa9vqBL8sCMeUxGvuXwQDty9RRFMSpVT9x-PVLTvFTpGlzom0U9kQ' : 'ABQIAAAA1HxejNRwsLuCM4npXmWXVRSqn96GdhD_ATNWxDNgWa3A5EXWHxQrao6MHCS6Es_c2v0t0KQ7iP-FTg';
            echo '<script src="https://www.google.com/uds/api?file=uds.js&amp;v=1.0&amp;key=' . $s_key . '"></script>';
            // Load Google Maps API v3
            echo '<script src="https://maps.google.co.uk/maps/api/js?sensor=false"></script>';
        }
    }
 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;
 }
 public function CreateControls()
 {
     $this->AddCssClass('form');
     require_once 'xhtml/forms/textbox.class.php';
     $this->SetButtonText('Save school');
     $school = $this->GetDataObject();
     /* @var $school School */
     # Get ground id
     $ground_id = new TextBox('ground-id', $school->Ground()->GetId(), $this->IsValidSubmit());
     $ground_id->SetMode(TextBoxMode::Hidden());
     $this->AddControl($ground_id);
     # add name
     $name_box = new TextBox('school-name', $school->Ground()->GetAddress()->GetPaon(), $this->IsValidSubmit());
     $name_box->AddAttribute('maxlength', 100);
     $name_box->AddAttribute('autocomplete', "off");
     $name = new XhtmlElement('label', 'School name');
     $name->AddAttribute('for', $name_box->GetXhtmlId());
     $this->AddControl($name);
     $this->AddControl($name_box);
     # add street
     $street_box = new TextBox('street', $school->Ground()->GetAddress()->GetStreetDescriptor(), $this->IsValidSubmit());
     $street_box->AddAttribute('maxlength', 250);
     $street_box->AddAttribute('autocomplete', "off");
     $street_box->AddCssClass("street");
     $street = new XhtmlElement('label', 'Road');
     $street->AddAttribute('for', $street_box->GetXhtmlId());
     $this->AddControl($street);
     $this->AddControl($street_box);
     # add locality
     $locality_box = new TextBox('locality', $school->Ground()->GetAddress()->GetLocality(), $this->IsValidSubmit());
     $locality_box->AddAttribute('maxlength', 250);
     $locality_box->AddAttribute('autocomplete', "off");
     $locality_box->AddCssClass("town");
     $locality = new XhtmlElement('label', 'Part of town');
     $locality->AddAttribute('for', $locality_box->GetXhtmlId());
     $this->AddControl($locality);
     $this->AddControl($locality_box);
     # add town
     $town_box = new TextBox('town', $school->Ground()->GetAddress()->GetTown(), $this->IsValidSubmit());
     $town_box->AddAttribute('maxlength', 100);
     $town_box->AddAttribute('autocomplete', "off");
     $town_box->AddCssClass("town");
     $town = new XhtmlElement('label', 'Town or village');
     $town->AddAttribute('for', $town_box->GetXhtmlId());
     $this->AddControl($town);
     $this->AddControl($town_box);
     # add administrative area
     $county_box = new TextBox('county', $school->Ground()->GetAddress()->GetAdministrativeArea(), $this->IsValidSubmit());
     $county_box->AddAttribute('maxlength', 100);
     $county_box->AddAttribute('autocomplete', "off");
     $county_box->AddCssClass("county");
     $county = new XhtmlElement('label', 'County');
     $county->AddAttribute('for', $county_box->GetXhtmlId());
     $this->AddControl($county);
     $this->AddControl($county_box);
     # add postcode
     $postcode_box = new TextBox('postcode', $school->Ground()->GetAddress()->GetPostcode(), $this->IsValidSubmit());
     $postcode_box->AddAttribute('maxlength', 8);
     $postcode_box->AddAttribute('autocomplete', "off");
     $postcode_box->AddCssClass("postcode");
     $postcode = new XhtmlElement('label', 'Postcode');
     $postcode->AddAttribute('for', $postcode_box->GetXhtmlId());
     $this->AddControl($postcode);
     $this->AddControl($postcode_box);
     # add lat/long
     $latitude = new TextBox('latitude', $school->Ground()->GetAddress()->GetLatitude(), $this->IsValidSubmit());
     $latitude->SetMode(TextBoxMode::Hidden());
     $this->AddControl($latitude);
     $longitude = new TextBox('longitude', $school->Ground()->GetAddress()->GetLongitude(), $this->IsValidSubmit());
     $longitude->SetMode(TextBoxMode::Hidden());
     $this->AddControl($longitude);
     $geoprecision = new TextBox('geoprecision', $school->Ground()->GetAddress()->GetGeoPrecision(), $this->IsValidSubmit());
     $geoprecision->SetMode(TextBoxMode::Hidden());
     $this->AddControl($geoprecision);
     # placeholder for client-side map
     $map = new XhtmlElement('div', null, "#map");
     $map->AddCssClass("map");
     $this->AddControl($map);
 }
 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);
 }
 protected function CreateControls()
 {
     $o_match = $this->GetDataObject();
     /* @var $o_match Match */
     $b_got_teams = !(is_null($o_match->GetHomeTeam()) || is_null($o_match->GetAwayTeam()));
     $b_future = ($o_match->GetId() and $o_match->GetStartTime() > gmdate('U'));
     // Move CSS class to div element
     $o_match_outer_1 = new XhtmlElement('div');
     if ($this->GetCssClass()) {
         $o_match_outer_1->SetCssClass('matchResultEdit ' . $this->GetCssClass());
     } else {
         $o_match_outer_1->SetCssClass('matchResultEdit');
     }
     $this->SetCssClass('');
     $o_match_outer_2 = new XhtmlElement('div');
     $o_match_box = new XhtmlElement('div');
     $this->AddControl($o_match_outer_1);
     $o_match_outer_1->AddControl($o_match_outer_2);
     $o_match_outer_2->AddControl($o_match_box);
     if ($this->GetShowHeading()) {
         $s_heading = str_replace('{0}', $o_match->GetTitle(), $this->GetHeading());
         $s_heading = str_replace('{1}', Date::BritishDate($o_match->GetStartTime(), false), $s_heading);
         $o_title_inner_1 = new XhtmlElement('span', htmlentities($s_heading, ENT_QUOTES, "UTF-8", false));
         $o_title_inner_2 = new XhtmlElement('span', $o_title_inner_1);
         $o_title_inner_3 = new XhtmlElement('span', $o_title_inner_2);
         $o_heading = new XhtmlElement($this->b_in_section ? 'h3' : 'h2', $o_title_inner_3);
         $o_match_box->AddControl($o_heading);
     }
     # Who's playing?
     $o_home_name = new TextBox($this->GetNamingPrefix() . 'Home');
     $o_away_name = new TextBox($this->GetNamingPrefix() . 'Away');
     $o_home_name->SetMode(TextBoxMode::Hidden());
     $o_away_name->SetMode(TextBoxMode::Hidden());
     if (!is_null($o_match->GetHomeTeam())) {
         $o_home_name->SetText($o_match->GetHomeTeam()->GetId() . ";" . $o_match->GetHomeTeam()->GetName());
     }
     if (!is_null($o_match->GetAwayTeam())) {
         $o_away_name->SetText($o_match->GetAwayTeam()->GetId() . ";" . $o_match->GetAwayTeam()->GetName());
     }
     $this->AddControl($o_home_name);
     $this->AddControl($o_away_name);
     # When? (for validator message only)
     $when = new TextBox($this->GetNamingPrefix() . 'Date', $o_match->GetStartTime());
     $when->SetMode(TextBoxMode::Hidden());
     $this->AddControl($when);
     # Who batted first?
     if (!$b_future) {
         $o_bat_first = new XhtmlSelect($this->GetNamingPrefix() . 'BatFirst');
         $o_bat_first->AddControl(new XhtmlOption("Don't know", ''));
         if ($b_got_teams) {
             $o_bat_first->AddControl(new XhtmlOption($o_match->GetHomeTeam()->GetName(), 'home'));
             $o_bat_first->AddControl(new XhtmlOption($o_match->GetAwayTeam()->GetName(), 'away'));
         } else {
             $o_bat_first->AddControl(new XhtmlOption('Home team', 'home'));
             $o_bat_first->AddControl(new XhtmlOption('Away team', 'away'));
         }
         if (!is_null($o_match->Result()->GetHomeBattedFirst())) {
             if ($o_match->Result()->GetHomeBattedFirst()) {
                 $o_bat_first->SelectOption('home');
             } else {
                 $o_bat_first->SelectOption('away');
             }
         }
         $o_bat_part = new FormPart('Who batted first?', $o_bat_first);
         $o_match_box->AddControl($o_bat_part);
     }
     # Who won?
     $o_winner = new XhtmlSelect($this->GetNamingPrefix() . 'Result');
     $o_winner->AddControl(new XhtmlOption($b_future ? 'The match will go ahead' : "Don't know", ''));
     $result_types = array(MatchResult::HOME_WIN, MatchResult::AWAY_WIN, MatchResult::HOME_WIN_BY_FORFEIT, MatchResult::AWAY_WIN_BY_FORFEIT, MatchResult::TIE, MatchResult::POSTPONED, MatchResult::CANCELLED, MatchResult::ABANDONED);
     if ($o_match->GetMatchType() == MatchType::TOURNAMENT_MATCH) {
         # You don't postpone a match in a tournament for another day
         unset($result_types[array_search(MatchResult::POSTPONED, $result_types, true)]);
     }
     foreach ($result_types as $result_type) {
         if (!$b_future or MatchResult::PossibleInAdvance($result_type)) {
             if ($b_got_teams) {
                 $o_winner->AddControl(new XhtmlOption($this->NameTeams(MatchResult::Text($result_type), $o_match->GetHomeTeam(), $o_match->GetAwayTeam()), $result_type));
             } else {
                 $o_winner->AddControl(new XhtmlOption(MatchResult::Text($result_type), $result_type));
             }
         }
     }
     $o_winner->SelectOption($o_match->Result()->GetResultType());
     $o_win_part = new FormPart($b_future ? 'Will it happen?' : 'Who won?', $o_winner);
     $o_match_box->AddControl($o_win_part);
     # If the match has already happened
     if (!$b_future) {
         # What did each team score?
         $this->CreateTeamScoreControls($o_match_box, 'Home', $o_match, $o_match->GetHomeTeam(), $o_match->Result()->GetHomeRuns(), $o_match->Result()->GetHomeWickets());
         $this->CreateTeamScoreControls($o_match_box, 'Away', $o_match, $o_match->GetAwayTeam(), $o_match->Result()->GetAwayRuns(), $o_match->Result()->GetAwayWickets());
         # Any comments?
         $comments = new TextBox($this->GetNamingPrefix() . 'Comments', '', $this->IsValidSubmit());
         $comments->SetMode(TextBoxMode::MultiLine());
         $comments->AddAttribute('class', 'matchReport');
         $comments_label = new XhtmlElement('label');
         $comments_label->AddAttribute('for', $comments->GetXhtmlId());
         $comments_label->AddCssClass('matchReport');
         $comments_label->AddControl('Add a match report:');
         $o_match_box->AddControl($comments_label);
         $o_match_box->AddControl($comments);
     }
     # Show audit data
     if ($o_match->GetLastAudit() != null) {
         require_once "data/audit-control.class.php";
         $o_match_box->AddControl(new AuditControl($o_match->GetLastAudit(), "match"));
     }
 }
 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 OnPreRender()
 {
     if ($this->b_show_date) {
         # create dropdown menu for day of month
         $o_day = new XhtmlSelect($this->GetXhtmlId() . '_day', '', $this->b_page_valid);
         if (!$this->GetRequireDate()) {
             $o_day->AddControl(new XhtmlOption());
         }
         for ($i = 1; $i <= 31; $i++) {
             $o_day->AddControl(new XhtmlOption($i, $i));
         }
         if ($this->i_timestamp != null and !($this->b_page_valid === false)) {
             $o_day->SelectOption(date('j', $this->i_timestamp));
         }
         # create label, and add controls
         $o_day_label = new XhtmlElement('label', 'Day');
         $o_day_label->AddAttribute('for', $o_day->GetXhtmlId());
         $o_day_label->SetCssClass('aural');
         $this->AddControl($o_day_label);
         $this->AddControl($o_day);
         # create dropdown menu for month
         $o_month = new XhtmlSelect($this->GetXhtmlId() . '_month', '', $this->b_page_valid);
         if (!$this->GetRequireDate()) {
             $o_month->AddControl(new XhtmlOption());
         }
         if ($this->month_end > $this->month_start) {
             for ($i = $this->month_start; $i <= $this->month_end; $i++) {
                 $s_monthname = date('F', gmmktime(0, 0, 0, $i, 1, 0));
                 $o_month->AddControl(new XhtmlOption($s_monthname, $i));
             }
         } else {
             # Support order of  Oct, Nov, Dec, Jan, Feb Mar
             for ($i = $this->month_start; $i <= 12; $i++) {
                 $s_monthname = date('F', gmmktime(0, 0, 0, $i, 1, 0));
                 $o_month->AddControl(new XhtmlOption($s_monthname, $i));
             }
             for ($i = 1; $i <= $this->month_end; $i++) {
                 $s_monthname = date('F', gmmktime(0, 0, 0, $i, 1, 0));
                 $o_month->AddControl(new XhtmlOption($s_monthname, $i));
             }
         }
         if ($this->i_timestamp != null and !($this->b_page_valid === false)) {
             $o_month->SelectOption(date('n', $this->i_timestamp));
         }
         # create label, and add controls
         $o_month_label = new XhtmlElement('label', 'Month');
         $o_month_label->AddAttribute('for', $o_month->GetXhtmlId());
         $o_month_label->SetCssClass('aural');
         $this->AddControl($o_month_label);
         $this->AddControl($o_month);
         # create dropdown for year
         if ($this->GetRequireDate() and $this->year_start == $this->year_end) {
             # If there's only one possible value for year and it's required, just hard-code it
             $o_year = new TextBox($this->GetXhtmlId() . '_year', $this->year_start, $this->b_page_valid);
             $o_year->SetMode(TextBoxMode::Hidden());
             $this->AddControl($o_year);
             $this->AddControl(' ' . $this->year_start);
         } else {
             $o_year = new XhtmlSelect($this->GetXhtmlId() . '_year', '', $this->b_page_valid);
             if (!$this->GetRequireDate()) {
                 $o_year->AddControl(new XhtmlOption());
             }
             for ($i = $this->year_start; $i <= $this->year_end; $i++) {
                 $o_option = new XhtmlOption($i, $i);
                 $o_year->AddControl($o_option);
             }
             if ($this->i_timestamp != null and !($this->b_page_valid === false)) {
                 $o_year->SelectOption(date('Y', $this->i_timestamp));
             }
             # create label, and add controls
             $o_year_label = new XhtmlElement('label', 'Year');
             $o_year_label->AddAttribute('for', $o_year->GetXhtmlId());
             $o_year_label->SetCssClass('aural');
             $this->AddControl($o_year_label);
             $this->AddControl($o_year);
         }
     } else {
         $o_day = new TextBox($this->GetXhtmlId() . '_day');
         $o_day->SetMode(TextBoxMode::Hidden());
         $o_day->SetText(date('j', $this->i_timestamp));
         $this->AddControl($o_day);
         $o_month = new TextBox($this->GetXhtmlId() . '_month');
         $o_month->SetMode(TextBoxMode::Hidden());
         $o_month->SetText(date('n', $this->i_timestamp));
         $this->AddControl($o_month);
         $o_year = new TextBox($this->GetXhtmlId() . '_year');
         $o_year->SetMode(TextBoxMode::Hidden());
         $o_year->SetText(date('Y', $this->i_timestamp));
         $this->AddControl($o_year);
     }
     if ($this->b_show_time) {
         if ($this->b_show_date) {
             $this->AddControl(' ');
         }
         $this->AddControl('<span class="time">');
         if ($this->b_show_date) {
             $this->AddControl('at ');
         }
         # create dropdown menu for hour
         $o_hour = new XhtmlSelect($this->GetXhtmlId() . '_hour', '', $this->b_page_valid);
         if (!$this->GetRequireTime()) {
             $o_hour->AddControl(new XhtmlOption());
         }
         for ($i = 1; $i <= 12; $i++) {
             $o_hour->AddControl(new XhtmlOption($i, $i));
         }
         if ($this->i_timestamp != null and $this->b_time_known and !($this->b_page_valid === false)) {
             $o_hour->SelectOption(date('g', $this->i_timestamp));
         }
         # create label, and add controls
         $o_hour_label = new XhtmlElement('label', 'Hour');
         $o_hour_label->AddAttribute('for', $o_hour->GetXhtmlId());
         $o_hour_label->SetCssClass('aural');
         $this->AddControl($o_hour_label);
         $this->AddControl($o_hour);
         # create dropdown menu for minute
         $o_minute = new XhtmlSelect($this->GetXhtmlId() . '_minute', '', $this->b_page_valid);
         if (!$this->GetRequireTime()) {
             $o_minute->AddControl(new XhtmlOption());
         }
         for ($i = 0; $i <= 59; $i++) {
             if ($i % $this->i_minute_interval == 0) {
                 $s_minute = $i > 9 ? (string) $i : "0" . (string) $i;
                 $o_minute->AddControl(new XhtmlOption($s_minute, $s_minute));
             }
         }
         if ($this->i_timestamp != null and $this->b_time_known and !($this->b_page_valid === false)) {
             $o_minute->SelectOption(date('i', $this->i_timestamp));
         }
         # create label, and add controls
         $o_min_label = new XhtmlElement('label', 'Minutes');
         $o_min_label->AddAttribute('for', $o_minute->GetXhtmlId());
         $o_min_label->SetCssClass('aural');
         $this->AddControl($o_min_label);
         $this->AddControl($o_minute);
         # create dropdown menu for am/pm
         $o_ampm = new XhtmlSelect($this->GetXhtmlId() . '_ampm', '', $this->b_page_valid);
         if (!$this->GetRequireTime()) {
             $o_ampm->AddControl(new XhtmlOption());
         }
         $o_ampm->AddControl(new XhtmlOption('am', 'am'));
         $o_ampm->AddControl(new XhtmlOption('pm', 'pm'));
         if ($this->i_timestamp != null and $this->b_time_known and !($this->b_page_valid === false)) {
             $o_ampm->SelectOption(date('a', $this->i_timestamp));
         }
         # create label, and add controls
         $o_ampm_label = new XhtmlElement('label', 'AM or PM');
         $o_ampm_label->AddAttribute('for', $o_ampm->GetXhtmlId());
         $o_ampm_label->SetCssClass('aural');
         $this->AddControl($o_ampm_label);
         $this->AddControl($o_ampm);
         $this->AddControl('</span>');
     } else {
         $o_hour = new TextBox($this->GetXhtmlId() . '_hour');
         $o_hour->SetMode(TextBoxMode::Hidden());
         if ($this->b_time_known) {
             $o_hour->SetText(date('g', $this->i_timestamp));
         }
         $this->AddControl($o_hour);
         $o_minute = new TextBox($this->GetXhtmlId() . '_minute');
         $o_minute->SetMode(TextBoxMode::Hidden());
         if ($this->b_time_known) {
             $o_minute->SetText(date('i', $this->i_timestamp));
         }
         $this->AddControl($o_minute);
         $o_ampm = new TextBox($this->GetXhtmlId() . '_ampm');
         $o_ampm->SetMode(TextBoxMode::Hidden());
         if ($this->b_time_known) {
             $o_ampm->SetText(date('a', $this->i_timestamp));
         }
         $this->AddControl($o_ampm);
     }
 }
 private function CreateTeamLink(Team $team)
 {
     $span = new XhtmlElement('span');
     $span->AddAttribute("typeof", "schema:SportsTeam");
     $span->AddAttribute("about", $team->GetLinkedDataUri());
     $link = new XhtmlElement('a', Html::Encode($team->GetName()));
     $link->AddAttribute("property", "schema:name");
     $link->AddAttribute('href', $team->GetNavigateUrl());
     $link->AddAttribute("rel", "schema:url");
     $span->AddControl($link);
     return $span;
 }
 /**
  * Creates standard controls used by most data edit forms
  *
  */
 protected function OnPreRender()
 {
     require_once 'xhtml/forms/textbox.class.php';
     require_once 'xhtml/forms/checkbox.class.php';
     require_once 'xhtml/forms/xhtml-select.class.php';
     # add id
     if (is_object($this->o_data_object) and method_exists($this->o_data_object, 'GetId') and $this->o_data_object->GetId()) {
         $o_id_box = new TextBox($this->s_naming_prefix . 'item', (string) $this->o_data_object->GetId());
         $o_id_box->SetMode(TextBoxMode::Hidden());
         $this->AddControl($o_id_box);
     }
     # Add save button if building the form
     # Add at top of form to trap enter key
     if ($this->b_render_base_element) {
         $o_buttons = new XhtmlElement('div');
         $o_buttons->AddCssClass($this->show_buttons_at_top ? 'buttonGroup buttonGroupTop' : 'buttonGroup aural');
         $o_save = new XhtmlElement('input');
         $o_save->SetEmpty(true);
         $o_save->AddAttribute('type', 'submit');
         $o_save->SetXhtmlId($this->GetNamingPrefix() . 'DataEditSave');
         $o_save->AddAttribute('name', $o_save->GetXhtmlId());
         $o_buttons->AddControl($o_save);
         if ($this->show_buttons_at_top and $this->GetAllowCancel()) {
             require_once 'xhtml/forms/button.class.php';
             $o_buttons->AddControl(new Button($this->GetNamingPrefix() . 'DataEditCancel', 'Cancel'));
         }
         $this->AddControl($o_buttons);
     }
     # fire event for child class to create its controls
     $this->CreateControls();
     # Add a second save button
     if ($this->b_render_base_element) {
         $o_save->AddAttribute('value', $this->GetButtonText());
         # Allow button text to be set late
         $o_save2 = clone $o_save;
         $o_save2->SetXhtmlId($this->GetNamingPrefix() . 'DataEditSave2');
         $o_save2->AddAttribute('name', $o_save2->GetXhtmlId());
         $o_save2->AddCssClass('primary');
         $o_buttons2 = new XhtmlElement('div');
         $o_buttons2->SetCssClass('buttonGroup');
         $o_buttons2->AddControl($o_save2);
         if ($this->GetAllowCancel()) {
             if (!$this->show_buttons_at_top) {
                 require_once 'xhtml/forms/button.class.php';
             }
             $cancel = new Button($this->GetNamingPrefix() . 'DataEditCancel2', 'Cancel');
             $cancel->SetCssClass('cancel');
             $o_buttons2->AddControl($cancel);
         }
         $this->AddControl($o_buttons2);
     }
     # Add page number if it's not the default
     if ($this->current_page != 1) {
         $page = new TextBox($this->GetNamingPrefix() . 'Page', $this->GetCurrentPage(), $this->IsValidSubmit());
         $page->SetMode(TextBoxMode::Hidden());
         $this->AddControl($page);
     }
     # to be valid, should all be in a div
     $o_container = new XhtmlElement('div');
     $o_container->SetControls($this->GetControls());
     if (!$this->b_render_base_element) {
         $o_container->SetCssClass($this->GetCssClass());
         $o_container->SetXhtmlId($this->GetXhtmlId());
     }
     $a_controls = array();
     $a_controls[] = $o_container;
     $this->SetControls($a_controls);
 }