Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
OLAT CI-CD Testing Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
GitLab is undergoing maintenance
You are on a read-only GitLab instance.
Show more breadcrumbs
Lars Oliver Dam
OLAT CI-CD Testing Project
Commits
3bf340c1
Commit
3bf340c1
authored
8 years ago
by
dfurrer
Browse files
Options
Downloads
Patches
Plain Diff
OO-1969:changed link from 'callto' to 'tel' , added method to format phonenumber for this link
parent
cad5aa9e
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
src/main/java/org/olat/user/propertyhandlers/PhonePropertyHandler.java
+9
-2
9 additions, 2 deletions
.../org/olat/user/propertyhandlers/PhonePropertyHandler.java
src/test/java/org/olat/user/UserPropertiesTest.java
+18
-0
18 additions, 0 deletions
src/test/java/org/olat/user/UserPropertiesTest.java
with
27 additions
and
2 deletions
src/main/java/org/olat/user/propertyhandlers/PhonePropertyHandler.java
+
9
−
2
View file @
3bf340c1
...
@@ -62,14 +62,21 @@ public class PhonePropertyHandler extends Generic127CharTextPropertyHandler {
...
@@ -62,14 +62,21 @@ public class PhonePropertyHandler extends Generic127CharTextPropertyHandler {
if
(
StringHelper
.
containsNonWhitespace
(
phonenr
))
{
if
(
StringHelper
.
containsNonWhitespace
(
phonenr
))
{
phonenr
=
StringHelper
.
escapeHtml
(
phonenr
);
phonenr
=
StringHelper
.
escapeHtml
(
phonenr
);
StringBuffer
sb
=
new
StringBuffer
();
StringBuffer
sb
=
new
StringBuffer
();
sb
.
append
(
"<a href=\"
callto
:"
)
sb
.
append
(
"<a href=\"
tel
:"
)
.
append
(
phonenr
).
append
(
"\"><i class='o_icon o_icon_phone'> </i> "
)
.
append
(
normalizePhonenumber
(
phonenr
)
)
.
append
(
"\"><i class='o_icon o_icon_phone'> </i> "
)
.
append
(
phonenr
).
append
(
"</a>"
);
.
append
(
phonenr
).
append
(
"</a>"
);
return
sb
.
toString
();
return
sb
.
toString
();
}
}
return
null
;
return
null
;
}
}
public
static
String
normalizePhonenumber
(
String
phonenr
){
phonenr
=
phonenr
.
split
(
"[A-Za-z]"
)[
0
];
//just take the first sequence before a alphabetic character appears
phonenr
=
phonenr
.
replaceAll
(
"\\(.*\\)"
,
""
);
// remove brackets and their contents
phonenr
=
phonenr
.
replaceAll
(
"[\\s/'\\-\\.,]"
,
""
);
//remove bad chars
return
phonenr
;
}
/* (non-Javadoc)
/* (non-Javadoc)
* @see org.olat.user.propertyhandlers.Generic127CharTextPropertyHandler#isValid(org.olat.core.gui.components.form.flexible.FormItem, java.util.Map)
* @see org.olat.user.propertyhandlers.Generic127CharTextPropertyHandler#isValid(org.olat.core.gui.components.form.flexible.FormItem, java.util.Map)
*/
*/
...
...
This diff is collapsed.
Click to expand it.
src/test/java/org/olat/user/UserPropertiesTest.java
+
18
−
0
View file @
3bf340c1
...
@@ -78,4 +78,22 @@ public class UserPropertiesTest {
...
@@ -78,4 +78,22 @@ public class UserPropertiesTest {
assertFalse
(
phoneHandler
.
isValidValue
(
null
,
"+41 43 frentix GmbH"
,
error
,
null
));
assertFalse
(
phoneHandler
.
isValidValue
(
null
,
"+41 43 frentix GmbH"
,
error
,
null
));
}
}
@Test
public
void
testPhonePropertyHandlerHTMLnormalizer
()
{
// test for valid phone number formats
assertTrue
(
PhonePropertyHandler
.
normalizePhonenumber
(
"043 544 90 00"
).
equals
(
"0435449000"
));
assertTrue
(
PhonePropertyHandler
.
normalizePhonenumber
(
"043/544'90'00"
).
equals
(
"0435449000"
));
assertTrue
(
PhonePropertyHandler
.
normalizePhonenumber
(
"043-544-90-00"
).
equals
(
"0435449000"
));
assertTrue
(
PhonePropertyHandler
.
normalizePhonenumber
(
"043.544.90.00"
).
equals
(
"0435449000"
));
assertTrue
(
PhonePropertyHandler
.
normalizePhonenumber
(
"+41 43 544 90 00"
).
equals
(
"+41435449000"
));
assertTrue
(
PhonePropertyHandler
.
normalizePhonenumber
(
"+41 (0)43 544 90 00"
).
equals
(
"+41435449000"
));
assertTrue
(
PhonePropertyHandler
.
normalizePhonenumber
(
"+41 43 544 90 00 x0"
).
equals
(
"+41435449000"
));
assertTrue
(
PhonePropertyHandler
.
normalizePhonenumber
(
"+41 43 544 90 00 ext. 0"
).
equals
(
"+41435449000"
));
assertTrue
(
PhonePropertyHandler
.
normalizePhonenumber
(
"+41 43 544 90 00 ext0"
).
equals
(
"+41435449000"
));
assertTrue
(
PhonePropertyHandler
.
normalizePhonenumber
(
"+41 43 544 90 00 ext 0"
).
equals
(
"+41435449000"
));
assertTrue
(
PhonePropertyHandler
.
normalizePhonenumber
(
"+41 43 544 90 00 extension 0"
).
equals
(
"+41435449000"
));
assertTrue
(
PhonePropertyHandler
.
normalizePhonenumber
(
"+41 43 544 90 00 Extension 0"
).
equals
(
"+41435449000"
));
assertTrue
(
PhonePropertyHandler
.
normalizePhonenumber
(
"+41 43 544 90 00 ext. 0"
).
equals
(
"+41435449000"
));
}
}
}
\ No newline at end of file
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