2121from invenio .messages import gettext_set_language
2222
2323
24- def format_email (email , email_href = "yes" , icon = "no" ):
24+ def format_email (email , email_href = "yes" , icon = "no" , vcard_support = "no" ):
2525 """Return formatted email address."""
26+ vcard_enabled = True if vcard_support .lower () == "yes" else False
27+
2628 if email_href .lower () == "yes" :
27- email = "<a href='mailto:{0}'>{0}</a>" .format (email )
29+ email = "<a {0}href='mailto:{1}'>{1}</a>" .format (
30+ "class='email' " if vcard_enabled else "" , email )
31+ else :
32+ if vcard_enabled :
33+ email = "<span class='email'>{0}</span>" .format (email )
2834 if icon .lower () == "yes" :
2935 icon_class = "fa fa-envelope"
3036 email = "<i class='{0}' style='font-size: 0.9em;'></i> {1}" .format (
3137 icon_class , email )
3238 return email
3339
3440
35- def format_phone_number (phone_number , icon = "no" ):
41+ def format_phone_number (phone_number , icon = "no" , vcard_support = "no" ):
3642 """Return formatted phone number."""
43+ if vcard_support .lower () == "yes" :
44+ phone_number = (
45+ "<span class='tel'>"
46+ "<span class='type' style='display: none;'>work</span>"
47+ "<span class='value'>{0}</span>"
48+ "</span>" .format (phone_number ))
3749 if icon .lower () == "yes" :
3850 icon_class = "fa fa-phone"
3951 phone_number = "<i class='{0}'></i> {1}" .format (
4052 icon_class , phone_number )
4153 return phone_number
4254
4355
44- def format_mobile_number (mobile_number , icon = "no" ):
56+ def format_mobile_number (mobile_number , icon = "no" , vcard_support = "no" ):
4557 """Return formatted mobile phone number."""
58+ if vcard_support .lower () == "yes" :
59+ mobile_number = (
60+ "<span class='tel'>"
61+ "<span class='type' style='display: none;'>cell</span>"
62+ "<span class='value'>{0}</span>"
63+ "</span>" .format (mobile_number ))
4664 if icon .lower () == "yes" :
4765 icon_class = "fa fa-mobile"
4866 mobile_number = "<i class='{0}'></i> {1}" .format (
4967 icon_class , mobile_number )
5068 return mobile_number
5169
5270
53- def format_fax_number (fax_number , icon = "no" ):
71+ def format_fax_number (fax_number , icon = "no" , vcard_support = "no" ):
5472 """Return formatted fax number."""
73+ if vcard_support .lower () == "yes" :
74+ fax_number = (
75+ "<span class='tel'>"
76+ "<span class='type' style='display: none;'>fax</span>"
77+ "<span class='value'>{0}</span>"
78+ "</span>" .format (fax_number ))
5579 if icon .lower () == "yes" :
5680 icon_class = "fa fa-fax"
5781 fax_number = "<i class='{0}'></i> {1}" .format (icon_class , fax_number )
5882 return fax_number
5983
6084
61- def format_element (bfo , contact_type = "all" , email_href = "yes" , icon = "no" ):
85+ def format_element (bfo , contact_type = "all" , vcard_support = "no" ,
86+ email_href = "yes" , icon = "no" ):
6287 """Return contact information for the record.
6388
6489 :param string contact_type: return all contact information if 'all',
@@ -79,10 +104,12 @@ def format_element(bfo, contact_type="all", email_href="yes", icon="no"):
79104 tbl_row = "<tr><th>{0}</th><td>{1}</td></tr>"
80105 if email :
81106 result += tbl_row .format (
82- _ ("Email address" ), format_email (email [0 ].lower (), email_href ))
107+ _ ("Email address" ), format_email (
108+ email [0 ].lower (), email_href , vcard_support = vcard_support ))
83109 if phone_number :
84110 result += tbl_row .format (
85- _ ("Phone number" ), format_phone_number (phone_number [0 ]))
111+ _ ("Phone number" ), format_phone_number (
112+ phone_number [0 ], vcard_support = vcard_support ))
86113 if mobile_number :
87114 result += tbl_row .format (
88115 _ ("Mobile number" ), format_mobile_number (mobile_number [0 ]))
0 commit comments