2 /***************************************************************************
3 * Copyright (C) 2003-2014 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
22 function display_address_isIdentity($idt, $value, $test_reverse = true
)
24 $value = strtolower(replace_accent($value));
25 $idt = strtolower(replace_accent($idt));
26 $idt = preg_replace('/[^a-z]/', '', $idt);
28 $value = preg_replace('/[^a-z]/', '', $value);
29 if (strpos($value, $idt) !== false ||
strpos($idt, $value) !== false ||
levenshtein($value, $idt) < strlen($idt) / 3) {
34 return display_address_isIdentity($idt, implode(' ', array_reverse(explode(' ', $value))), false
);
39 function smarty_function_display_address($param, $smarty)
45 if ($adr->phones() && count($adr->phones())) {
46 require_once 'function.display_phones.php';
47 $txthtml .= smarty_function_display_phones(array('tels' => $adr->phones()), $smarty);
48 } elseif (isset($param['phones']) && count($param['phones'])) {
49 require_once 'function.display_phones.php';
50 $txthtml .= smarty_function_display_phones(array('tels' => $param['phones']), $smarty);
52 if (!isset($param['nodiv']) && $txthtml != '' && isset($param['pos'])) {
53 $txthtml = '<div class="adresse" style="float: ' . $param['pos'] . '">' . $txthtml . '</div>';
58 $lines = explode("\n", $txtad);
59 $idt = array_shift($lines);
62 if (!display_address_isIdentity($param['for'], $idt)) {
63 array_unshift($lines, $idt);
69 $map = "<a href=\"http://maps.google.fr/?q="
70 . urlencode(implode(", ", $lines) . " ($idt)")
71 . "\"><img src=\"images/icons/map.gif\" alt=\"Google Maps\" title=\"Carte\"/></a>";
72 if ($adr->flags
->hasflag('mail')) {
73 $mail = ' <img src="images/icons/email_open.gif" alt="Adresse courier" title="On peut lui envoyer du courier à cette adresse." />';
78 if ($adr->comment
!= "")
80 $commentHtml = str_replace(array('&', '"'), array('&', '"'), $adr->comment
);
81 $commentJs = str_replace(array('\\', '\''), array('\\\\', '\\\''), $commentHtml);
82 $comment = "<img style=\"margin-left: 5px;\" src=\"images/icons/comments.gif\""
83 . " onmouseover=\"return overlib('"
86 . " onmouseout=\"nd();\""
87 . " alt=\"Commentaire\" title=\""
92 array_unshift($lines, $idt);
96 if ($param['titre_div'])
97 $txthtml .= '<div class="titre">' . pl_entity_decode($param['titre']) . ' ' . $map . $mail . $comment . "</div>\n";
99 $txthtml .= '<em>' . pl_entity_decode($param['titre']) . ' </em>' . $map . $mail . $comment . "<br />\n";
101 foreach ($lines as $line)
103 $txthtml .= "<strong>" . pl_entities($line) . "</strong><br/>\n";
105 if ($adr->phones() != null
) {
106 require_once 'function.display_phones.php';
107 $txthtml .= smarty_function_display_phones(array('tels' => $adr->phones()),$smarty);
108 } else if (isset($param['phones']) && count($param['phones'])) {
109 require_once 'function.display_phones.php';
110 $txthtml .= smarty_function_display_phones(array('tels' => $param['phones']),$smarty);
112 if (!$param['nodiv']) {
113 $pos = $param['pos'] ?
" style='float: " . $param['pos'] . "'" : '';
114 $txthtml = "<div class='adresse' $pos>\n".$txthtml."</div>\n";
119 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8: