Removes user confusing geocoding multichoice.
authorStéphane Jacob <sj@m4x.org>
Tue, 3 May 2011 12:10:49 +0000 (14:10 +0200)
committerStéphane Jacob <sj@m4x.org>
Tue, 3 May 2011 12:10:49 +0000 (14:10 +0200)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
classes/address.php
htdocs/javascript/profile.js
templates/geoloc/form.address.tpl

index fc438e5..fb4eb44 100644 (file)
@@ -316,8 +316,6 @@ class Address
     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';
@@ -580,17 +578,8 @@ class Address
         $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) {
@@ -602,30 +591,19 @@ class Address
             }
         }
 
-        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()
@@ -655,10 +633,6 @@ class Address
             '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;
@@ -723,14 +697,7 @@ class Address
 
     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,
index d4899ec..0219aeb 100644 (file)
@@ -333,20 +333,6 @@ function addressChanged(prefid)
     $('#' + 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)
index 27c51b4..0fb4845 100644 (file)
 {*                                                                        *}
 {**************************************************************************}
 
-{if t($address.geocodedText)}
-<div class="erreur center {$prefid}_geoloc">
-  Le géocodage n'a pas donné un résultat certain&nbsp;! Tu as le choix entre&nbsp;:
-</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>&nbsp;;</li>
-    <li><a href="javascript:validGeoloc('{$prefid}','{$id}',1)" style="color: green">notre suggestion (à droite)</a>&nbsp;;</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&nbsp;:</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}" />