/**
  * Test #10398 -- elgg_parse_emails()
  * https://github.com/Elgg/Elgg/pull/10398
  */
 public function test_elgg_parse_emails()
 {
     $cases = array('no.email.here' => 'no.email.here', 'simple email mail@test.com test' => 'simple email <a href="mailto:mail@test.com" rel="nofollow">mail@test.com</a> test', 'simple paragraph <p>mail@test.com</p>' => 'simple paragraph <p><a href="mailto:mail@test.com" rel="nofollow">mail@test.com</a></p>', 'multiple matches mail@test.com test mail@test.com test' => 'multiple matches <a href="mailto:mail@test.com" rel="nofollow">mail@test.com</a> test <a href="mailto:mail@test.com" rel="nofollow">mail@test.com</a> test', 'invalid email 1 @invalid.com test' => 'invalid email 1 @invalid.com test', 'invalid email 2 mail@invalid. test' => 'invalid email 2 mail@invalid. test', 'no double parsing <a href="mailto:mail@test.com" rel="nofollow">mail@test.com</a> test' => 'no double parsing <a href="mailto:mail@test.com" rel="nofollow">mail@test.com</a> test', 'no double parsing 2 <a href="#">mail@test.com</a> test' => 'no double parsing 2 <a href="#">mail@test.com</a> test', 'no double parsing 3 <a href="#">with a lot of text - mail@test.com - around it</a> test' => 'no double parsing 3 <a href="#">with a lot of text - mail@test.com - around it</a> test');
     foreach ($cases as $input => $output) {
         $this->assertEqual($output, elgg_parse_emails($input));
     }
 }
Beispiel #2
0
 * @uses $vars['value'] HTML to display
 * @uses $vars['class']
 * @uses $vars['parse_urls'] Turn urls into links? Default is true.
 * @uses $vars['parse_emails'] Turn email addresses into mailto links? Default is true.
 * @uses $vars['sanitize'] Sanitize HTML? (highly recommended) Default is true.
 * @uses $vars['autop'] Convert line breaks to paragraphs? Default is true.
 */
$vars['class'] = elgg_extract_class($vars, 'elgg-output');
$parse_urls = elgg_extract('parse_urls', $vars, true);
unset($vars['parse_urls']);
$parse_emails = elgg_extract('parse_emails', $vars, true);
unset($vars['parse_emails']);
$sanitize = elgg_extract('sanitize', $vars, true);
unset($vars['sanitize']);
$autop = elgg_extract('autop', $vars, true);
unset($vars['autop']);
$text = $vars['value'];
unset($vars['value']);
if ($parse_urls) {
    $text = parse_urls($text);
}
if ($parse_emails) {
    $text = elgg_parse_emails($text);
}
if ($sanitize) {
    $text = filter_tags($text);
}
if ($autop) {
    $text = elgg_autop($text);
}
echo elgg_format_element('div', $vars, $text);