/** * 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); } }
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"); } }
private function InfoWindowContent(Ground $ground) { $content = "'<div class=\"map-info\">' +\r\n '<h2>" . str_replace("'", "\\'", Html::Encode($ground->GetNameAndTown())) . "</h2>' +\r\n '<p>Home to: "; $teams = $ground->Teams()->GetItems(); $length = count($teams); for ($i = 0; $i < $length; $i++) { if ($i > 0 and $i == $length - 1) { $content .= " and "; } else { if ($i > 0) { $content .= ", "; } } $content .= '<a href="' . Html::Encode($teams[$i]->GetNavigateUrl()) . '">' . str_replace("'", "\\'", Html::Encode($teams[$i]->GetNameAndType())) . '</a>'; } $content .= "</p></div>'"; return $content; }