public $south = null;
public $east = null;
public $west = null;
- public $geocodedText = null;
- public $geocodeChosen = null;
// Database's field required for both 'home' and 'job' addresses.
public $pub = 'ax';
$this->postalText = $text;
}
- public function format(array $format = array())
+ public function format()
{
- if (empty($format)) {
- $format['requireGeocoding'] = false;
- $format['stripGeocoding'] = false;
- $format['postalText'] = false;
- } else {
- foreach (array('requireGeocoding', 'stripGeocoding', 'postalText') as $type) {
- $format[$type] = (isset($format[$type])) ? $format[$type] : false;
- }
- }
$this->text = trim($this->text);
$this->phones = Phone::formatFormArray($this->phones, $this->error, new ProfileVisibility($this->pub));
if ($this->removed == 1) {
}
}
- if ($format['requireGeocoding'] || $this->changed == 1) {
+ $this->formatPostalAddress();
+ if ($this->changed == 1) {
$gmapsGeocoder = new GMapsGeocoder();
$gmapsGeocoder->getGeocodedAddress($this);
- $this->changed = 0;
- $this->error = !empty($this->geocodedText);
- }
- if ($format['stripGeocoding'] || ($this->type == self::LINK_COMPANY && $this->error) || $this->geocodeChosen === '0') {
- if ($this->geocodeChosen === '0') {
- $mailer = new PlMailer('profile/geocoding.mail.tpl');
- $mailer->assign('text', $this->text);
- $mailer->assign('geoloc', $this->geocodedText);
- $mailer->send();
- }
- $gmapsGeocoder = new GMapsGeocoder();
- $gmapsGeocoder->stripGeocodingFromAddress($this);
+ }
+ foreach (array('administrativeArea', 'subAdministrativeArea', 'locality') as $area) {
+ Geocoder::getAreaId($this, $area);
}
if ($this->countryId == '') {
$this->countryId = null;
}
- $this->geocodeChosen = null;
- if ($format['postalText']) {
- $this->formatPostalAddress();
- }
- return !$this->error;
+
+ return true;
}
public function toFormArray()
'changed' => $this->changed,
'removed' => $this->removed,
);
- if (!is_null($this->geocodedText)) {
- $address['geocodedText'] = $this->geocodedText;
- $address['geocodeChosen'] = $this->geocodeChosen;
- }
if ($this->type == self::LINK_PROFILE || $this->type == self::LINK_JOB) {
$address['pub'] = $this->pub;
public function save()
{
- static $areas = array('administrativeArea', 'subAdministrativeArea', 'locality');
-
- $this->format(array('postalText' => true));
if (!$this->isEmpty()) {
- foreach ($areas as $area) {
- Geocoder::getAreaId($this, $area);
- }
-
XDB::execute('INSERT IGNORE INTO profile_addresses (pid, jobid, groupid, type, id, flags, accuracy,
text, postalText, postalCode, localityId,
subAdministrativeAreaId, administrativeAreaId,
$('#' + prefid + '_cont').find('[name*=changed]').val("1");
}
-function validGeoloc(prefid, id, geoloc)
-{
- if (geoloc == 1) {
- $('#' + prefid + '_cont').find('[name*=text]').val($('#' + prefid + '_cont').find('[name*=geocodedText]').val());
- $('#' + prefid + '_cont').find('[name*=postalText]').val('');
- }
- if (geoloc > 0) {
- $('#' + prefid + '_cont').find("[name*='[geocodedText]']").remove();
- }
- $('#' + prefid + '_cont').find('[name*=text]').removeClass('error');
- $('#' + prefid + '_cont').find('[name*=geocodeChosen]').val(geoloc);
- $('.' + prefid + '_geoloc').remove();
-}
-
// {{{1 Phones
function addTel(prefid, prefname, subField, mainField, mainId)
{* *}
{**************************************************************************}
-{if t($address.geocodedText)}
-<div class="erreur center {$prefid}_geoloc">
- Le géocodage n'a pas donné un résultat certain ! Tu as le choix entre :
-</div>
-<div class="{$prefid}_geoloc">
- <ul>
- <li><a href="javascript:validGeoloc('{$prefid}','{$id}',2)"
- title="Garder le texte de l'adresse que tu as renseignée tout en utilisant les informations trouvées par le géocodage pour te localiser sur le planisphère et dans lors d'une recherche dans l'annuaire.">
- le texte de ton adresse localisé à l'endroit que nous te suggérons</a>.</li>
- <li><a href="javascript:validGeoloc('{$prefid}','{$id}',0)" style="color: red">ton adresse (à gauche)</a> ;</li>
- <li><a href="javascript:validGeoloc('{$prefid}','{$id}',1)" style="color: green">notre suggestion (à droite)</a> ;</li>
- </ul>
-</div>
-{/if}
-
-<div>
- <textarea name="{$prefname}[text]" cols="30" rows="4" onkeyup="addressChanged('{$prefid}')"
- {if t($address.geocodedText)}class="error"{/if}>{$address.text}</textarea>
-{if t($address.geocodedText)}
- <textarea cols="30" rows="4" class="valid {$prefid}_geoloc">{$address.geocodedText}</textarea>
-{/if}
-</div>
-{if !$isMe}<div><small><strong>Adress postale :</strong><br />{$address.postalText|nl2br}</small></div>{/if}
-{if t($address.geocodedText)}
-<input type="hidden" name="{$prefname}[geocodeChosen]" value="1" />
-<input type="hidden" name="{$prefname}[geocodedText]" value="{$address.geocodedText}" />
-{/if}
+<div><textarea name="{$prefname}[text]" cols="30" rows="4" onkeyup="addressChanged('{$prefid}')">{$address.text}</textarea></div>
<input type="hidden" name="{$prefname}[accuracy]" value="{$address.accuracy}" />
<input type="hidden" name="{$prefname}[postalText]" value="{$address.postalText}" />
<input type="hidden" name="{$prefname}[postalCode]" value="{$address.postalCode}" />