function OnPreRender()
 {
     /* @var $o_ground Ground */
     foreach ($this->a_grounds as $o_ground) {
         if ($o_ground instanceof Ground) {
             $o_link = new XhtmlElement('a', Html::Encode($o_ground->GetNameAndTown()));
             $o_link->AddAttribute('href', $o_ground->GetNavigateUrl());
             $o_li = new XhtmlElement('li');
             $o_li->AddControl($o_link);
             $precision = array(GeoPrecision::Unknown() => 'No map', GeoPrecision::Exact() => 'Exact', GeoPrecision::Postcode() => 'Postcode', GeoPrecision::StreetDescriptor() => 'Street', GeoPrecision::Town() => 'Town');
             if (!is_null($o_ground->GetAddress()->GetGeoPrecision())) {
                 $o_li->AddControl(' (Map: ' . Html::Encode($precision[$o_ground->GetAddress()->GetGeoPrecision()]) . ')');
             }
             $this->AddControl($o_li);
         }
     }
 }
 function OnPageLoad()
 {
     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");
     }
 }
 function OnPreRender()
 {
     require_once 'xhtml/forms/form-part.class.php';
     require_once 'xhtml/forms/textbox.class.php';
     # add lines
     $o_saon_box = new TextBox('saon', $this->o_data_object->GetSaon());
     $o_saon_box->AddAttribute('maxlength', 250);
     $o_saon = new FormPart('Address within building', $o_saon_box);
     $this->AddControl($o_saon);
     $o_line1_box = new TextBox('paon', $this->o_data_object->GetPaon());
     $o_line1_box->AddAttribute('maxlength', 250);
     $o_line1 = new FormPart('Building name or number', $o_line1_box);
     $this->AddControl($o_line1);
     $o_line2_box = new TextBox('streetDescriptor', $this->o_data_object->GetStreetDescriptor());
     $o_line2_box->AddAttribute('maxlength', 250);
     $o_line2 = new FormPart('Street name', $o_line2_box);
     $this->AddControl($o_line2);
     $o_line3_box = new TextBox('locality', $this->o_data_object->GetLocality());
     $o_line3_box->AddAttribute('maxlength', 250);
     $o_line3 = new FormPart('Village or part of town', $o_line3_box);
     $this->AddControl($o_line3);
     # add town
     $o_town_box = new TextBox('town', $this->o_data_object->GetTown());
     $o_town_box->AddAttribute('maxlength', 100);
     $o_town = new FormPart('Town', $o_town_box);
     $this->AddControl($o_town);
     # add county
     $o_county_box = new TextBox('county', $this->o_data_object->GetAdministrativeArea());
     $o_county_box->AddAttribute('maxlength', 100);
     $o_county = new FormPart('County', $o_county_box);
     $this->AddControl($o_county);
     # add postcode
     $o_postcode_box = new TextBox('postcode', $this->o_data_object->GetPostcode());
     $o_postcode_box->AddAttribute('maxlength', 8);
     $o_postcode = new FormPart('Postcode', $o_postcode_box);
     $this->AddControl($o_postcode);
     # add geolocation
     $o_lat_box = new TextBox('lat', $this->o_data_object->GetLatitude());
     $o_lat_box->SetMaxLength(20);
     $o_lat = new FormPart('Latitude', $o_lat_box);
     $this->AddControl($o_lat);
     $o_long_box = new TextBox('long', $this->o_data_object->GetLongitude());
     $o_long_box->SetMaxLength(20);
     $o_long = new FormPart('Longitude', $o_long_box);
     $this->AddControl($o_long);
     $o_precision = new XhtmlSelect('geoprecision');
     $o_precision->AddControl(new XhtmlOption("Don't know", ''));
     $o_precision->AddControl(new XhtmlOption('Exact', GeoPrecision::Exact()));
     $o_precision->AddControl(new XhtmlOption('Postcode', GeoPrecision::Postcode()));
     $o_precision->AddControl(new XhtmlOption('Street', GeoPrecision::StreetDescriptor()));
     $o_precision->AddControl(new XhtmlOption('Town', GeoPrecision::Town()));
     $o_precision->SelectOption($this->o_data_object->GetGeoPrecision());
     $o_precision_part = new FormPart('How accurate is lat/long?', $o_precision);
     $this->AddControl($o_precision_part);
     $o_map = new XhtmlElement('div');
     $o_map->SetXhtmlId('map');
     $o_map->SetCssClass('formControl');
     $o_map_container = new XhtmlElement('div', $o_map);
     $o_map_container->SetCssClass('formPart');
     $this->AddControl($o_map_container);
 }