function OnPageLoad()
    {
        ?>
<h1>Manage roles</h1>
<table>
    <thead><tr><th>Role</th><th>Action</th></tr></thead>
    <tbody>
	<?php 
        foreach ($this->roles as $role) {
            ?>
		<tr>
		    <td><a href="role.php?item=<?php 
            echo Html::Encode($role->getRoleId());
            ?>
"><?php 
            echo Html::Encode($role->getRoleName());
            ?>
</a></td>
		    <td><a href="roledelete.php?item=<?php 
            echo Html::Encode($role->getRoleId());
            ?>
">Delete</a></td>
		</tr>
		<?php 
        }
        ?>
	</tbody>
</table>
<?php 
        $this->AddSeparator();
        require_once 'stoolball/user-edit-panel.class.php';
        $panel = new UserEditPanel($this->GetSettings(), '');
        $panel->AddLink('add a role', 'role.php');
        echo $panel;
    }
    function OnPageLoad()
    {
        if (is_object($this->data_object)) {
            echo new XhtmlElement('h1', Html::Encode('Delete role: ' . $this->data_object->getRoleName()));
        } else {
            echo new XhtmlElement('h1', 'Delete role');
            $this->deleted = true;
        }
        if ($this->deleted) {
            ?>
			<p>The role has been deleted.</p>
			<p><a href="roles.php">View all roles</a></p>
			<?php 
        } else {
            ?>
				<p>Deleting a role cannot be undone.</p>
				<p>Are you sure you want to delete this role?</p>
				<form method="post" class="deleteButtons">
				<div>
				<input type="submit" value="Delete role" name="delete" />
				<input type="submit" value="Cancel" name="cancel" />
				</div>
				</form>
				<?php 
            $this->AddSeparator();
            require_once 'stoolball/user-edit-panel.class.php';
            $panel = new UserEditPanel($this->GetSettings(), 'this role');
            $panel->AddLink('edit this role', "role.php?item=" . $this->data_object->getRoleId());
            echo $panel;
        }
    }
 function OnPageLoad()
 {
     echo new XhtmlElement('h1', Html::Encode($this->GetPageTitle()));
     echo new CategoryTreeControl($this->GetCategories());
     $this->AddSeparator();
     require_once "stoolball/user-edit-panel.class.php";
     $panel = new UserEditPanel($this->GetSettings());
     $panel->AddLink("add a category", "categoryedit.php");
     echo $panel;
 }
 function OnPageLoad()
 {
     echo new XhtmlElement('h1', Html::Encode($this->GetPageTitle()));
     echo new ClubListControl($this->a_clubs);
     if (AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_TEAMS)) {
         require_once "stoolball/user-edit-panel.class.php";
         $this->AddSeparator();
         $panel = new UserEditPanel($this->GetSettings(), "clubs and schools");
         $panel->AddLink("add a club or school", "/play/clubs/clubedit.php");
         echo $panel;
     }
 }
 function OnPageLoad()
 {
     echo new XhtmlElement('h1', htmlentities($this->GetPageTitle(), ENT_QUOTES, "UTF-8", false));
     echo new XhtmlElement('div', $this->content, "play");
     $this->ShowSocialAccounts();
     if (AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_COMPETITIONS)) {
         $this->AddSeparator();
         require_once 'stoolball/user-edit-panel.class.php';
         $panel = new UserEditPanel($this->GetSettings(), '');
         $panel->AddLink('add a competition', '/play/competitions/competitionedit.php');
         echo $panel;
     }
 }
 function OnPageLoad()
 {
     echo new XhtmlElement('h1', Html::Encode($this->GetPageTitle()));
     # display the category
     $o_category = is_object($this->o_category) ? $this->o_category : new Category();
     $this->o_edit->SetDataObject($o_category);
     echo $this->o_edit;
     if ($this->o_category instanceof Category) {
         $this->AddSeparator();
         require_once "stoolball/user-edit-panel.class.php";
         $panel = new UserEditPanel($this->GetSettings(), "this category");
         $panel->AddLink("delete this category", $this->o_category->GetDeleteCategoryUrl());
         echo $panel;
     }
 }
 /**
  * Creates a TeamEditPanel
  *
  * @param SiteSettings $settings
  * @param Team $team
  * @param Season[] $seasons
  * @param Match[] $matches
  */
 public function __construct(SiteSettings $settings, Team $team, $seasons, $matches)
 {
     parent::__construct($settings, " this team");
     $is_one_time_team = $team->GetTeamType() == Team::ONCE;
     if (!$is_one_time_team) {
         $this->AddLink('tell us about your team', $settings->GetUrl('TeamAdd'));
     }
     if (AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_TEAMS, $team->GetLinkedDataUri())) {
         $this->AddLink('edit this team', $team->GetEditTeamUrl());
     }
     if (AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_TEAMS)) {
         $this->AddLink('delete this team', $team->GetDeleteTeamUrl());
     }
     if (!$is_one_time_team) {
         $b_in_league = false;
         $b_in_cup = false;
         if (is_array($seasons)) {
             foreach ($seasons as $season) {
                 /* @var $season Season */
                 if (!$b_in_cup and $season->MatchTypes()->Contains(MatchType::CUP)) {
                     $b_in_cup = true;
                 }
                 if (!$b_in_league and $season->MatchTypes()->Contains(MatchType::LEAGUE)) {
                     $b_in_league = true;
                 }
                 if ($b_in_cup and $b_in_league) {
                     break;
                 }
             }
         }
         $this->AddLink('add practice', $team->GetAddMatchNavigateUrl(MatchType::PRACTICE));
         $this->AddLink('add friendly match', $team->GetAddMatchNavigateUrl(MatchType::FRIENDLY));
         $this->AddLink('add tournament', $team->GetAddMatchNavigateUrl(MatchType::TOURNAMENT));
         if ($b_in_league) {
             $this->AddLink('add league match', $team->GetAddMatchNavigateUrl(MatchType::LEAGUE));
         }
         if ($b_in_cup) {
             $this->AddLink('add cup match', $team->GetAddMatchNavigateUrl(MatchType::CUP));
         }
         if (is_array($matches) and count($matches)) {
             # Make sure there's at least one match which is not a tournament or a practice
             foreach ($matches as $o_match) {
                 /* @var $o_match Match */
                 if ($o_match->GetMatchType() == MatchType::PRACTICE or $o_match->GetMatchType() == MatchType::TOURNAMENT or $o_match->GetMatchType() == MatchType::TOURNAMENT_MATCH) {
                     continue;
                 } else {
                     $this->AddLink('update results', $team->GetResultsNavigateUrl());
                     break;
                 }
             }
             $this->AddLink('add matches to your calendar', $team->GetCalendarNavigateUrl());
         }
     }
 }
    function OnPageLoad()
    {
        if (!$this->player instanceof Player) {
            echo new XhtmlElement('h1', 'Player already deleted');
            echo new XhtmlElement('p', "The player you're trying to delete does not exist or has already been deleted.");
            return;
        }
        echo new XhtmlElement('h1', 'Delete player: <cite>' . Html::Encode($this->player->GetName()) . '</cite>');
        if ($this->player->GetPlayerRole() != Player::PLAYER) {
            ?>
Sorry, an extras player can't be deleted.<?php 
            return;
        }
        if ($this->b_deleted) {
            echo "<p>" . Html::Encode($this->player->GetName()) . "'s information has been deleted.</p>\n\t\t\t<p><a href=\"" . Html::Encode($this->player->Team()->GetPlayersNavigateUrl()) . "\">List players for " . Html::Encode($this->player->Team()->GetName()) . "</a></p>";
        } else {
            $has_permission = AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_PLAYERS);
            if ($has_permission) {
                $s_detail = $this->player->GetName() . " has ";
                switch ($this->player->GetTotalMatches()) {
                    case 0:
                        $s_detail .= "not played any matches";
                        break;
                    case 1:
                        $s_detail .= "played one match";
                        break;
                    default:
                        $s_detail .= "played " . $this->player->GetTotalMatches() . " matches";
                        break;
                }
                $s_detail .= " for " . $this->player->Team()->GetName() . '. ';
                echo new XhtmlElement('p', Html::Encode($s_detail));
                ?>
<p>Deleting a player cannot be undone. Their scores and performances
will be removed from all match scorecards and statistics.</p>
<p>Are you sure you want to delete this player?</p>
<form action="<?php 
                echo Html::Encode($this->player->GetDeleteUrl());
                ?>
" method="post"
	class="deleteButtons">
<div><input type="submit" value="Delete player" name="delete" /> <input
	type="submit" value="Cancel" name="cancel" /></div>
</form>
				<?php 
                $this->AddSeparator();
                require_once 'stoolball/user-edit-panel.class.php';
                $panel = new UserEditPanel($this->GetSettings(), $this->player->GetName());
                $panel->AddLink("view this player", $this->player->GetPlayerUrl());
                $panel->AddLink("rename this player", $this->player->GetEditUrl());
                echo $panel;
            } else {
                ?>
<p>Sorry, you can't delete a player unless you're responsible for
updating their team.</p>
<p><a href="<?php 
                echo Html::Encode($this->player->GetPlayerUrl());
                ?>
">Go back to <?php 
                echo Html::Encode($this->player->GetName());
                ?>
's
profile</a></p>
				<?php 
            }
        }
    }
    function OnPageLoad()
    {
        require_once 'xhtml/navigation/tabs.class.php';
        require_once 'stoolball/match-list-control.class.php';
        require_once 'stoolball/season-list-control.class.php';
        /* @var $season Season */
        $season = $this->competition->GetWorkingSeason();
        echo new XhtmlElement('h1', Html::Encode($this->season->GetCompetitionName()));
        $tabs = array('Summary' => '');
        if ($season->MatchTypes()->Contains(MatchType::LEAGUE)) {
            $tabs['Table'] = $season->GetTableUrl();
        }
        if (count($season->GetTeams())) {
            $tabs['Map'] = $season->GetMapUrl();
        }
        $tabs['Statistics'] = $season->GetStatisticsUrl();
        echo new Tabs($tabs);
        ?>

        <div class="box tab-box">
            <div class="dataFilter"></div>
            <div class="box-content">
  
        <?php 
        # Add intro
        if ($this->competition->GetIntro()) {
            $intro = htmlentities($this->competition->GetIntro(), ENT_QUOTES, "UTF-8", false);
            $intro = XhtmlMarkup::ApplyParagraphs($intro);
            $intro = XhtmlMarkup::ApplyLists($intro);
            $intro = XhtmlMarkup::ApplySimpleXhtmlTags($intro, false);
            $intro = XhtmlMarkup::ApplyLinks($intro);
            echo $intro;
        }
        # Add season intro
        if ($season->GetIntro()) {
            $intro = htmlentities($season->GetIntro(), ENT_QUOTES, "UTF-8", false);
            $intro = XhtmlMarkup::ApplyCharacterEntities($intro);
            $intro = XhtmlMarkup::ApplyParagraphs($intro);
            $intro = XhtmlMarkup::ApplyLinks($intro);
            $intro = XhtmlMarkup::ApplyLists($intro);
            $intro = XhtmlMarkup::ApplySimpleTags($intro);
            $intro = XhtmlMarkup::ApplyTables($intro);
            echo $intro;
        }
        # Add not active, if relevant
        if (!$this->competition->GetIsActive()) {
            echo new XhtmlElement('p', new XhtmlElement('strong', 'This competition isn\'t played any more.'));
        }
        # Add matches
        $a_matches = $season->GetMatches();
        $i_matches = count($a_matches);
        if ($i_matches > 0) {
            echo new XhtmlElement('h2', 'Matches in ' . htmlentities($season->GetName(), ENT_QUOTES, "UTF-8", false) . ' season');
            $o_matches = new MatchListControl($a_matches);
            if ($season->MatchTypes()->Contains(MatchType::LEAGUE)) {
                $o_matches->SetMatchTypesToLabel(array(MatchType::FRIENDLY, MatchType::CUP, MatchType::PRACTICE));
            } else {
                if ($season->MatchTypes()->Contains(MatchType::CUP)) {
                    $o_matches->SetMatchTypesToLabel(array(MatchType::FRIENDLY, MatchType::PRACTICE));
                } else {
                    $o_matches->SetMatchTypesToLabel(array(MatchType::PRACTICE));
                }
            }
            echo $o_matches;
        }
        # Add teams
        $a_teams = $season->GetTeams();
        if (count($a_teams) > 0) {
            require_once 'stoolball/team-list-control.class.php';
            echo new XhtmlElement('h2', 'Teams playing in ' . htmlentities($season->GetName(), ENT_QUOTES, "UTF-8", false) . ' season');
            echo new TeamListControl($a_teams);
        }
        # Add results
        if ($season->GetResults()) {
            $s_results = htmlentities($season->GetResults(), ENT_QUOTES, "UTF-8", false);
            $s_results = XhtmlMarkup::ApplyCharacterEntities($s_results);
            $s_results = XhtmlMarkup::ApplyParagraphs($s_results);
            $s_results = XhtmlMarkup::ApplyLinks($s_results);
            $s_results = XhtmlMarkup::ApplyLists($s_results);
            $s_results = XhtmlMarkup::ApplySimpleTags($s_results);
            $s_results = XhtmlMarkup::ApplyTables($s_results);
            echo $s_results;
        }
        # Add contact details
        $s_contact = $this->competition->GetContact();
        $s_website = $this->competition->GetWebsiteUrl();
        if ($s_contact or $s_website) {
            echo new XhtmlElement('h2', 'Contact details');
        }
        if ($s_contact) {
            $s_contact = htmlentities($s_contact, ENT_QUOTES, "UTF-8", false);
            $s_contact = XhtmlMarkup::ApplyCharacterEntities($s_contact);
            require_once 'email/email-address-protector.class.php';
            $protector = new EmailAddressProtector($this->GetSettings());
            $s_contact = $protector->ApplyEmailProtection($s_contact, AuthenticationManager::GetUser()->IsSignedIn());
            $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;
        }
        if ($s_website) {
            echo new XhtmlAnchor("Visit the " . htmlentities($this->competition->GetName(), ENT_QUOTES, "UTF-8", false) . ' website', $s_website);
        }
        # Check for other seasons. Check is >2 becuase current season is there twice - added above
        if (count($this->competition->GetSeasons()) > 2) {
            require_once "stoolball/season-list-control.class.php";
            echo new XhtmlElement('h2', 'Other seasons in the ' . htmlentities($this->competition->GetName(), ENT_QUOTES, "UTF-8", false), "screen");
            $season_list = new SeasonListControl($this->competition->GetSeasons());
            $season_list->SetExcludedSeasons(array($this->season));
            $season_list->AddCssClass("screen");
            echo $season_list;
        }
        ?>
        </div>
        </div>
        <?php 
        $this->ShowSocial();
        $this->AddSeparator();
        # Panel for updates
        $you_can = new UserEditPanel($this->GetSettings(), 'this season');
        $you_can->AddCssClass("with-tabs");
        if (AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_COMPETITIONS)) {
            $you_can->AddLink('edit this competition', $this->competition->GetEditCompetitionUrl());
            $you_can->AddLink('delete this competition', $this->competition->GetDeleteCompetitionUrl());
            $you_can->AddLink('edit this season', $this->season->GetEditSeasonUrl());
            # Only offer delete option if there's more than one season. Don't want to delete last season because
            # that leaves an empty competition which won't display. Instead, must delete whole competition with its one remaining season.
            if (count($this->competition->GetSeasons()) > 1) {
                $you_can->AddLink('delete this season', $this->season->GetDeleteSeasonUrl());
            }
        }
        foreach ($this->season->MatchTypes() as $i_type) {
            if ($i_type != MatchType::PRACTICE and $i_type != MatchType::TOURNAMENT_MATCH) {
                $you_can->AddLink('add a ' . MatchType::Text($i_type), $this->season->GetNewMatchNavigateUrl($i_type));
            }
        }
        if (count($this->season->GetMatches())) {
            # Make sure there's at least one match which is not a tournament or a practice
            foreach ($this->season->GetMatches() as $o_match) {
                /* @var $o_match Match */
                if ($o_match->GetMatchType() == MatchType::PRACTICE or $o_match->GetMatchType() == MatchType::TOURNAMENT or $o_match->GetMatchType() == MatchType::TOURNAMENT_MATCH) {
                    continue;
                } else {
                    $you_can->AddLink('update results', $this->season->GetResultsNavigateUrl());
                    break;
                }
            }
            $you_can->AddLink('add matches to your calendar', $this->season->GetCalendarNavigateUrl());
        }
        echo $you_can;
        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, $this->season->GetName() . " season");
        }
    }
    function OnPageLoad()
    {
        echo new XhtmlElement('h1', 'Delete team: ' . htmlentities($this->data_object->GetName(), ENT_QUOTES, "UTF-8", false));
        if ($this->deleted) {
            ?>
			<p>The team has been deleted.</p>
			<p><a href="/teams">View all teams</a></p>
			<?php 
        } else {
            if ($this->has_permission) {
                ?>
				<p>Deleting a team cannot be undone. All players will be deleted, and the team will be removed from existing matches.</p>
				<p>Are you sure you want to delete this team?</p>
				<form action="<?php 
                echo htmlentities($this->data_object->GetDeleteTeamUrl(), ENT_QUOTES, "UTF-8", false);
                ?>
" method="post" class="deleteButtons">
				<div>
				<input type="submit" value="Delete team" name="delete" />
				<input type="submit" value="Cancel" name="cancel" />
				</div>
				</form>
				<?php 
                $this->AddSeparator();
                require_once 'stoolball/user-edit-panel.class.php';
                $panel = new UserEditPanel($this->GetSettings(), 'this team');
                $panel->AddLink('view this team', $this->data_object->GetNavigateUrl());
                $panel->AddLink('edit this team', $this->data_object->GetEditTeamUrl());
                echo $panel;
            } else {
                ?>
				<p>Sorry, you're not allowed to delete this team.</p>
				<p><a href="<?php 
                echo htmlentities($this->data_object->GetNavigateUrl(), ENT_QUOTES, "UTF-8", false);
                ?>
">Go back to the team</a></p>
				<?php 
            }
        }
    }
 public function OnPageLoad()
 {
     if ($this->not_found) {
         require_once $_SERVER['DOCUMENT_ROOT'] . "/wp-content/themes/stoolball/section-404.php";
         return;
     }
     if ($this->regenerating) {
         echo $this->regenerating_control;
         return;
     }
     # Container element for structured data
     echo '<div typeof="schema:Person" about="' . htmlentities($this->player->GetLinkedDataUri(), ENT_QUOTES, "UTF-8", false) . '">';
     $querystring = '?player=' . $this->player->GetId();
     if ($_SERVER["QUERY_STRING"]) {
         $querystring = htmlspecialchars('?' . $_SERVER["QUERY_STRING"]);
     }
     require_once "stoolball/statistics/player-summary-control.class.php";
     echo new \Stoolball\Statistics\PlayerSummaryControl($this->player, $this->filter, $this->filter_matched_nothing, $querystring);
     if ($this->player->GetPlayerRole() == Player::PLAYER) {
         require_once 'xhtml/navigation/tabs.class.php';
         $tabs = array('Batting' => $this->player->GetPlayerUrl(), 'Bowling and fielding' => '');
         echo new Tabs($tabs);
         ?>
         <div class="box tab-box">
             <div class="dataFilter"></div>
             <div class="box-content">
         <?php 
     }
     # Filter control
     echo $this->filter_control;
     if ($this->player->Bowling()->GetCount()) {
         //			echo "<h2>Bowling</h2>";
         # Overview table
         $bowling_table = new XhtmlTable();
         $bowling_table->SetCssClass("numeric");
         $bowling_table->SetCaption("Bowling");
         $bowling_heading_row = new XhtmlRow(array('<abbr title="Innings" class="small">Inn</abbr><span class="large">Innings</span>', '<abbr title="Overs" class="small">Ov</abbr><span class="large">Overs</span>', '<abbr title="Maiden overs" class="small">Md</abbr><abbr title="Maiden overs" class="large">Mdns</abbr>', "Runs", '<abbr title="Wickets" class="small">Wk</abbr><abbr title="Wickets" class="large">Wkts</abbr>', "Best", '<abbr title="Economy" class="small">Econ</abbr><span class="large">Economy</span>', '<abbr title="Average" class="small">Avg</abbr><span class="large">Average</span>', '<abbr title="Strike rate" class="small">S/R</abbr><span class="large">Strike rate</span>', '<abbr title="5 wickets" class="small">5 wk</abbr><abbr title="5 wickets" class="large">5 wkts</abbr>'));
         $bowling_heading_row->SetIsHeader(true);
         $bowling_table->AddRow($bowling_heading_row);
         $bowling_table->AddRow(new XhtmlRow(array($this->player->BowlingInnings(), $this->player->Overs(), $this->player->MaidenOvers(), $this->player->RunsAgainst(), $this->player->WicketsTaken(), is_null($this->player->BestBowling()) ? "&#8211;" : $this->player->BestBowling(), is_null($this->player->BowlingEconomy()) ? "&#8211;" : $this->player->BowlingEconomy(), is_null($this->player->BowlingAverage()) ? "&#8211;" : $this->player->BowlingAverage(), is_null($this->player->BowlingStrikeRate()) ? "&#8211;" : $this->player->BowlingStrikeRate(), $this->player->FiveWicketHauls())));
         echo $bowling_table;
         echo '<p class="statsViewAll"><a href="/play/statistics/bowling-performances' . $querystring . '">Bowling performances &#8211; view all and filter</a></p>';
     }
     ?>
     <span class="chart-js-template" id="economy-chart"></span>
     <span class="chart-js-template" id="bowling-average-chart"></span>
     <span class="chart-js-template" id="wickets-chart"></span>
     <?php 
     # Fielding
     $catches = $this->player->GetCatches();
     $run_outs = $this->player->GetRunOuts();
     if ($catches or $run_outs) {
         $fielding_table = new XhtmlTable();
         $fielding_table->SetCssClass("numeric");
         $fielding_table->SetCaption("Fielding");
         $fielding_heading_row = new XhtmlRow(array('Catches', "Run-outs"));
         $fielding_heading_row->SetIsHeader(true);
         $fielding_table->AddRow($fielding_heading_row);
         $fielding_table->AddRow(new XhtmlRow(array($catches, $run_outs)));
         echo $fielding_table;
     }
     $this->ShowSocial();
     if ($this->player->GetPlayerRole() == Player::PLAYER) {
         ?>
         </div>
         </div>
         <?php 
     }
     # End container for structured data
     echo "</div>";
     if ($this->player->GetPlayerRole() == Player::PLAYER) {
         $has_permission = AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_TEAMS, $this->player->Team()->GetLinkedDataUri());
         $has_admin_permission = AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_PLAYERS);
         if ($has_permission) {
             $this->AddSeparator();
             $panel = new UserEditPanel($this->GetSettings());
             $panel->AddLink("rename this player", $this->player->GetEditUrl());
             if ($has_admin_permission) {
                 $panel->AddLink("delete this player", $this->player->GetDeleteUrl());
             }
             echo $panel;
         }
     }
 }
    function OnPageLoad()
    {
        echo new XhtmlElement('h1', Html::Encode($this->club->GetName()));
        $a_teams = $this->club->GetItems();
        if (count($a_teams) > 0) {
            echo new TeamListControl($a_teams);
        }
        if ($this->club->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 
        }
        $has_facebook_group_url = ($this->club->GetFacebookUrl() and strpos($this->club->GetFacebookUrl(), '/groups/') !== false);
        $has_facebook_page_url = ($this->club->GetFacebookUrl() and !$has_facebook_group_url);
        if ($has_facebook_page_url) {
            $this->ShowFacebookPage($this->club->GetFacebookUrl(), $this->club->GetName());
        }
        if ($has_facebook_group_url or $this->club->GetTwitterAccount() or $this->club->GetInstagramAccount()) {
            ?>
            <div class="social screen">
            <?php 
            if ($has_facebook_group_url) {
                ?>
                <a href="<?php 
                echo Html::Encode($this->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 ($this->club->GetTwitterAccount()) {
                ?>
                <a href="https://twitter.com/<?php 
                echo Html::Encode(substr($this->club->GetTwitterAccount(), 1));
                ?>
" class="twitter-follow-button">Follow <?php 
                echo Html::Encode($this->club->GetTwitterAccount());
                ?>
</a>
                <script src="https://platform.twitter.com/widgets.js"></script>
            <?php 
            }
            if ($this->club->GetInstagramAccount()) {
                ?>
                <a href="https://www.instagram.com/<?php 
                echo Html::Encode(trim($this->club->GetInstagramAccount(), '@'));
                ?>
/?ref=badge" class="instagram"><img src="//badges.instagram.com/static/images/ig-badge-view-24.png" alt="Instagram" /></a>
                <?php 
            }
            ?>
            </div>
            <?php 
        }
        $can_edit = AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_TEAMS);
        if ($can_edit or $has_facebook_page_url) {
            $this->AddSeparator();
        }
        if ($can_edit) {
            $club_or_school = $this->club->GetTypeOfClub() == Club::SCHOOL ? "school" : "club";
            require_once 'stoolball/user-edit-panel.class.php';
            $panel = new UserEditPanel($this->GetSettings(), "this {$club_or_school}");
            $panel->AddLink("edit this {$club_or_school}", $this->club->GetEditClubUrl());
            if ($this->club->GetTypeOfClub() == Club::SCHOOL) {
                $panel->AddLink("edit this school as a club", $this->club->GetEditClubUrl() . "/club");
            }
            $panel->AddLink("delete this {$club_or_school}", $this->club->GetDeleteClubUrl());
            echo $panel;
        }
        parent::OnPageLoad();
    }
    function OnPageLoad()
    {
        if (!$this->match instanceof Match) {
            echo new XhtmlElement('h1', ucfirst($this->match_or_tournament) . ' already deleted');
            echo new XhtmlElement('p', "The " . $this->match_or_tournament . " you're trying to delete does not exist or has already been deleted.");
            return;
        }
        echo new XhtmlElement('h1', 'Delete ' . $this->match_or_tournament . ': <cite>' . htmlentities($this->match->GetTitle(), ENT_QUOTES, "UTF-8", false) . '</cite>');
        if ($this->b_deleted) {
            ?>
			<p>The <?php 
            echo $this->match_or_tournament;
            ?>
 has been deleted.</p>
			<?php 
            if ($this->match->GetTournament() instanceof Match) {
                echo '<p><a href="' . htmlentities($this->match->GetTournament()->GetNavigateUrl(), ENT_QUOTES, "UTF-8", false) . '">Go to ' . htmlentities($this->match->GetTournament()->GetTitle(), ENT_QUOTES, "UTF-8", false) . '</a></p>';
            } else {
                if ($this->match->Seasons()->GetCount()) {
                    foreach ($this->match->Seasons() as $season) {
                        echo '<p><a href="' . htmlentities($season->GetNavigateUrl(), ENT_QUOTES, "UTF-8", false) . '">Go to ' . htmlentities($season->GetCompetitionName(), ENT_QUOTES, "UTF-8", false) . '</a></p>';
                    }
                } else {
                    echo '<p><a href="/matches/">View all matches</a></p>';
                }
            }
        } else {
            $has_permission = (AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_MATCHES) or AuthenticationManager::GetUser()->GetId() == $this->match->GetAddedBy()->GetId());
            if ($has_permission) {
                $s_detail = 'This is a ' . MatchType::Text($this->match->GetMatchType());
                $s_detail .= $this->match->GetIsStartTimeKnown() ? ' starting at ' : ' on ';
                $s_detail .= $this->match->GetStartTimeFormatted() . '. ';
                $s_context = '';
                if ($this->match->GetTournament() instanceof Match) {
                    $s_context = "It's in the " . $this->match->GetTournament()->GetTitle();
                }
                if ($this->match->Seasons()->GetCount()) {
                    $season = $this->match->Seasons()->GetFirst();
                    $b_the = !(stristr($season->GetCompetitionName(), 'the ') === 0);
                    $s_context .= $s_context ? ', in ' : 'It\'s in ';
                    $s_context .= $b_the ? 'the ' : '';
                    if ($this->match->Seasons()->GetCount() == 1) {
                        $s_context .= $season->GetCompetitionName() . '.';
                    } else {
                        $s_context .= 'following seasons: ';
                    }
                }
                $s_detail .= $s_context;
                echo new XhtmlElement('p', htmlentities($s_detail, ENT_QUOTES, "UTF-8", false));
                if ($this->match->Seasons()->GetCount() > 1) {
                    $seasons = new XhtmlElement('ul');
                    foreach ($this->match->Seasons() as $season) {
                        $seasons->AddControl(new XhtmlElement('li', htmlentities($season->GetCompetitionName(), ENT_QUOTES, "UTF-8", false)));
                    }
                    echo $seasons;
                }
                if ($this->match->GetMatchType() == MatchType::TOURNAMENT) {
                    ?>
					<p>Deleting a tournament cannot be undone.</p>
					<?php 
                } else {
                    ?>
					<p>Deleting a match cannot be undone. The match will be removed from all league tables and statistics.</p>
					<?php 
                }
                ?>
				<p>Are you sure you want to delete this <?php 
                echo $this->match_or_tournament;
                ?>
?</p>
				<form action="<?php 
                echo htmlentities($this->match->GetDeleteNavigateUrl(), ENT_QUOTES, "UTF-8", false);
                ?>
" method="post" class="deleteButtons">
				<div>
				<input type="submit" value="Delete <?php 
                echo $this->match_or_tournament;
                ?>
" name="delete" />
				<input type="submit" value="Cancel" name="cancel" />
				</div>
				</form>
				<?php 
                $this->AddSeparator();
                require_once 'stoolball/user-edit-panel.class.php';
                $panel = new UserEditPanel($this->GetSettings(), 'this ' . $this->match_or_tournament);
                $panel->AddLink('view this ' . $this->match_or_tournament, $this->match->GetNavigateUrl());
                $panel->AddLink('edit this ' . $this->match_or_tournament, $this->match->GetEditNavigateUrl());
                echo $panel;
            } else {
                ?>
				<p>Sorry, you can't delete a <?php 
                echo $this->match_or_tournament;
                ?>
 unless you added it.</p>
				<p><a href="<?php 
                echo htmlentities($this->match->GetNavigateUrl(), ENT_QUOTES, "UTF-8", false);
                ?>
">Go back to <?php 
                echo $this->match_or_tournament;
                ?>
</a></p>
				<?php 
            }
        }
    }
    function OnPageLoad()
    {
        echo new XhtmlElement('h1', Html::Encode('Delete season: ' . $this->data_object->GetCompetitionName()));
        if ($this->deleted) {
            ?>
			<p>The season has been deleted.</p>
			<p><a href="<?php 
            echo Html::Encode($this->data_object->GetCompetition()->GetNavigateUrl());
            ?>
">View <?php 
            echo Html::Encode($this->data_object->GetCompetition()->GetName());
            ?>
</a></p>
			<?php 
        } else {
            # Only offer delete option if there's more than one season. Don't want to delete last season because
            # that leaves an empty competition which won't display. Instead, must delete whole competition with its one remaining season.
            if ($this->has_permission and $this->seasons_in_competition > 1) {
                ?>
				<p>Deleting a season cannot be undone. Matches will not be deleted, but they will no longer be a part of this season.</p>
				<p>Are you sure you want to delete this season?</p>
				<form action="<?php 
                echo Html::Encode($this->data_object->GetDeleteSeasonUrl());
                ?>
" method="post" class="deleteButtons">
				<div>
				<input type="submit" value="Delete season" name="delete" />
				<input type="submit" value="Cancel" name="cancel" />
				</div>
				</form>
				<?php 
                $this->AddSeparator();
                require_once 'stoolball/user-edit-panel.class.php';
                $panel = new UserEditPanel($this->GetSettings(), 'this season');
                $panel->AddLink('view this season', $this->data_object->GetNavigateUrl());
                $panel->AddLink('edit this season', $this->data_object->GetEditSeasonUrl());
                echo $panel;
            } else {
                ?>
				<p>Sorry, you're not allowed to delete this season.</p>
				<p><a href="<?php 
                echo Html::Encode($this->data_object->GetNavigateUrl());
                ?>
">Go back to the season</a></p>
				<?php 
            }
        }
    }
    function OnPageLoad()
    {
        $is_tournament = $this->match->GetMatchType() == MatchType::TOURNAMENT;
        $class = $is_tournament ? "match" : "match vevent";
        ?>
        <div class="$class" typeof="schema:SportsEvent" about="<?php 
        echo Html::Encode($this->match->GetLinkedDataUri());
        ?>
">
        <?php 
        require_once 'xhtml/navigation/tabs.class.php';
        $tabs = array('Summary' => '');
        if ($is_tournament) {
            $tabs['Tournament statistics'] = $this->match->GetNavigateUrl() . '/statistics';
            # Make sure the reader knows this is a tournament, and the player type
            $says_tournament = strpos(strtolower($this->match->GetTitle()), 'tournament') !== false;
            $player_type = PlayerType::Text($this->match->GetPlayerType());
            $says_player_type = strpos(strtolower($this->match->GetTitle()), strtolower(rtrim($player_type, '\''))) !== false;
            $page_title = $this->match->GetTitle() . ", " . Date::BritishDate($this->match->GetStartTime(), false);
            if (!$says_tournament and !$says_player_type) {
                $page_title .= ' (' . $player_type . ' stoolball tournament)';
            } else {
                if (!$says_tournament) {
                    $page_title .= ' stoolball tournament';
                } else {
                    if (!$says_player_type) {
                        $page_title .= ' (' . $player_type . ')';
                    }
                }
            }
            $heading = new XhtmlElement('h1', $page_title);
            $heading->AddAttribute("property", "schema:name");
            echo $heading;
        } else {
            if ($this->match->GetMatchType() == MatchType::TOURNAMENT_MATCH) {
                $tabs['Match statistics'] = $this->match->GetNavigateUrl() . '/statistics';
                $tabs['Tournament statistics'] = $this->match->GetTournament()->GetNavigateUrl() . '/statistics';
                $page_title = $this->match->GetTitle() . " in the " . $this->match->GetTournament()->GetTitle();
            } else {
                $tabs['Statistics'] = $this->match->GetNavigateUrl() . '/statistics';
                $page_title = $this->match->GetTitle();
            }
            $o_title = new XhtmlElement('h1', Html::Encode($page_title));
            $o_title->AddAttribute("property", "schema:name");
            # hCalendar
            $o_title->SetCssClass('summary');
            $o_title_meta = new XhtmlElement('span', ' (stoolball)');
            $o_title_meta->SetCssClass('metadata');
            $o_title->AddControl($o_title_meta);
            if ($this->match->GetMatchType() !== MatchType::TOURNAMENT_MATCH) {
                $o_title->AddControl(", " . Date::BritishDate($this->match->GetStartTime(), false));
            }
            echo $o_title;
        }
        echo new Tabs($tabs);
        ?>
        <div class="box tab-box">
            <div class="dataFilter"></div>
            <div class="box-content">
        <?php 
        if ($is_tournament) {
            require_once 'stoolball/tournaments/tournament-control.class.php';
            echo new TournamentControl($this->GetSettings(), $this->match);
        } else {
            require_once 'stoolball/matches/match-control.class.php';
            echo new MatchControl($this->GetSettings(), $this->match);
        }
        $this->DisplayComments();
        $this->ShowSocial();
        ?>
            </div>
        </div>
        </div>
        <?php 
        $this->AddSeparator();
        # add/edit/delete options
        $user_is_admin = AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_MATCHES);
        $user_is_owner = AuthenticationManager::GetUser()->GetId() == $this->match->GetAddedBy()->GetId();
        $panel = new UserEditPanel($this->GetSettings(), 'this match');
        $panel->AddCssClass("with-tabs");
        if ($user_is_admin or $user_is_owner) {
            $link_text = $is_tournament ? 'tournament' : 'match';
            $panel->AddLink('edit this ' . $link_text, $this->match->GetEditNavigateUrl());
        } else {
            if ($this->match->GetMatchType() != MatchType::PRACTICE and !$is_tournament) {
                $panel->AddLink('update result', $this->match->GetEditNavigateUrl());
            }
        }
        if ($is_tournament) {
            $panel->AddCssClass("with-tabs");
            if ($user_is_admin or $user_is_owner) {
                $panel->AddLink('add or remove teams', $this->match->EditTournamentTeamsUrl());
            }
            $panel->AddLink('add or remove matches', $this->match->GetEditTournamentMatchesUrl());
            if (count($this->match->GetMatchesInTournament())) {
                $panel->AddLink('update results', $this->match->GetNavigateUrl() . "/matches/results");
            }
        }
        if ($user_is_admin or $user_is_owner) {
            if ($is_tournament) {
                $panel->AddLink('edit where to list this tournament', $this->match->EditTournamentCompetitionsUrl());
            }
            $link_text = $is_tournament ? 'tournament' : 'match';
            $panel->AddLink('delete this ' . $link_text, $this->match->GetDeleteNavigateUrl());
        }
        if ($this->match->GetMatchType() != MatchType::TOURNAMENT_MATCH and $this->match->GetStartTime() > time()) {
            $link_text = $is_tournament ? 'tournament' : 'match';
            $panel->AddLink("add {$link_text} to your calendar", $this->match->GetCalendarNavigateUrl());
        }
        echo $panel;
        if ($this->has_player_stats) {
            $tournament = $is_tournament ? $this->match : $this->match->GetTournament();
            require_once 'stoolball/statistics-highlight-table.class.php';
            echo new StatisticsHighlightTable($this->best_batting, $this->most_runs, $this->best_bowling, $this->most_wickets, $this->most_catches, "tournament");
            echo '<p class="playerSummaryMore"><a href="' . $tournament->GetNavigateUrl() . '/statistics">Tournament statistics</a></p>';
        }
    }
 function OnPageLoad()
 {
     if ($this->user instanceof User) {
         echo '<div typeof="sioc:UserAccount" about="' . Html::Encode($this->user->GetLinkedDataUri()) . '">';
         echo '<h1>' . Html::Encode($this->user->GetName()) . '</h1>';
         # table of personal info
         $o_table = new XhtmlElement('table');
         $o_table->SetCssClass('profile-info');
         $o_table->AddAttribute('summary', 'Personal information about ' . $this->user->GetName());
         $s_real_name = $this->user->GetRealName();
         if ($s_real_name and $s_real_name != $this->user->GetName()) {
             $o_tr = new XhtmlElement('tr');
             $o_tr->AddControl(new XhtmlElement('th', 'Real name'));
             $o_tr->AddControl(new XhtmlElement('td', Html::Encode($s_real_name)));
             $o_table->AddControl($o_tr);
         }
         if ($this->user->GetSignUpDate()) {
             $o_tr = new XhtmlElement('tr');
             $o_tr->AddControl(new XhtmlElement('th', 'Signed up'));
             $o_tr->AddControl(new XhtmlElement('td', Date::BritishDate($this->user->GetSignUpDate())));
             $o_table->AddControl($o_tr);
         }
         if ($this->user->GetGender()) {
             $o_tr = new XhtmlElement('tr');
             $o_tr->AddControl(new XhtmlElement('th', 'Gender'));
             $cell = new XhtmlElement('td', Html::Encode(ucfirst($this->user->GetGender())));
             $cell->AddAttribute("property", "gender");
             $o_tr->AddControl($cell);
             $o_table->AddControl($o_tr);
         }
         if ($this->user->GetOccupation()) {
             $o_tr = new XhtmlElement('tr');
             $o_tr->AddControl(new XhtmlElement('th', 'Occupation'));
             $o_tr->AddControl(new XhtmlElement('td', Html::Encode($this->user->GetOccupation())));
             $o_table->AddControl($o_tr);
         }
         if ($this->user->GetInterests()) {
             $o_tr = new XhtmlElement('tr');
             $o_tr->AddControl(new XhtmlElement('th', 'Interests'));
             $o_tr->AddControl(new XhtmlElement('td', $this->ApplyInterestsMarkup($this->user->GetInterests())));
             $o_table->AddControl($o_tr);
         }
         if ($this->user->GetLocation()) {
             $o_tr = new XhtmlElement('tr');
             $o_tr->AddControl(new XhtmlElement('th', 'Location'));
             $o_tr->AddControl(new XhtmlElement('td', Html::Encode($this->user->GetLocation())));
             $o_table->AddControl($o_tr);
         }
         echo $o_table;
         if (isset($this->a_messages) and is_array($this->a_messages) and count($this->a_messages)) {
             $s_count = count($this->a_messages) > 10 ? '10 newest of ' . $this->user->GetTotalMessages() . ' ' : '';
             echo new XhtmlElement('h2', Html::Encode($this->user->GetName() . "'s " . $s_count . 'comments'));
             $o_list = new XhtmlElement('ul');
             foreach ($this->a_messages as $o_message) {
                 $o_item = new XhtmlElement('li');
                 $subscribed_to = $o_message->GetReviewItem()->GetTitle();
                 if ($o_message->GetReviewItem() instanceof ReviewItem and $o_message->GetReviewItem()->GetNavigateUrl(true)) {
                     $subscribed_to = '<a typeof="sioc:Post" about="' . Html::Encode($o_message->MessageLinkedDataUri()) . '" href="' . Html::Encode($o_message->GetReviewItem()->GetNavigateUrl(true)) . '#message' . $o_message->GetId() . '">' . $subscribed_to . '</a>';
                 }
                 $o_item->AddControl($subscribed_to);
                 $o_item->AddControl('<div class="detail">Posted ' . Date::BritishDateAndTime($o_message->GetDate()) . '</div>');
                 $o_item->AddAttribute("rel", "sioc:creator_of");
                 $o_list->AddControl($o_item);
             }
             echo $o_list;
         }
         # End sioc:UserAccount entity
         echo '</div>';
         if (AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_USERS_AND_PERMISSIONS)) {
             $this->AddSeparator();
             require_once "stoolball/user-edit-panel.class.php";
             $panel = new UserEditPanel($this->GetSettings(), "this user");
             $panel->AddLink("edit this user", $this->user->GetEditUserUrl());
             echo $panel;
         }
     } else {
         require_once $_SERVER['DOCUMENT_ROOT'] . "/wp-content/themes/stoolball/section-404.php";
     }
 }
    function OnPageLoad()
    {
        echo new XhtmlElement('h1', Html::Encode('Delete ground: ' . $this->data_object->GetName()));
        if ($this->deleted) {
            ?>
<p>
	The ground has been deleted.
</p>
<p>
	<a href="/yesnosorry/groundlist.php">View all grounds</a>
</p>
<?php 
        } else {
            if ($this->has_permission) {
                ?>
<p>
	Deleting a ground cannot be undone. The ground will be removed from existing matches.
</p>
<p>
	Are you sure you want to delete this ground?
</p>
<form action="<?php 
                echo Html::Encode($this->data_object->GetDeleteGroundUrl());
                ?>
" method="post" class="deleteButtons">
	<div>
		<input type="submit" value="Delete ground" name="delete" />
		<input type="submit" value="Cancel" name="cancel" />
	</div>
</form>
<?php 
                $this->AddSeparator();
                require_once 'stoolball/user-edit-panel.class.php';
                $panel = new UserEditPanel($this->GetSettings(), 'this ground');
                $panel->AddLink('view this ground', $this->data_object->GetNavigateUrl());
                $panel->AddLink('edit this ground', $this->data_object->GetEditGroundUrl());
                echo $panel;
            } else {
                ?>
<p>
	Sorry, you're not allowed to delete this ground.
</p>
<p>
	<a href="<?php 
                echo Html::Encode($this->data_object->GetNavigateUrl());
                ?>
">Go back to the ground</a>
</p>
<?php 
            }
        }
    }
    function OnPageLoad()
    {
        echo new XhtmlElement('h1', htmlentities($this->GetPageTitle(), ENT_QUOTES, "UTF-8", false));
        ?>
        <div class="small">
        <?php 
        if (is_null($this->player_type) and !$this->administrative_area) {
            ?>
            <nav>
            <ul class="nav">
            	<li><a href="/teams/map">Map of stoolball teams</a></li>
            	<li><a href="/teams/mixed">Mixed teams</a></li>
            	<li><a href="/teams/ladies">Ladies' teams</a></li>
            	<li><a href="/teams/junior">Junior teams</a></li>
            	<li><a href="/teams/past">Past teams</a></li>
            	<li><a href="/play/manage/start-a-new-stoolball-team/">Start a team</a></li>
            	<li><a href="<?php 
            echo $this->GetSettings()->GetUrl('TeamAdd');
            ?>
">Tell us about your team</a></li>
            </ul>
            </nav>

    		 <?php 
        }
        $this->DisplayTeams();
        ?>
        </div>
        <?php 
        require_once 'xhtml/navigation/tabs.class.php';
        $tabs = array('List of teams' => '', 'Map of teams' => '/teams/map');
        echo new Tabs($tabs, 'large');
        ?>
        <div class="box tab-box large">
        <div class="dataFilter"><nav>
                        <?php 
        if ($this->administrative_area) {
            $total_teams = count($this->teams);
            $teams_text = $total_teams == 1 ? "team" : "teams";
            echo "<p class=\"total\">{$total_teams} {$teams_text}</p>";
        }
        ?>
            <p class="follow-on large">Show me:</p>
            <div class="multiple-filters follow-on">
                <ul class="first-filter">
                    <?php 
        $area = $this->administrative_area ? "/" . $this->administrative_area : "";
        echo $this->player_type === null ? '<li><em>Current teams</em></li>' : '<li><a href="/teams/all' . $area . '">Current teams</a></li>';
        echo $this->player_type === PlayerType::LADIES ? '<li><em>Ladies</em></li>' : '<li><a href="/teams/ladies' . $area . '">Ladies</a></li>';
        echo $this->player_type === PlayerType::MIXED ? '<li><em>Mixed</em></li>' : '<li><a href="/teams/mixed' . $area . '">Mixed</a></li>';
        echo $this->player_type === PlayerType::JUNIOR_MIXED ? '<li><em>Junior</em></li>' : '<li><a href="/teams/junior' . $area . '">Junior</a></li>';
        echo $this->player_type === 0 ? '<li><em>Past teams</em></li>' : '<li><a href="/teams/past' . $area . '">Past teams</a></li>';
        ?>
                </ul>
            <?php 
        $html = '<ul class="following-filter">';
        foreach ($this->areas as $area) {
            $area_url = preg_replace('/[^a-z]/', "", strtolower($area));
            if ($area_url == $this->administrative_area) {
                $html .= '<li><em>' . htmlentities($area, ENT_QUOTES, "UTF-8", false) . '</em></li>';
            } else {
                $html .= '<li><a href="/teams/' . (isset($_GET['player']) ? HTML::Encode(preg_replace('/[^a-z]/', "", $_GET['player'])) : "all") . '/' . $area_url . '">' . htmlentities($area, ENT_QUOTES, "UTF-8", false) . '</a></li>';
            }
        }
        $html .= "</ul>";
        echo $html;
        ?>
            </div>
            <p>Can't find it? <a href="<?php 
        echo $this->GetSettings()->GetUrl('TeamAdd');
        ?>
">Tell us about your team</a> 
                <span class="or">or</span> <a href="/play/manage/start-a-new-stoolball-team/">start a new team</a></p>
        </nav></div>

        <div class="box-content play">
        <?php 
        $this->DisplayTeams();
        ?>
        </div>
        </div>
        <?php 
        $add_teams = AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_TEAMS);
        $add_grounds = AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_GROUNDS);
        if ($add_teams or $add_grounds) {
            $this->AddSeparator();
            require_once 'stoolball/user-edit-panel.class.php';
            $panel = new UserEditPanel($this->GetSettings(), '');
            if ($add_teams) {
                $panel->AddLink('add a team', '/teams/add');
            }
            if ($add_grounds) {
                $panel->AddLink('add a ground', '/play/grounds/groundedit.php');
            }
            echo $panel;
        } else {
            $this->ShowSocialAccounts();
        }
    }
    function OnPageLoad()
    {
        echo new XhtmlElement('h1', Html::Encode('Delete club: ' . $this->data_object->GetName()));
        if ($this->deleted) {
            ?>
			<p>The club has been deleted.</p>
			<p><a href="/play/clubs/">View all clubs</a></p>
			<?php 
        } else {
            if ($this->has_permission) {
                ?>
				<p>Deleting a club cannot be undone.</p>
				<p>Are you sure you want to delete this club?</p>
				<form action="<?php 
                echo Html::Encode($this->data_object->GetDeleteClubUrl());
                ?>
" method="post" class="deleteButtons">
				<div>
				<input type="submit" value="Delete club" name="delete" />
				<input type="submit" value="Cancel" name="cancel" />
				</div>
				</form>
				<?php 
                $this->AddSeparator();
                require_once 'stoolball/user-edit-panel.class.php';
                $panel = new UserEditPanel($this->GetSettings(), 'this club');
                $panel->AddLink('view this club', $this->data_object->GetNavigateUrl());
                $panel->AddLink('edit this club', $this->data_object->GetEditClubUrl());
                echo $panel;
            } else {
                ?>
				<p>Sorry, you're not allowed to delete this club.</p>
				<p><a href="<?php 
                echo Html::Encode($this->data_object->GetNavigateUrl());
                ?>
">Go back to the club</a></p>
				<?php 
            }
        }
    }
 public function OnPageLoad()
 {
     if ($this->not_found) {
         require_once $_SERVER['DOCUMENT_ROOT'] . "/wp-content/themes/stoolball/section-404.php";
         return;
     }
     if ($this->regenerating) {
         echo $this->regenerating_control;
         return;
     }
     # Container element for structured data
     echo '<div typeof="schema:Person" about="' . htmlentities($this->player->GetLinkedDataUri(), ENT_QUOTES, "UTF-8", false) . '">';
     $querystring = '?player=' . $this->player->GetId();
     if ($_SERVER["QUERY_STRING"]) {
         $querystring = htmlspecialchars('?' . $_SERVER["QUERY_STRING"]);
     }
     require_once "stoolball/statistics/player-summary-control.class.php";
     echo new \Stoolball\Statistics\PlayerSummaryControl($this->player, $this->filter, $this->filter_matched_nothing, $querystring);
     if ($this->player->GetPlayerRole() == Player::PLAYER) {
         require_once 'xhtml/navigation/tabs.class.php';
         $tabs = array('Batting' => '', 'Bowling and fielding' => $this->player->GetPlayerUrl() . '/bowling');
         echo new Tabs($tabs);
         ?>
         <div class="box tab-box">
             <div class="dataFilter"></div>
             <div class="box-content">
         <?php 
     }
     # Filter control
     echo $this->filter_control;
     # Batting stats
     if ($this->player->TotalBattingInnings()) {
         //echo "<h2>Batting</h2>";
         # Overview table
         $batting_table = new XhtmlTable();
         $batting_table->SetCssClass("numeric");
         $batting_table->SetCaption("Batting");
         $batting_heading_row = new XhtmlRow(array('<abbr title="Innings" class="small">Inn</abbr><span class="large">Innings</span>', "Not out", "Runs", "50s", "100s", "Best", '<abbr title="Average" class="small">Avg</abbr><span class="large">Average</span>', '<abbr title="Strike rate" class="small">S/R</abbr><span class="large">Strike rate</span>'));
         $batting_heading_row->SetIsHeader(true);
         $batting_table->AddRow($batting_heading_row);
         $batting_table->AddRow(new XhtmlRow(array($this->player->TotalBattingInnings(), $this->player->NotOuts(), $this->player->TotalRuns(), $this->player->Fifties(), $this->player->Centuries(), $this->player->BestBatting(), is_null($this->player->BattingAverage()) ? "&#8211;" : $this->player->BattingAverage(), is_null($this->player->BattingStrikeRate()) ? "&#8211;" : $this->player->BattingStrikeRate())));
         echo $batting_table;
         if ($this->player->TotalBattingInnings()) {
             echo '<p class="statsViewAll"><a href="/play/statistics/individual-scores' . $querystring . '">Individual scores &#8211; view all and filter</a></p>';
         }
         ?>
         <span class="chart-js-template" id="score-spread-chart"></span>
         <span class="chart-js-template" id="batting-form-chart"></span>
         <span class="chart-js-template" id="dismissals-chart"></span>
         <?php 
     }
     $this->ShowSocial();
     if ($this->player->GetPlayerRole() == Player::PLAYER) {
         ?>
         </div>
         </div>
         <?php 
     }
     # End container for structured data
     echo "</div>";
     if ($this->player->GetPlayerRole() == Player::PLAYER) {
         $has_permission = AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_TEAMS, $this->player->Team()->GetLinkedDataUri());
         $has_admin_permission = AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_PLAYERS);
         if ($has_permission) {
             $this->AddSeparator();
             $panel = new UserEditPanel($this->GetSettings());
             $panel->AddLink("rename this player", $this->player->GetEditUrl());
             if ($has_admin_permission) {
                 $panel->AddLink("delete this player", $this->player->GetDeleteUrl());
             }
             echo $panel;
         }
     }
 }
 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");
     }
 }
    public function OnPageLoad()
    {
        echo '<article typeof="schema:SportsTeam" about="' . htmlentities($this->team->GetLinkedDataUri(), ENT_QUOTES, "UTF-8", false) . '">';
        echo '<h1>Players for <span property="schema:name">' . htmlentities($this->team->GetName(), ENT_QUOTES, "UTF-8", false) . "</span></h1>";
        require_once 'xhtml/navigation/tabs.class.php';
        $tabs = array('Summary' => $this->team->GetNavigateUrl());
        $tabs['Players'] = '';
        $tabs['Statistics'] = $this->team->GetStatsNavigateUrl();
        echo new Tabs($tabs);
        ?>
        <div class="box tab-box">
            <div class="dataFilter"></div>
            <div class="box-content">
        <?php 
        if (count($this->players) > 4) {
            $threshold = (int) gmdate("Y") - 1;
            $list_open = false;
            echo '<div class="player-list">';
            foreach ($this->players as $player) {
                /* @var $player Player */
                if ($player->GetPlayerRole() == Player::PLAYER and (gmdate("Y", $player->GetLastPlayedDate()) >= $threshold or $player->GetLastPlayedDate() == 0)) {
                    if (!$list_open) {
                        echo '<h2>Current and recent players</h2><ol rel="schema:members">';
                        $list_open = true;
                    }
                    echo '<li typeof="schema:Person" about="' . htmlentities($player->GetLinkedDataUri(), ENT_QUOTES, "UTF-8", false) . '"><a property="schema:name" rel="schema:url" href="' . htmlentities($player->GetPlayerUrl(), ENT_QUOTES, "UTF-8", false) . '">' . htmlentities($player->GetName(), ENT_QUOTES, "UTF-8", false) . "</a></li>";
                }
            }
            if ($list_open) {
                echo "</ol>";
            }
            $list_open = false;
            foreach ($this->players as $player) {
                /* @var $player Player */
                if ($player->GetPlayerRole() == Player::PLAYER and gmdate("Y", $player->GetLastPlayedDate()) < $threshold and $player->GetLastPlayedDate() != 0) {
                    if (!$list_open) {
                        echo '<h2>Former players</h2><ol rel="schema:members">';
                        $list_open = true;
                    }
                    echo '<li typeof="schema:Person" about="' . htmlentities($player->GetLinkedDataUri(), ENT_QUOTES, "UTF-8", false) . '"><a property="schema:name" rel="schema:url" href="' . htmlentities($player->GetPlayerUrl(), ENT_QUOTES, "UTF-8", false) . '">' . htmlentities($player->GetName(), ENT_QUOTES, "UTF-8", false) . "</a></li>";
                }
            }
            if ($list_open) {
                echo "</ol>";
            }
            $list_open = false;
            foreach ($this->players as $player) {
                /* @var $player Player */
                if ($player->GetPlayerRole() != Player::PLAYER) {
                    if (!$list_open) {
                        echo "<h2>Extras</h2><ul>";
                        $list_open = true;
                    }
                    echo '<li><a href="' . htmlentities($player->GetPlayerUrl(), ENT_QUOTES, "UTF-8", false) . '">' . htmlentities($player->GetName(), ENT_QUOTES, "UTF-8", false) . "</a></li>";
                }
            }
            if ($list_open) {
                echo "</ul>";
            }
            echo "</div>";
        } else {
            ?>
<p>There aren't any player statistics for this team yet.</p>
<p>To find out how to add them, see <a href="/play/manage/website/matches-and-results-why-you-should-add-yours/">Matches and results &#8211; why you should add yours</a>.</p>
			<?php 
        }
        ?>
        </div>
        </div>
        </article>
        <?php 
        $this->AddSeparator();
        if (AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_TEAMS, $this->team->GetLinkedDataUri())) {
            # Create a panel with actions
            $panel = new UserEditPanel($this->GetSettings());
            $panel->AddCssClass("with-tabs");
            #$panel->AddLink("add a player", $this->team->GetPlayerAddNavigateUrl());
            echo $panel;
            $this->BuySomething();
        } else {
            echo '<div class="with-tabs">';
            $this->BuySomething();
            echo '</div>';
        }
    }