Overview
Comment:Implement check_email modifier
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 6b326834d3f7bc557160d974250c13df9466b714c7a91749c76227253a2de131
User & Date: bohwaz on 2022-03-16 01:34:32
Other Links: manifest | tags
Context
2022-03-18
00:30
Fix invalid return in getPositionFromType check-in: fff03a444a user: bohwaz tags: trunk, stable
2022-03-16
01:34
Implement check_email modifier check-in: 6b326834d3 user: bohwaz tags: trunk
00:11
Implement mail brindille function check-in: dab3aa61aa user: bohwaz tags: trunk, stable
Changes

Modified src/include/lib/Garradin/UserTemplate/Modifiers.php from [418f637151] to [a8c52296fb].

1
2
3
4
5


6
7
8
9
10
11
12
<?php

namespace Garradin\UserTemplate;

use Garradin\Utils;



class Modifiers
{
	const PHP_MODIFIERS_LIST = [
		'strtolower',
		'strtoupper',
		'ucfirst',





>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php

namespace Garradin\UserTemplate;

use Garradin\Utils;

use KD2\SMTP;

class Modifiers
{
	const PHP_MODIFIERS_LIST = [
		'strtolower',
		'strtoupper',
		'ucfirst',
37
38
39
40
41
42
43

44
45
46
47
48
49
50
51
52
53
54
55
56





57
58
59
60
61
62
63
		'protect_contact',
		'atom_date',
		'xml_escape',
		'replace',
		'regexp_replace',
		'remove_leading_number',
		'get_leading_number',

	];

	const LEADING_NUMBER_REGEXP = '/^([\d.]+)\s*[.\)]\s*/';

	static public function replace($str, $find, $replace): string
	{
		return str_replace($find, $replace, $str);
	}

	static public function regexp_replace($str, $pattern, $replace)
	{
		return preg_replace($pattern, $replace, $str);
	}






	/**
	 * UTF-8 aware intelligent substr
	 * @param  string  $str         UTF-8 string
	 * @param  integer $length      Maximum string length
	 * @param  string  $placeholder Placeholder text to append at the string if it has been cut
	 * @param  boolean $strict_cut  If true then will cut in the middle of words







>













>
>
>
>
>







39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
		'protect_contact',
		'atom_date',
		'xml_escape',
		'replace',
		'regexp_replace',
		'remove_leading_number',
		'get_leading_number',
		'check_email',
	];

	const LEADING_NUMBER_REGEXP = '/^([\d.]+)\s*[.\)]\s*/';

	static public function replace($str, $find, $replace): string
	{
		return str_replace($find, $replace, $str);
	}

	static public function regexp_replace($str, $pattern, $replace)
	{
		return preg_replace($pattern, $replace, $str);
	}

	static public function check_email($str)
	{
		return SMTP::checkEmailIsValid($str, true);
	}

	/**
	 * UTF-8 aware intelligent substr
	 * @param  string  $str         UTF-8 string
	 * @param  integer $length      Maximum string length
	 * @param  string  $placeholder Placeholder text to append at the string if it has been cut
	 * @param  boolean $strict_cut  If true then will cut in the middle of words