Task #0002125: type , missed phoneTo for mobile , phone and faxTo, several
emails separated by a comma
This commit is contained in:
parent
3decfb84c2
commit
68d41b82ca
3 changed files with 51 additions and 9 deletions
|
|
@ -1637,12 +1637,38 @@ function phoneTo($p_tel) {
|
|||
|
||||
/**
|
||||
* @brief compose a HTML string with email
|
||||
* @param $p_email
|
||||
* @param string $p_email email or emails separated by a comma
|
||||
* @return false|string returns false if email not valide
|
||||
*/
|
||||
function mailTo($p_email) {
|
||||
if ( filter_var($p_email,FILTER_VALIDATE_EMAIL) ) {
|
||||
$r=sprintf('<a href="mailto:%s">%s</a>',h($p_email),h($p_email));
|
||||
if (empty($p_email )) return "";
|
||||
$nComma=preg_match("/,/",$p_email);
|
||||
if ( $nComma > 0) {
|
||||
$aEmail=explode(",",$p_email);
|
||||
} else {
|
||||
$aEmail[0]=$p_email;
|
||||
}
|
||||
$r="";
|
||||
foreach ($aEmail as $email) {
|
||||
if ( filter_var(trim($email),FILTER_VALIDATE_EMAIL) ) {
|
||||
$r.=sprintf('<a href="mailto:%s">%s</a> ',h($email),h($email));
|
||||
} else {
|
||||
$r.=sprintf("%s",h($email));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief compose a HTML string with fax
|
||||
* @param string $p_fax fax number
|
||||
* @return false|string returns false if $p_fax is empty
|
||||
*/
|
||||
function FaxTo($p_tel) {
|
||||
if (!empty($p_tel)) {
|
||||
$r=sprintf('<a href="fax:%s">%s</a>',h($p_tel),h($p_tel));
|
||||
return $r;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ $from=$http->request("ac","string","");
|
|||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?=$contact['contact_mobile']?>
|
||||
<?=phoneTo($contact['contact_mobile'])?>
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
|
|
@ -82,12 +82,10 @@ $from=$http->request("ac","string","");
|
|||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php if (!empty($contact['contact_phone'])):?>
|
||||
<a href="tel:<?=$contact['contact_phone']?>"><?=$contact['contact_phone']?></a>
|
||||
<?php endif;?>
|
||||
<?=phoneTo($contact['contact_phone'])?>
|
||||
</td>
|
||||
<td>
|
||||
<?=$contact['contact_phone']?>
|
||||
<?=FaxTo($contact['contact_fax'])?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
|
|
|
|||
|
|
@ -393,7 +393,25 @@ class Ac_CommonTest extends TestCase
|
|||
$expect=sprintf('<a href="mailto:%s">%s</a>',h("test@noalyss.be"),h("test@noalyss.be"));
|
||||
$expect=preg_replace('/\s+/','',$expect);
|
||||
$this->assertEquals(strtoupper($expect),strtoupper(preg_replace("/\s+/",'',mailTo('test@noalyss.be'))),);
|
||||
$this->assertFalse(mailTo('test@noalyss.@be'),"Send email to invalidate email");
|
||||
$this->assertEquals('test@noalyss.@be',mailTo('test@noalyss.@be'),"Send email to invalidate email");
|
||||
$expect=sprintf('<a href="mailto:%s">%s</a>',h("test@noalyss.be"),h("test@noalyss.be"));
|
||||
$expect.=sprintf('<a href="mailto:%s">%s</a>',h("test2@noalyss.be"),h("test2@noalyss.be"));
|
||||
$expect=preg_replace('/\s+/','',$expect);
|
||||
$this->assertEquals($expect,
|
||||
preg_replace('/\s+/','',mailTo('test@noalyss.be,test2@noalyss.be'))
|
||||
,"Send email to invalidate email");
|
||||
|
||||
}
|
||||
/**
|
||||
* @testdox Test the FAX tag
|
||||
* @return void
|
||||
*/
|
||||
function testFaxTo()
|
||||
{
|
||||
$this->assertFalse(faxTo(""),"Invalide phone");
|
||||
$expect=sprintf('<a href="fax:%s">%s</a>',h(123),h(123));
|
||||
$expect=preg_replace('/\s+/','',$expect);
|
||||
$this->assertEquals(strtoupper($expect),strtoupper(preg_replace("/\s+/",'',faxTo('123'))),);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue