function OnPrePageLoad()
 {
     if ($this->page_not_found) {
         $this->SetPageTitle('Page not found');
         return;
     }
     $title = "Statistics for the " . $this->tournament->GetTitle() . ", " . Date::BritishDate($this->tournament->GetStartTime());
     $this->SetPageTitle($title);
     $this->SetContentConstraint(StoolballPage::ConstrainBox());
     $this->SetContentCssClass('stats');
 }
 /**
  * (non-PHPdoc)
  * @see data/DataManager#BuildItems($o_result)
  */
 public function BuildItems(MySqlRawData $result)
 {
     $this->Clear();
     while ($o_row = $result->fetch()) {
         $o_sub = new Subscription($this->GetSettings());
         $o_sub->SetType($o_row->item_type);
         $o_sub->SetSubscribeDate($o_row->date_changed);
         $o_sub->SetSubscribedItemId($o_row->item_id);
         switch ($o_sub->GetType()) {
             case ContentType::STOOLBALL_MATCH:
                 $o_sub->SetTitle($o_row->match_title);
                 $o_sub->SetContentDate(Date::BritishDate($o_row->start_time));
                 $o_sub->SetSubscribedItemUrl($o_row->short_url);
                 break;
         }
         $this->Add($o_sub);
     }
 }
 function OnPrePageLoad()
 {
     if ($this->page_not_found) {
         $this->SetPageTitle('Page not found');
         return;
     }
     $title = "Statistics for " . $this->match->GetTitle() . ", " . Date::BritishDate($this->match->GetStartTime(), false);
     $this->SetPageTitle($title);
     $this->SetContentConstraint(StoolballPage::ConstrainBox());
     if ($this->has_statistics) {
         $this->LoadClientScript("/scripts/lib/chart.min.js");
         $this->LoadClientScript("/scripts/chart.js?v=2");
         $this->LoadClientScript("/play/statistics/match.js");
         ?>
         <!--[if lte IE 8]><script src="/scripts/lib/excanvas.compiled.js"></script><![endif]-->
         <?php 
     }
 }
 public function OnPreRender()
 {
     $i = $this->first_result;
     $last_value = "";
     foreach ($this->bowling_data as $bowling) {
         $current_value = $bowling["wickets"] . "/" . $bowling["runs_conceded"];
         if ($current_value != $last_value) {
             # If 11th value is not same as 10th, stop. This can happen because DB query sees selects all performances with the same number of wickets as the tenth.
             if (!is_null($this->max_results) and $i > $this->max_results) {
                 break;
             }
             $pos = $i;
             $last_value = $current_value;
         } else {
             $pos = "=";
         }
         $i++;
         $position = new XhtmlCell(false, $pos);
         $position->SetCssClass("position");
         $player = new XhtmlCell(false, '<a property="schema:name" rel="schema:url" href="' . $bowling["player_url"] . '">' . $bowling["player_name"] . "</a>");
         $player->SetCssClass("player");
         $player->AddAttribute("typeof", "schema:Person");
         $player->AddAttribute("about", "http://www.stoolball.org.uk/id/player" . $bowling["player_url"]);
         if ($this->display_team) {
             $team = new XhtmlCell(false, $bowling["team_name"]);
             $team->SetCssClass("team");
         }
         $opposition = new XhtmlCell(false, $bowling["opposition_name"]);
         $opposition->SetCssClass("team");
         $date = new XhtmlCell(false, Date::BritishDate($bowling["match_time"], false, true, $this->display_team));
         $date->SetCssClass("date");
         $wickets = new XhtmlCell(false, $bowling["wickets"]);
         $wickets->SetCssClass("numeric");
         $runs = new XhtmlCell(false, $bowling["runs_conceded"]);
         $runs->SetCssClass("numeric");
         if ($this->display_team) {
             $row = new XhtmlRow(array($position, $player, $team, $opposition, $date, $wickets, $runs));
         } else {
             $row = new XhtmlRow(array($position, $player, $opposition, $date, $wickets, $runs));
         }
         $this->AddRow($row);
     }
     parent::OnPreRender();
 }
 public function OnPreRender()
 {
     $i = $this->first_result;
     $last_value = "";
     foreach ($this->batting_data as $batting) {
         $current_value = $batting["runs_scored"];
         $not_out = ($batting["how_out"] == Batting::NOT_OUT or $batting["how_out"] == Batting::RETIRED or $batting["how_out"] == Batting::RETIRED_HURT);
         if ($not_out) {
             $current_value .= "*";
         }
         if ($current_value != $last_value) {
             # If 11th value is not same as 10th, stop. This can happen because DB query sees 40* and 40 as equal, but they're not.
             if (!is_null($this->max_results) and $i > $this->max_results) {
                 break;
             }
             $pos = $i;
             $last_value = $current_value;
         } else {
             $pos = "=";
         }
         $i++;
         $position = new XhtmlCell(false, $pos);
         $position->SetCssClass("position");
         $player = new XhtmlCell(false, '<a property="schema:name" rel="schema:url" href="' . $batting["player_url"] . '">' . $batting["player_name"] . "</a>");
         $player->SetCssClass("player");
         $player->AddAttribute("typeof", "schema:Person");
         $player->AddAttribute("about", "http://www.stoolball.org.uk/id/player" . $batting["player_url"]);
         if ($this->display_team) {
             $team = new XhtmlCell(false, $batting["team_name"]);
             $team->SetCssClass("team");
         }
         $opposition = new XhtmlCell(false, $batting["opposition_name"]);
         $opposition->SetCssClass("team");
         $date = new XhtmlCell(false, Date::BritishDate($batting["match_time"], false, true, $this->display_team));
         $date->SetCssClass("date");
         $runs = new XhtmlCell(false, $current_value);
         $runs->SetCssClass("numeric");
         if (!$not_out) {
             $runs->AddCssClass("out");
         }
         $balls_faced = is_null($batting["balls_faced"]) ? "&#8211;" : '<span class="balls-faced">' . $batting["balls_faced"] . '</span>';
         $balls = new XhtmlCell(false, $balls_faced);
         $balls->SetCssClass("numeric");
         if ($this->display_team) {
             $row = new XhtmlRow(array($position, $player, $team, $opposition, $date, $runs, $balls));
         } else {
             $row = new XhtmlRow(array($position, $player, $opposition, $date, $runs, $balls));
         }
         $this->AddRow($row);
     }
     parent::OnPreRender();
 }
 function OnPrePageLoad()
 {
     /* @var $match Match */
     # set page title
     if ($this->tournament instanceof Match) {
         $action = "Edit ";
         $this->SetPageTitle($action . $this->tournament->GetTitle() . ', ' . Date::BritishDate($this->tournament->GetStartTime()));
     } else {
         $this->SetPageTitle('Page not found');
     }
     $this->SetContentCssClass('matchEdit');
     $this->SetContentConstraint(StoolballPage::ConstrainText());
 }
 public function OnPrePageLoad()
 {
     /* @var $match Match */
     $this->SetContentConstraint(StoolballPage::ConstrainText());
     if ($this->page_not_found) {
         $this->SetPageTitle('Page not found');
         return;
         # Don't load any JS
     }
     # Set page title
     $edit_or_update = ($this->b_user_is_match_admin or $this->b_user_is_match_owner) ? "Edit" : "Update";
     if ($this->match->GetStartTime() > gmdate('U') and !$this->b_user_is_match_admin and !$this->b_user_is_match_owner) {
         $step = "";
         # definitely only this step because match in future and can't change date
     } else {
         $step = ", step 1 of 4";
     }
     $this->SetPageTitle("{$edit_or_update} " . $this->match->GetTitle() . ', ' . Date::BritishDate($this->match->GetStartTime()) . $step);
     # Load JavaScript
     if ($this->b_user_is_match_admin or $this->b_user_is_match_owner) {
         $this->LoadClientScript('/scripts/match-fixture-edit-control-5.js');
     }
     if ($this->b_user_is_match_admin) {
         $this->LoadClientScript('matchedit-admin-3.js', true);
     }
     $this->LoadClientScript('matchedit.js', true);
 }
 /**
  * If the tournament parameter is in the query string apply tournament filter
  * @param SiteSettings $settings
  * @param MySqlConnection $connection
  * @param StatisticsManager $statistics_manager
  */
 public static function ApplyTournamentFilter(SiteSettings $settings, MySqlConnection $connection, StatisticsManager $statistics_manager)
 {
     $filter = "";
     if (isset($_GET['tournament']) and is_numeric($_GET['tournament'])) {
         require_once 'stoolball/match-manager.class.php';
         $match_manager = new MatchManager($settings, $connection);
         $match_manager->ReadByMatchId(array($_GET['tournament']));
         $tournament = $match_manager->GetFirst();
         unset($match_manager);
         if (!is_null($tournament)) {
             $statistics_manager->FilterByTournament(array($tournament->GetId()));
             $filter = "in the " . $tournament->GetTitle() . " on " . Date::BritishDate($tournament->GetStartTime()) . " ";
         }
     }
     return $filter;
 }
 function OnPrePageLoad()
 {
     /* @var $match Match */
     # set page title
     if ($this->tournament instanceof Match) {
         $action = $this->adding ? "Add " : "Edit ";
         $this->SetPageTitle($action . $this->tournament->GetTitle() . ', ' . Date::BritishDate($this->tournament->GetStartTime()));
     } else {
         $this->SetPageTitle('Page not found');
     }
     $this->SetContentCssClass('matchEdit');
     $this->SetContentConstraint(StoolballPage::ConstrainText());
     $except = array();
     if ($this->tournament instanceof Match) {
         foreach ($this->tournament->GetAwayTeams() as $team) {
             $except[] = $team->GetId();
         }
     }
     $this->LoadClientScript("/scripts/lib/jquery-ui-1.8.11.custom.min.js");
     $this->LoadClientScript("/play/teams/suggest-teams.js.php?except=" . trim(implode(",", $except), ","));
     ?>
     <link rel="stylesheet" type="text/css" href="/css/custom-theme/jquery-ui-1.8.11.custom.css" media="all" />
     <?php 
 }
 /**
  * @return void
  * @desc Create DataValidator objects to validate the edit control
  */
 public function CreateValidators()
 {
     require_once 'data/validation/required-field-validator.class.php';
     require_once 'data/validation/numeric-validator.class.php';
     require_once 'data/validation/length-validator.class.php';
     $o_match = $this->GetDataObject();
     /* @var $o_match Match */
     $s_match_date = $this->GetShowDateInValidationErrors() ? ' for ' . Date::BritishDate($o_match->GetStartTime(), false) : '';
     $s_home_team = (is_object($o_match) and is_object($o_match->GetHomeTeam())) ? $o_match->GetHomeTeam()->GetName() : 'home team';
     $s_away_team = (is_object($o_match) and is_object($o_match->GetAwayTeam())) ? $o_match->GetAwayTeam()->GetName() : 'away team';
     $this->AddValidator(new NumericValidator($this->GetNamingPrefix() . 'HomeRuns', 'The ' . $s_home_team . ' score' . $s_match_date . ' should be a number. For example: \'5\', not \'five\'.'));
     $this->AddValidator(new NumericValidator($this->GetNamingPrefix() . 'HomeWickets', 'The ' . $s_home_team . ' wickets' . $s_match_date . ' should be a number. For example: \'5\', not \'five\'.'));
     $this->AddValidator(new NumericValidator($this->GetNamingPrefix() . 'AwayRuns', 'The ' . $s_away_team . ' score' . $s_match_date . ' should be a number. For example: \'5\', not \'five\'.'));
     $this->AddValidator(new NumericValidator($this->GetNamingPrefix() . 'AwayWickets', 'The ' . $s_away_team . ' wickets' . $s_match_date . ' should be a number. For example: \'5\', not \'five\'.'));
     $this->AddValidator(new NumericValidator($this->GetNamingPrefix() . 'Result', 'The result identifier' . $s_match_date . ' should be a number'));
 }
    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 OnPrePageLoad()
 {
     /* @var $match Match */
     # set page title
     if ($this->tournament instanceof Match) {
         $this->SetPageTitle('Edit ' . $this->tournament->GetTitle() . ', ' . Date::BritishDate($this->tournament->GetStartTime()));
     } else {
         $this->SetPageTitle('Page not found');
     }
     $this->SetContentCssClass('matchEdit');
     $this->SetContentConstraint(StoolballPage::ConstrainText());
     $this->LoadClientScript('/scripts/tournament-edit-control-3.js');
 }
 /**
  * @return string
  * @param int $i_utc_timestamp
  * @param bool $b_include_day_name
  * @param Refer to "this Sunday" rather than "Sunday 12 June" $b_relative_date
  * @param Use Jan, Feb etc rather than January, February etc $b_short_month
  * @desc Get a date in the format "10am, Sunday 1 January 2000"
  */
 public static function BritishDateAndTime($i_utc_timestamp, $b_include_day_name = true, $b_relative_date = true, $b_short_month = false)
 {
     return Date::Time($i_utc_timestamp) . Date::TimeDateSeparator($i_utc_timestamp) . Date::BritishDate($i_utc_timestamp, $b_include_day_name, $b_relative_date, $b_short_month);
 }
    public function OnPrePageLoad()
    {
        /* @var $match Match */
        #$this->SetContentConstraint(StoolballPage::ConstrainText());
        $this->SetContentCssClass('scorecardPage');
        $this->SetContentCssClass('scorecardPage');
        if ($this->page_not_found) {
            $this->SetPageTitle('Page not found');
            return;
            # Don't load any JS
        }
        # Set page title
        $edit_or_update = ($this->b_user_is_match_admin or $this->b_user_is_match_owner) ? "Edit" : "Update";
        $step = ", step " . $this->editor->GetCurrentPage() . " of 4";
        $this->SetPageTitle("{$edit_or_update} " . $this->match->GetTitle() . ', ' . Date::BritishDate($this->match->GetStartTime()) . $step);
        # Load JavaScript
        $autocomplete_team_ids = array();
        if ($this->match->GetHomeTeamId()) {
            $autocomplete_team_ids[] = $this->match->GetHomeTeamId();
        }
        if ($this->match->GetAwayTeamId()) {
            $autocomplete_team_ids[] = $this->match->GetAwayTeamId();
        }
        if (count($autocomplete_team_ids)) {
            $this->LoadClientScript("/scripts/lib/jquery-ui-1.8.11.custom.min.js");
            $this->LoadClientScript("/play/playersuggest.js.php?v=2&amp;team=" . implode(",", $autocomplete_team_ids));
            // . "&amp;time=" . time());
            ?>
<link rel="stylesheet" type="text/css" href="/css/custom-theme/jquery-ui-1.8.11.custom.css" media="all" />
			<?php 
        }
        $this->LoadClientScript('scorecard.js', true);
    }
 function GetSubscribeDateCell($o_sub)
 {
     $o_td = new XhtmlElement('td', Html::Encode(ucfirst(Date::BritishDate($o_sub->GetSubscribeDate()))));
     $o_td->SetCssClass('date');
     return $o_td;
 }
 private function BuildBowlingTimeline(array $bowling)
 {
     $data = "";
     $total_performances = count($bowling);
     $show_every_second_performance = $total_performances > $this->max_x_axis_scale_points;
     for ($i = 0; $i < $total_performances; $i++) {
         $performance = $bowling[$i];
         /* @var $performance Bowling */
         if (!$show_every_second_performance or $i % 2 === 0) {
             if (strlen($data)) {
                 $data .= ",";
             }
             $data .= '"' . Date::BritishDate($performance->GetMatch()->GetStartTime(), false, false, true) . '"';
         }
     }
     return $data;
 }
    public function OnLoadPageData()
    {
        $i_one_day = 86400;
        $i_start = gmdate('U') - $i_one_day * 1;
        # yesterday
        $i_end = gmdate('U') + $i_one_day * 365;
        # this year
        # Check for player type
        $player_type = null;
        if (isset($_GET['player']) and is_numeric($_GET['player'])) {
            $player_type = (int) $_GET['player'];
        }
        $a_player_types = is_null($player_type) ? null : array($player_type);
        if ($player_type == PlayerType::JUNIOR_MIXED) {
            $a_player_types[] = PlayerType::GIRLS;
            $a_player_types[] = PlayerType::BOYS;
        }
        $manager = new MatchManager($this->GetSettings(), $this->GetDataConnection());
        $manager->FilterByMatchType(array(MatchType::TOURNAMENT));
        $manager->FilterByPlayerType($a_player_types);
        $manager->FilterByDateStart($i_start);
        $manager->FilterByDateEnd($i_end);
        $manager->ReadMatchSummaries();
        $tournaments = $manager->GetItems();
        unset($manager);
        ?>
$(function()
{
	// Make the placeholder big enough for a map
	var mapControl = document.getElementById("map");
	mapControl.style.width = '100%';
	mapControl.style.height = '400px';

	// Create the map
	var myLatlng = new google.maps.LatLng(51.07064141136184, -0.31114161014556885); // Horsham
	var myOptions = {
		zoom : $(window).width() > 400 ? 9 : 8,
		center : myLatlng,
		mapTypeId : google.maps.MapTypeId.ROADMAP
	};
	var map = new google.maps.Map(mapControl, myOptions);
	var markers = [];
	var info;
<?php 
        # There might be multiple tournaments at one ground. Rearrange tournaments so that they're indexed by ground.
        $grounds = array();
        foreach ($tournaments as $tournament) {
            /* @var $tournament Match */
            $ground_id = $tournament->GetGroundId();
            if (!array_key_exists($ground_id, $grounds)) {
                $grounds[$ground_id] = array();
            }
            $grounds[$ground_id][] = $tournament;
        }
        foreach ($grounds as $tournaments) {
            /* @var $ground Ground */
            $ground = $tournaments[0]->GetGround();
            if (!is_object($ground) or !$ground->GetAddress()->GetLatitude() or !$ground->GetAddress()->GetLongitude()) {
                continue;
            }
            $content = "'<div class=\"map-info\">' +\n\t'<h2>" . str_replace("'", "\\'", $ground->GetNameAndTown()) . "</h2>";
            foreach ($tournaments as $tournament) {
                /* @var $tournament Match */
                $title = $tournament->GetTitle() . ", " . Date::BritishDate($tournament->GetStartTime(), false, true, false);
                $content .= '<p><a href="' . $tournament->GetNavigateUrl() . '">' . str_replace("'", "\\'", $title) . '</a></p>';
            }
            $content .= "</div>'";
            # And marker and click event to trigger info window. Wrap info window in function to isolate marker, otherwise the last marker
            # is always used for the position of the info window.
            echo "var marker = new google.maps.Marker({\n\t\t\tposition : new google.maps.LatLng(" . $ground->GetAddress()->GetLatitude() . "," . $ground->GetAddress()->GetLongitude() . "),\n\t\t\tshadow: Stoolball.Maps.WicketShadow(),\n\t\t\ticon: Stoolball.Maps.WicketIcon(),\n\t\t\ttitle : '" . str_replace("'", "\\'", $ground->GetNameAndTown()) . "'\n\t\t  });\n\t\t  markers.push(marker);\n\n\t\t  (function(marker){\n\t\t\t  google.maps.event.addListener(marker, 'click', function()\n\t\t\t  {\n\t\t\t  \tvar content = {$content};\n\t\t\t  \tif (!info) info = new google.maps.InfoWindow();\n\t\t\t  \tinfo.setContent(content);\n\t\t\t  \tinfo.open(map, marker);\n\t\t\t  });\n\t\t  })(marker);\n\t\t  ";
        }
        ?>
	var style = [{
        url: '/images/features/map-markers.gif',
        height: 67,
        width: 31,
        textColor: '#ffffff',
        textSize: 10
      }];
	var clusterer = new MarkerClusterer(map, markers, { 'gridSize': 30, styles: style });
});
<?php 
        exit;
    }
    /**
     * 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>');
    }
 public function OnPreRender()
 {
     $i = $this->first_result;
     $last_value = "";
     foreach ($this->performance_data as $performance) {
         $current_value = "";
         if (array_key_exists("runs_scored", $performance)) {
             $current_batting_value = $performance["runs_scored"];
             $not_out = ($performance["how_out"] == Batting::NOT_OUT or $performance["how_out"] == Batting::RETIRED or $performance["how_out"] == Batting::RETIRED_HURT);
             if ($not_out) {
                 $current_batting_value .= "*";
             }
             $current_value .= $current_batting_value;
         }
         if (array_key_exists("wickets", $performance)) {
             $current_bowling_value = $performance["wickets"] . "/" . $performance["runs_conceded"];
             $current_value .= $current_bowling_value;
         }
         if (array_key_exists("catches", $performance)) {
             $current_value .= $performance["catches"];
         }
         if (array_key_exists("run_outs", $performance)) {
             $current_value .= $performance["run_outs"];
         }
         if ($current_value != $last_value) {
             $pos = $i;
             $last_value = $current_value;
         } else {
             $pos = "=";
         }
         $i++;
         $fields = array();
         if ($this->show_position) {
             $position = new XhtmlCell(false, $pos);
             $position->SetCssClass("position");
             $fields[] = $position;
         }
         $player = new XhtmlCell(false, '<a property="schema:name" rel="schema:url" href="' . $performance["player_url"] . '">' . $performance["player_name"] . "</a>");
         $player->SetCssClass("player");
         $player->AddAttribute("typeof", "schema:Person");
         $player->AddAttribute("about", "http://www.stoolball.org.uk/id/player" . $performance["player_url"]);
         $fields[] = $player;
         $match = new XhtmlCell(false, '<a property="schema:name" rel="schema:url" href="' . $performance["match_url"] . '">' . $performance["match_title"] . "</a>");
         $match->AddAttribute("typeof", "schema:SportsEvent");
         $match->AddAttribute("about", "https://www.stoolball.org.uk/id/match" . $performance["match_url"]);
         $match->SetCssClass("match");
         $fields[] = $match;
         $date = new XhtmlCell(false, Date::BritishDate($performance["match_time"], false, true, true));
         $date->SetCssClass("date");
         $fields[] = $date;
         if (array_key_exists("runs_scored", $performance)) {
             $runs = new XhtmlCell(false, $current_batting_value == "" ? "&#8211;" : $current_batting_value);
             $runs->SetCssClass("numeric");
             if (!$not_out) {
                 $runs->AddCssClass("out");
             }
             $fields[] = $runs;
         }
         if (array_key_exists("wickets", $performance)) {
             $bowling = new XhtmlCell(false, $current_bowling_value == "/" ? "&#8211;" : $current_bowling_value);
             $bowling->SetCssClass("numeric");
             $fields[] = $bowling;
         }
         if (array_key_exists("catches", $performance)) {
             $catches = new XhtmlCell(false, $performance["catches"] == "0" ? "&#8211;" : $performance["catches"]);
             $catches->SetCssClass("numeric");
             $fields[] = $catches;
         }
         if (array_key_exists("run_outs", $performance)) {
             $runouts = new XhtmlCell(false, $performance["run_outs"] == "0" ? "&#8211;" : $performance["run_outs"]);
             $runouts->SetCssClass("numeric");
             $fields[] = $runouts;
         }
         $row = new XhtmlRow($fields);
         $this->AddRow($row);
     }
     parent::OnPreRender();
 }
 /**
  * Gets the match start time as an English string in the format 10am, Monday 1 January 2000
  *
  * @param Include name of day before the date $b_include_day_name
  * @param Refer to "this Sunday" rather than "Sunday 12 June" $b_relative_date
  * @param $abbreviate_where_possible
  * @return string
  */
 public function GetStartTimeFormatted($b_include_day_name = true, $b_relative_date = true, $abbreviate_where_possible = false)
 {
     if ($this->GetIsStartTimeKnown()) {
         return Date::BritishDateAndTime($this->GetStartTime(), $b_include_day_name, $b_relative_date, $abbreviate_where_possible);
     } else {
         return Date::BritishDate($this->GetStartTime(), $b_include_day_name, $b_relative_date, $abbreviate_where_possible);
     }
 }
 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";
     }
 }