From: x2003bruneau Date: Sun, 27 May 2007 15:44:22 +0000 (+0000) Subject: Better fix for GoogleMaps X-Git-Tag: xorg/0.9.15~275 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=3641a0e689294f9a00c4c2aaa27f3afb1720f930;p=platal.git Better fix for GoogleMaps plugins/function.display_address.php | 30 ++++++++++++++++++++++++++++-- templates/admin/synchro_ax.tpl | 4 ++-- templates/geoloc/address.tpl | 2 +- templates/profile/fiche_referent.tpl | 2 +- templates/profile/profile.tpl | 11 +++++++---- 5 files changed, 39 insertions(+), 10 deletions(-) git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1841 839d8a87-29fc-0310-9880-83ba4fa771e5 --- diff --git a/plugins/function.display_address.php b/plugins/function.display_address.php index fe5d355..81fbebe 100644 --- a/plugins/function.display_address.php +++ b/plugins/function.display_address.php @@ -19,6 +19,22 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ +function display_address_isIdentity($idt, $value, $test_reverse = true) +{ + $value = strtolower(replace_accent($value)); + $idt = strtolower(replace_accent($idt)); + $idt = preg_replace('/[^a-z]/', '', $idt); + + $value = preg_replace('/[^a-z]/', '', $value); + if (strpos($value, $idt) !== false || strpos($idt, $value) !== false || levenshtein($value, $idt) < strlen($idt) / 3) { + return true; + } + + if ($test_reverse) { + return display_address_isIdentity($idt, implode(' ', array_reverse(explode(' ', $value))), false); + } + return false; +} function smarty_function_display_address($param, &$smarty) { @@ -30,14 +46,24 @@ function smarty_function_display_address($param, &$smarty) !$param['adr']['fax'] && !$param['adr']['mobile']) return ""; + $lines = explode("\n", $txtad); - $idt = array_shift($lines); + $idt = array_shift($lines); + $restore = true; + + if (!display_address_isIdentity($param['for'], $idt)) { + array_unshift($lines, $idt); + $idt = $param['for']; + $restore = false; + } $txthtml = ""; $map = "\"Google"; - array_unshift($lines, $idt); + if ($restore) { + array_unshift($lines, $idt); + } if ($param['titre']) { if ($param['titre_div']) diff --git a/templates/admin/synchro_ax.tpl b/templates/admin/synchro_ax.tpl index 5427b02..c8adc6e2 100644 --- a/templates/admin/synchro_ax.tpl +++ b/templates/admin/synchro_ax.tpl @@ -90,7 +90,7 @@ Adresses Effacer l'adresse {$adr.adrid}. {else} {if $adr.adrid}Modifier l'adresse {$adr.adrid} :{else}Ajouter l'adresse :{/if} - {include file='geoloc/address.tpl' address=$adr no_div=1} + {include file='geoloc/address.tpl' address=$adr no_div=1 for="`$x.prenom` `$x.nom`"} {/if} {/foreach} @@ -127,7 +127,7 @@ Emplois Poste : {$pro.poste} {/if} - {include file='geoloc/address.tpl' address=$pro no_div=1} + {include file='geoloc/address.tpl' address=$pro no_div=1 for=$pro.entreprise} {/if} {/foreach} diff --git a/templates/geoloc/address.tpl b/templates/geoloc/address.tpl index 0867a52..0bfef79 100644 --- a/templates/geoloc/address.tpl +++ b/templates/geoloc/address.tpl @@ -20,6 +20,6 @@ {* *} {**************************************************************************} -{display_address adr=$address titre=$titre titre_div=$titre_div no_div=$no_div} +{display_address adr=$address titre=$titre titre_div=$titre_div no_div=$no_div for=$for} {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} diff --git a/templates/profile/fiche_referent.tpl b/templates/profile/fiche_referent.tpl index c5bd2c6..f05f71d 100644 --- a/templates/profile/fiche_referent.tpl +++ b/templates/profile/fiche_referent.tpl @@ -66,7 +66,7 @@ {foreach from=$adr_pro item="address" key="i"}

{$address.entreprise}

{include file="include/emploi.tpl" address=$address} - {include file="geoloc/address.tpl" address=$address titre="Adresse : "} + {include file="geoloc/address.tpl" address=$address titre="Adresse : " for=$address.entreprise}
 
{/foreach} diff --git a/templates/profile/profile.tpl b/templates/profile/profile.tpl index 09dd97d..6f049b1 100644 --- a/templates/profile/profile.tpl +++ b/templates/profile/profile.tpl @@ -132,11 +132,14 @@ function chgMainWinLoc(strPage)

Contact :

{foreach from=$x.adr item="address" key="i"} {if $address.active} - {include file="geoloc/address.tpl" address=$address titre_div=true titre="Mon adresse actuelle :"} + {include file="geoloc/address.tpl" address=$address titre_div=true titre="Mon adresse actuelle :" + for="`$x.prenom` `$x.nom`"} {elseif $address.secondaire} - {include file="geoloc/address.tpl" address=$address titre_div=true titre="Adresse secondaire :"} + {include file="geoloc/address.tpl" address=$address titre_div=true titre="Adresse secondaire :" + for="`$x.prenom` `$x.nom`"} {else} - {include file="geoloc/address.tpl" address=$address titre_div=true titre="Adresse principale :"} + {include file="geoloc/address.tpl" address=$address titre_div=true titre="Adresse principale :" + for="`$x.prenom` `$x.nom`"} {/if} {/foreach}
 
@@ -149,7 +152,7 @@ function chgMainWinLoc(strPage)

Informations professionnelles :

{foreach from=$x.adr_pro item="address" key="i"} {include file="include/emploi.tpl" address=$address} - {include file="geoloc/address.tpl" address=$address titre="Adresse : "} + {include file="geoloc/address.tpl" address=$address titre="Adresse : " for=$address.entreprise}
 
{/foreach}