Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mailgo
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
mailgo
Commits
e7fd6a5e
Commit
e7fd6a5e
authored
7 months ago
by
Nikolay Grachev
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3288416
: add D10 support, drop D8, code style improvements
parent
feed80aa
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mailgo.info.yml
+1
-6
1 addition, 6 deletions
mailgo.info.yml
src/MailGoManager.php
+9
-6
9 additions, 6 deletions
src/MailGoManager.php
with
10 additions
and
12 deletions
mailgo.info.yml
+
1
−
6
View file @
e7fd6a5e
...
...
@@ -2,12 +2,7 @@ name: MailGo
description
:
Module implements MailGo library behaviour.
package
:
Filters
type
:
module
core_version_requirement
:
^
8.8
|| ^
9
core_version_requirement
:
^
9
|| ^
10
configure
:
mailgo.global_config_form
dependencies
:
-
drupal:link
-
drupal:filter
-
drupal:path
-
drupal:text
libraries
:
-
mailgo/mailgo
This diff is collapsed.
Click to expand it.
src/MailGoManager.php
+
9
−
6
View file @
e7fd6a5e
...
...
@@ -13,6 +13,12 @@ use Psr\Container\ContainerInterface;
*/
class
MailGoManager
{
const
EMAIL_REGEX
=
"/(((?<!
\"
|')(?<!mailto:)[a-z0-9_\-\.]+)@(([a-z0-9\-]+\.([a-z]
{
2,4})(?:\.[a-z]{2
}
)?)(?!
\"
|'|<\/a)))/i"
;
const
PHONE_REGEX
=
"/((?<!
\"
|')(?<!tel:|callto:)\+\d
{
1,3}[\d\s-]{7,
}
(?!
\"
|'|<\/a))/"
;
const
MAILTO_LINK_REGEX
=
"/<a(?:.*)href=(?:
\"
|')mailto:(.+)(?:
\"
|')(?:.*)>(.+)<\/a>/Ui"
;
/**
* Module config.
*
...
...
@@ -77,11 +83,10 @@ class MailGoManager {
* Processed text
*/
public
function
processEmailsInText
(
string
$text
,
$noSpam
=
FALSE
)
{
$regex
=
"/(((?<!
\"
|')(?<!mailto:)[a-z0-9_\-\.]+)@(([a-z0-9\-]+\.([a-z]
{
2,4})(?:\.[a-z]{2
}
)?)(?!
\"
|'|<\/a)))/i"
;
$replace
=
$noSpam
?
"<a href=
\"
#mailgo
\"
data-address=
\"
$2
\"
data-domain=
\"
$3
\"
>$1</a>"
:
"<a href=
\"
mailto:$1
\"
>$1</a>"
;
return
preg_replace
(
$regex
,
$replace
,
$text
);
return
preg_replace
(
self
::
EMAIL_REGEX
,
$replace
,
$text
);
}
/**
...
...
@@ -94,9 +99,8 @@ class MailGoManager {
* Processed text
*/
public
function
processPhonesInText
(
string
$text
)
{
$regex
=
"/((?<!
\"
|')(?<!tel:|callto:)\+\d
{
1,3}[\d\s-]{7,
}
(?!
\"
|'|<\/a))/"
;
$replace
=
"<a href=
\"
tel:$1
\"
>$1</a>"
;
return
preg_replace
(
$regex
,
$replace
,
$text
);
return
preg_replace
(
self
::
PHONE_REGEX
,
$replace
,
$text
);
}
/**
...
...
@@ -122,8 +126,7 @@ class MailGoManager {
* Processed text
*/
public
function
stripMailto
(
string
$text
)
{
$regex
=
"/<a(?:.*)href=(?:
\"
|')mailto:(.+)(?:
\"
|')(?:.*)>(.+)<\/a>/Ui"
;
return
preg_replace
(
$regex
,
"$1"
,
$text
);
return
preg_replace
(
self
::
MAILTO_LINK_REGEX
,
"$1"
,
$text
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment