function OnPrePageLoad() { # set page title $this->SetPageTitle(is_object($this->ground) ? $this->ground->GetNameAndTown() . ': Edit stoolball ground' : 'New stoolball ground'); $this->LoadClientScript('/scripts/maps-3.js'); $this->LoadClientScript('/play/grounds/groundedit.js'); }
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() { $title = "Statistics at " . $this->ground->GetNameAndTown(); if ($this->season) { $title .= " in the {$this->season} season"; } echo "<h1>" . htmlentities($title, ENT_QUOTES, "UTF-8", false) . "</h1>"; # See what stats we've got available require_once "_summary-data-found.php"; require_once 'xhtml/navigation/tabs.class.php'; $tabs = array('Summary' => $this->ground->GetNavigateUrl(), 'Statistics' => ''); echo new Tabs($tabs); ?> <div class="box tab-box"> <div class="dataFilter"></div> <div class="box-content"> <?php if (!$has_player_stats) { $yet = $this->season ? "in the {$this->season} season yet" : "yet"; echo "<p>There aren't any statistics for " . htmlentities($this->ground->GetName() . ' ' . $yet, ENT_QUOTES, "UTF-8", false) . '.</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 - why you should add yours</a>.</p>'; } else { require_once "_summary-controls.php"; # Link to other seasons if (count($this->seasons_with_statistics) > 1) { echo new XhtmlElement('h2', 'More statistics for ' . htmlentities($this->ground->GetName(), ENT_QUOTES, "UTF-8", false)); echo '<ul class="season-list">'; if ($this->season) { echo "<li><a href=\"" . htmlentities($this->ground->GetStatsNavigateUrl(), ENT_QUOTES, "UTF-8", false) . "\">All seasons</a></li>"; } foreach ($this->seasons_with_statistics as $season) { $season_url = $season->GetStartYear(); if ($season->GetStartYear() != $season->GetEndYear()) { $season_url .= "-" . substr($season->GetEndYear(), 2, 2); } # Link to season if it's not the current season. Important to use !== because # we're comparing numeric strings and with != 2009-10 is equal to 2009 if (!isset($_GET['params']) or (string) $season_url !== (string) $_GET["params"]) { echo "<li><a href=\"" . htmlentities($this->ground->GetStatsNavigateUrl() . "/" . $season_url, ENT_QUOTES, "UTF-8", false) . "\">" . htmlentities($season->GetYears(), ENT_QUOTES, "UTF-8", false) . " season</a></li>"; } } echo "</ul>"; } } ?> </div> </div> <?php }
/** * @return void * @desc Re-build from data posted by this control the data object this control is editing */ function BuildPostedDataObject() { $o_ground = new Ground($this->GetSettings()); if (isset($_POST['item'])) { $o_ground->SetId($_POST['item']); } $o_ground->SetDirections($_POST['directions']); $o_ground->SetParking($_POST['parking']); $o_ground->SetFacilities($_POST['facilities']); $o_ground->SetAddress($this->o_address_edit->GetDataObject()); $o_ground->SetShortUrl($_POST[$this->GetNamingPrefix() . 'ShortUrl']); $this->SetDataObject($o_ground); }
/** * @return void * @desc Re-build from data posted by this control the data object this control is editing */ function BuildPostedDataObject() { $team = new Team($this->GetSettings()); if (isset($_POST['item'])) { $team->SetId($_POST['item']); } if (isset($_POST['name'])) { $team->SetName($_POST['name']); } $team->SetWebsiteUrl($_POST['websiteUrl']); $team->SetIsActive(isset($_POST['playing'])); $team->SetIntro(ucfirst(trim($_POST['intro']))); $team->SetPlayingTimes($_POST['times']); $team->SetCost($_POST['yearCost']); $team->SetContact($_POST['contact']); $team->SetPrivateContact($_POST['private']); $ground = new Ground($this->GetSettings()); $ground->SetId($_POST['ground']); $team->SetGround($ground); if (isset($_POST['team_type'])) { $team->SetTeamType($_POST['team_type']); if ($team->GetTeamType() == Team::SCHOOL_YEARS) { $team->SetSchoolYears(array(1 => isset($_POST['year1']), 2 => isset($_POST['year2']), 3 => isset($_POST['year3']), 4 => isset($_POST['year4']), 5 => isset($_POST['year5']), 6 => isset($_POST['year6']), 7 => isset($_POST['year7']), 8 => isset($_POST['year8']), 9 => isset($_POST['year9']), 10 => isset($_POST['year10']), 11 => isset($_POST['year11']), 12 => isset($_POST['year12']))); } } if ($this->is_admin) { $team->SetShortUrl($_POST[$this->GetNamingPrefix() . 'ShortUrl']); $team->SetPlayerType($_POST['playerType']); if (isset($_POST['club']) and is_numeric($_POST['club'])) { $club = new Club($this->GetSettings()); $club->SetId($_POST['club']); $team->SetClub($club); } } $this->SetDataObject($team); }
/** * Populates the collection of business objects from raw data * * @return bool * @param MySqlRawData $o_result */ protected function BuildItems(MySqlRawData $o_result) { # use CollectionBuilder to handle duplicates $o_ground_builder = new CollectionBuilder(); $o_ground = null; while ($row = $o_result->fetch()) { # check whether this is a new ground if (!$o_ground_builder->IsDone($row->ground_id)) { # store any exisiting ground if ($o_ground != null) { $this->Add($o_ground); } # create the new ground $o_ground = new Ground($this->o_settings); $o_ground->SetId($row->ground_id); $o_ground->SetDirections($row->directions); $o_ground->SetParking($row->parking); $o_ground->SetFacilities($row->facilities); $o_ground->SetShortUrl($row->short_url); $o_ground->SetDateUpdated($row->date_changed); if (isset($row->update_search) and $row->update_search == 1) { $o_ground->SetSearchUpdateRequired(); } $o_address = $o_ground->GetAddress(); $o_address->SetSaon($row->saon); $o_address->SetPaon($row->paon); $o_address->SetStreetDescriptor($row->street_descriptor); $o_address->SetLocality($row->locality); $o_address->SetTown($row->town); $o_address->SetAdministrativeArea($row->administrative_area); $o_address->SetPostcode($row->postcode); if (isset($row->latitude)) { $o_address->SetGeoLocation($row->latitude, $row->longitude, $row->geo_precision); } $o_ground->SetAddress($o_address); } if (isset($row->team_name)) { $team = new Team($this->GetSettings()); $team->SetName($row->team_name); $team->SetShortUrl($row->team_short_url); $team->SetPlayerType($row->player_type_id); $o_ground->Teams()->Add($team); } } # store final ground if ($o_ground != null) { $this->Add($o_ground); } }
/** * Helper to build ground for a match from raw data * * @param Match $o_match * @param DataRow $o_row */ private function BuildGround(Match $o_match, $o_row) { if (isset($o_row->ground_id)) { $o_ground = new Ground($this->GetSettings()); $o_ground->SetId($o_row->ground_id); if (isset($o_row->ground_short_url)) { $o_ground->SetShortUrl($o_row->ground_short_url); } if (isset($o_row->town)) { $o_addr = $o_ground->GetAddress(); $o_addr->SetSaon($o_row->saon); $o_addr->SetPaon($o_row->paon); if (isset($o_row->street_descriptor)) { $o_addr->SetStreetDescriptor($o_row->street_descriptor); } if (isset($o_row->locality)) { $o_addr->SetLocality($o_row->locality); } $o_addr->SetTown($o_row->town); if (isset($o_row->postcode)) { $o_addr->SetPostcode($o_row->postcode); } } if (isset($o_row->latitude)) { $o_addr->SetGeoLocation($o_row->latitude, $o_row->longitude, $o_row->geo_precision); } $o_match->SetGround($o_ground); unset($o_ground); } }
/** * Builds a match object containing the result information posted by the control * */ public function BuildPostedDataObject() { $o_match = new Match($this->GetSettings()); # Get match id $s_key = $this->GetNamingPrefix() . 'item'; if (isset($_POST[$s_key])) { $s_id = $_POST[$s_key]; if (strlen($s_id)) { $o_match->SetId($s_id); } } # Get the short URL $s_key = $this->GetNamingPrefix() . 'ShortUrl'; if (isset($_POST[$s_key])) { $o_match->SetShortUrl($_POST[$s_key]); } # Get the start date $s_key = $this->GetNamingPrefix() . 'Start'; $o_match->SetStartTime(DateControl::GetPostedTimestampUtc($s_key)); $o_match->SetIsStartTimeKnown(DateControl::GetIsTimePosted($s_key)); # Get the home team # Test for (int)$_POST[$s_key] deliberately excludes "Not known" value, which is 0 $o_home = new Team($this->GetSettings()); $s_key = $this->GetNamingPrefix() . 'Home'; if (isset($_POST[$s_key]) and strlen($_POST[$s_key]) and (int) $_POST[$s_key]) { $o_home->SetId($_POST[$s_key]); $o_match->SetHomeTeam($o_home); } # Get the away team # Test for (int)$_POST[$s_key] deliberately excludes "Not known" value, which is 0 $o_away = new Team($this->GetSettings()); $s_key = $this->GetNamingPrefix() . 'Away'; if (isset($_POST[$s_key]) and strlen($_POST[$s_key]) and (int) $_POST[$s_key]) { $o_away->SetId($_POST[$s_key]); $o_match->SetAwayTeam($o_away); } # Get the ground $s_key = $this->GetNamingPrefix() . 'Ground'; if (isset($_POST[$s_key]) and strlen($_POST[$s_key])) { $o_ground = new Ground($this->GetSettings()); $o_ground->SetId($_POST[$s_key]); $o_match->SetGround($o_ground); } # Get the notes $s_key = $this->GetNamingPrefix() . 'Notes'; if (isset($_POST[$s_key])) { $o_match->SetNotes($_POST[$s_key]); } # Get the match type $s_key = $this->GetNamingPrefix() . 'MatchType'; if (isset($_POST[$s_key]) and is_numeric($_POST[$s_key])) { $o_match->SetMatchType($_POST[$s_key]); } # Get the tournament if ($o_match->GetMatchType() == MatchType::TOURNAMENT_MATCH) { $s_key = $this->GetNamingPrefix() . 'Tournament'; if (isset($_POST[$s_key]) and is_numeric($_POST[$s_key])) { $tournament = new Match($this->GetSettings()); $tournament->SetMatchType(MatchType::TOURNAMENT); $tournament->SetId($_POST[$s_key]); $o_match->SetTournament($tournament); } } # Get the season $s_key = $this->GetNamingPrefix() . 'Season'; if (isset($_POST[$s_key]) and strlen($_POST[$s_key])) { $o_season = new Season($this->GetSettings()); $o_season->SetId($_POST[$s_key]); $o_match->Seasons()->Add($o_season); } $this->SetDataObject($o_match); }
/** * Display info * * @param float $time * @param int $memoryUsage */ protected static function measureInfo(float $time, int $memoryUsage) { $data = [$memoryUsage - static::$lastMemoryUsage, memory_get_peak_usage(), memory_get_peak_usage(true)]; echo Ground::debugText(vsprintf(static::MEASURE_FORMAT, array_merge([number_format(($time - static::$lastTime) * 1000, 4)], array_map('number_format', $data)))); }
public function __construct(Ground $ground) { $this->ground = $ground; $this->searchable = new SearchItem("ground", "ground" . $ground->GetId(), $ground->GetNavigateUrl(false), $ground->GetNameAndTown()); $this->searchable->Description($this->GetSearchDescription()); $this->searchable->WeightOfType(800); $keywords = array($ground->GetAddress()->GetLocality(), $ground->GetAddress()->GetTown()); $this->searchable->Keywords(implode(" ", $keywords)); $content = array($ground->GetAddress()->GetStreetDescriptor(), $ground->GetAddress()->GetAdministrativeArea(), $ground->GetDirections(), $ground->GetParking(), $ground->GetFacilities()); $this->searchable->FullText(implode(" ", $content)); $this->searchable->RelatedLinksHtml('<ul>' . '<li><a href="' . $ground->GetStatsNavigateUrl() . '">Statistics</a></li>' . '</ul>'); }
private function MarkerScript(Ground $ground, $content, $markersArrayName) { # 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. return "var marker = new google.maps.Marker({\r\n position : new google.maps.LatLng(" . $ground->GetAddress()->GetLatitude() . "," . $ground->GetAddress()->GetLongitude() . "),\r\n shadow: Stoolball.Maps.WicketShadow(),\r\n icon: Stoolball.Maps.WicketIcon(),\r\n title : '" . str_replace("'", "\\'", $ground->GetNameAndTown()) . "'\r\n });\r\n {$markersArrayName}.push(marker);\r\n\r\n (function(marker){\r\n google.maps.event.addListener(marker, 'click', function()\r\n {\r\n var content = {$content};\r\n if (!info) info = new google.maps.InfoWindow();\r\n info.setContent(content);\r\n info.open(map, marker);\r\n });\r\n })(marker);\r\n "; }
/** * Populates the collection of business objects from raw data * * @return bool * @param MySqlRawData $o_result */ protected function BuildItems(MySqlRawData $o_result) { /* @var $o_season Season */ $this->Clear(); # use CollectionBuilder to handle duplicates $o_season_builder = new CollectionBuilder(); $o_team_builder = new CollectionBuilder(); $o_rule_builder = new CollectionBuilder(); $o_points_builder = new CollectionBuilder(); $o_type_builder = new CollectionBuilder(); $o_season = null; while ($o_row = $o_result->fetch()) { # check whether this is a new season if (!$o_season_builder->IsDone($o_row->season_id)) { # store any exisiting season and reset if ($o_season != null) { $this->Add($o_season); $o_team_builder->Reset(); $o_rule_builder->Reset(); $o_points_builder->Reset(); $o_type_builder->Reset(); } # create the new season $o_season = new Season($this->GetSettings()); $this->BuildSeason($o_season, $o_row); } # Teams the first cause of multiple rows if (isset($o_row->team_id)) { if (!$o_team_builder->IsDone($o_row->team_id)) { if (isset($o_team)) { unset($o_team); } $o_team = new Team($this->GetSettings()); $o_team->SetId($o_row->team_id); $o_team->SetName($o_row->team_name); $ground = new Ground($this->GetSettings()); $ground->SetId($o_row->team_ground_id); $o_team->SetGround($ground); if (isset($o_row->team_short_url)) { $o_team->SetShortUrl($o_row->team_short_url); } $o_season->AddTeam($o_team); if (isset($o_row->withdrawn_league) and (bool) $o_row->withdrawn_league) { $o_season->TeamsWithdrawnFromLeague()->Add($o_team); } } # Points adjustments - should come with team and in order of team if (isset($o_row->point_id) and !$o_points_builder->IsDone($o_row->point_id)) { $o_point = new PointsAdjustment($o_row->point_id, $o_row->points, $o_team, $o_row->reason, $o_row->points_date); $o_season->PointsAdjustments()->Add($o_point); } } # Season rules if (isset($o_row->season_rule_id) and !$o_rule_builder->IsDone($o_row->season_rule_id)) { $o_mr = new MatchResult($o_row->match_result_id); $o_mr->SetHomePoints($o_row->home_points); $o_mr->SetAwayPoints($o_row->away_points); $o_season->PossibleResults()->Add($o_mr); unset($o_mr); } # Match types if (isset($o_row->season_match_type) and !$o_type_builder->IsDone($o_row->season_match_type)) { $o_season->MatchTypes()->Add((int) $o_row->season_match_type); } } # store final season if ($o_season != null) { $this->Add($o_season); } return true; }
/** * Populates the collection of business objects from raw data * * @return bool * @param MySqlRawData $o_result */ protected function BuildItems(MySqlRawData $o_result) { $this->Clear(); $o_match_builder = new CollectionBuilder(); $o_team_builder = new CollectionBuilder(); while ($o_row = $o_result->fetch()) { if (!$o_match_builder->IsDone($o_row->match_id)) { if (isset($o_match)) { $this->Add($o_match); $o_team_builder->Reset(); } # create new $o_match = new Match($this->GetSettings()); $o_match->SetId($o_row->match_id); if (isset($o_row->start_time)) { $o_match->SetStartTime($o_row->start_time); } if (isset($o_row->home_runs)) { $o_match->Result()->SetHomeRuns($o_row->home_runs); } if (isset($o_row->away_runs)) { $o_match->Result()->SetAwayRuns($o_row->away_runs); } if (isset($o_row->match_result_id)) { $o_match->Result()->SetResultType($o_row->match_result_id); } if (isset($o_row->home_team_id) and !is_null($o_row->home_team_id)) { $o_home = new Team($this->o_settings); $o_home->SetId($o_row->home_team_id); if (isset($o_row->home_team_name)) { $o_home->SetName($o_row->home_team_name); } if (isset($o_row->home_short_url)) { $o_home->SetShortUrl($o_row->home_short_url); } $o_match->SetHomeTeam($o_home); unset($o_home); } if (isset($o_row->ground_id)) { $o_ground = new Ground($this->GetSettings()); $o_ground->SetId($o_row->ground_id); $o_match->SetGround($o_ground); unset($o_ground); } } # Add away teams if (isset($o_row->away_team_id) && !$o_team_builder->IsDone($o_row->away_team_id)) { $o_away = new Team($this->o_settings); $o_away->SetId($o_row->away_team_id); if (isset($o_row->away_team_name)) { $o_away->SetName($o_row->away_team_name); } if (isset($o_row->away_short_url)) { $o_away->SetShortUrl($o_row->away_short_url); } $o_match->AddAwayTeam($o_away); unset($o_away); } } # Add final match if (isset($o_match)) { $this->Add($o_match); } return true; }
/** * Gets the format to use for a ground's short URLs * * @return ShortUrlFormat */ public function GetShortUrlFormat() { return Ground::GetShortUrlFormatForType($this->o_settings); }
/** * Builds a match object containing the result information posted by the control * */ public function BuildPostedDataObject() { $match = new Match($this->GetSettings()); $match->SetMatchType(MatchType::TOURNAMENT); # Get match id $s_key = $this->GetNamingPrefix() . 'item'; if (isset($_POST[$s_key])) { $s_id = $_POST[$s_key]; if (strlen($s_id)) { $match->SetId($s_id); } } # Get the title $s_key = $this->GetNamingPrefix() . 'Title'; if (isset($_POST[$s_key])) { $match->SetTitle(strip_tags($_POST[$s_key])); } # Get the qualification type $s_key = $this->GetNamingPrefix() . 'Qualify'; if (isset($_POST[$s_key])) { $match->SetQualificationType($_POST[$s_key]); } # Get the player type $s_key = $this->GetNamingPrefix() . 'PlayerType'; if (isset($_POST[$s_key])) { $match->SetPlayerType($_POST[$s_key]); } $s_key = $this->GetNamingPrefix() . "Players"; if (isset($_POST[$s_key]) and strlen($_POST[$s_key])) { $match->SetMaximumPlayersPerTeam($_POST[$s_key]); } # Get the number of overs $s_key = $this->GetNamingPrefix() . "Overs"; if (isset($_POST[$s_key]) and strlen($_POST[$s_key])) { $match->SetOvers($_POST[$s_key]); } # Get the short URL $s_key = $this->GetNamingPrefix() . 'ShortUrl'; if (isset($_POST[$s_key])) { $match->SetShortUrl($_POST[$s_key]); } # Get the start date $s_key = $this->GetNamingPrefix() . 'Start'; $match->SetStartTime(DateControl::GetPostedTimestampUtc($s_key)); $match->SetIsStartTimeKnown(DateControl::GetIsTimePosted($s_key)); # Get the initial team $team = new Team($this->GetSettings()); $s_key = $this->GetNamingPrefix() . 'ContextTeam'; if (isset($_POST[$s_key]) and strlen($_POST[$s_key])) { $team->SetId($_POST[$s_key]); $match->AddAwayTeam($team); } # Get the ground $s_key = $this->GetNamingPrefix() . 'Ground'; if (isset($_POST[$s_key]) and strlen($_POST[$s_key])) { $o_ground = new Ground($this->GetSettings()); $o_ground->SetId($_POST[$s_key]); $match->SetGround($o_ground); } # Get the notes $s_key = $this->GetNamingPrefix() . 'Notes'; if (isset($_POST[$s_key])) { $match->SetNotes($_POST[$s_key]); } $this->SetDataObject($match); }
function OnPageLoad() { echo '<div class="ground vcard" typeof="schema:Place" about="' . $this->ground->GetLinkedDataUri() . '">'; $o_fn = new XhtmlElement('h1', htmlentities($this->ground->GetNameAndTown(), ENT_QUOTES, "UTF-8", false)); $o_fn->SetCssClass('fn'); $o_fn->AddAttribute("property", "schema:name"); echo $o_fn; require_once 'xhtml/navigation/tabs.class.php'; $tabs = array('Summary' => '', 'Statistics' => $this->ground->GetStatsNavigateUrl()); echo new Tabs($tabs); ?> <div class="box tab-box"> <div class="dataFilter"></div> <div class="box-content"> <?php $address = new XhtmlElement("div"); $address->AddAttribute("rel", "schema:address"); $address->AddAttribute("resource", $this->ground->GetLinkedDataUri() . "#PostalAddress"); $postal = new PostalAddressControl($this->ground->GetAddress()); $postal->AddAttribute("about", $this->ground->GetLinkedDataUri() . "#PostalAddress"); $address->AddControl($postal); echo $address; # Show teams based at this ground if ($this->ground->Teams()->GetCount()) { require_once "stoolball/team-list-control.class.php"; echo "<h2>Teams based at this ground</h2>" . new TeamListControl($this->ground->Teams()->GetItems()); } if (!is_null($this->ground->GetAddress()->GetLatitude()) and !is_null($this->ground->GetAddress()->GetLongitude())) { $o_geo = new XhtmlElement('div'); $o_geo->SetXhtmlId('geoGround'); $o_geo->AddAttribute("rel", "schema:geo"); $o_geo->AddAttribute("resource", $this->ground->GetLinkedDataUri() . "#geo"); $o_latlong = new XhtmlElement('p'); $o_latlong->SetCssClass('geo'); # geo microformat $o_latlong->AddAttribute("about", $this->ground->GetLinkedDataUri() . "#geo"); $o_latlong->AddAttribute("typeof", "schema:GeoCoordinates"); $o_latlong->AddControl('Latitude '); $o_lat = new XhtmlElement('span', (string) $this->ground->GetAddress()->GetLatitude()); $o_lat->SetCssClass('latitude'); # geo microformat $o_lat->AddAttribute("property", "schema:latitude"); $o_latlong->AddControl($o_lat); $o_latlong->AddControl('; longitude '); $o_long = new XhtmlElement('span', (string) $this->ground->GetAddress()->GetLongitude()); $o_long->SetCssClass('longitude'); # geo microformat $o_long->AddAttribute("property", "schema:longitude"); $o_latlong->AddControl($o_long); $o_geo->AddControl($o_latlong); $s_place = ''; $s_class = ''; switch ($this->ground->GetAddress()->GetGeoPrecision()) { case GeoPrecision::Exact(): $s_place = $this->ground->GetNameAndTown(); $s_class = 'exact'; break; case GeoPrecision::Postcode(): $s_place = $this->ground->GetAddress()->GetPostcode(); $s_class = 'postcode'; break; case GeoPrecision::StreetDescriptor(): $s_place = $this->ground->GetAddress()->GetStreetDescriptor() . ', ' . $this->ground->GetAddress()->GetTown(); $s_class = 'street'; break; case GeoPrecision::Town(): $s_place = $this->ground->GetAddress()->GetTown(); $s_class = 'town'; break; } $o_map_link = new XhtmlAnchor('Map of <span class="' . $s_class . '">' . htmlentities($s_place, ENT_QUOTES, "UTF-8", false) . '</span> on Google Maps', 'http://maps.google.co.uk/?z=16&q=' . urlencode($this->ground->GetNameAndTown()) . '@' . $this->ground->GetAddress()->GetLatitude() . ',' . $this->ground->GetAddress()->GetLongitude() . '&ll=' . $this->ground->GetAddress()->GetLatitude() . ',' . $this->ground->GetAddress()->GetLongitude()); $o_map = new XhtmlElement('div', $o_map_link); $o_geo->AddControl($o_map); echo $o_geo; } if ($this->ground->GetDirections()) { echo new XhtmlElement('h2', 'Directions'); $s_directions = htmlentities($this->ground->GetDirections(), ENT_QUOTES, "UTF-8", false); $s_directions = XhtmlMarkup::ApplyCharacterEntities($s_directions); $s_directions = XhtmlMarkup::ApplyParagraphs($s_directions); $s_directions = XhtmlMarkup::ApplySimpleTags($s_directions); echo $s_directions; } if ($this->ground->GetParking()) { echo new XhtmlElement('h2', 'Parking'); $s_parking = htmlentities($this->ground->GetParking(), ENT_QUOTES, "UTF-8", false); $s_parking = XhtmlMarkup::ApplyCharacterEntities($s_parking); $s_parking = XhtmlMarkup::ApplyParagraphs($s_parking); $s_parking = XhtmlMarkup::ApplySimpleTags($s_parking); $s_parking = XhtmlMarkup::ApplyLinks($s_parking); echo $s_parking; } if ($this->ground->GetFacilities()) { echo new XhtmlElement('h2', 'Facilities'); $s_facilities = htmlentities($this->ground->GetFacilities(), ENT_QUOTES, "UTF-8", false); $s_facilities = XhtmlMarkup::ApplyCharacterEntities($s_facilities); $s_facilities = XhtmlMarkup::ApplyParagraphs($s_facilities); $s_facilities = XhtmlMarkup::ApplySimpleTags($s_facilities); $s_facilities = XhtmlMarkup::ApplyLinks($s_facilities); echo $s_facilities; } $o_meta = new XhtmlElement('p'); $o_meta->SetCssClass('metadata'); $o_meta->AddControl('Status: '); $o_uid = new XhtmlElement('span', $this->ground->GetLinkedDataUri()); $o_uid->SetCssClass('uid'); $o_meta->AddControl($o_uid); $o_meta->AddControl(' last updated at '); $o_rev = new XhtmlElement('abbr', Date::BritishDateAndTime($this->ground->GetDateUpdated())); $o_rev->SetTitle(Date::Microformat($this->ground->GetDateUpdated())); $o_rev->SetCssClass('rev'); $o_meta->AddControl($o_rev); $o_meta->AddControl(', sort as '); $o_url = new XhtmlAnchor(htmlentities($this->ground->GetAddress()->GenerateSortName(), ENT_QUOTES, "UTF-8", false), $this->ground->GetNavigateUrl()); $o_url->SetCssClass('url sort-string'); $o_meta->AddControl($o_url); echo $o_meta; echo "</div>"; ?> </div> </div> <?php $this->AddSeparator(); $o_user = new UserEditPanel($this->GetSettings(), 'this ground'); $o_user->AddCssClass("with-tabs"); if (AuthenticationManager::GetUser()->Permissions()->HasPermission(PermissionType::MANAGE_GROUNDS)) { $o_user->AddLink("edit this ground", $this->ground->GetEditGroundUrl()); $o_user->AddLink("delete this ground", $this->ground->GetDeleteGroundUrl()); } echo $o_user; # Show top players if ($this->has_player_stats) { require_once 'stoolball/statistics-highlight-table.class.php'; echo new StatisticsHighlightTable($this->best_batting, $this->most_runs, $this->best_bowling, $this->most_wickets, $this->most_catches, "All seasons"); } }
/** * Populates the collection of business objects from raw data * * @return bool * @param MySqlRawData $o_result */ protected function BuildItems(MySqlRawData $o_result) { $this->Clear(); /* @var $o_team Team */ # use CollectionBuilder to handle duplicates $o_team_builder = new CollectionBuilder(); $o_season_builder = new CollectionBuilder(); $o_team = null; while ($row = $o_result->fetch()) { # check whether this is a new team if (!$o_team_builder->IsDone($row->team_id)) { # store any exisiting team if ($o_team != null) { $this->Add($o_team); $o_season_builder->Reset(); } # create the new team $o_team = new Team($this->o_settings); $o_team->SetId($row->team_id); $o_team->SetName($row->team_name); if (isset($row->website)) { $o_team->SetWebsiteUrl($row->website); } if (isset($row->active)) { $o_team->SetIsActive($row->active); } if (isset($row->team_type)) { $o_team->SetTeamType($row->team_type); } if (isset($row->intro)) { $o_team->SetIntro($row->intro); } if (isset($row->playing_times)) { $o_team->SetPlayingTimes($row->playing_times); } if (isset($row->cost)) { $o_team->SetCost($row->cost); } if (isset($row->contact)) { $o_team->SetContact($row->contact); } if (isset($row->contact_nsa)) { $o_team->SetPrivateContact($row->contact_nsa); } if (isset($row->short_url)) { $o_team->SetShortUrl($row->short_url); } if (isset($row->player_type_id)) { $o_team->SetPlayerType($row->player_type_id); } $o_team->SetSchoolYears(array(1 => isset($row->year1) and $row->year1, 2 => isset($row->year2) and $row->year2, 3 => isset($row->year3) and $row->year3, 4 => isset($row->year4) and $row->year4, 5 => isset($row->year5) and $row->year5, 6 => isset($row->year6) and $row->year6, 7 => isset($row->year7) and $row->year7, 8 => isset($row->year8) and $row->year8, 9 => isset($row->year9) and $row->year9, 10 => isset($row->year10) and $row->year10, 11 => isset($row->year11) and $row->year11, 12 => isset($row->year12) and $row->year12)); if (isset($row->update_search) and $row->update_search == 1) { $o_team->SetSearchUpdateRequired(); } if (isset($row->date_changed)) { $o_team->SetLastAudit(new AuditData($row->modified_by_id, $row->known_as, $row->date_changed)); } $club = new Club($this->GetSettings()); if (isset($row->club_id)) { $club->SetId($row->club_id); if (isset($row->club_name)) { $club->SetName($row->club_name); } if (isset($row->twitter)) { $club->SetTwitterAccount($row->twitter); } if (isset($row->facebook)) { $club->SetFacebookUrl($row->facebook); } if (isset($row->instagram)) { $club->SetInstagramAccount($row->instagram); } if (isset($row->clubmark)) { $club->SetClubmarkAccredited($row->clubmark); } if (isset($row->club_short_url)) { $club->SetShortUrl($row->club_short_url); } } # If the website is actually a Facebook page, move it, overriding the club Facebook page is necessary if (strpos($o_team->GetWebsiteUrl(), 'facebook.com/') !== false) { $club->SetFacebookUrl($o_team->GetWebsiteUrl()); $o_team->SetWebsiteUrl(''); } $o_team->SetClub($club); if (isset($row->ground_id) and $row->ground_id) { $o_ground = new Ground($this->o_settings); $o_ground->SetId($row->ground_id); $address = $o_ground->GetAddress(); if (isset($row->saon)) { $address->SetSaon($row->saon); } if (isset($row->town)) { if (isset($row->paon)) { $address->SetPaon($row->paon); } if (isset($row->street_descriptor)) { $address->SetStreetDescriptor($row->street_descriptor); } if (isset($row->locality)) { $address->SetLocality($row->locality); } $address->SetTown($row->town); if (isset($row->administrative_area)) { $address->SetAdministrativeArea($row->administrative_area); } if (isset($row->postcode)) { $address->SetPostcode($row->postcode); } if (isset($row->latitude)) { $address->SetGeoLocation($row->latitude, $row->longitude, null); } $o_ground->SetAddress($address); } if (isset($row->ground_short_url)) { $o_ground->SetShortUrl($row->ground_short_url); } $o_team->SetGround($o_ground); } } # Competition/Season a cause of multiple rows if (isset($row->season_id) and !$o_season_builder->IsDone($row->season_id) and isset($row->competition_id)) { $o_season = new Season($this->o_settings); $o_season->SetId($row->season_id); $o_season->SetName($row->season_name); $o_season->SetIsLatest($row->is_latest); $o_season->SetStartYear($row->start_year); $o_season->SetEndYear($row->end_year); if (isset($row->season_short_url)) { $o_season->SetShortUrl($row->season_short_url); } $o_competition = new Competition($this->o_settings); $o_competition->SetId($row->competition_id); $o_competition->SetName($row->competition_name); $o_season->SetCompetition($o_competition); $o_team->Seasons()->Add(new TeamInSeason(null, $o_season, isset($row->withdrawn_league) ? $row->withdrawn_league : null)); unset($o_season); unset($o_competition); } } # store final team if ($o_team != null) { $this->Add($o_team); } return true; }
/** * Gets the short URL formats for the site * * @return ShortUrlFormat[] */ public function GetShortUrlFormats() { require_once 'http/short-url-format.class.php'; $a_formats = array(); require_once 'stoolball/clubs/club.class.php'; $a_formats[] = Club::GetShortUrlFormatForType($this); require_once 'stoolball/competition.class.php'; $a_formats[] = Competition::GetShortUrlFormatForType($this); require_once 'stoolball/ground.class.php'; $a_formats[] = Ground::GetShortUrlFormatForType($this); require_once 'stoolball/match.class.php'; $a_formats[] = Match::GetShortUrlFormatForType($this); require_once 'stoolball/season.class.php'; $a_formats[] = Season::GetShortUrlFormatForType($this); require_once 'stoolball/team.class.php'; $a_formats[] = Team::GetShortUrlFormatForType($this); require_once 'stoolball/player.class.php'; $a_formats[] = Player::GetShortUrlFormatForType($this); return $a_formats; }
/** * Return readable list of variables of instance * * @return string */ public function __toString() : string { $items = method_exists($this, '__debugInfo') ? $this->__debugInfo() : (array) $this; return Ground::debugText(get_class($this) . ' {' . ($items ? "\n" . VariableInspector::itemsInfo($items, '#444') : '') . '}'); }