/**
  * Gets the name of the ground and the town it's in
  *
  * @return string
  */
 function GetNameAndTown()
 {
     $s_text = $this->o_address->GetSaon();
     if ($this->o_address->GetPaon()) {
         if ($s_text) {
             $s_text .= ', ';
         }
         $s_text .= $this->o_address->GetPaon();
     }
     if ($this->o_address->GetTown()) {
         $s_text .= ', ';
         if ($this->o_address->GetLocality() and strlen($this->o_address->GetTown()) > 5 and substr_compare($this->o_address->GetTown(), 'near ', 0, 5, true) == 0) {
             $s_text .= $this->o_address->GetLocality();
         } else {
             $s_text .= $this->o_address->GetTown();
         }
     }
     return $s_text;
 }
 /**
  * @return void
  * @desc Re-build from data posted by this control the data object this control is editing
  */
 public function BuildPostedDataObject()
 {
     $school = new School($this->GetSettings());
     if (isset($_POST['item'])) {
         $school->SetId($_POST['item']);
     }
     $school->SetName($_POST['school-name'] . ", " . $_POST["town"]);
     $school->Ground()->SetId($_POST['ground-id']);
     $address = new PostalAddress();
     $address->SetPaon($_POST['school-name']);
     $address->SetStreetDescriptor($_POST['street']);
     $address->SetLocality($_POST['locality']);
     $address->SetTown($_POST['town']);
     $address->SetAdministrativeArea($_POST['county']);
     $address->SetPostcode($_POST['postcode']);
     $address->SetGeoLocation($_POST['latitude'], $_POST['longitude'], $_POST['geoprecision']);
     $school->Ground()->SetAddress($address);
     $this->SetDataObject($school);
 }
 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);
 }
 function OnPreRender()
 {
     $s_text = "";
     $linked_data_street_address = ($this->o_address->GetSaon() or $this->o_address->GetPaon() or $this->o_address->GetStreetDescriptor());
     if ($linked_data_street_address) {
         $s_text .= '<span property="schema:streetAddress">';
     }
     if ($this->o_address->GetSaon() or $this->o_address->GetPaon()) {
         $s_text .= '<span class="extended-address">';
     }
     $s_text .= Html::Encode($this->o_address->GetSaon());
     if ($this->o_address->GetPaon()) {
         if ($this->o_address->GetSaon()) {
             $s_text .= '<br />';
         }
         $s_text .= Html::Encode($this->o_address->GetPaon());
     }
     if ($this->o_address->GetSaon() or $this->o_address->GetPaon()) {
         $s_text .= '</span>';
     }
     if ($this->o_address->GetStreetDescriptor()) {
         if ($s_text) {
             $s_text .= '<br />';
         }
         $s_text .= '<span class="street-address">' . Html::Encode($this->o_address->GetStreetDescriptor()) . '</span>';
     }
     if ($linked_data_street_address) {
         $s_text .= '</span>';
     }
     $b_locality = false;
     if ($this->o_address->GetLocality()) {
         if ($s_text) {
             $s_text .= '<br />';
         }
         $s_text .= '<span class="locality" property="schema:addressLocality">' . Html::Encode($this->o_address->GetLocality());
         $b_locality = true;
     }
     if ($this->o_address->GetTown()) {
         if ($s_text) {
             $s_text .= '<br />';
         }
         if (!$b_locality) {
             $s_text .= '<span class="locality" property="schema:addressLocality">';
         }
         $s_text .= Html::Encode($this->o_address->GetTown()) . '</span>';
     } else {
         if ($b_locality) {
             $s_text .= '</span>';
         }
     }
     if ($this->o_address->GetAdministrativeArea()) {
         if ($s_text) {
             $s_text .= '<br />';
         }
         $s_text .= '<span class="region" property="schema:addressRegion">' . Html::Encode($this->o_address->GetAdministrativeArea()) . '</span>';
     }
     if ($this->o_address->GetPostcode()) {
         if ($s_text) {
             $s_text .= ' ';
         }
         $s_text .= '<span class="postal-code" property="schema:postalCode">' . Html::Encode(strtoupper($this->o_address->GetPostcode())) . '</span>';
     }
     if ($s_text) {
         $this->AddControl($s_text);
     } else {
         $this->SetVisible(false);
     }
 }