refactor + validate.pl
authorPierre Habouzit (MadCoder <pierre.habouzit@m4x.org>
Mon, 13 Dec 2004 17:14:57 +0000 (17:14 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:26:39 +0000 (23:26 +0200)
git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-89

bin/xhtml/validate.pl
htdocs/vcard.php

index 48f4588..e8800e8 100755 (executable)
@@ -25,7 +25,7 @@ use HTTP::Request::Common 'POST';
 print LWP::UserAgent
   ->new
   ->request(
-            POST 'http://amaretto.inria.fr:8080/w3c-markup-validator/check',
+            POST 'http://murphy.polytechnique.org/w3c-markup-validator/check',
             Content_Type => 'form-data',
             Content      => [
                              output => 'xml',
index 394b67d..121a8fc 100644 (file)
@@ -23,21 +23,14 @@ require_once("xorg.inc.php");
 new_nonhtml_page('vcard.tpl', AUTH_COOKIE);
 require_once("xorg.misc.inc.php");
 
-function format_adr($params, &$smarty) {
+function format_adr($params, &$smarty)
+{
     // $adr1, $adr2, $adr3, $cp, $ville, $region, $pays
     extract($params['adr']);
-    $res = ";;";
-    if (! empty($adr1)) $res .= "$adr1\n";
-    if (! empty($adr2)) $res .= "$adr2\n";
-    if (! empty($adr3)) $res .= "$adr3\n";
-    if (! empty($adr1) || ! empty($adr2) || ! empty($adr3))
-        $res = substr($res, 0, -1);
-    $res .= ";";
-    if (! empty($ville)) $res .= "$ville;"; else $res .= ";";
-    if (! empty($region)) $res .= "$region;"; else $res .= ";";
-    if (! empty($cp)) $res .= "$cp;"; else $res .= ";";
-    if (! empty($pays)) $res .= "$pays";
-    return quoted_printable_encode($res);
+    $adr = $adr1;
+    $adr = trim("$adr\n$adr2");
+    $adr = trim("$adr\n$adr3");
+    return quoted_printable_encode(";;$adr;$ville;$region;$cp;$pays");
 }
 
 $page->register_modifier('qp_enc', 'quoted_printable_encode');