FINAL suepr merge step : added all modules to this super repos
This commit is contained in:
339
sites/all/modules/contrib/form/phone/LICENSE.txt
Normal file
339
sites/all/modules/contrib/form/phone/LICENSE.txt
Normal file
@@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
62
sites/all/modules/contrib/form/phone/README.int.txt
Normal file
62
sites/all/modules/contrib/form/phone/README.int.txt
Normal file
@@ -0,0 +1,62 @@
|
||||
About the International Phone Number format
|
||||
===========================================
|
||||
|
||||
These rules have been formulated off of the E.123 (for display) and
|
||||
E.164 (for input) specifications published by the ITU. In order to
|
||||
prevent ambiguity, we have chosen to restrict some of the stipulations
|
||||
these specifications give.
|
||||
|
||||
In summary, country calling codes are assigned by the ITU Telecommunication
|
||||
Standardization Sector in E.164. We take an international phone number to
|
||||
have the form +XX YYYYYYY where XX is the country code, and YYYYYYY to be
|
||||
the subscriber's number, possibly with intervening spaces. The maximum
|
||||
length for these phone numbers is 15.
|
||||
|
||||
Reference materials can be found here:
|
||||
- http://www.itu.int/rec/T-REC-E.123/en
|
||||
- http://www.itu.int/rec/T-REC-E.164/en
|
||||
|
||||
Modifications to E.123
|
||||
----------------------
|
||||
|
||||
7.1: The international prefix symbol "+" MUST prefix international
|
||||
phone numbers. All numbers missing this symbol will be assumed to be in
|
||||
the default country code.
|
||||
|
||||
When reformatting numbers to a standard format, the following conventions
|
||||
will be taken:
|
||||
|
||||
7.2: Parentheses will be normalized to spaces.
|
||||
|
||||
We do not support the multiple phone numbers as described by (7.4); users
|
||||
can always specify that multiple values are allowed if this is desired.
|
||||
The functionality specified by 7.5, 7.6 and 8 IS NOT implemented.
|
||||
|
||||
9.2 specifies that spacing SHALL OCCUR between the country code, the trunk
|
||||
code and the subscriber number. As trunk codes are omitted by convention,
|
||||
this means the only guaranteed separation will be between the country code
|
||||
and subscriber number. Our implementation MAY treat hyphens, spaces and
|
||||
parentheses as advisory indicators as to where spaces should be placed.
|
||||
However, +1 7329060489 will stay as it was specified, while +1 (732) 906-0489
|
||||
will be normalized to +1 732 906 0489. As a future feature, rules may
|
||||
be implemented for country codes specifying these conventions, however,
|
||||
I have deemed such functionality out of scope for now.
|
||||
|
||||
The Drupal task specifies that we should validate country codes, however,
|
||||
due to the highly volatile nature of these codes, the author does not
|
||||
believe that it is a good idea to maintain a list of valid country codes.
|
||||
Thus, we only validate that the country code is three or less digits.
|
||||
|
||||
Modifications to E.164
|
||||
----------------------
|
||||
|
||||
Our processing for NDD's will be similarly constrained. As per
|
||||
7.3.2, we will treat 0 as a valid trunk code for all countries.
|
||||
Other digits may be specified if the fall in the form of (X), where X is
|
||||
a single digit that is 7 or 8.
|
||||
|
||||
Postscript
|
||||
----------
|
||||
|
||||
Modifications to our implementation will occur as necessary by user bug
|
||||
reports.
|
84
sites/all/modules/contrib/form/phone/README.txt
Normal file
84
sites/all/modules/contrib/form/phone/README.txt
Normal file
@@ -0,0 +1,84 @@
|
||||
|
||||
Copyright 2010 http://www.arvoriad.com
|
||||
|
||||
|
||||
Description
|
||||
-----------
|
||||
This module provides a phone field type for CCK.
|
||||
|
||||
Features:
|
||||
---------
|
||||
* Validation of phone numbers : support of
|
||||
+ France,
|
||||
+ Belgium,
|
||||
+ Great Britain,
|
||||
+ Switzerland,
|
||||
+ Italy,
|
||||
+ Greece,
|
||||
+ Netherland,
|
||||
+ Israel,
|
||||
+ Russia,
|
||||
+ Ukraine,
|
||||
+ Australia
|
||||
+ Spain,
|
||||
+ Czech,
|
||||
+ Hungary,
|
||||
+ Poland (mobile only),
|
||||
+ Costa Rica,
|
||||
+ Panamana,
|
||||
+ Brazil,
|
||||
+ Chili,
|
||||
+ New Zealand,
|
||||
+ China,
|
||||
+ Hong-Kong,
|
||||
+ Macau,
|
||||
+ Philippine,
|
||||
+ Singapore,
|
||||
+ US,
|
||||
+ Swiss,
|
||||
+ Jordan,
|
||||
+ Egypt,
|
||||
+ South Africa,
|
||||
+ Pakistan,
|
||||
and Canadian phone numbers
|
||||
and generic international phone numbers
|
||||
* Formating of phone numbers
|
||||
* Option for internationalization of phone numbers
|
||||
* IPhone support
|
||||
* Phone CCK fields can be used as a Token
|
||||
* This module is compatible with module http://drupal.org/project/node_import Node Import module, this module allowing to import data into phone fields
|
||||
|
||||
Prerequisites
|
||||
-------------
|
||||
The phone.module requires the content.module to be installed.
|
||||
|
||||
Installation
|
||||
------------
|
||||
To install, copy the phone directory and all its contents to your modules
|
||||
directory.
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
To enable this module, visit administer -> modules, and enable phone.
|
||||
|
||||
Bugs/Features/Patches:
|
||||
----------------------
|
||||
If you want to report bugs, feature requests, or submit a patch, please do so
|
||||
at the project page on the Drupal web site.
|
||||
http://drupal.org/project/phone
|
||||
|
||||
Todo List:
|
||||
----------
|
||||
* add support to other country phone numbers
|
||||
* improve the validation of phone numbers for the different countries
|
||||
* internationalization of the module
|
||||
|
||||
Author
|
||||
------
|
||||
Thierry Guégan (http://www.arvoriad.com)
|
||||
|
||||
If you use this module, find it useful, and want to send the author
|
||||
a thank you note, then use the Feedback/Contact page at the URL above.
|
||||
|
||||
The author can also be contacted for paid customizations of this
|
||||
and other modules.
|
46
sites/all/modules/contrib/form/phone/countries.txt
Normal file
46
sites/all/modules/contrib/form/phone/countries.txt
Normal file
@@ -0,0 +1,46 @@
|
||||
ad => Andorran
|
||||
ar => Argentinan
|
||||
au => Australia
|
||||
bd => Bangladesh
|
||||
be => Belgium
|
||||
bn => Brunei
|
||||
br => Brazil
|
||||
by => Belarussia
|
||||
ca => Canadian
|
||||
ca => US & Canada
|
||||
ch => Switzerland
|
||||
cl => Chili
|
||||
cr => Costa Rica
|
||||
cs => Czech Republic
|
||||
cy => Cyprus
|
||||
de => Germany
|
||||
dk => Danish
|
||||
dz => Algeria
|
||||
ee => Estonia
|
||||
eg => Egypt
|
||||
es => Spain
|
||||
fr => France
|
||||
gp => Guadeloupe
|
||||
gw => Guinea Bissau
|
||||
hk => Hong-Kong
|
||||
hr => Croatia
|
||||
hu => Hungary
|
||||
il => Israel
|
||||
in => India
|
||||
it => Italy
|
||||
jo => Jordania
|
||||
mo => Macao
|
||||
nl => Netherland
|
||||
nz => New Zealand
|
||||
pa => Panamana
|
||||
ph => Philippine
|
||||
pk => Pakistan
|
||||
pl => Poland
|
||||
pt => Portugal
|
||||
ru => Russia
|
||||
se => Sweden
|
||||
sg => Singapore
|
||||
sn => Senegal
|
||||
ua => Ukraine
|
||||
uk => United Kingdom
|
||||
us => US
|
283
sites/all/modules/contrib/form/phone/include/phone.au.inc
Normal file
283
sites/all/modules/contrib/form/phone/include/phone.au.inc
Normal file
@@ -0,0 +1,283 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* CCK Field for Australian phone numbers.
|
||||
*/
|
||||
|
||||
function phone_au_metadata() {
|
||||
return array(
|
||||
'error' => '"%value" is not a valid Australian phone number<br>Australian phone numbers should contain only numbers with an optional prefix of "+61"',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verification for Australian Phone Numbers.
|
||||
* According to http://www.itu.int/itudoc/itu-t/number/a/aus/70772.html
|
||||
* (Released 2005/10/03, retrieved 2008/04/14)
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return boolean Returns boolean FALSE if the phone number is not valid.
|
||||
*/
|
||||
function valid_au_phone_number($phonenumber) {
|
||||
|
||||
//$phonenumber = trim($phonenumber);
|
||||
|
||||
// strip formatting chars
|
||||
$phonenumber = preg_replace('/[\-() ]/', '', $phonenumber);
|
||||
// strip optional '+61' or '0' prefixes
|
||||
$phonenumber = preg_replace('/^(\+61|0)/', '', $phonenumber);
|
||||
|
||||
//$rules[] = array("Prefix","Minimum length","Maximum length");
|
||||
$rules[] = array("10", 5, 15);
|
||||
$rules[] = array("12", 5, 15);
|
||||
$rules[] = array("13", 6, 10);
|
||||
$rules[] = array("1451", 9, 9);
|
||||
$rules[] = array("1452", 9, 9);
|
||||
$rules[] = array("1453", 9, 9);
|
||||
$rules[] = array("1471", 9, 9);
|
||||
$rules[] = array("16", 5, 9);
|
||||
$rules[] = array("1800", 10, 10);
|
||||
$rules[] = array("1801", 8, 8);
|
||||
$rules[] = array("1900", 10, 10);
|
||||
$rules[] = array("1901", 10, 10);
|
||||
$rules[] = array("1902", 10, 10);
|
||||
$rules[] = array("1906", 10, 10);
|
||||
$rules[] = array("1983", 9, 9);
|
||||
$rules[] = array("2001", 4, 4);
|
||||
$rules[] = array("2002", 4, 4);
|
||||
$rules[] = array("2003", 4, 4);
|
||||
//$rules[] = array("2", 9, 9); // More specific rules follow
|
||||
$rules[] = array("240", 9, 9);
|
||||
$rules[] = array("242", 9, 9);
|
||||
$rules[] = array("243", 9, 9);
|
||||
$rules[] = array("244", 9, 9);
|
||||
$rules[] = array("245", 9, 9);
|
||||
$rules[] = array("246", 9, 9);
|
||||
$rules[] = array("247", 9, 9);
|
||||
$rules[] = array("248", 9, 9);
|
||||
$rules[] = array("249", 9, 9);
|
||||
$rules[] = array("260", 9, 9);
|
||||
$rules[] = array("261", 9, 9);
|
||||
$rules[] = array("262", 9, 9);
|
||||
$rules[] = array("263", 9, 9);
|
||||
$rules[] = array("264", 9, 9);
|
||||
$rules[] = array("265", 9, 9);
|
||||
$rules[] = array("266", 9, 9);
|
||||
$rules[] = array("267", 9, 9);
|
||||
$rules[] = array("268", 9, 9);
|
||||
$rules[] = array("269", 9, 9);
|
||||
$rules[] = array("28", 9, 9);
|
||||
$rules[] = array("29", 9, 9);
|
||||
//$rules[] = array("3", 9, 9); // More specific rules follow
|
||||
$rules[] = array("350", 9, 9);
|
||||
$rules[] = array("351", 9, 9);
|
||||
$rules[] = array("352", 9, 9);
|
||||
$rules[] = array("353", 9, 9);
|
||||
$rules[] = array("354", 9, 9);
|
||||
$rules[] = array("355", 9, 9);
|
||||
$rules[] = array("356", 9, 9);
|
||||
$rules[] = array("357", 9, 9);
|
||||
$rules[] = array("358", 9, 9);
|
||||
$rules[] = array("359", 9, 9);
|
||||
$rules[] = array("362", 9, 9);
|
||||
$rules[] = array("363", 9, 9);
|
||||
$rules[] = array("364", 9, 9);
|
||||
$rules[] = array("38", 9, 9);
|
||||
$rules[] = array("39", 9, 9);
|
||||
// begin mobile phone numbers
|
||||
$rules[] = array("400", 9, 9);
|
||||
$rules[] = array("401", 9, 9);
|
||||
$rules[] = array("402", 9, 9);
|
||||
$rules[] = array("403", 9, 9);
|
||||
$rules[] = array("404", 9, 9);
|
||||
$rules[] = array("405", 9, 9);
|
||||
$rules[] = array("406", 9, 9);
|
||||
$rules[] = array("407", 9, 9);
|
||||
$rules[] = array("408", 9, 9);
|
||||
$rules[] = array("409", 9, 9);
|
||||
$rules[] = array("410", 9, 9);
|
||||
$rules[] = array("411", 9, 9);
|
||||
$rules[] = array("412", 9, 9);
|
||||
$rules[] = array("413", 9, 9);
|
||||
$rules[] = array("414", 9, 9);
|
||||
$rules[] = array("415", 9, 9);
|
||||
$rules[] = array("416", 9, 9);
|
||||
$rules[] = array("417", 9, 9);
|
||||
$rules[] = array("418", 9, 9);
|
||||
$rules[] = array("419", 9, 9);
|
||||
$rules[] = array("420", 9, 9);
|
||||
$rules[] = array("4200", 9, 9);
|
||||
$rules[] = array("42010", 9, 9);
|
||||
$rules[] = array("421", 9, 9);
|
||||
$rules[] = array("422", 9, 9);
|
||||
$rules[] = array("423", 9, 9);
|
||||
$rules[] = array("424", 9, 9);
|
||||
$rules[] = array("425", 9, 9);
|
||||
$rules[] = array("4251", 9, 9);
|
||||
$rules[] = array("4252", 9, 9);
|
||||
$rules[] = array("4253", 9, 9);
|
||||
$rules[] = array("4256", 9, 9);
|
||||
$rules[] = array("4257", 9, 9);
|
||||
$rules[] = array("4258", 9, 9);
|
||||
$rules[] = array("427", 9, 9);
|
||||
$rules[] = array("428", 9, 9);
|
||||
$rules[] = array("429", 9, 9);
|
||||
$rules[] = array("430", 9, 9);
|
||||
$rules[] = array("4300", 9, 9);
|
||||
$rules[] = array("4301", 9, 9);
|
||||
$rules[] = array("4302", 9, 9);
|
||||
$rules[] = array("4303", 9, 9);
|
||||
$rules[] = array("4304", 9, 9);
|
||||
$rules[] = array("4305", 9, 9);
|
||||
$rules[] = array("431", 9, 9);
|
||||
$rules[] = array("432", 9, 9);
|
||||
$rules[] = array("433", 9, 9);
|
||||
$rules[] = array("434", 9, 9);
|
||||
$rules[] = array("435", 9, 9);
|
||||
$rules[] = array("4350", 9, 9);
|
||||
$rules[] = array("437", 9, 9);
|
||||
$rules[] = array("438", 9, 9);
|
||||
$rules[] = array("439", 9, 9);
|
||||
$rules[] = array("447", 9, 9);
|
||||
$rules[] = array("448", 9, 9);
|
||||
$rules[] = array("449", 9, 9);
|
||||
$rules[] = array("449", 9, 9);
|
||||
$rules[] = array("450", 9, 9);
|
||||
$rules[] = array("451", 9, 9);
|
||||
$rules[] = array("457", 9, 9);
|
||||
$rules[] = array("458", 9, 9);
|
||||
$rules[] = array("4590", 9, 9);
|
||||
$rules[] = array("4591", 9, 9);
|
||||
$rules[] = array("4592", 9, 9);
|
||||
$rules[] = array("466", 9, 9);
|
||||
$rules[] = array("488", 9, 9);
|
||||
// end mobile phone numbers
|
||||
$rules[] = array("50", 9, 9);
|
||||
$rules[] = array("51", 9, 9);
|
||||
$rules[] = array("52", 9, 9);
|
||||
$rules[] = array("53", 9, 9);
|
||||
$rules[] = array("54", 9, 9);
|
||||
$rules[] = array("55", 9, 9);
|
||||
$rules[] = array("56", 9, 9);
|
||||
$rules[] = array("57", 9, 9);
|
||||
$rules[] = array("58", 9, 9);
|
||||
//$rules[] = array("59", 9, 9); //Not for use after 31 December 2005
|
||||
//$rules[] = array("7", 9, 9); // More specific rules follow
|
||||
$rules[] = array("73", 9, 9);
|
||||
$rules[] = array("740", 9, 9);
|
||||
$rules[] = array("741", 9, 9);
|
||||
$rules[] = array("745", 9, 9);
|
||||
$rules[] = array("746", 9, 9);
|
||||
$rules[] = array("747", 9, 9);
|
||||
$rules[] = array("749", 9, 9);
|
||||
$rules[] = array("754", 9, 9);
|
||||
$rules[] = array("755", 9, 9);
|
||||
$rules[] = array("756", 9, 9);
|
||||
//$rules[] = array("8", 9, 9); // More specific rules follow
|
||||
$rules[] = array("86", 9, 9);
|
||||
$rules[] = array("871", 9, 9);
|
||||
$rules[] = array("872", 9, 9);
|
||||
$rules[] = array("873", 9, 9);
|
||||
$rules[] = array("874", 9, 9);
|
||||
$rules[] = array("880", 9, 9);
|
||||
$rules[] = array("881", 9, 9);
|
||||
$rules[] = array("882", 9, 9);
|
||||
$rules[] = array("883", 9, 9);
|
||||
$rules[] = array("884", 9, 9);
|
||||
$rules[] = array("885", 9, 9);
|
||||
$rules[] = array("886", 9, 9);
|
||||
$rules[] = array("887", 9, 9);
|
||||
$rules[] = array("888", 9, 9);
|
||||
$rules[] = array("889", 9, 9);
|
||||
$rules[] = array("890", 9, 9);
|
||||
$rules[] = array("891", 9, 9);
|
||||
$rules[] = array("892", 9, 9);
|
||||
$rules[] = array("893", 9, 9);
|
||||
$rules[] = array("894", 9, 9);
|
||||
$rules[] = array("895", 9, 9);
|
||||
$rules[] = array("896", 9, 9);
|
||||
$rules[] = array("897", 9, 9);
|
||||
$rules[] = array("898", 9, 9);
|
||||
$rules[] = array("899", 9, 9);
|
||||
|
||||
foreach ($rules as $rule) {
|
||||
if (preg_match('/^'.$rule[0].'/', $phonenumber) && strlen($phonenumber) >= $rule[1] && strlen($phonenumber) <= $rule[2]) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formatting for Australian Phone Numbers. Based upon ITU-T E.123 (but let's not get too crazy)
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return string Returns a string containing the phone number with some formatting.
|
||||
*/
|
||||
function format_au_phone_number($phonenumber, $field = FALSE) {
|
||||
$prefix = '';
|
||||
$extension = '';
|
||||
// strip old formatting chars
|
||||
$phonenumber = preg_replace('/[\-() ]/', '', $phonenumber);
|
||||
|
||||
/*
|
||||
* strip and save the +61 prefix if found
|
||||
*/
|
||||
if (preg_match('/^\+61/', $phonenumber, $match)) {
|
||||
$prefix = '+61 ';
|
||||
$phonenumber = str_replace('+61', '', $phonenumber);
|
||||
}
|
||||
|
||||
/*
|
||||
* strip and save the extension (x9999) postfix if found
|
||||
*/
|
||||
if (preg_match('/(x[0-9]+)$/', $phonenumber, $match)) {
|
||||
$extension = ' ('.$match[1].')';
|
||||
$phonenumber = preg_replace('/x[0-9]+$/', '', $phonenumber);
|
||||
}
|
||||
|
||||
/*
|
||||
* geographic numbers and UPT
|
||||
* Eg. (02) 9999 9999 or +61 (2) 9999 9999
|
||||
*/
|
||||
if (preg_match('/^(0{0,1}[23578])([0-9]{4})([0-9]{4})$/', $phonenumber, $match)) {
|
||||
return $prefix . '(' . $match[1] . ') ' . $match[2] . ' ' . $match[3] . $extension;
|
||||
}
|
||||
|
||||
/*
|
||||
* mobile numbers
|
||||
* Eg. 0423 999 999 or +61 423 999 999
|
||||
*/
|
||||
if (preg_match('/^(0{0,1}4[0-9]{2})([0-9]{3})([0-9]{3})$/', $phonenumber, $match)) {
|
||||
return $prefix . $match[1] . ' ' . $match[2] . ' ' . $match[3] . $extension;
|
||||
}
|
||||
|
||||
/*
|
||||
* 10 digit numbers
|
||||
* Eg. 1800 999 999
|
||||
*/
|
||||
if (preg_match('/^([0-9]{4})([0-9]{3})([0-9]{3})$/', $phonenumber, $match)) {
|
||||
return $prefix . $match[1] . ' ' . $match[2] . ' ' . $match[3] . $extension;
|
||||
}
|
||||
|
||||
/*
|
||||
* 9 digit satellite or dialup data numbers
|
||||
* Eg. 1471 99999
|
||||
*/
|
||||
if (preg_match('/^(14[0-9]{2}|1983)([0-9]{5})$/', $phonenumber, $match)) {
|
||||
return $prefix . $match[1] . ' ' . $match[2] . $extension;
|
||||
}
|
||||
|
||||
/*
|
||||
* 6 digit numbers
|
||||
* Eg. 13 99 99
|
||||
*/
|
||||
if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})$/', $phonenumber, $match)) {
|
||||
return $prefix . $match[1] . ' ' . $match[2] . ' ' . $match[3] . $extension;
|
||||
}
|
||||
|
||||
// default
|
||||
return $prefix . $phonenumber . $extension;
|
||||
}
|
||||
|
48
sites/all/modules/contrib/form/phone/include/phone.be.inc
Normal file
48
sites/all/modules/contrib/form/phone/include/phone.be.inc
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* CCK Field for Belgian phone numbers.
|
||||
*/
|
||||
|
||||
function phone_be_metadata() {
|
||||
// These strings are translated using t() on output.
|
||||
return array(
|
||||
'error' => '"%value" is not a valid Belgian phone number<br>Belgian phone numbers should only ...',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that $phonenumber is valid
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return boolean Returns boolean FALSE if the phone number is not valid.
|
||||
*/
|
||||
function valid_be_phone_number($phonenumber) {
|
||||
// define regular expression
|
||||
$regex = "/^(\+32|0)[1-9]\d{7,8}$/i";
|
||||
|
||||
|
||||
$phonenumber = str_replace(array(' ','-','(',')'), '', $phonenumber);
|
||||
// return true if valid, false otherwise
|
||||
return (bool) preg_match($regex, $phonenumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formatting for Belgian Phone Numbers.
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return string Returns a string containting the phone number with some formatting.
|
||||
*/
|
||||
function format_be_phone_number($phonenumber, $field) {
|
||||
|
||||
$phonenumber = trim($phonenumber);
|
||||
|
||||
if ($field['phone_country_code']) {
|
||||
if ($matches[1] != "+32") {
|
||||
$phonenumber = "+32" . " " . $phonenumber;
|
||||
}
|
||||
}
|
||||
|
||||
return $phonenumber;
|
||||
}
|
51
sites/all/modules/contrib/form/phone/include/phone.br.inc
Normal file
51
sites/all/modules/contrib/form/phone/include/phone.br.inc
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* CCK Field for Brazilian phone numbers.
|
||||
* (based on CCK Field for French phone numbers.)
|
||||
*/
|
||||
define('PHONE_BR_REGEX', "/^(\+|0{2}|)?(55|0|)[\s.-]?((\(0?[1-9][0-9]\))|(0?[1-9][0-9]))[\s.-]?([1-9][0-9]{2,4})[\s.-]?([0-9]{4})$/");
|
||||
|
||||
function phone_br_metadata() {
|
||||
return array(
|
||||
'error' => '"%value" is not a valid Brazilian phone number<br>Brazilian phone numbers should contain only numbers and spaces and - and be like 099 9999-9999, 99 9999-9999 or 99 99999-9999 with an optional prefix of "+55".',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verification for Brazilian Phone Numbers.
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return boolean Returns boolean FALSE if the phone number is not valid.
|
||||
*/
|
||||
function valid_br_phone_number($phonenumber) {
|
||||
|
||||
$phonenumber = trim($phonenumber);
|
||||
/*
|
||||
$phonenumber = str_replace(array(' ','-','(',')'), '', $phonenumber);
|
||||
*/
|
||||
return (bool) preg_match(PHONE_BR_REGEX, $phonenumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formatting for Brazilian Phone Numbers.
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return string Returns a string containting the phone number with some formatting.
|
||||
*/
|
||||
function format_br_phone_number($phonenumber, $field = FALSE) {
|
||||
$phone = str_replace(array(' ','-','(',')'), '', $phonenumber);
|
||||
if (preg_match(PHONE_BR_REGEX, $phone, $matches) != 1) {
|
||||
return $phonenumber; // this is possible?
|
||||
}
|
||||
$formatedphone = '';
|
||||
if ($field && $field['phone_country_code']) {
|
||||
$formatedphone .= '+55 ';
|
||||
}
|
||||
$formatedphone .= '(' . $matches[3] . ')';
|
||||
$formatedphone .= ' ' . $matches[6] . '-';
|
||||
$formatedphone .= '' . $matches[7];
|
||||
|
||||
return $formatedphone;
|
||||
}
|
91
sites/all/modules/contrib/form/phone/include/phone.ca.inc
Normal file
91
sites/all/modules/contrib/form/phone/include/phone.ca.inc
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* CCK Field for Canadian phone numbers.
|
||||
*/
|
||||
|
||||
function phone_ca_metadata() {
|
||||
return array(
|
||||
'error' => '"%value" is not a valid North American phone number<br>North American Phone numbers should only contain numbers and + and - and ( and ) and spaces and be like 999-999-9999. Please enter a valid ten-digit phone number with optional extension.',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that $phonenumber is a valid ten-digit North American phone number
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return boolean Returns boolean FALSE if the phone number is not valid.
|
||||
*/
|
||||
|
||||
function valid_ca_phone_number($phonenumber) {
|
||||
|
||||
$phonenumber = trim($phonenumber);
|
||||
|
||||
// define regular expression
|
||||
$regex = '/
|
||||
\D* # ignore non-digits
|
||||
(\d*) # an optional 1
|
||||
\D* # optional separator
|
||||
[2-9][0-8]\d # area code (Allowed range of [2-9] for the first digit, [0-8] for the second, and [0-9] for the third digit)
|
||||
\D* # optional separator
|
||||
[2-9]\d{2} # 3-digit prefix (cannot start with 0 or 1)
|
||||
\D* # optional separator
|
||||
\d{4} # 4-digit line number
|
||||
\D* # optional separator
|
||||
\d* # optional extension
|
||||
\D* # ignore trailing non-digits
|
||||
/x';
|
||||
// return true if valid, false otherwise
|
||||
$result = preg_match($regex, $phonenumber, $matches);
|
||||
return ($result && ($matches[1] == '' || $matches[1] == '1'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a valid North American phone number into standard (444) 867-5309 x1234 format
|
||||
*
|
||||
* @param $phonenumber must be a valid ten-digit number (with optional extension)
|
||||
*
|
||||
*/
|
||||
function format_ca_phone_number($phonenumber, $field) {
|
||||
|
||||
// define regular expression
|
||||
$regex = '/
|
||||
\D* # ignore non-digits
|
||||
(\d*) # an optional 1
|
||||
\D* # optional separator
|
||||
([2-9][0-8]\d) # area code (Allowed range of [2-9] for the first digit, [0-8] for the second, and [0-9] for the third digit)
|
||||
\D* # optional separator
|
||||
([2-9]\d{2}) # 3-digit prefix (cannot start with 0 or 1)
|
||||
\D* # optional separator
|
||||
(\d{4}) # 4-digit line number
|
||||
\D* # optional separator
|
||||
(\d*) # optional extension
|
||||
\D* # ignore trailing non-digits
|
||||
/x';
|
||||
|
||||
// get digits of phone number
|
||||
preg_match($regex, $phonenumber, $matches);
|
||||
|
||||
$separator = isset($field['ca_phone_separator']) ? $field['ca_phone_separator'] : '-';
|
||||
|
||||
// construct ten-digit phone number
|
||||
$phonenumber =
|
||||
( $field['ca_phone_parentheses'] ?
|
||||
'(' . $matches[2] . ') ' :
|
||||
$matches[2] . $separator ) .
|
||||
$matches[3] . $separator . $matches[4];
|
||||
|
||||
// Optional extension
|
||||
if ($matches[5] != '') {
|
||||
$phonenumber .= ' x' . $matches[5];
|
||||
}
|
||||
|
||||
if ($field['phone_country_code']) {
|
||||
// This condition check is pointless.
|
||||
if ($matches[1] != '1') {
|
||||
$phonenumber = '1' . ' ' . $phonenumber;
|
||||
}
|
||||
}
|
||||
return $phonenumber;
|
||||
}
|
51
sites/all/modules/contrib/form/phone/include/phone.ch.inc
Normal file
51
sites/all/modules/contrib/form/phone/include/phone.ch.inc
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* CCK Field for Switzerland phone numbers.
|
||||
*/
|
||||
|
||||
define('PHONE_CH_REGEX', "%(\+41|0|0041)([2-9]\d{8})$%");
|
||||
|
||||
function phone_ch_metadata() {
|
||||
// These strings are translated using t() on output.
|
||||
return array(
|
||||
'error' => '"%value" is not a valid Swiss phone number<br>Swiss phone numbers should only contain numbers and spaces and be like 099 999 99 99',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verification for private/standr switzerland Phone Numbers (E.164/2002).
|
||||
* According to http://en.wikipedia.org/wiki/Telephone_numbers_in_Switzerland#After_2002
|
||||
* (Released 2002)
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return boolean Returns boolean FALSE if the phone number is not valid.
|
||||
*/
|
||||
function valid_ch_phone_number($phonenumber) {
|
||||
$phonenumber = str_replace(array(' ','-','.','/','(',')'), '', $phonenumber);
|
||||
$match =array();
|
||||
$result = (bool) preg_match(PHONE_CH_REGEX, $phonenumber, $match);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formatting for Switzerland Phone Numbers.
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return string Returns a string containting the phone number with some formatting.
|
||||
*/
|
||||
function format_ch_phone_number($phonenumber, $field = FALSE) {
|
||||
$phone = str_replace(array(' ','-','.','/','(',')'), '', $phonenumber);
|
||||
$matches =array();
|
||||
if (preg_match(PHONE_CH_REGEX, $phone, $matches) != 1) {
|
||||
return $phonenumber; // not a switzerland phone number
|
||||
}
|
||||
|
||||
$value =($field && $field['phone_country_code'] ? '+41 (0)' : '0') .
|
||||
substr($matches[2],0,2).
|
||||
' '.substr($matches[2],2,3).
|
||||
' '.substr($matches[2],5,2).
|
||||
' '.substr($matches[2],7);
|
||||
return $value;
|
||||
}
|
49
sites/all/modules/contrib/form/phone/include/phone.cl.inc
Normal file
49
sites/all/modules/contrib/form/phone/include/phone.cl.inc
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* CCK Field for Chili phone numbers.
|
||||
*/
|
||||
|
||||
function phone_cl_metadata() {
|
||||
// These strings are translated using t() on output.
|
||||
return array(
|
||||
'error' => '"%value" is not a valid Chilean mobile phone number<br>Chili phone numbers should only ...',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that $phonenumber is valid
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return boolean Returns boolean FALSE if the phone number is not valid.
|
||||
*/
|
||||
function valid_cl_phone_number($phonenumber) {
|
||||
// define regular expression
|
||||
$regex = "/^((\(\d{3}\) ?)|(\d{3}-)|(\(\d{2}\) ?)|(\d{2}-)|(\(\d{1}\) ?)|(\d{1}-))?\d{3}-(\d{3}|\d{4})$/i";
|
||||
|
||||
// return true if valid, false otherwise
|
||||
return (bool) preg_match($regex, $phonenumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formatting for Chili Phone Numbers.
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return string Returns a string containting the phone number with some formatting.
|
||||
*/
|
||||
function format_cl_phone_number($phonenumber, $field) {
|
||||
|
||||
//$phonenumber = trim($phonenumber);
|
||||
|
||||
// do some formatting on the phone number
|
||||
|
||||
/* ==> to be done ==> add the country code
|
||||
if ($field['phone_country_code']) {
|
||||
if ($matches[1] != "+39") {
|
||||
$phonenumber = "+39" . " " . $phonenumber;
|
||||
}
|
||||
}
|
||||
*/
|
||||
return $phonenumber;
|
||||
}
|
41
sites/all/modules/contrib/form/phone/include/phone.cn.inc
Normal file
41
sites/all/modules/contrib/form/phone/include/phone.cn.inc
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* CCK Field for China phone numbers.
|
||||
*/
|
||||
|
||||
function phone_cn_metadata() {
|
||||
// These strings are translated using t() on output.
|
||||
return array(
|
||||
'error' => '"%value" is not a valid Chinese phone number!<br>Chinese phone numbers should ...',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that $phonenumber is a valid Chinese phone number
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return boolean Returns boolean FALSE if the phone number is not valid.
|
||||
*/
|
||||
function valid_cn_phone_number($phonenumber) {
|
||||
|
||||
$phonenumber = trim($phonenumber);
|
||||
|
||||
// define regular expression
|
||||
$regex = '/^(\+86|86)?( |-)?([0-9]{11}|([0-9]{3,4}(\-|\.| )[0-9]{3,8})|[0-9]{2}( |\-)[0-9]{4}[ ][0-9]{4}|[0-9]{2}\.[0-9]{2}\.[0-9]{2}\.[0-9]{2}\.[0-9]{2})$/';
|
||||
|
||||
// return true if valid, false otherwise
|
||||
return (bool) preg_match($regex, $phonenumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a valid Chinese phone number into standard ... format
|
||||
*
|
||||
* @param $phonenumber must be a valid number (with optional international prefix)
|
||||
*
|
||||
*/
|
||||
function format_cn_phone_number($phonenumber, $field) {
|
||||
|
||||
return $phonenumber;
|
||||
}
|
73
sites/all/modules/contrib/form/phone/include/phone.cr.inc
Normal file
73
sites/all/modules/contrib/form/phone/include/phone.cr.inc
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* CCK Field for Costa Rican phone numbers.
|
||||
*/
|
||||
|
||||
function phone_cr_metadata() {
|
||||
// These strings are translated using t() on output.
|
||||
return array(
|
||||
'error' => '"%value" is not a valid Costa Rican phone number!<br>Costa Rican phone numbers should contain only numbers and spaces be like 99 99 99 99 with an optional prefix of "+506" or "00506".',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that $phonenumber is a valid eight-digit Costa Rican phone number
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return boolean Returns boolean FALSE if the phone number is not valid.
|
||||
*/
|
||||
function valid_cr_phone_number($phonenumber) {
|
||||
|
||||
//$phonenumber = trim($phonenumber);
|
||||
|
||||
// define regular expression
|
||||
$regex = "/(00)?[\s|-]?((\+)?[\s|-]?[0-9]{3})?[\s|-]?([0-9]{2})[\s|-]?([0-9]{2})[\s|-]?([0-9]{2})[\s|-]?([0-9]{2})[\s|-]?/";
|
||||
|
||||
// return true if valid, false otherwise
|
||||
return (bool) preg_match($regex, $phonenumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a valid Costa Rican phone number into standard (+506) 5555 55 55 format
|
||||
*
|
||||
* @param $phonenumber must be a valid eight-digit number (with optional international prefix)
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
Accepts:
|
||||
+506 88798857
|
||||
+506 88-79-88-57
|
||||
00506 88798857
|
||||
00506 88-79-88-57
|
||||
Rejects:
|
||||
+506 8 8798857
|
||||
+506 8 8-79-88-57
|
||||
00506 8 8798857
|
||||
00506 8 8-79-88-57 */
|
||||
|
||||
function format_cr_phone_number($phonenumber, $field = FALSE) {
|
||||
|
||||
// define regular expression
|
||||
$regex = "/(00)?[\s|-]?((\+)?[\s|-]?[0-9]{3})?[\s|-]?([0-9]{2})[\s|-]?([0-9]{2})[\s|-]?([0-9]{2})[\s|-]?([0-9]{2})[\s|-]?/";
|
||||
|
||||
// get digits of phone number
|
||||
//dprint_r($matches);
|
||||
preg_match($regex, $phonenumber, $matches);
|
||||
|
||||
// construct eight-digit phone number
|
||||
|
||||
//dprint_r($matches);
|
||||
$phonenumber = $matches[4] . '-' . $matches[5] . '-' . $matches[6] . '-' . $matches[7];
|
||||
|
||||
if($matches[2]){
|
||||
if($matches[1])
|
||||
$phonenumber = "+" . $matches[2] . " " . $phonenumber;
|
||||
else
|
||||
$phonenumber = $matches[2] . " " . $phonenumber;
|
||||
}
|
||||
|
||||
return $phonenumber;
|
||||
}
|
54
sites/all/modules/contrib/form/phone/include/phone.cs.inc
Normal file
54
sites/all/modules/contrib/form/phone/include/phone.cs.inc
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* CCK Field for Czech phone numbers.
|
||||
*/
|
||||
|
||||
function phone_cs_metadata() {
|
||||
// These strings are translated using t() on output.
|
||||
return array(
|
||||
'error' => '"%value" is not a valid Czech phone number!<br>Czech phone numbers should contain only numbers and spaces be like 999 999 999 with an optional prefix of "+420" or "00420".',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that $phonenumber is a valid nine-digit Czech phone number
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return boolean Returns boolean FALSE if the phone number is not valid.
|
||||
*/
|
||||
function valid_cs_phone_number($phonenumber) {
|
||||
|
||||
$phonenumber = trim($phonenumber);
|
||||
|
||||
// define regular expression
|
||||
$regex = '/^((?:\+|00)420)? ?(\d{3}) ?(\d{3}) ?(\d{3})$/';
|
||||
|
||||
// return true if valid, false otherwise
|
||||
return (bool) preg_match($regex, $phonenumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a valid Czech phone number into standard (+420) 999 999 999 format
|
||||
*
|
||||
* @param $phonenumber must be a valid nine-digit number (with optional international prefix)
|
||||
*
|
||||
*/
|
||||
function format_cs_phone_number($phonenumber, $field) {
|
||||
|
||||
// define regular expression
|
||||
$regex = '/^((?:\+|00)420)? ?(\d{3}) ?(\d{3}) ?(\d{3})$/';
|
||||
|
||||
// get digits of phone number
|
||||
preg_match($regex, $phonenumber, $matches);
|
||||
|
||||
if ($field['phone_country_code']) {
|
||||
$phonenumber = '+420' . ' ' . $matches[2] .' '. $matches[3] .' '. $matches[4];
|
||||
}
|
||||
else {
|
||||
$phonenumber = $matches[2] .' '. $matches[3] .' '. $matches[4];
|
||||
}
|
||||
|
||||
return $phonenumber;
|
||||
}
|
143
sites/all/modules/contrib/form/phone/include/phone.eg.inc
Normal file
143
sites/all/modules/contrib/form/phone/include/phone.eg.inc
Normal file
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
/* 2009/10/24, Ahmad Gharbeia: initial release
|
||||
|
||||
General phone number format is +20 (#[#]) #######[#]
|
||||
currently (10/2009) only Greater Cairo (including all of Giza) has 8 digits:
|
||||
Regional area codes:
|
||||
??????? ?????? 2
|
||||
?????????? 3
|
||||
????????? 13
|
||||
?????? ?? ????? 15
|
||||
??????? 4
|
||||
??????? 45
|
||||
????? 46
|
||||
???????? 47
|
||||
???????? 48
|
||||
???????? 5
|
||||
??????? 55
|
||||
????? 57
|
||||
?????? 62
|
||||
??????????? 64
|
||||
??????? 65
|
||||
??????? 66
|
||||
?????? 68
|
||||
???? ????? 69
|
||||
??? ???? 82
|
||||
?????? 84
|
||||
?????? 86
|
||||
????? 88
|
||||
?????? ?????? 92
|
||||
????? 93
|
||||
?????? 95
|
||||
??? 96
|
||||
????? 97
|
||||
mobile network operators' area codes:
|
||||
Mobinil: 12, 16
|
||||
Vodafone: 10, 19
|
||||
Etisalat: 11, 18
|
||||
|
||||
**/
|
||||
define('AREA_CODE_REGEX', "
|
||||
(
|
||||
1(3|5)
|
||||
|3
|
||||
|4(5|6|7|8|)
|
||||
|5(5|7|)
|
||||
|6(2|4|5|6|8|9)
|
||||
|8(2|4|6|8)
|
||||
|9(2|3|5|6|7)
|
||||
)
|
||||
");
|
||||
|
||||
define('MOBILE_CODE_REGEX', "1(0|2|1|6|8|9)"); //area codes 10, 11, 12, 16, 18, or 19
|
||||
|
||||
define('TELEPHONE_REGEX', "
|
||||
(\+20)\s # optional countrycode optionally followed by a space
|
||||
(
|
||||
\(2\)\s(2|3)\d{3}\s\d{4} # 8-digit numbers begining with 2 or 3 (Greater Cairo: Cairo and Giza, both having area code = 2)
|
||||
|
|
||||
\(" . AREA_CODE_REGEX . "\)\s\d{3}\s\d{4} # all other areas' numbers have 7 digits. Checks for correct area codes
|
||||
|
|
||||
\(" . MOBILE_CODE_REGEX . "\)\s\d{3}\s\d{4} # mobile operators' networks' area codes; followed by 7 digits
|
||||
)
|
||||
(\s\#\s\d+)? # optional extension number shown with a hash divider
|
||||
");
|
||||
|
||||
function phone_eg_metadata() {
|
||||
// These strings are translated using t() on output.
|
||||
return array(
|
||||
'error' => '"%value" is not a valid phone number in Egypt. Telephone numbers in Egypt have the format +20 (#[#]) 1234567[8], where the digts between ( ) is the area or network code, without a leading zero; and digits between [ ] are optional',
|
||||
);
|
||||
|
||||
}#end function phone_eg_metadata;
|
||||
|
||||
|
||||
function valid_eg_phone_number($phonenumber) {
|
||||
/*
|
||||
accepts:
|
||||
properly formatted: [+20][ ][(]#[#][)][ ]1234[ ]567[#]
|
||||
common: [(][0#[#]][)][ ]123[ ]456[#]
|
||||
area code could be within paranthises and|or prefixed with 0
|
||||
*/
|
||||
|
||||
$regex = "/^ # the same as the model regex above, but with elements made optional
|
||||
(\+20)?\s? # country code, with following space being optional
|
||||
(
|
||||
(\(0?2\)|0?2)\s?(2|3)\d{3}\s?\d{4} # Greater Cairo, with leading optional zeros and optional braces around the area code
|
||||
|
|
||||
(\(0?" . AREA_CODE_REGEX . "\)|0?" . AREA_CODE_REGEX . ")\s?\d{3}\s?\d{4} # other areas, with optional leading zeros and braces
|
||||
|
|
||||
(\(0?" . MOBILE_CODE_REGEX . "\)|0?" . MOBILE_CODE_REGEX . ")\s?\d{3}\s?\d{4} # mobiles, with optional leading zeros and braces
|
||||
)
|
||||
(\s?\#\s?\d+)? # extension
|
||||
$/x";
|
||||
|
||||
return (bool) preg_match($regex, $phonenumber);
|
||||
|
||||
}#end function valid_eg_phone_number;
|
||||
|
||||
|
||||
function format_eg_phone_number($phonenumber, $field) {
|
||||
if (preg_match("/^" . TELEPHONE_REGEX . "$/x", $phonenumber)) { //already in proper format
|
||||
return $phonenumber;
|
||||
}
|
||||
else { //remove country code, zeros, and braces
|
||||
$phonenumber = preg_replace("/(^(\+20)?\s?|\(0?|\)|^0?)/", '', $phonenumber);
|
||||
}
|
||||
|
||||
//If there are some spaces in the number assume some level of preformatting
|
||||
if (preg_match("/ /", $phonenumber)) {
|
||||
$regex = "/^
|
||||
(
|
||||
(\d{1,2}) # area code
|
||||
\s* # ignore required separator
|
||||
(\d{3,4}) # 4 digits in case of Greater Cairo
|
||||
\s*
|
||||
(\d{4})
|
||||
)
|
||||
((\s*\#)?(\d*))? # extension
|
||||
$/x";
|
||||
preg_match($regex, $phonenumber, $matches);
|
||||
$area = $matches[2];
|
||||
$number = $matches[3] . ' ' . $matches[4];
|
||||
$extension = $matches[7];
|
||||
}
|
||||
else { //no spaces?, then apply some guessing
|
||||
$regex = "/^ # order is important in this one
|
||||
(
|
||||
(\d)(\d{4})(\d{4}) # 2 area code, followed by 8 digits begining with 2 or 3: Greater Cairo
|
||||
|
|
||||
(\d{1,2})(\d{3})(\d{4}) # 1 or 2-digit area code followed by 7 digits: regional or mobile
|
||||
)
|
||||
((\s*\#)?(\d*))?
|
||||
$/x";
|
||||
preg_match($regex, $phonenumber, $matches);
|
||||
$area = $matches[2];
|
||||
$number = $matches[3] . ' ' . $matches[4];
|
||||
$extension = $matches[5];
|
||||
}
|
||||
|
||||
return '+20 (' . $area . ') ' . $number . (empty($extension) ? '' : " #$extension");
|
||||
}#end function format_eg_phone_number;
|
||||
|
49
sites/all/modules/contrib/form/phone/include/phone.el.inc
Normal file
49
sites/all/modules/contrib/form/phone/include/phone.el.inc
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* CCK Field for Greek phone numbers.
|
||||
*/
|
||||
|
||||
function phone_el_metadata() {
|
||||
// These strings are translated using t() on output.
|
||||
return array(
|
||||
'error' => '"%value" is not a valid Greek phone number<br>Greek phone numbers should only ...',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that $phonenumber is valid
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return boolean Returns boolean FALSE if the phone number is not valid.
|
||||
*/
|
||||
function valid_el_phone_number($phonenumber) {
|
||||
// define regular expression
|
||||
$regex = "/^(\+30)?[ ]?([0-9]{3,4}(\/|-| )?[0-9]{6,7})$/i";
|
||||
|
||||
// return true if valid, false otherwise
|
||||
return (bool) preg_match($regex, $phonenumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formatting for Greek Phone Numbers.
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return string Returns a string containting the phone number with some formatting.
|
||||
*/
|
||||
function format_el_phone_number($phonenumber, $field) {
|
||||
|
||||
//$phonenumber = trim($phonenumber);
|
||||
|
||||
// do some formatting on the phone number
|
||||
$phonenumber = str_replace("[ -]", "", $phonenumber);
|
||||
|
||||
if ($field['phone_country_code']) {
|
||||
if ($matches[1] != "+30") {
|
||||
$phonenumber = "+30" . " " . $phonenumber;
|
||||
}
|
||||
}
|
||||
|
||||
return $phonenumber;
|
||||
}
|
73
sites/all/modules/contrib/form/phone/include/phone.es.inc
Normal file
73
sites/all/modules/contrib/form/phone/include/phone.es.inc
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* CCK Field for Spanish phone numbers.
|
||||
*/
|
||||
|
||||
function phone_es_metadata() {
|
||||
// These strings are translated using t() on output.
|
||||
return array(
|
||||
'error' => '"%value" is not a valid Spanish phone number<br>Spanish phone numbers should only contains numbers and spaces and be like 999 999 999',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Verifies that $phonenumber is a valid nine-digit Spanish phone number
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return boolean Returns boolean FALSE if the phone number is not valid.
|
||||
*/
|
||||
function valid_es_phone_number($phonenumber) {
|
||||
|
||||
$phonenumber = trim($phonenumber);
|
||||
|
||||
// define regular expression
|
||||
//$regex = "/
|
||||
// \D* # optional separator
|
||||
// [69]\d{2} # first group of numbers
|
||||
// \D* # optional separator
|
||||
// \d{3} # second group
|
||||
// \D* # optional separator
|
||||
// \d{3} # third group
|
||||
// \D* # ignore trailing non-digits
|
||||
// $/x";
|
||||
|
||||
$regex = '/^[0-9]{2,3}-? ?[0-9]{6,7}$/';
|
||||
|
||||
|
||||
// return true if valid, false otherwise
|
||||
return (bool) preg_match($regex, $phonenumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a valid Spanish phone number into standard (+34) 916 555 777 format
|
||||
*
|
||||
* @param $phonenumber must be a valid nine-digit number (with optional international prefix)
|
||||
*
|
||||
*/
|
||||
function format_es_phone_number($phonenumber, $field = FALSE) {
|
||||
|
||||
// define regular expression
|
||||
//$regex = "/
|
||||
// \D* # optional separator
|
||||
// ([69]\d{2}) # first group of numbers
|
||||
// \D* # optional separator
|
||||
// (\d{3}) # second group
|
||||
// \D* # optional separator
|
||||
// (\d{3}) # third group
|
||||
// \D* # ignore trailing non-digits
|
||||
// $/x";
|
||||
|
||||
$regex = '/^[0-9]{2,3}-? ?[0-9]{6,7}$/';
|
||||
|
||||
// get digits of phone number
|
||||
preg_match($regex, $phonenumber, $matches);
|
||||
|
||||
// construct ten-digit phone number
|
||||
$phonenumber = $matches[1] . ' ' . $matches[2] . ' ' . $matches[3];
|
||||
|
||||
return $phonenumber;
|
||||
}
|
||||
|
46
sites/all/modules/contrib/form/phone/include/phone.fr.inc
Normal file
46
sites/all/modules/contrib/form/phone/include/phone.fr.inc
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* CCK Field for French phone numbers.
|
||||
*/
|
||||
|
||||
define('PHONE_FR_REGEX', '/(\+33|0)([1-9]\d{8}|85\d{7}|87[0-57-9]\d{6})$/');
|
||||
|
||||
function phone_fr_metadata() {
|
||||
// These strings are translated using t() on output.
|
||||
return array(
|
||||
'error' => '"%value" is not a valid French phone number<br>French phone numbers should only contain numbers and spaces and be like 99 99 99 99 99',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verification for French Phone Numbers.
|
||||
* According to http://www.itu.int/itudoc/itu-t/number/f/fra/70680.html
|
||||
* (Released 2006/01/26, retrieved 2008/08/12)
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return boolean Returns boolean FALSE if the phone number is not valid.
|
||||
*/
|
||||
function valid_fr_phone_number($phonenumber) {
|
||||
|
||||
//$phonenumber = trim($phonenumber);
|
||||
|
||||
$phonenumber = str_replace(array(' ','-','(',')'), '', $phonenumber);
|
||||
return (bool) preg_match(PHONE_FR_REGEX, $phonenumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formatting for French Phone Numbers.
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return string Returns a string containting the phone number with some formatting.
|
||||
*/
|
||||
function format_fr_phone_number($phonenumber, $field = FALSE) {
|
||||
$phone = str_replace(array(' ','-','(',')'), '', $phonenumber);
|
||||
if (preg_match(PHONE_FR_REGEX, $phone, $matches) != 1) {
|
||||
return $phonenumber; // not a french phone number
|
||||
}
|
||||
|
||||
return ($field && $field['phone_country_code'] ? '+33 ' : '0') . $matches[2];
|
||||
}
|
143
sites/all/modules/contrib/form/phone/include/phone.gb.inc
Normal file
143
sites/all/modules/contrib/form/phone/include/phone.gb.inc
Normal file
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* CCK Field for British phone numbers.
|
||||
*/
|
||||
|
||||
function phone_gb_metadata() {
|
||||
// These strings are translated using t() on output.
|
||||
return array(
|
||||
'error' => '"%value" is not a valid British (UK) phone number<br>British Phone numbers should .... ',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that $phonenumber is a valid eleven-digit United Kingdom phone number
|
||||
*
|
||||
* Regular expression adapted from Amos Hurd's regex at RegExLib.com
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return boolean Returns boolean FALSE if the phone number is not valid.
|
||||
*/
|
||||
|
||||
function valid_gb_phone_number($phonenumber) {
|
||||
|
||||
/*
|
||||
Accepts:
|
||||
+441970123456
|
||||
+44(0)1970123456
|
||||
+44 1970 123 456
|
||||
+44 (0)1970 123 456
|
||||
(01970) 123456 #0001
|
||||
Rejects:
|
||||
(+441970)123456
|
||||
+44(1970)123456
|
||||
+44 01970 123 456
|
||||
(0197) 0123456 #01
|
||||
*/
|
||||
$regex = "/
|
||||
(
|
||||
(^\+44\s?(\(0\))?\d{4}|^\(?0\d{4}\)?){1}\s?\d{3}\s?\d{3} # 4 digit area code with optional +44 internationalisation or not, optional spaces and brackets.
|
||||
|
|
||||
(^\+44\s?(\(0\))?\d{3}|^\(?0\d{3}\)?){1}\s?\d{3}\s?\d{4} # 3 digit area code with optional +44 internationalisation or not, optional spaces and brackets.
|
||||
|
|
||||
(^\+44\s?(\(0\))?\d{2}|^\(?0\d{2}\)?){1}\s?\d{4}\s?\d{4} # 2 digit area code with optional +44 internationalisation or not, optional spaces and brackets.
|
||||
|
|
||||
(^\+44\s?(\(0\))?\d{1}|^\(?0\d{1}\)?){1}\s?\d{5}\s?\d{5} # 1 digit area code with optional +44 internationalisation or not, optional spaces and brackets.
|
||||
)
|
||||
(\s?\#\d*)? # optional extension number shown with a hash divider
|
||||
/x";
|
||||
|
||||
if (!preg_match($regex, $phonenumber)) {
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a valid United Kingdom phone number into standard +44 (0)1970 123 456 #001 international format
|
||||
*
|
||||
* @param $phonenumber must be a valid eleven-digit number (with optional extension)
|
||||
*
|
||||
*/
|
||||
function format_gb_phone_number($phonenumber, $field = FALSE) {
|
||||
|
||||
$area = $number = $extension = '';
|
||||
|
||||
//If we already have the formatting we want just return
|
||||
if (preg_match(
|
||||
"/
|
||||
(
|
||||
\+44\s\(0\)\d{4}\s\d{3}\s\d{3} # 4 digit area code
|
||||
|
|
||||
\+44\s\(0\)\d{3}\s\d{3}\s\d{4} # 3 digit area code
|
||||
|
|
||||
\+44\s\(0\)\d{2}\s\d{4}\s\d{4} # 2 digit area code
|
||||
)
|
||||
(\s\#\d*)?
|
||||
/",$phonenumber)) {
|
||||
return $phonenumber;
|
||||
}
|
||||
else {
|
||||
//Simplify to 10 digit number and clean up ready for international reformat.
|
||||
$phonenumber = preg_replace("/^(\+44)?\s?(\(?0\)?)?/","",$phonenumber);
|
||||
$phonenumber = preg_replace("/\(/","",$phonenumber);
|
||||
$phonenumber = preg_replace("/\(0/","",$phonenumber);
|
||||
$phonenumber = preg_replace("/\)/","",$phonenumber);
|
||||
|
||||
//If there are some spaces in the number assume some level of preformatting
|
||||
if(preg_match("/ /",$phonenumber)) {
|
||||
$regex = "/
|
||||
# 4 digit area code.
|
||||
(
|
||||
(\d{4}) # capture 4 digit area code
|
||||
\s+ # ignore required separator to make a distinction with other area codes
|
||||
(\d{3}) # capture first set of numbers in the local number
|
||||
\s* # ignore optional separator
|
||||
(\d{3}) # capture second set of numbers in the local number
|
||||
|
|
||||
# 3 digit area code.
|
||||
(\d{3}) # capture 3 digit area code
|
||||
\s+ # ignore required seperator
|
||||
(\d{3}) # capture first set of numbers in the local number
|
||||
\s* # ignore possible boundary
|
||||
(\d{4}) # capture second set of numbers in the local number
|
||||
|
|
||||
# 2 digit area code.
|
||||
(\d{2}) # capture 2 digit area code
|
||||
\s+ # ignore required boundary to make a distinction with other area codes
|
||||
(\d{4}) # capture first set of numbers in the local number
|
||||
\s* # ignore possible boundary
|
||||
(\d{4}) # capture second set of numbers in the local number
|
||||
)
|
||||
# capture the optional extension number
|
||||
(\s*\#)?
|
||||
(\d{4}|\d{3})?
|
||||
/x";
|
||||
preg_match($regex, $phonenumber, $matches);
|
||||
$area = $matches[2].$matches[5].$matches[8];
|
||||
$number = $matches[3].$matches[6].$matches[9].' '.$matches[4].$matches[7].$matches[10];
|
||||
$extension = $matches[12];
|
||||
}
|
||||
//If there are no spaces in the number assume 4 digit area code.
|
||||
else {
|
||||
preg_match("/(\d{4})(\d{3})(\d{3})\#?(\d*)?/",$phonenumber, $matches);
|
||||
$area = $matches[1];
|
||||
$number = $matches[2].' '.$matches[3];
|
||||
$extension = $matches[4];
|
||||
}
|
||||
|
||||
if ($field['phone_country_code']) {
|
||||
$phonenumber = '+44 (0)'.$area.' '.$number;
|
||||
}
|
||||
else {
|
||||
$phonenumber = '0'.$area.' '.$number;
|
||||
}
|
||||
$phonenumber .= (empty($extension))?'':" #$extension";
|
||||
}
|
||||
return $phonenumber;
|
||||
}
|
52
sites/all/modules/contrib/form/phone/include/phone.hu.inc
Normal file
52
sites/all/modules/contrib/form/phone/include/phone.hu.inc
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* CCK Field for Hungarian phone numbers.
|
||||
*/
|
||||
|
||||
define('PHONE_HU_REGEX', "/^(\+36|06|)[\s.-]?([0-9]{1,2})[\s.-]?([0-9]{2,3})[\s.-]?([0-9]{2,4})$/");
|
||||
|
||||
function phone_hu_metadata() {
|
||||
// These strings are translated using t() on output.
|
||||
return array(
|
||||
'error' => '"%value" is not a valid Hungarian phone number!<br>Hungarian phone numbers should contain only numbers and spaces be like 70 999 9999 with an optional prefix of "+36" or "06".',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that $phonenumber is a valid nine-digit Hungarian phone number
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return boolean Returns boolean FALSE if the phone number is not valid.
|
||||
*/
|
||||
function valid_hu_phone_number($phonenumber) {
|
||||
|
||||
$phonenumber = trim($phonenumber);
|
||||
|
||||
// return true if valid, false otherwise
|
||||
return (bool) preg_match(PHONE_HU_REGEX, $phonenumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a valid Hungarian phone number into standard (+36) ..... format
|
||||
*
|
||||
* @param $phonenumber must be a valid nine-digit number (with optional international prefix)
|
||||
*
|
||||
*/
|
||||
function format_hu_phone_number($phonenumber, $field = FALSE) {
|
||||
$phonenumber = trim($phonenumber);
|
||||
// get digits of phone number
|
||||
preg_match(PHONE_HU_REGEX, $phonenumber, $matches);
|
||||
|
||||
$formatedphone = '';
|
||||
if ($field && $field['phone_country_code']) {
|
||||
$formatedphone .= '+36 ';
|
||||
}
|
||||
|
||||
// construct ten-digit phone number
|
||||
$formatedphone .= $matches[2] . ' ' . $matches[3] . ' ' . $matches[4];
|
||||
|
||||
return $formatedphone;
|
||||
}
|
||||
|
108
sites/all/modules/contrib/form/phone/include/phone.il.inc
Normal file
108
sites/all/modules/contrib/form/phone/include/phone.il.inc
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
//drived from au module and manipulated by Moshe Beeri, email: moshe.beeri (at-shetrudel) google mail
|
||||
|
||||
/**
|
||||
* @file
|
||||
* CCK Field for Isreali phone numbers.
|
||||
*/
|
||||
|
||||
function phone_il_metadata() {
|
||||
return array(
|
||||
'error' => '"%value" is not a valid Israeli phone number',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verification for Israel Phone Numbers.
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return boolean Returns boolean FALSE if the phone number is not valid.
|
||||
*/
|
||||
function valid_il_phone_number($phonenumber) {
|
||||
|
||||
//$phonenumber = trim($phonenumber);
|
||||
|
||||
// strip formatting chars
|
||||
$phonenumber = preg_replace('/[\-() ]/', '', $phonenumber);
|
||||
// strip optional '+972' or '0' prefixes
|
||||
$phonenumber = preg_replace('/^(\+972)/', '', $phonenumber);
|
||||
|
||||
//$rules[] = array("Prefix","Minimum length","Maximum length");
|
||||
|
||||
//http://he.wikipedia.org/wiki/%D7%A7%D7%99%D7%93%D7%95%D7%9E%D7%AA_%D7%98%D7%9C%D7%A4%D7%95%D7%9F
|
||||
|
||||
$rules[] = array("02", 7, 10);
|
||||
$rules[] = array("03", 7, 10);
|
||||
$rules[] = array("04", 7, 10);
|
||||
$rules[] = array("08", 7, 10);
|
||||
$rules[] = array("09", 7, 10);
|
||||
$rules[] = array("072", 7, 10);
|
||||
$rules[] = array("073", 7, 10);
|
||||
$rules[] = array("074", 7, 10);
|
||||
$rules[] = array("076", 7, 10);
|
||||
$rules[] = array("077", 7, 10);
|
||||
$rules[] = array("078", 7, 10);
|
||||
$rules[] = array("050", 7, 10);
|
||||
$rules[] = array("052", 7, 10);
|
||||
$rules[] = array("054", 7, 10);
|
||||
$rules[] = array("057", 7, 10);
|
||||
$rules[] = array("1800", 6, 10);
|
||||
$rules[] = array("1801", 6, 10);
|
||||
$rules[] = array("1700", 6, 10);
|
||||
|
||||
foreach ($rules as $rule) {
|
||||
if (preg_match('/^'.$rule[0].'/', $phonenumber) && strlen($phonenumber) >= $rule[1] && strlen($phonenumber) <= $rule[2]) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formatting for Israeli Phone Numbers. Based upon ITU-T E.123 (but let's not get too crazy)
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return string Returns a string containing the phone number with some formatting.
|
||||
*/
|
||||
function format_il_phone_number($phonenumber) {
|
||||
$prefix = '';
|
||||
$extension = '';
|
||||
// strip old formatting chars
|
||||
$phonenumber = preg_replace('/[\-() ]/', '', $phonenumber);
|
||||
|
||||
/*
|
||||
* strip and save the +9726 prefix if found
|
||||
*/
|
||||
if (preg_match('/^\+972/', $phonenumber, $match)) {
|
||||
$prefix = '+972 ';
|
||||
$phonenumber = str_replace('+972', '', $phonenumber);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 9 phones digit numbers
|
||||
* Eg. 03 9999 999
|
||||
*/
|
||||
if (preg_match('/^([0-9]{2})([0-9]{4})([0-9]{3})$/', $phonenumber, $match)) {
|
||||
return $prefix . $match[1] . ' ' . $match[2] . ' ' . $match[3] . $extension;
|
||||
}
|
||||
|
||||
/*
|
||||
* 10 digit numbers
|
||||
* Eg. 1800 999 999
|
||||
*/
|
||||
if (preg_match('/^([0-9]{4})([0-9]{3})([0-9]{3})$/', $phonenumber, $match)) {
|
||||
return $prefix . $match[1] . ' ' . $match[2] . ' ' . $match[3] . $extension;
|
||||
}
|
||||
|
||||
/*
|
||||
* cell phone
|
||||
* Eg. 054 9999 999
|
||||
*/
|
||||
if (preg_match('/^([0-9]{3})([0-9]{4})([0-9]{3})$/', $phonenumber, $match)) {
|
||||
return $prefix . $match[1] . ' ' . $match[2] . ' ' . $match[3] . $extension;
|
||||
}
|
||||
|
||||
// default
|
||||
return $prefix . $phonenumber . $extension;
|
||||
}
|
354
sites/all/modules/contrib/form/phone/include/phone.int.inc
Normal file
354
sites/all/modules/contrib/form/phone/include/phone.int.inc
Normal file
@@ -0,0 +1,354 @@
|
||||
<?php
|
||||
|
||||
function phone_int_metadata() {
|
||||
// These strings are translated using t() on output.
|
||||
return array(
|
||||
'error' => '"%value" is not a valid Italian phone number<br>Italian phone numbers should only ...',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that $phonenumber is a valid international phone number as per ITU or,
|
||||
* if a default country code is specified, a valid subscriber number.
|
||||
*
|
||||
* @see http://www.itu.int/rec/T-REC-E.123/en
|
||||
*
|
||||
* @param $phonenumber
|
||||
* International phone number to validate
|
||||
* @return
|
||||
* TRUE if valid, FALSE if otherwise.
|
||||
*/
|
||||
function valid_int_phone_number($phonenumber) {
|
||||
$phonenumber = trim($phonenumber);
|
||||
if ($phonenumber === '') {
|
||||
return FALSE;
|
||||
}
|
||||
$phonenumber = _normalize_country_code($phonenumber);
|
||||
$base_phonenumber = str_replace(array('.', '(', ')', '[', ']', '-', '+', ' '), '', $phonenumber);
|
||||
if (!isset($field['phone_int_max_length'])) {
|
||||
$field['phone_int_max_length'] = 15;
|
||||
}
|
||||
if (strlen($base_phonenumber) > $field['phone_int_max_length']) {
|
||||
$error = t('Invalid international phone number: Phone number is too long; international phone numbers are limited to 15 digits.');
|
||||
return FALSE;
|
||||
}
|
||||
// Check if digits are used in the base_phonenumber
|
||||
if (!ctype_digit($base_phonenumber)) {
|
||||
$error = t('Invalid international phone number: Phone number contains invalid characters; only allowed characters are numbers and punctuation.');
|
||||
return FALSE;
|
||||
}
|
||||
// Extract country code and see if it's correct:
|
||||
preg_match('/^\+(\d+)/', $phonenumber, $matches);
|
||||
$cc = $matches[1];
|
||||
if (strlen($cc) > 3) {
|
||||
$error = array(
|
||||
t('Invalid international phone number: Country code "+%cc" is too long; valid country codes are three digits or less.'),
|
||||
array('%cc' => $cc)
|
||||
);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//drupal_set_message('langue cc = ' . $cc, 'error');
|
||||
|
||||
// TODO: Check if parentheses/brackets add up.
|
||||
// TODO: Validate the number against the country rules.
|
||||
// For now, validate only against a limited number of countries.
|
||||
|
||||
$countrycode = phone_country_code_convert($cc);
|
||||
//drupal_set_message('langue countrycode = ' . $countrycode, 'error');
|
||||
if (!empty($countrycode)) {
|
||||
$valid_phone_function = 'valid_'. $countrycode . '_phone_number';
|
||||
module_load_include('inc', 'phone', 'phone.'. $countrycode);
|
||||
if (function_exists($valid_phone_function)) {
|
||||
return $valid_phone_function($phonenumber, $field);
|
||||
}
|
||||
else {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats $phonenumber into the standard representation of international
|
||||
* numbers as per E.123.
|
||||
*
|
||||
* @param $phonenumber
|
||||
* International phone number to format
|
||||
* @return
|
||||
* Formatted international phone number
|
||||
*/
|
||||
function format_int_phone_number($phonenumber, $field = array()) {
|
||||
$phonenumber = trim($phonenumber);
|
||||
if ($phonenumber === '') {
|
||||
return '';
|
||||
}
|
||||
$phonenumber = _normalize_country_code($phonenumber, $field);
|
||||
$bits = preg_split('/[.()\[\]\- ]/', $phonenumber, -1, PREG_SPLIT_NO_EMPTY);
|
||||
// $bits[0] is the country code WITH a plus sign.
|
||||
if (isset($bits[1])) {
|
||||
// This is the first non-CC segment, so it could have the NDN.
|
||||
switch ($bits[1][0]) {
|
||||
case 0:
|
||||
$bits[1] = substr($bits[1], 1);
|
||||
break;
|
||||
}
|
||||
switch ($bits[1]) {
|
||||
case 0:
|
||||
case 7:
|
||||
case 8:
|
||||
array_splice($bits, 1, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return implode(' ', $bits);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a country code to a phone number if necessary.
|
||||
*
|
||||
* @param $phonenumber
|
||||
* International or local phone number to format
|
||||
* @return
|
||||
* International phone number with country code
|
||||
*/
|
||||
function _normalize_country_code($phonenumber, $field = array()) {
|
||||
if ($phonenumber[0] !== '+') {
|
||||
$cc = isset($field['phone_default_country_code']) ? $field['phone_default_country_code'] : '1';
|
||||
return "+$cc $phonenumber";
|
||||
}
|
||||
return $phonenumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the country code in the desired format.
|
||||
*
|
||||
* @todo Fill in the rest of the country code values.
|
||||
*
|
||||
* @param $code
|
||||
* Country code to convert (either numeric or 2-letter abbreviation)
|
||||
* @param $input_type
|
||||
* Type of country code to convert (either numeric or 2-letter abbreviation)
|
||||
* @return
|
||||
* Converted country code
|
||||
*/
|
||||
function phone_country_code_convert($code, $input_type = 'digits') {
|
||||
static $codes;
|
||||
if (!$codes) {
|
||||
$codes = array(
|
||||
'1' => 'ca',
|
||||
'1' => 'us',
|
||||
'7' => 'ru',
|
||||
'20' => 'eg',
|
||||
'27' => 'za',
|
||||
'30' => 'gr',
|
||||
'31' => 'nl',
|
||||
'32' => 'be',
|
||||
'33' => 'fr',
|
||||
'34' => 'es',
|
||||
'36' => 'hu',
|
||||
'39' => 'it',
|
||||
'39' => 'va',
|
||||
'40' => 'ro',
|
||||
'41' => 'ch',
|
||||
'43' => 'at',
|
||||
'44' => 'gb',
|
||||
'45' => 'dk',
|
||||
'46' => 'se',
|
||||
'47' => 'no',
|
||||
'48' => 'pl',
|
||||
'49' => 'de',
|
||||
'51' => 'pe',
|
||||
'52' => 'mx',
|
||||
'53' => 'cu',
|
||||
'54' => 'ar',
|
||||
'55' => 'br',
|
||||
'56' => 'cl',
|
||||
'57' => 'co',
|
||||
'58' => 've',
|
||||
'60' => 'my',
|
||||
'61' => 'au',
|
||||
'61' => 'cc',
|
||||
'61' => 'cx',
|
||||
'62' => 'id',
|
||||
'63' => 'ph',
|
||||
'64' => 'nz',
|
||||
'65' => 'sg',
|
||||
'66' => 'th',
|
||||
'81' => 'jp',
|
||||
'82' => 'kr',
|
||||
'84' => 'vn',
|
||||
'86' => 'cn',
|
||||
'90' => 'tr',
|
||||
'91' => 'in',
|
||||
'92' => 'pk',
|
||||
'93' => 'af',
|
||||
'94' => 'lk',
|
||||
'95' => 'mm',
|
||||
'98' => 'ir',
|
||||
'212' => 'ma',
|
||||
'213' => 'dz',
|
||||
'216' => 'tn',
|
||||
'218' => 'ly',
|
||||
'220' => 'gm',
|
||||
'221' => 'sn',
|
||||
'222' => 'mr',
|
||||
'223' => 'ml',
|
||||
'224' => 'gn',
|
||||
'225' => 'ci',
|
||||
'226' => 'bf',
|
||||
'227' => 'ne',
|
||||
'228' => 'tg',
|
||||
'229' => 'bj',
|
||||
'230' => 'mu',
|
||||
'231' => 'lr',
|
||||
'232' => 'sl',
|
||||
'233' => 'gh',
|
||||
'234' => 'ng',
|
||||
'235' => 'td',
|
||||
'236' => 'cf',
|
||||
'237' => 'cm',
|
||||
'238' => 'cv',
|
||||
'239' => 'st',
|
||||
'240' => 'gq',
|
||||
'241' => 'ga',
|
||||
'242' => 'cg',
|
||||
'243' => 'cd',
|
||||
'244' => 'ao',
|
||||
'245' => 'gw',
|
||||
'246' => 'io',
|
||||
'248' => 'sc',
|
||||
'249' => 'sd',
|
||||
'250' => 'rw',
|
||||
'251' => 'et',
|
||||
'252' => 'so',
|
||||
'253' => 'dj',
|
||||
'254' => 'ke',
|
||||
'255' => 'tz',
|
||||
'256' => 'ug',
|
||||
'257' => 'bi',
|
||||
'258' => 'mz',
|
||||
'260' => 'zm',
|
||||
'261' => 'mg',
|
||||
'263' => 'zw',
|
||||
'264' => 'na',
|
||||
'265' => 'mw',
|
||||
'266' => 'ls',
|
||||
'267' => 'bw',
|
||||
'268' => 'sz',
|
||||
'269' => 'km',
|
||||
'269' => 'yt',
|
||||
'290' => 'sh',
|
||||
'291' => 'er',
|
||||
'297' => 'aw',
|
||||
'298' => 'fo',
|
||||
'299' => 'gl',
|
||||
'350' => 'gi',
|
||||
'351' => 'pt',
|
||||
'352' => 'lu',
|
||||
'353' => 'ie',
|
||||
'354' => 'is',
|
||||
'355' => 'al',
|
||||
'356' => 'mt',
|
||||
'357' => 'cy',
|
||||
'358' => 'fi',
|
||||
'359' => 'bg',
|
||||
'370' => 'lt',
|
||||
'371' => 'lv',
|
||||
'372' => 'ee',
|
||||
'373' => 'md',
|
||||
'374' => 'am',
|
||||
'375' => 'by',
|
||||
'376' => 'ad',
|
||||
'377' => 'mc',
|
||||
'378' => 'sm',
|
||||
'380' => 'ua',
|
||||
'381' => 'rs',
|
||||
'382' => 'me',
|
||||
'385' => 'hr',
|
||||
'386' => 'si',
|
||||
'387' => 'ba',
|
||||
'389' => 'mk',
|
||||
'420' => 'cz',
|
||||
'421' => 'sk',
|
||||
'423' => 'li',
|
||||
'500' => 'fk',
|
||||
'501' => 'bz',
|
||||
'502' => 'gt',
|
||||
'503' => 'sv',
|
||||
'504' => 'hn',
|
||||
'505' => 'ni',
|
||||
'506' => 'cr',
|
||||
'507' => 'pa',
|
||||
'508' => 'pm',
|
||||
'509' => 'ht',
|
||||
'590' => 'gp',
|
||||
'591' => 'bo',
|
||||
'592' => 'gy',
|
||||
'593' => 'ec',
|
||||
'594' => 'gf',
|
||||
'595' => 'py',
|
||||
'596' => 'mq',
|
||||
'597' => 'sr',
|
||||
'598' => 'uy',
|
||||
'599' => 'an',
|
||||
'670' => 'tp',
|
||||
'672' => 'nf',
|
||||
'673' => 'bn',
|
||||
'674' => 'nr',
|
||||
'675' => 'pg',
|
||||
'676' => 'to',
|
||||
'677' => 'sb',
|
||||
'678' => 'vu',
|
||||
'679' => 'fj',
|
||||
'680' => 'pw',
|
||||
'681' => 'wf',
|
||||
'682' => 'ck',
|
||||
'683' => 'nu',
|
||||
'686' => 'ki',
|
||||
'687' => 'nc',
|
||||
'688' => 'tv',
|
||||
'689' => 'pf',
|
||||
'690' => 'tk',
|
||||
'691' => 'fm',
|
||||
'692' => 'mh',
|
||||
'850' => 'kp',
|
||||
'852' => 'hk',
|
||||
'853' => 'mo',
|
||||
'855' => 'kh',
|
||||
'856' => 'la',
|
||||
'880' => 'bd',
|
||||
'886' => 'tw',
|
||||
'960' => 'mv',
|
||||
'961' => 'lb',
|
||||
'962' => 'jo',
|
||||
'963' => 'sy',
|
||||
'964' => 'iq',
|
||||
'965' => 'kw',
|
||||
'966' => 'sa',
|
||||
'967' => 'ye',
|
||||
'968' => 'om',
|
||||
'970' => 'ps',
|
||||
'971' => 'ae',
|
||||
'972' => 'il',
|
||||
'973' => 'bh',
|
||||
'974' => 'qa',
|
||||
'975' => 'bt',
|
||||
'976' => 'mn',
|
||||
'977' => 'np',
|
||||
'992' => 'tj',
|
||||
'993' => 'tm',
|
||||
'994' => 'az',
|
||||
'995' => 'ge',
|
||||
'996' => 'kg',
|
||||
'998' => 'uz',
|
||||
);
|
||||
}
|
||||
|
||||
if ($input_type == 'alpha') {
|
||||
$codes = array_flip($codes);
|
||||
}
|
||||
return isset($codes[$code]) ? $codes[$code] : FALSE;
|
||||
}
|
||||
|
49
sites/all/modules/contrib/form/phone/include/phone.it.inc
Normal file
49
sites/all/modules/contrib/form/phone/include/phone.it.inc
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* CCK Field for Italian phone numbers.
|
||||
*/
|
||||
|
||||
function phone_it_metadata() {
|
||||
// These strings are translated using t() on output.
|
||||
return array(
|
||||
'error' => '"%value" is not a valid Italian phone number<br>Italian phone numbers should only ...',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that $phonenumber is valid
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return boolean Returns boolean FALSE if the phone number is not valid.
|
||||
*/
|
||||
function valid_it_phone_number($phonenumber) {
|
||||
// define regular expression
|
||||
$regex = "/^(\+39)?[ ]?([0-9]{2,3}(\/|-| )?[0-9]{6,7})$/i";
|
||||
|
||||
// return true if valid, false otherwise
|
||||
return (bool) preg_match($regex, $phonenumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formatting for Italian Phone Numbers.
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return string Returns a string containting the phone number with some formatting.
|
||||
*/
|
||||
function format_it_phone_number($phonenumber, $field) {
|
||||
|
||||
//$phonenumber = trim($phonenumber);
|
||||
|
||||
// do some formatting on the phone number
|
||||
$phonenumber = str_replace("[ -]", "", $phonenumber);
|
||||
|
||||
if ($field['phone_country_code']) {
|
||||
if ($matches[1] != "+39") {
|
||||
$phonenumber = "+39" . " " . $phonenumber;
|
||||
}
|
||||
}
|
||||
|
||||
return $phonenumber;
|
||||
}
|
101
sites/all/modules/contrib/form/phone/include/phone.jo.inc
Normal file
101
sites/all/modules/contrib/form/phone/include/phone.jo.inc
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This plugin is contributed by Untitled Web http://untitledstudios.com
|
||||
* @author Rashad Majali <rashad.612@gmail.com> http://drupal.org/user/319686
|
||||
* @file
|
||||
* CCK Field for Jordanian phone numbers.
|
||||
*/
|
||||
|
||||
function phone_jo_metadata(){
|
||||
// These strings are translated using t() on output.
|
||||
return array(
|
||||
'error' => '"%value" is not a valid Jordanian phone number, Please check the spaces and dashes in your number.',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verification for Jordanian Phone Numbers.
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return boolean Returns boolean FALSE if the phone number is not valid.
|
||||
*/
|
||||
function valid_jo_phone_number($phonenumber){
|
||||
|
||||
/**
|
||||
Accepts:
|
||||
|
||||
Mobile numbers: (X refers to network code, it might be 7,8,9).
|
||||
|
||||
+9627X1234567
|
||||
+962-7X1234567
|
||||
+962 7X1234567
|
||||
009627X1234567
|
||||
00962-7X1234567
|
||||
00962 7X1234567
|
||||
|
||||
962... accepted as well
|
||||
|
||||
07X1234567
|
||||
|
||||
Local area numbers: (X refers to region code, i.e. Amman[6], north [2], middle [5], south[3]).
|
||||
+962X1234567
|
||||
+962-X-1234567
|
||||
+962X-1234567
|
||||
+962 X 1234567
|
||||
+962X 1234567
|
||||
+962 X1234567
|
||||
|
||||
00962X1234567
|
||||
00962-X-1234567
|
||||
00962X-1234567
|
||||
00962 X 1234567
|
||||
00962X 1234567
|
||||
00962 X1234567
|
||||
|
||||
962... accepted as well
|
||||
|
||||
0X1234567
|
||||
0X-1234567
|
||||
0X 1234567
|
||||
|
||||
Rejects:
|
||||
|
||||
Generally rejects any number without leading code.
|
||||
starts with X instead of 0X
|
||||
|
||||
Mobile:
|
||||
7X1234567
|
||||
7 X1234567 and similar formats
|
||||
+962 7 X1234567 and similar formats
|
||||
|
||||
Local:
|
||||
X1234567
|
||||
X-1234567
|
||||
X 1234567 and similar formats
|
||||
|
||||
*/
|
||||
$regex = "/(^(\+962|00962|962|0)[-\s]{0,1}[7]{1}[7-9]{1}[0-9]{7}$) | (^(\+962|00962|962|0)[-\s]{0,1}[2-6][-\s]{0,1}[0-9]{7}$)/x";
|
||||
|
||||
return (bool) preg_match($regex, $phonenumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formatting for Jordanian Phone Numbers.
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return string Returns a string containting the phone number with some formatting.
|
||||
*/
|
||||
function format_jo_phone_number($phonenumber, $field = FALSE){
|
||||
|
||||
|
||||
$phonenumber = trim($phonenumber);
|
||||
$regex = "/(^(\+962|00962|962|0)[-\s]{0,1}[7]{1}[7-9]{1}[0-9]{7}$) | (^(\+962|00962|962|0)[-\s]{0,1}[2-6][-\s]{0,1}[0-9]{7}$)/x";
|
||||
preg_match($regex, $phonenumber, $matches);
|
||||
|
||||
$phonenumber = preg_replace('/^(\+962|00962|962|0)|[-\s]/', '', $matches[0]);
|
||||
|
||||
|
||||
return '+962'.$phonenumber;
|
||||
|
||||
}
|
87
sites/all/modules/contrib/form/phone/include/phone.nl.inc
Normal file
87
sites/all/modules/contrib/form/phone/include/phone.nl.inc
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* CCK Field for Dutch phone numbers.
|
||||
*/
|
||||
|
||||
function phone_nl_metadata() {
|
||||
// These strings are translated using t() on output.
|
||||
return array(
|
||||
'error' => '"%value" is not a valid Dutch phone number!<br>Dutch phone numbers should contain only numbers and spaces and - and be like 099-9999999 with an optional prefix of "+31".',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that $phonenumber is a valid ten-digit Dutch phone number with spaces and -
|
||||
*
|
||||
* Regular expression adapted from Nico Lubbers's regex at RegExLib.com
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return boolean Returns boolean FALSE if the phone number is not valid.
|
||||
*/
|
||||
function valid_nl_phone_number($phonenumber) {
|
||||
|
||||
//$phonenumber = trim($phonenumber);
|
||||
|
||||
/*
|
||||
Accepts:
|
||||
06-12345678
|
||||
06 123 456 78
|
||||
010-1234567
|
||||
020 123 4567
|
||||
0221-123456
|
||||
0221 123 456
|
||||
Rejects:
|
||||
05-12345678
|
||||
123-4567890
|
||||
123 456 7890
|
||||
*/
|
||||
|
||||
// define regular expression
|
||||
$regex = '/
|
||||
([0]{1}[6]{1}[-\s]+[1-9]{1}[\s]*([0-9]{1}[\s]*){7}) # Mobile phonenumber
|
||||
|
|
||||
([0]{1}[1-9]{1}[0-9]{2}[-\s]+[1-9]{1}[\s]*([0-9]{1}[\s]*){5}) # Phonenumber with 4 digit area code
|
||||
|
|
||||
([0]{1}[1-9]{1}[0-9]{1}[-\s]+[1-9]{1}[\s]*([0-9]{1}[\s]*){6}) # Phonenumber with 3 digit area code
|
||||
/x';
|
||||
|
||||
// return true if valid, false otherwise
|
||||
return (bool) preg_match($regex, $phonenumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formatting for Dutch Phone Numbers into standard area-phonenumber or with extra country code +31 international format
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return string Returns a string containting the phone number with some formatting.
|
||||
*/
|
||||
function format_nl_phone_number($phonenumber, $field) {
|
||||
|
||||
$areacode = $localnumber = '';
|
||||
// Mobile number
|
||||
if (preg_match('/([0]{1}[6]{1}[-\s]+[1-9]{1}[\s]*([0-9]{1}[\s]*){7})/', $phonenumber)) {
|
||||
preg_match('/([0]{1}[6]{1})[-\s]+([1-9]{1}[\s]*([0-9]{1}[\s]*){7})/', $phonenumber, $matches);
|
||||
}
|
||||
// Phonenumber with 4 digit area code
|
||||
if (preg_match('/([0]{1}[1-9]{1}[0-9]{2}[-\s]+[1-9]{1}[\s]*([0-9]{1}[\s]*){5})/', $phonenumber)) {
|
||||
preg_match('/([0]{1}[1-9]{1}[0-9]{2})[-\s]+([1-9]{1}[\s]*([0-9]{1}[\s]*){5})/', $phonenumber, $matches);
|
||||
}
|
||||
// Phonenumber with 3 digit area code
|
||||
if (preg_match('/([0]{1}[1-9]{1}[0-9]{1}[-\s]+[1-9]{1}[\s]*([0-9]{1}[\s]*){6})/', $phonenumber)) {
|
||||
preg_match('/([0]{1}[1-9]{1}[0-9]{1})[-\s]+([1-9]{1}[\s]*([0-9]{1}[\s]*){6})/', $phonenumber, $matches);
|
||||
}
|
||||
|
||||
$areacode = $matches[1];
|
||||
$localnumber = preg_replace('/ /', '', $matches[2]);
|
||||
$phonenumber = $areacode. '-'. $localnumber;
|
||||
|
||||
// Add Country code if needed
|
||||
if ($field['phone_country_code']) {
|
||||
$areacode = preg_replace('/^0/', '', $areacode);
|
||||
$phonenumber = '+31-'. $areacode. '-'. $localnumber;
|
||||
}
|
||||
|
||||
return $phonenumber;
|
||||
}
|
224
sites/all/modules/contrib/form/phone/include/phone.nz.inc
Normal file
224
sites/all/modules/contrib/form/phone/include/phone.nz.inc
Normal file
@@ -0,0 +1,224 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* @file
|
||||
* CCK Field for New Zealand phone numbers.
|
||||
*/
|
||||
|
||||
function phone_nz_metadata() {
|
||||
// These strings are translated using t() on output.
|
||||
return array(
|
||||
'error' => '"%value" is not a valid New Zealand phone number!<br>New Zealand phone numbers should contain only numbers, spaces, brackets and "-". They should look like 04 123 4567 or can optionally omit the leading 0 and have a prefix of "+64".',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verification for New Zealand Phone Numbers.
|
||||
* As supplied by http://www.itu.int/itudoc/itu-t/number/n/nzl/76195_ww9.doc, April 2009
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return boolean returns boolean FALSE if the phone number is not valid.
|
||||
*/
|
||||
function valid_nz_phone_number($phonenumber) {
|
||||
|
||||
//$phonenumber = trim($phonenumber);
|
||||
|
||||
// strip formatting chars
|
||||
$phonenumber = preg_replace('/[\-() ]/', '', $phonenumber);
|
||||
// strip optional '+64' or '0' prefixes
|
||||
$phonenumber = preg_replace('/^(\+64|0)/', '', $phonenumber);
|
||||
|
||||
//$rules[] = array("Prefix","Minimum length","Maximum length");
|
||||
|
||||
// special purpose service codes and numbers
|
||||
/*// Enable if required
|
||||
$rules[] = array('10', 3, 3);
|
||||
$rules[] = array('12', 6, 7); // NZ Direct Service
|
||||
$rules[] = array('60', 4, 4); // Directory Assistance (operator only) - Maybe shouldn't be in here
|
||||
$rules[] = array('83', 5, 8); // "Enhanced Voice Services"
|
||||
$rules[] = array('86', 8, 8); // "Enhanced Paging Services"
|
||||
$rules[] = array('87', 4, 8); // "PSTN access to data services"
|
||||
*/
|
||||
|
||||
// Mobile
|
||||
$rules[] = array('20', 9, 9); // mobile radio / Orcon mobile
|
||||
|
||||
$rules[] = array('22', 8, 10); // NZ Communications (actual lengths subject to change)
|
||||
|
||||
$rules[] = array('210', 8, 10); // Vodafone
|
||||
$rules[] = array('211', 8, 9); // Vodafone
|
||||
$rules[] = array('212', 8, 9); // Vodafone
|
||||
$rules[] = array('213', 8, 9); // Vodafone
|
||||
$rules[] = array('214', 8, 9); // Vodafone
|
||||
$rules[] = array('215', 8, 9); // Vodafone
|
||||
$rules[] = array('216', 8, 9); // Vodafone
|
||||
$rules[] = array('217', 8, 9); // Vodafone
|
||||
$rules[] = array('218', 8, 9); // Vodafone
|
||||
$rules[] = array('219', 8, 9); // Vodafone
|
||||
|
||||
$rules[] = array('24', 8, 8); // Scott Base
|
||||
//$rules[] = array('25', 8, 9); // Old Telecom 025, now unused
|
||||
$rules[] = array('26', 8, 9); // Telecom Paging
|
||||
$rules[] = array('27', 9, 9); // Telecom 027 mobile
|
||||
$rules[] = array('29', 8, 9); // TelstraClear mobile
|
||||
|
||||
// South Island regional
|
||||
$rules[] = array('32', 8, 8);
|
||||
$rules[] = array('33', 8, 8);
|
||||
$rules[] = array('34', 8, 8);
|
||||
$rules[] = array('35', 8, 8);
|
||||
$rules[] = array('36', 8, 8);
|
||||
$rules[] = array('37', 8, 8);
|
||||
$rules[] = array('39', 8, 8);
|
||||
|
||||
// Wellington regional
|
||||
$rules[] = array('42', 8, 8);
|
||||
$rules[] = array('43', 8, 8);
|
||||
$rules[] = array('44', 8, 8);
|
||||
$rules[] = array('45', 8, 8);
|
||||
$rules[] = array('46', 8, 8);
|
||||
$rules[] = array('48', 8, 8);
|
||||
$rules[] = array('49', 8, 8);
|
||||
|
||||
// Manawatu, Taranaki, Hawkes Bay, Gisborne, Wairarapa, Otaki regional
|
||||
$rules[] = array('62', 8, 8);
|
||||
$rules[] = array('63', 8, 8);
|
||||
$rules[] = array('67', 8, 8);
|
||||
$rules[] = array('68', 8, 8);
|
||||
$rules[] = array('69', 8, 8);
|
||||
|
||||
// Waikato, BOP, Taumarunui regional
|
||||
$rules[] = array('73', 8, 8);
|
||||
$rules[] = array('75', 8, 8);
|
||||
$rules[] = array('62', 8, 8);
|
||||
$rules[] = array('78', 8, 8);
|
||||
$rules[] = array('79', 8, 8);
|
||||
|
||||
// Freecall
|
||||
$rules[] = array('80', 8, 10);
|
||||
|
||||
// Pay-call
|
||||
$rules[] = array('90', 8, 10);
|
||||
|
||||
// Auckland + Northland regional
|
||||
$rules[] = array('92', 8, 8);
|
||||
$rules[] = array('93', 8, 8);
|
||||
$rules[] = array('94', 8, 8);
|
||||
$rules[] = array('95', 8, 8);
|
||||
$rules[] = array('96', 8, 8);
|
||||
$rules[] = array('98', 8, 8);
|
||||
$rules[] = array('99', 8, 8);
|
||||
|
||||
foreach ($rules as $rule) {
|
||||
if (preg_match('/^'.$rule[0].'/', $phonenumber) && strlen($phonenumber) >= $rule[1] && strlen($phonenumber) <= $rule[2]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formatting for New Zealand Phone Numbers.
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return string Returns a string containing the phone number with some formatting.
|
||||
*/
|
||||
function format_nz_phone_number($phonenumber, $field) {
|
||||
$prefix = '';
|
||||
$extension = '';
|
||||
// strip old formatting chars
|
||||
$phonenumber = preg_replace('/[\-() ]/', '', $phonenumber);
|
||||
|
||||
/*
|
||||
* strip and save the +64 prefix if found
|
||||
*/
|
||||
if (preg_match('/^\+64/', $phonenumber, $match)) {
|
||||
$prefix = '+64';
|
||||
$phonenumber = str_replace('+64', '', $phonenumber);
|
||||
}
|
||||
else {
|
||||
$prefix = '0';
|
||||
|
||||
/*
|
||||
* Remove a leading 0, if present
|
||||
*/
|
||||
if (preg_match('/^0/', $phonenumber, $match)) {
|
||||
$phonenumber = substr($phonenumber, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* strip and save the extension (x9999) postfix if found
|
||||
*/
|
||||
if (preg_match('/(x[0-9]+)$/', $phonenumber, $match)) {
|
||||
$extension = ' '.$match[1];
|
||||
$phonenumber = preg_replace('/x[0-9]+$/', '', $phonenumber);
|
||||
}
|
||||
|
||||
/*
|
||||
* geographic numbers
|
||||
* Eg. (04) 123 4578
|
||||
*/
|
||||
if (preg_match('/^([34679])([0-9]{3})([0-9]{4})$/', $phonenumber, $match)) {
|
||||
return _format_nz_phone_number_prefix($prefix, $match[1]) . $match[2] . ' ' . $match[3] . $extension;
|
||||
}
|
||||
|
||||
/*
|
||||
* 8 digit mobile numbers
|
||||
* Eg. 021 123 123
|
||||
*/
|
||||
if (preg_match('/^(2[12679])([0-9]{3})([0-9]{3})$/', $phonenumber, $match)) {
|
||||
return _format_nz_phone_number_prefix($prefix, $match[1]) . $match[2] . ' ' . $match[3] . $extension;
|
||||
}
|
||||
|
||||
/*
|
||||
* 9 digit mobile numbers
|
||||
* Eg. 021 123 4567
|
||||
*/
|
||||
if (preg_match('/^(2[12679])([0-9]{3})([0-9]{4})$/', $phonenumber, $match)) {
|
||||
return _format_nz_phone_number_prefix($prefix, $match[1]) . $match[2] . ' ' . $match[3] . $extension;
|
||||
}
|
||||
|
||||
/*
|
||||
* 10 digit mobile numbers
|
||||
* Eg. 021 1234 1234
|
||||
*/
|
||||
if (preg_match('/^(2[12679])([0-9]{4})([0-9]{4})$/', $phonenumber, $match)) {
|
||||
return _format_nz_phone_number_prefix($prefix, $match[1]) . $match[2] . ' ' . $match[3] . $extension;
|
||||
}
|
||||
|
||||
/**
|
||||
* 0800/0900 numbers (a bit random)
|
||||
*/
|
||||
if (preg_match('/^(900|800)(\d+)$/', $phonenumber, $match)) {
|
||||
// How we format depends on the length
|
||||
$formatted = null;
|
||||
switch(strlen($match[2])) {
|
||||
case 5: $formatted = preg_replace('/^(\d{2})(\d{3})$/', '$1$2', $match[2]); break;
|
||||
case 6: $formatted = preg_replace('/^(\d{3})(\d{3})$/', '$1$2', $match[2]); break;
|
||||
case 7: $formatted = preg_replace('/^(\d{3})(\d{4})$/', '$1 $2', $match[2]); break;
|
||||
}
|
||||
return _format_nz_phone_number_prefix($prefix, $match[1]).$formatted;
|
||||
}
|
||||
|
||||
// default (probably bad)
|
||||
return $prefix . $phonenumber . $extension;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats the prefix as either +64 4 or (04), depending on the original prefix context
|
||||
*
|
||||
* @param string $prefix either '+64' or '0'
|
||||
* @param string $area_code the area code, eg. 4, 21, 27 etc
|
||||
* @return string the formatted prefix
|
||||
*/
|
||||
function _format_nz_phone_number_prefix($prefix, $area_code) {
|
||||
$area_code = intval($area_code);
|
||||
if (in_array($area_code, array('800', '900'))) {
|
||||
return ($prefix == '0') ? $prefix.$area_code.' ' : $prefix.' '.$area_code.' ';
|
||||
}
|
||||
else {
|
||||
return ($prefix == '0') ? '('.$prefix.$area_code.') ' : $prefix.' '.$area_code.' ';
|
||||
}
|
||||
}
|
70
sites/all/modules/contrib/form/phone/include/phone.pa.inc
Normal file
70
sites/all/modules/contrib/form/phone/include/phone.pa.inc
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* CCK field for Panamanian phone numbers
|
||||
*/
|
||||
/*
|
||||
* ((00|\+)?[0-9]{3}[\s])? #First group 00507 or +507 (plus space)
|
||||
* ([0-9]{3,4}) #Second group three or four numbers (four for cellphones)
|
||||
* [\s|-]? space or dash
|
||||
* ([0-9]{4}) #Third group
|
||||
*
|
||||
* Accepted:
|
||||
* 00507 2603133
|
||||
* +507 260-4343
|
||||
* 260 3133
|
||||
* 260-3133
|
||||
*
|
||||
* Cellphones
|
||||
* +507 6545-4345
|
||||
* 6545-4345
|
||||
* 6545 4345
|
||||
* 65454345
|
||||
*/
|
||||
define('PHONE_PA_REGEX', '/((00|\+)?[0-9]{3}[\s])?([0-9]{3,4})[\s|-]?([0-9]{4})/');
|
||||
|
||||
function phone_pa_metadata() {
|
||||
// These strings are translated using t() on output.
|
||||
return array(
|
||||
'error' => '"%value" is not a valid Panamanian phone number!<br>Panamanian phone numbers should contain only numbers, spaces and dashes be like 9999-999, 9999 999 or 9999999 with an optional prefix of "+507" or "00507".',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that $phonenumber is a valid nine-digit Panamanian phone number
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return boolean Returns boolean FALSE if the phone number is not valid.
|
||||
*/
|
||||
function valid_pa_phone_number($phonenumber) {
|
||||
|
||||
//$phonenumber = trim($phonenumber);
|
||||
|
||||
// define regular expression
|
||||
// return true if valid, false otherwise
|
||||
return (bool) preg_match(PHONE_PA_REGEX, $phonenumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a valid Panamenian phone number into standard (+507) 260-4324 format
|
||||
*
|
||||
* @param $phonenumber must be a valid nine-digit number (with optional international prefix)
|
||||
*
|
||||
*/
|
||||
function format_pa_phone_number($phonenumber, $field = FALSE) {
|
||||
// get digits of phone number
|
||||
preg_match(PHONE_PA_REGEX, $phonenumber, $matches);
|
||||
if (preg_match(PHONE_PA_REGEX, $phonenumber, $matches) != 1) {
|
||||
return $phonenumber; // not a Panamanian phone number
|
||||
}
|
||||
$phonenumber = $matches[3] . '-' . $matches[4];
|
||||
if (trim($matches[1]) != '') {
|
||||
$phonenumber = '+' . substr($matches[1], -4) . $phonenumber;
|
||||
}
|
||||
elseif ($field && isset($field['phone_country_code'])) {
|
||||
$phonenumber = '+507 ' . $phonenumber;
|
||||
}
|
||||
|
||||
return $phonenumber;
|
||||
}
|
127
sites/all/modules/contrib/form/phone/include/phone.ph.inc
Normal file
127
sites/all/modules/contrib/form/phone/include/phone.ph.inc
Normal file
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* CCK Field for Philippine phone numbers.
|
||||
*/
|
||||
|
||||
function phone_ph_metadata() {
|
||||
// These strings are translated using t() on output.
|
||||
return array(
|
||||
'error' => '"%value" is not a valid Philippine phone number<br />Example of valid Philippine phone numbers: +63 (2) 123-4567 or +63 (2) 123-4567 loc. 123 or mobile +63 (919) 123-4567',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that $phonenumber is a valid ten-digit Philippine phone number
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return boolean Returns boolean FALSE if the phone number is not valid.
|
||||
*/
|
||||
|
||||
function valid_ph_phone_number($phonenumber) {
|
||||
|
||||
/*
|
||||
Accepts:
|
||||
+63197071234567
|
||||
+63197071234567
|
||||
+63(19707) 1234567
|
||||
+63(19707) 123-4567
|
||||
+63 19707 123 4567
|
||||
+63 19707 123-4567
|
||||
(19707) 1234567 loc. 1234
|
||||
*/
|
||||
$regex = "/
|
||||
(
|
||||
(^\+63\s?\(?\d{5}\)?|^\(?\d{5}\)?){1}\s?\d{3}(\S?|\s?)?\d{4} # 5 digit area code with optional +63 internationalisation or not, optional spaces and brackets.
|
||||
|
|
||||
(^\+63\s?\(?\d{4}\)?|^\(?\d{4}\)?){1}\s?\d{3}(\S?|\s?)?\d{4} # 4 digit area code with optional +63 internationalisation or not, optional spaces and brackets.
|
||||
|
|
||||
(^\+63\s?\(?\d{3}\)?|^\(?\d{3}\)?){1}\s?\d{3}(\S?|\s?)?\d{4} # 3 digit area code with optional +63 internationalisation or not, optional spaces and brackets.
|
||||
|
|
||||
(^\+63\s?\(?\d{2}\)?|^\(?\d{2}\)?){1}\s?\d{3}(\S?|\s?)?\d{4} # 2 digit area code with optional +63 internationalisation or not, optional spaces and brackets.
|
||||
|
|
||||
(^\+63\s?\(?\d{1}\)?|^\(?\d{1}\)?){1}\s?\d{3}(\S?|\s?)?\d{4} # 1 digit area code with optional +63 internationalisation or not, optional spaces and brackets.
|
||||
)
|
||||
(\s?\#\d*)? # optional extension number shown with a loc. divider
|
||||
/x";
|
||||
// return true if valid, false otherwise
|
||||
if (!preg_match($regex, $phonenumber)) {
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a valid Philippine phone number into standard +63 (2) 123-4567 or +63 (2) 123-4567 loc. 123 or mobile +63 (919) 123-4567
|
||||
*
|
||||
* @param $phonenumber must be a valid ten-digit number (with optional extension)
|
||||
*
|
||||
*/
|
||||
function format_ph_phone_number($phonenumber, $field = FALSE) {
|
||||
|
||||
$area = $number = $extension = $description = '';
|
||||
|
||||
//Simplify to 10 digit number and clean up ready for international reformat.
|
||||
$phonenumber = preg_replace("/^\+63/","",$phonenumber);
|
||||
$phonenumber = preg_replace("/\(/","",$phonenumber);
|
||||
$phonenumber = preg_replace("/\)/","",$phonenumber);
|
||||
|
||||
//If there are some spaces in the number assume some level of preformatting
|
||||
$regex = "/
|
||||
# 5 digit area code.
|
||||
(
|
||||
(\d{5}) # capture 5 digit area code
|
||||
(\s*)? # ignore required separator to make a distinction with other area codes
|
||||
(\d{3}) # capture first set of numbers in the local number
|
||||
(\S?|\s*)? # ignore optional separator
|
||||
(\d{4}) # capture second set of numbers in the local number
|
||||
|
|
||||
# 4 digit area code.
|
||||
(\d{4}) # capture 4 digit area code
|
||||
(\s*)? # ignore required seperator
|
||||
(\d{3}) # capture first set of numbers in the local number
|
||||
(\S?|\s*)? # ignore possible boundary
|
||||
(\d{4}) # capture second set of numbers in the local number
|
||||
|
|
||||
# 3 digit area code.
|
||||
(\d{3}) # capture 3 digit area code
|
||||
(\s*)? # ignore required seperator
|
||||
(\d{3}) # capture first set of numbers in the local number
|
||||
(\S?|\s*)? # ignore possible boundary
|
||||
(\d{4}) # capture second set of numbers in the local number
|
||||
|
|
||||
# 2 digit area code.
|
||||
(\d{2}) # capture 2 digit area code
|
||||
(\s*)? # ignore required seperator
|
||||
(\d{3}) # capture first set of numbers in the local number
|
||||
(\S?|\s*)? # ignore possible boundary
|
||||
(\d{4}) # capture second set of numbers in the local number
|
||||
|
|
||||
# 1 digit area code.
|
||||
(\d{1}) # capture 1 digit area code
|
||||
(\s*)? # ignore required boundary to make a distinction with other area codes
|
||||
(\d{3}) # capture first set of numbers in the local number
|
||||
(\S?|\s*)? # ignore possible boundary
|
||||
(\d{4}) # capture second set of numbers in the local number
|
||||
)
|
||||
# capture the optional extension number
|
||||
(\s*loc\.\s*|\s*ext\.\s*)?
|
||||
(\d*)?
|
||||
([a-zA-Z0-9\-\. \/\,\']{0,})?
|
||||
/x";
|
||||
preg_match($regex, $phonenumber, $matches);
|
||||
$area = $matches[2] . $matches[7] . $matches[12] . $matches[17] . $matches[22];
|
||||
$number = $matches[4] . $matches[9] . $matches[14] . $matches[19] . $matches[24] . '-' . $matches[6] . $matches[11] . $matches[16] . $matches[21] . $matches[26];
|
||||
$extension = $matches[28];
|
||||
$description = $matches[29];
|
||||
|
||||
$phonenumber = '+63 (' . $area . ') ' . $number;
|
||||
$phonenumber .= (empty($extension)) ? '' : " loc. $extension";
|
||||
$phonenumber .= (empty($description))? '' : " $description";
|
||||
|
||||
return $phonenumber;
|
||||
}
|
49
sites/all/modules/contrib/form/phone/include/phone.pk.inc
Normal file
49
sites/all/modules/contrib/form/phone/include/phone.pk.inc
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* CCK Field for Pakistanese phone numbers.
|
||||
*/
|
||||
|
||||
function phone_pk_metadata() {
|
||||
// These strings are translated using t() on output.
|
||||
return array(
|
||||
'error' => '"%value" is not a valid Pakistanese mobile phone number<br>Pakistanese phone numbers should only ...',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that $phonenumber is valid
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return boolean Returns boolean FALSE if the phone number is not valid.
|
||||
*/
|
||||
function valid_pk_phone_number($phonenumber) {
|
||||
// define regular expression
|
||||
$regex = "/^(\+)?([9]{1}[2]{1})?-? ?(\()?([0]{1})?[1-9]{2,4}(\))?-? ??(\()?[1-9]{4,7}(\))?$/i";
|
||||
|
||||
// return true if valid, false otherwise
|
||||
return (bool) preg_match($regex, $phonenumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formatting for Pakistan Phone Numbers.
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return string Returns a string containting the phone number with some formatting.
|
||||
*/
|
||||
function format_pk_phone_number($phonenumber, $field) {
|
||||
|
||||
//$phonenumber = trim($phonenumber);
|
||||
|
||||
// do some formatting on the phone number
|
||||
|
||||
/* ==> to be done ==> add the country code
|
||||
if ($field['phone_country_code']) {
|
||||
if ($matches[1] != "+39") {
|
||||
$phonenumber = "+39" . " " . $phonenumber;
|
||||
}
|
||||
}
|
||||
*/
|
||||
return $phonenumber;
|
||||
}
|
49
sites/all/modules/contrib/form/phone/include/phone.pl.inc
Normal file
49
sites/all/modules/contrib/form/phone/include/phone.pl.inc
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* CCK Field for Poland phone numbers.
|
||||
*/
|
||||
|
||||
function phone_pl_metadata() {
|
||||
// These strings are translated using t() on output.
|
||||
return array(
|
||||
'error' => '"%value" is not a valid Polish mobile phone number<br>Polish phone numbers should only ...',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that $phonenumber is valid
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return boolean Returns boolean FALSE if the phone number is not valid.
|
||||
*/
|
||||
function valid_pl_phone_number($phonenumber) {
|
||||
// define regular expression
|
||||
$regex = "/^(\+48\s+)?\d{3}(\s*|\-)\d{3}(\s*|\-)\d{3}$/i";
|
||||
|
||||
// return true if valid, false otherwise
|
||||
return (bool) preg_match($regex, $phonenumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formatting for Polish Phone Numbers.
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return string Returns a string containting the phone number with some formatting.
|
||||
*/
|
||||
function format_pl_phone_number($phonenumber, $field) {
|
||||
|
||||
//$phonenumber = trim($phonenumber);
|
||||
|
||||
// do some formatting on the phone number
|
||||
|
||||
/* ==> to be done ==> add the country code
|
||||
if ($field['phone_country_code']) {
|
||||
if ($matches[1] != "+39") {
|
||||
$phonenumber = "+39" . " " . $phonenumber;
|
||||
}
|
||||
}
|
||||
*/
|
||||
return $phonenumber;
|
||||
}
|
74
sites/all/modules/contrib/form/phone/include/phone.ru.inc
Normal file
74
sites/all/modules/contrib/form/phone/include/phone.ru.inc
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* CCK Field for Russian phone numbers.
|
||||
*/
|
||||
|
||||
function phone_ru_metadata() {
|
||||
// These strings are translated using t() on output.
|
||||
return array(
|
||||
'error' => '"%value" is not a valid Russian phone number<br>Russian Phone numbers should .... ',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that $phonenumber is a valid ten-digit Russian phone number
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return boolean Returns boolean FALSE if the phone number is not valid.
|
||||
*/
|
||||
|
||||
function valid_ru_phone_number($phonenumber) {
|
||||
|
||||
//$phonenumber = trim($phonenumber);
|
||||
|
||||
// define regular expression
|
||||
$regex = "/
|
||||
\D* # ignore non-digits
|
||||
[78]? # an optional 78
|
||||
\D* # optional separator
|
||||
\d{3,5} # area code 3-5 digit
|
||||
\D* # optional separator
|
||||
\d{1,3} # 3-digit prefix
|
||||
\D* # optional separator
|
||||
\d{2} # 2-digit line number
|
||||
\D* # optional separator
|
||||
\d{2} # 2-digit line number
|
||||
\D* # ignore trailing non-digits
|
||||
/x";
|
||||
// return true if valid, false otherwise
|
||||
return (bool) preg_match($regex, $phonenumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a valid Russian phone number into standard +7 (495) 567-53-09 or +7 (444xx) 67-53-09 or mobile 8 910 414-56-90 format
|
||||
*
|
||||
* @param $phonenumber must be a valid ten-digit number (with optional extension)
|
||||
*
|
||||
*/
|
||||
function format_ru_phone_number($phonenumber, $field = FALSE) {
|
||||
|
||||
// define regular expression
|
||||
$regex = "/
|
||||
^\D* # ignore non-digits
|
||||
([78])? # an optional 78
|
||||
\D* # optional separator
|
||||
(\d{3,5}) # area code 3-5 digit
|
||||
\D* # optional separator
|
||||
(\d{1,3}) # capture 3-digit prefix
|
||||
\D* # optional separator
|
||||
(\d{2}) # 2-digit line number
|
||||
\D* # optional separator
|
||||
(\d{2}) # 2-digit line number
|
||||
\D* # ignore trailing non-digits
|
||||
/x";
|
||||
|
||||
// get digits of phone number
|
||||
preg_match($regex, $phonenumber, $matches);
|
||||
|
||||
// construct ten-digit phone number
|
||||
$phonenumber = $matches[1] . ' (' . $matches[2] . ') ' . $matches[3] . ' - ' . $matches[4] . ' - ' . $matches[5];
|
||||
|
||||
return $phonenumber;
|
||||
}
|
49
sites/all/modules/contrib/form/phone/include/phone.se.inc
Normal file
49
sites/all/modules/contrib/form/phone/include/phone.se.inc
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* CCK Field for Swedish phone numbers.
|
||||
*/
|
||||
|
||||
function phone_se_metadata() {
|
||||
// These strings are translated using t() on output.
|
||||
return array(
|
||||
'error' => '"%value" is not a valid Swedish mobile phone number<br>Swedish phone numbers should only ...',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that $phonenumber is valid
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return boolean Returns boolean FALSE if the phone number is not valid.
|
||||
*/
|
||||
function valid_se_phone_number($phonenumber) {
|
||||
// define regular expression
|
||||
$regex = "/^(([+]\d{2}[ ][1-9]\d{0,2}[ ])|([0]\d{1,3}[-]))((\d{2}([ ]\d{2}){2})|(\d{3}([ ]\d{3})*([ ]\d{2})+))$/i";
|
||||
|
||||
// return true if valid, false otherwise
|
||||
return (bool) preg_match($regex, $phonenumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formatting for Sweden Phone Numbers.
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return string Returns a string containting the phone number with some formatting.
|
||||
*/
|
||||
function format_se_phone_number($phonenumber, $field) {
|
||||
|
||||
//$phonenumber = trim($phonenumber);
|
||||
|
||||
// do some formatting on the phone number
|
||||
|
||||
/* ==> to be done ==> add the country code
|
||||
if ($field['phone_country_code']) {
|
||||
if ($matches[1] != "+39") {
|
||||
$phonenumber = "+39" . " " . $phonenumber;
|
||||
}
|
||||
}
|
||||
*/
|
||||
return $phonenumber;
|
||||
}
|
59
sites/all/modules/contrib/form/phone/include/phone.sg.inc
Normal file
59
sites/all/modules/contrib/form/phone/include/phone.sg.inc
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* CCK Field for Singapore phone numbers.
|
||||
*/
|
||||
|
||||
function phone_sg_metadata() {
|
||||
// These strings are translated using t() on output.
|
||||
return array(
|
||||
'error' => '"%value" is not a valid Singaporean phone number<br>Singaporean phone numbers should only ...',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that $phonenumber is valid
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return boolean Returns boolean FALSE if the phone number is not valid.
|
||||
*/
|
||||
function valid_sg_phone_number($phonenumber) {
|
||||
// define regular expression
|
||||
/*
|
||||
See: http://en.wikipedia.org/wiki/Telephone_numbers_in_Singapore
|
||||
|
||||
Accepts:
|
||||
+6561234567 / +6581234567 / +6591234567
|
||||
+65 61234567 / +65 81234567 / +65 91234567
|
||||
61234567 / 81234567 / 91234567
|
||||
*/
|
||||
|
||||
$regex = '/^(\+65)?\s?[689]\d{7}$/i';
|
||||
|
||||
|
||||
// return true if valid, false otherwise
|
||||
return (bool) preg_match($regex, $phonenumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formatting for Singapore Phone Numbers.
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return string Returns a string containting the phone number with some formatting.
|
||||
*/
|
||||
function format_sg_phone_number($phonenumber, $field) {
|
||||
|
||||
//$phonenumber = trim($phonenumber);
|
||||
|
||||
// do some formatting on the phone number
|
||||
|
||||
/* ==> to be done ==> add the country code
|
||||
if ($field['phone_country_code']) {
|
||||
if ($matches[1] != "+39") {
|
||||
$phonenumber = "+39" . " " . $phonenumber;
|
||||
}
|
||||
}
|
||||
*/
|
||||
return $phonenumber;
|
||||
}
|
49
sites/all/modules/contrib/form/phone/include/phone.sn.inc
Normal file
49
sites/all/modules/contrib/form/phone/include/phone.sn.inc
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* CCK Field for Senegalese phone numbers.
|
||||
*/
|
||||
|
||||
define('PHONE_SN_REGEX', '/((\+221|00221)?)((7[7608][0-9]{7}$)|(3[03][98][0-9]{6}$))/');
|
||||
|
||||
|
||||
function phone_sn_metadata() {
|
||||
// These strings are translated using t() on output.
|
||||
return array(
|
||||
'error' => '"%value" is not a valid Senegalese phone number',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verification for Senegalese Phone Numbers.
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return boolean Returns boolean FALSE if the phone number is not valid.
|
||||
*/
|
||||
function valid_sn_phone_number($phonenumber) {
|
||||
|
||||
$phonenumber = str_replace(array(' ', '-', '(', ')') , '', $phonenumber);
|
||||
return (bool) preg_match(PHONE_SN_REGEX, $phonenumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formatting for Senegalese Phone Numbers.
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return string Returns the phone number as string.
|
||||
*/
|
||||
function format_sn_phone_number($phonenumber, $field = FALSE) {
|
||||
$phone = str_replace(array(' ', '-', '(', ')'), '', $phonenumber);
|
||||
if (preg_match(PHONE_SN_REGEX, $phone, $matches) != 1) {
|
||||
return $phonenumber; // not a french phone number
|
||||
}
|
||||
//
|
||||
if (in_array($matches[0], array('+221', '00221'))) {
|
||||
return $matches[2];
|
||||
}
|
||||
else {
|
||||
return $matches[0];
|
||||
}
|
||||
}
|
||||
|
581
sites/all/modules/contrib/form/phone/include/phone.ua.inc
Normal file
581
sites/all/modules/contrib/form/phone/include/phone.ua.inc
Normal file
@@ -0,0 +1,581 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* CCK Field for Ukrainian phone numbers.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Helper function knows all valid country codes.
|
||||
*
|
||||
* @return array of stings for use in preg_match* fuunctions.
|
||||
*
|
||||
* Return PREG string elements in array like "44\d{7}|278\d{6}" which will match
|
||||
* all nine-digit valid numbers.
|
||||
* Please note - leading zero stripped for both mobile and landline.
|
||||
*
|
||||
* For performance reason there are a set of strings instead of single very long one.
|
||||
*/
|
||||
function _phone_ua_get_valid_masks() {
|
||||
$result = cache_get('phone' . __FUNCTION__);
|
||||
|
||||
if( !empty($result) ) {
|
||||
return $result->data;
|
||||
}
|
||||
|
||||
$mobiles = array(
|
||||
"39",
|
||||
"50",
|
||||
"63",
|
||||
"66",
|
||||
"67",
|
||||
"68",
|
||||
"91",
|
||||
"92",
|
||||
"93",
|
||||
"94",
|
||||
"95",
|
||||
"96",
|
||||
"97",
|
||||
"98",
|
||||
"99",
|
||||
);
|
||||
|
||||
$landlines = array(
|
||||
"255",
|
||||
"260",
|
||||
"263",
|
||||
"265",
|
||||
"268",
|
||||
"269",
|
||||
"271",
|
||||
"272",
|
||||
"278",
|
||||
"312",
|
||||
"3131",
|
||||
"3132",
|
||||
"3133",
|
||||
"3134",
|
||||
"3135",
|
||||
"3136",
|
||||
"3137",
|
||||
"3141",
|
||||
"3142",
|
||||
"3143",
|
||||
"3144",
|
||||
"3145",
|
||||
"3146",
|
||||
"322",
|
||||
"3230",
|
||||
"3231",
|
||||
"3234",
|
||||
"3236",
|
||||
"3238",
|
||||
"3239",
|
||||
"3241",
|
||||
"3244",
|
||||
"3245",
|
||||
"3247",
|
||||
"3248",
|
||||
"3249",
|
||||
"3251",
|
||||
"3252",
|
||||
"3254",
|
||||
"3255",
|
||||
"3256",
|
||||
"3257",
|
||||
"3259",
|
||||
"32606",
|
||||
"3261",
|
||||
"3263",
|
||||
"3264",
|
||||
"3265",
|
||||
"3266",
|
||||
"3269",
|
||||
"3310",
|
||||
"3322",
|
||||
"3342",
|
||||
"3344",
|
||||
"3346",
|
||||
"3348",
|
||||
"3352",
|
||||
"3355",
|
||||
"3357",
|
||||
"3362",
|
||||
"3363",
|
||||
"3365",
|
||||
"3366",
|
||||
"3368",
|
||||
"3372",
|
||||
"3374",
|
||||
"3376",
|
||||
"3377",
|
||||
"3379",
|
||||
"342",
|
||||
"3430",
|
||||
"3431",
|
||||
"3432",
|
||||
"3433",
|
||||
"3434",
|
||||
"3435",
|
||||
"3436",
|
||||
"3438",
|
||||
"3471",
|
||||
"3472",
|
||||
"3474",
|
||||
"3475",
|
||||
"3476",
|
||||
"3477",
|
||||
"3478",
|
||||
"3479",
|
||||
"352",
|
||||
"3540",
|
||||
"3541",
|
||||
"3542",
|
||||
"3543",
|
||||
"3544",
|
||||
"3546",
|
||||
"3547",
|
||||
"3548",
|
||||
"3549",
|
||||
"3550",
|
||||
"3551",
|
||||
"3552",
|
||||
"3554",
|
||||
"3555",
|
||||
"3557",
|
||||
"3558",
|
||||
"362",
|
||||
"3632",
|
||||
"3633",
|
||||
"3634",
|
||||
"3635",
|
||||
"3636",
|
||||
"3637",
|
||||
"3650",
|
||||
"3651",
|
||||
"3652",
|
||||
"3653",
|
||||
"3654",
|
||||
"3655",
|
||||
"3656",
|
||||
"3657",
|
||||
"3658",
|
||||
"3659",
|
||||
"372",
|
||||
"373",
|
||||
"3740",
|
||||
"3741",
|
||||
"382",
|
||||
"384",
|
||||
"385",
|
||||
"412",
|
||||
"4130",
|
||||
"4132",
|
||||
"4133",
|
||||
"4134",
|
||||
"4135",
|
||||
"4136",
|
||||
"4137",
|
||||
"4138",
|
||||
"4139",
|
||||
"414",
|
||||
"4161",
|
||||
"4162",
|
||||
"4231",
|
||||
"4232",
|
||||
"4241",
|
||||
"432",
|
||||
"4330",
|
||||
"4331",
|
||||
"4332",
|
||||
"4333",
|
||||
"4334",
|
||||
"4335",
|
||||
"4336",
|
||||
"4337",
|
||||
"43388",
|
||||
"4340",
|
||||
"4341",
|
||||
"4342",
|
||||
"4343",
|
||||
"4344",
|
||||
"4345",
|
||||
"4346",
|
||||
"4347",
|
||||
"4348",
|
||||
"4349",
|
||||
"4350",
|
||||
"4351",
|
||||
"4352",
|
||||
"4353",
|
||||
"4355",
|
||||
"4356",
|
||||
"4357",
|
||||
"4358",
|
||||
"44",
|
||||
"462",
|
||||
"4631",
|
||||
"4632",
|
||||
"4633",
|
||||
"4634",
|
||||
"4635",
|
||||
"4636",
|
||||
"4637",
|
||||
"4641",
|
||||
"4642",
|
||||
"4643",
|
||||
"4644",
|
||||
"4645",
|
||||
"4646",
|
||||
"4653",
|
||||
"4654",
|
||||
"4655",
|
||||
"4656",
|
||||
"4657",
|
||||
"4658",
|
||||
"4659",
|
||||
"472",
|
||||
"473",
|
||||
"4740",
|
||||
"4741",
|
||||
"4742",
|
||||
"4744",
|
||||
"4745",
|
||||
"4746",
|
||||
"4747",
|
||||
"4748",
|
||||
"4749",
|
||||
"482",
|
||||
"484",
|
||||
"4851",
|
||||
"4852",
|
||||
"4853",
|
||||
"4854",
|
||||
"4855",
|
||||
"4856",
|
||||
"4857",
|
||||
"4858",
|
||||
"4859",
|
||||
"4860",
|
||||
"4861",
|
||||
"4862",
|
||||
"4863",
|
||||
"4864",
|
||||
"4865",
|
||||
"4866",
|
||||
"4867",
|
||||
"4868",
|
||||
"512",
|
||||
"5131",
|
||||
"5132",
|
||||
"5133",
|
||||
"5134",
|
||||
"5135",
|
||||
"5136",
|
||||
"5151",
|
||||
"5152",
|
||||
"5153",
|
||||
"5154",
|
||||
"5158",
|
||||
"5159",
|
||||
"5161",
|
||||
"5162",
|
||||
"5163",
|
||||
"5167",
|
||||
"5168",
|
||||
"522",
|
||||
"5233",
|
||||
"5234",
|
||||
"5235",
|
||||
"5236",
|
||||
"5237",
|
||||
"5238",
|
||||
"5239",
|
||||
"5240",
|
||||
"5241",
|
||||
"5242",
|
||||
"5250",
|
||||
"5251",
|
||||
"5252",
|
||||
"5253",
|
||||
"5254",
|
||||
"5256",
|
||||
"5257",
|
||||
"5258",
|
||||
"5259",
|
||||
"532",
|
||||
"5340",
|
||||
"5341",
|
||||
"5342",
|
||||
"5343",
|
||||
"5344",
|
||||
"5345",
|
||||
"5346",
|
||||
"5347",
|
||||
"5348",
|
||||
"5350",
|
||||
"5351",
|
||||
"5352",
|
||||
"5353",
|
||||
"5354",
|
||||
"5355",
|
||||
"5356",
|
||||
"5357",
|
||||
"5358",
|
||||
"5359",
|
||||
"536",
|
||||
"5361",
|
||||
"5362",
|
||||
"5363",
|
||||
"5364",
|
||||
"5365",
|
||||
"5366",
|
||||
"542",
|
||||
"5422",
|
||||
"5442",
|
||||
"5443",
|
||||
"5444",
|
||||
"5445",
|
||||
"5446",
|
||||
"5447",
|
||||
"5448",
|
||||
"5449",
|
||||
"5451",
|
||||
"5452",
|
||||
"5453",
|
||||
"5454",
|
||||
"5455",
|
||||
"5456",
|
||||
"5457",
|
||||
"5458",
|
||||
"5459",
|
||||
"552",
|
||||
"553",
|
||||
"5542",
|
||||
"5543",
|
||||
"5544",
|
||||
"5545",
|
||||
"5546",
|
||||
"5547",
|
||||
"5548",
|
||||
"5549",
|
||||
"56",
|
||||
"5610",
|
||||
"5611",
|
||||
"5612",
|
||||
"5615",
|
||||
"5616",
|
||||
"5617",
|
||||
"5618",
|
||||
"562",
|
||||
"5630",
|
||||
"5632",
|
||||
"5633",
|
||||
"5636",
|
||||
"5638",
|
||||
"5639",
|
||||
"564",
|
||||
"5650",
|
||||
"5651",
|
||||
"5652",
|
||||
"5653",
|
||||
"5655",
|
||||
"5656",
|
||||
"5657",
|
||||
"5658",
|
||||
"5662",
|
||||
"5663",
|
||||
"5665",
|
||||
"5667",
|
||||
"5668",
|
||||
"567",
|
||||
"569",
|
||||
"572",
|
||||
"574",
|
||||
"575",
|
||||
"5761",
|
||||
"5762",
|
||||
"5763",
|
||||
"5764",
|
||||
"5765",
|
||||
"5766",
|
||||
"612",
|
||||
"6131",
|
||||
"6132",
|
||||
"6133",
|
||||
"6136",
|
||||
"6137",
|
||||
"6138",
|
||||
"6139",
|
||||
"6140",
|
||||
"6141",
|
||||
"6142",
|
||||
"6143",
|
||||
"6144",
|
||||
"6145",
|
||||
"6147",
|
||||
"6153",
|
||||
"6156",
|
||||
"6162",
|
||||
"6165",
|
||||
"6175",
|
||||
"6178",
|
||||
"619",
|
||||
"6212",
|
||||
"6214",
|
||||
"6217",
|
||||
"622",
|
||||
"6232",
|
||||
"6236",
|
||||
"6237",
|
||||
"6239",
|
||||
"6242",
|
||||
"6243",
|
||||
"6244",
|
||||
"6246",
|
||||
"6247",
|
||||
"6249",
|
||||
"6250",
|
||||
"6252",
|
||||
"6253",
|
||||
"6254",
|
||||
"6255",
|
||||
"6256",
|
||||
"6257",
|
||||
"6259",
|
||||
"6261",
|
||||
"6262",
|
||||
"6264",
|
||||
"6267",
|
||||
"6269",
|
||||
"6272",
|
||||
"6273",
|
||||
"6274",
|
||||
"6275",
|
||||
"6277",
|
||||
"6278",
|
||||
"6279",
|
||||
"629",
|
||||
"642",
|
||||
"6431",
|
||||
"6432",
|
||||
"6433",
|
||||
"6434",
|
||||
"6435",
|
||||
"6436",
|
||||
"6441",
|
||||
"6442",
|
||||
"6443",
|
||||
"6444",
|
||||
"6445",
|
||||
"6446",
|
||||
"6451",
|
||||
"6452",
|
||||
"6453",
|
||||
"6454",
|
||||
"6455",
|
||||
"6456",
|
||||
"6461",
|
||||
"6462",
|
||||
"6463",
|
||||
"6464",
|
||||
"6465",
|
||||
"6466",
|
||||
"6471",
|
||||
"6472",
|
||||
"6473",
|
||||
"6474",
|
||||
"652",
|
||||
"654",
|
||||
"655",
|
||||
"6560",
|
||||
"6561",
|
||||
"6562",
|
||||
"6563",
|
||||
"6564",
|
||||
"6565",
|
||||
"6566",
|
||||
"6569",
|
||||
"692",
|
||||
);
|
||||
|
||||
$all_codes = array_merge($mobiles, $landlines);
|
||||
|
||||
$TOTAL_DIGITS = 9;
|
||||
$ITEMS_PER_LINE = 30;
|
||||
$counter = 0;
|
||||
$line = '';
|
||||
foreach ($all_codes as $code) {
|
||||
if (++$counter >= $ITEMS_PER_LINE) {
|
||||
$result[] = $line;
|
||||
$counter = 0;
|
||||
$line = '';
|
||||
}
|
||||
$item = $code . '\d{' . ($TOTAL_DIGITS - strlen($code)) . '}';
|
||||
$line .= (empty($line) ? '' : '|') . $item;
|
||||
}
|
||||
$result[] = $line;
|
||||
|
||||
cache_set('phone' . __FUNCTION__, $result);
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
function phone_ua_metadata() {
|
||||
// These strings are translated using t() on output.
|
||||
return array(
|
||||
'error' => '"%value" is not a valid Ukrainian mobile phone number<br />'
|
||||
. 'Ukrainian phone numbers should only have 10 digits staring with 0 with optional country prefix +38 .<br />'
|
||||
. 'And, of course, city or mobile code - a first few digits after 0 - have to be valid.',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that $phonenumber is valid
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return boolean Returns boolean FALSE if the phone number is not valid.
|
||||
*/
|
||||
function valid_ua_phone_number($phonenumber) {
|
||||
// For adressing Ukraine phones used both +38 and +380 as a prefix.
|
||||
// So lets clean up any spaces, pareenthesis, minus signs etc first.
|
||||
$cleaning_pattern = '/( |\-|\(|\))*/';
|
||||
$refined_phonenumber = preg_replace($cleaning_pattern, '', $phonenumber);
|
||||
|
||||
// define regular expression
|
||||
$code_packs = _phone_ua_get_valid_masks();
|
||||
foreach ($code_packs as $codes) {
|
||||
// $regex = "/^((8|\+38)-?)?\s*(\(?044\)?)?-?\d{3}-?\d{2}-?\d{2}$/i";
|
||||
// Please note - pure 8 as a prefix is obsolete.
|
||||
$regex = "/^(\+38)?0(" . $codes . ")$/";
|
||||
if (preg_match($regex, $refined_phonenumber)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// return true if valid, false otherwise
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formatting for Unkraine Phone Numbers.
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return string Returns a string containting the phone number with some formatting.
|
||||
*/
|
||||
function format_ua_phone_number($phonenumber, $field) {
|
||||
|
||||
//$phonenumber = trim($phonenumber);
|
||||
|
||||
// do some formatting on the phone number
|
||||
|
||||
/* ==> to be done ==> add the country code
|
||||
if ($field['phone_country_code']) {
|
||||
if ($matches[1] != "+39") {
|
||||
$phonenumber = "+39" . " " . $phonenumber;
|
||||
}
|
||||
}
|
||||
*/
|
||||
return $phonenumber;
|
||||
}
|
65
sites/all/modules/contrib/form/phone/include/phone.za.inc
Normal file
65
sites/all/modules/contrib/form/phone/include/phone.za.inc
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* CCK Field for South African phone numbers.
|
||||
*/
|
||||
|
||||
function phone_za_metadata() {
|
||||
// These strings are translated using t() on output.
|
||||
return array(
|
||||
'error' => '"%value" is not a valid South African phone number!<br>South African phone numbers should only contain numbers with an optional prefix of "+27".',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that $phonenumber is a valid South African phone number
|
||||
*
|
||||
* @param string $phonenumber
|
||||
* @return boolean Returns boolean FALSE if the phone number is not valid.
|
||||
*/
|
||||
function valid_za_phone_number($phonenumber) {
|
||||
|
||||
$phonenumber = trim($phonenumber);
|
||||
|
||||
// define regular expression
|
||||
$regex = '/^((?:\+27|27)|0)[ ]*((\d{2})(-| )?(\d{3})(-| )?(\d{4})|(\d{2})( |-)(\d{7}))$/';
|
||||
|
||||
// return true if valid, false otherwise
|
||||
return (bool) preg_match($regex, $phonenumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a valid South African phone number into standard ... format
|
||||
*
|
||||
* @param $phonenumber must be a valid ... digit number (with optional international prefix)
|
||||
*
|
||||
*/
|
||||
function format_za_phone_number($phonenumber, $field) {
|
||||
|
||||
// define regular expression
|
||||
$regex = '/^((?:\+27|27)|0)[ ]*((\d{2})(-| )?(\d{3})(-| )?(\d{4})|(\d{2})( |-)(\d{7}))$/';
|
||||
|
||||
// get digits of phone number
|
||||
preg_match($regex, $phonenumber, $matches);
|
||||
|
||||
/*
|
||||
drupal_set_message('$matches[1] = ' . $matches[1], 'error');
|
||||
drupal_set_message('$matches[2] = ' . $matches[2], 'error');
|
||||
drupal_set_message('$matches[3] = ' . $matches[3], 'error');
|
||||
drupal_set_message('$matches[4] = ' . $matches[4], 'error');
|
||||
drupal_set_message('$matches[5] = ' . $matches[5], 'error');
|
||||
drupal_set_message('$matches[6] = ' . $matches[6], 'error');
|
||||
drupal_set_message('$matches[7] = ' . $matches[7], 'error');
|
||||
drupal_set_message('$matches[8] = ' . $matches[8], 'error');
|
||||
*/
|
||||
|
||||
if ($field['phone_country_code']) {
|
||||
$phonenumber = '+27' . ' ' . $matches[3] .'-'. $matches[5] .'-'. $matches[7];
|
||||
}
|
||||
else {
|
||||
$phonenumber = '0' . $matches[3] .'-'. $matches[5] .'-'. $matches[7];
|
||||
}
|
||||
|
||||
return $phonenumber;
|
||||
}
|
59
sites/all/modules/contrib/form/phone/phone.feeds.inc
Normal file
59
sites/all/modules/contrib/form/phone/phone.feeds.inc
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Implements Feeds support for Phone fields.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_feeds_processor_targets_alter().
|
||||
*
|
||||
* @see FeedsNodeProcessor::getMappingTargets().
|
||||
*/
|
||||
function phone_feeds_processor_targets_alter(&$targets, $entity_type, $bundle_name) {
|
||||
foreach (field_info_instances($entity_type, $bundle_name) as $name => $instance) {
|
||||
$info = field_info_field($name);
|
||||
if ($info['type'] == 'phone') {
|
||||
$targets[$name . ':url'] = array(
|
||||
'name' => check_plain($instance['label']),
|
||||
'callback' => 'phone_feeds_set_target',
|
||||
'description' => t('The @label field of the node.', array('@label' => $instance['label'])),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for mapping. Here is where the actual mapping happens.
|
||||
*
|
||||
* When the callback is invoked, $target contains the name of the field the
|
||||
* user has decided to map to and $value contains the value of the feed item
|
||||
* element the user has picked as a source.
|
||||
*/
|
||||
function phone_feeds_set_target($source, $entity, $target, $value) {
|
||||
if (empty($value)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle non-multiple value fields.
|
||||
if (!is_array($value)) {
|
||||
$value = array($value);
|
||||
}
|
||||
|
||||
// Iterate over all values.
|
||||
$i = 0;
|
||||
$info = field_info_field($target);
|
||||
list($field_name, $sub_field) = explode(':', $target);
|
||||
foreach ($value as $v) {
|
||||
if (empty($v[0])) {
|
||||
continue;
|
||||
}
|
||||
if (!is_array($v) && !is_object($v)) {
|
||||
$field['und'][$i]['value'] = $v;
|
||||
}
|
||||
if ($info['cardinality'] == 1) {
|
||||
break;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$entity->{$field_name} = $field;
|
||||
}
|
42
sites/all/modules/contrib/form/phone/phone.info
Normal file
42
sites/all/modules/contrib/form/phone/phone.info
Normal file
@@ -0,0 +1,42 @@
|
||||
name = Phone
|
||||
description = The phone module allows administrators to define a field type for phone numbers.
|
||||
package = Fields
|
||||
dependencies[] = field
|
||||
files[] = phone.migrate.inc
|
||||
files[] = tests/phone.au.test
|
||||
files[] = tests/phone.be.test
|
||||
files[] = tests/phone.br.test
|
||||
files[] = tests/phone.ca.test
|
||||
files[] = tests/phone.ch.test
|
||||
files[] = tests/phone.cl.test
|
||||
files[] = tests/phone.cn.test
|
||||
files[] = tests/phone.cr.test
|
||||
files[] = tests/phone.cs.test
|
||||
files[] = tests/phone.eg.test
|
||||
files[] = tests/phone.es.test
|
||||
files[] = tests/phone.fr.test
|
||||
files[] = tests/phone.hu.test
|
||||
files[] = tests/phone.il.test
|
||||
files[] = tests/phone.int.test
|
||||
files[] = tests/phone.it.test
|
||||
files[] = tests/phone.jo.test
|
||||
files[] = tests/phone.nl.test
|
||||
files[] = tests/phone.nz.test
|
||||
files[] = tests/phone.pa.test
|
||||
files[] = tests/phone.ph.test
|
||||
files[] = tests/phone.pk.test
|
||||
files[] = tests/phone.pl.test
|
||||
files[] = tests/phone.ru.test
|
||||
files[] = tests/phone.se.test
|
||||
files[] = tests/phone.sg.test
|
||||
files[] = tests/phone.ua.test
|
||||
files[] = tests/phone.uk.test
|
||||
files[] = tests/phone.za.test
|
||||
core = 7.x
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-01-14
|
||||
version = "7.x-1.0-beta1"
|
||||
core = "7.x"
|
||||
project = "phone"
|
||||
datestamp = "1389732224"
|
||||
|
25
sites/all/modules/contrib/form/phone/phone.install
Normal file
25
sites/all/modules/contrib/form/phone/phone.install
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Install/Update/Uninstall functions for phone module
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_field_schema().
|
||||
*/
|
||||
function phone_field_schema($field) {
|
||||
return array(
|
||||
'columns' => array(
|
||||
'value' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => FALSE,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// TODO: data migration from the old DB structure, could be tough..
|
||||
|
40
sites/all/modules/contrib/form/phone/phone.migrate.inc
Normal file
40
sites/all/modules/contrib/form/phone/phone.migrate.inc
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* @file phone.migrate.inc
|
||||
* Code to implement hook_content_migrate_field_alter, content_migrate_instance_alter() and content_migrate_data_record_alter()
|
||||
* on behalf of the former phone module, moved into a separate file for efficiency.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_content_migrate_field_alter().
|
||||
*
|
||||
* Use this to tweak the conversion of field settings
|
||||
* from the D6 style to the D7 style for specific
|
||||
* situations not handled by basic conversion,
|
||||
* as when field types or settings are changed.
|
||||
*/
|
||||
function phone_field_alter(&$field_value, $instance_value) {
|
||||
if (substr($field_value['type'], 2) === '_phone') {
|
||||
$code = substr($field_value['type'], 0, 2);
|
||||
$field_value['type'] = 'phone';
|
||||
$field_value['settings']['country'] = $code;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_migrate_api().
|
||||
*/
|
||||
function phone_migrate_api() {
|
||||
return array('api' => 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap Migrate's simple field handler for 'phone' fields.
|
||||
*/
|
||||
class MigratePhoneFieldHandler extends MigrateSimpleFieldHandler {
|
||||
|
||||
public function __construct() {
|
||||
$this->registerTypes(array('phone'));
|
||||
}
|
||||
|
||||
}
|
386
sites/all/modules/contrib/form/phone/phone.module
Normal file
386
sites/all/modules/contrib/form/phone/phone.module
Normal file
@@ -0,0 +1,386 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Function which holds an array of supported countries.
|
||||
*
|
||||
* @param string $countrycode
|
||||
* @return boolean Returns the whole array of countries $countrycode isn't specified and a country name for when it is specified.
|
||||
*/
|
||||
function phone_countries($code = NULL) {
|
||||
static $countries;
|
||||
|
||||
if (!isset($countries)) {
|
||||
$countries = array(
|
||||
'fr' => 'France',
|
||||
'be' => 'Belgium',
|
||||
'it' => 'Italy',
|
||||
'el' => 'Greece',
|
||||
'ch' => 'Switzerland',
|
||||
'ca' => 'US & Canada',
|
||||
'cr' => 'Costa Rica',
|
||||
'pa' => 'Panama',
|
||||
'gb' => 'Great Britain - United Kingdom',
|
||||
'ru' => 'Russia',
|
||||
'ua' => 'Ukraine',
|
||||
'es' => 'Spain',
|
||||
'au' => 'Australia',
|
||||
'cs' => 'Czech Republic',
|
||||
'hu' => 'Hungary',
|
||||
'pl' => 'Poland - mobiles only',
|
||||
'nl' => 'Netherland',
|
||||
'se' => 'Sweden',
|
||||
'za' => 'South Africa',
|
||||
'il' => 'Israel',
|
||||
'nz' => 'New Zealand',
|
||||
'br' => 'Brazil',
|
||||
'cl' => 'Chile',
|
||||
'cn' => 'China',
|
||||
'hk' => 'Hong-Kong',
|
||||
'mo' => 'Macao',
|
||||
'ph' => 'The Philippines',
|
||||
'sg' => 'Singapore',
|
||||
'sn' => 'Senegal',
|
||||
'jo' => 'Jordan',
|
||||
'eg' => 'Egypt',
|
||||
'pk' => 'Pakistan',
|
||||
'int' => 'International Phone Numbers per E.123',
|
||||
);
|
||||
}
|
||||
return ($code === NULL) ? $countries : (isset($countries[$code]) ? $countries[$code] : NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @defgroup field_api_hooks Field API Hook Implementations
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of hook_field_info().
|
||||
*/
|
||||
function phone_field_info() {
|
||||
return array(
|
||||
'phone' => array(
|
||||
'label' => t('Phone Number'),
|
||||
'instance_settings' => array(
|
||||
'phone_country_code' => 0,
|
||||
'phone_default_country_code' => '1',
|
||||
'phone_int_max_length' => 15,
|
||||
'ca_phone_separator' => '-',
|
||||
'ca_phone_parentheses' => 1,
|
||||
),
|
||||
'default_formatter' => 'phone',
|
||||
'default_widget' => 'phone_textfield',
|
||||
'property_type' => 'text',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_field_is_empty().
|
||||
*/
|
||||
function phone_field_is_empty($item, $field) {
|
||||
return empty($item['value']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_field_settings_form().
|
||||
*/
|
||||
function phone_field_settings_form($field, $instance, $has_data) {
|
||||
$settings = $field['settings'];
|
||||
|
||||
$form = array();
|
||||
$form['country'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Country'),
|
||||
'#options' => phone_countries(),
|
||||
'#default_value' => isset ($settings['country']) ? $settings['country'] : NULL,
|
||||
'#description' => t('Which country-specific rules should this field be validated against and formatted according to.'),
|
||||
'#disabled' => $has_data,
|
||||
'#required' => TRUE,
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_field_instance_settings_form().
|
||||
*/
|
||||
function phone_field_instance_settings_form($field, $instance) {
|
||||
$settings = $instance['settings'];
|
||||
|
||||
$form['phone_country_code'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Add the country code if not filled by the user'),
|
||||
'#default_value' => $settings['phone_country_code'],
|
||||
);
|
||||
|
||||
if ($field['settings']['country'] == 'int') {
|
||||
$form['phone_int_help'] = array(
|
||||
'#type' => 'markup',
|
||||
'#value' => t('International phone numbers are in the form +XX YYYYYYY where XX is a country code and YYYYYYY is the local number. This field type is based off of the <a href="http://www.itu.int/rec/T-REC-E.123/en">E.123 specification</a>.'),
|
||||
);
|
||||
$form['phone_default_country_code'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Default country code to add to international numbers without one (omit + sign)'),
|
||||
'#default_value' => $settings['phone_default_country_code'],
|
||||
);
|
||||
$form['phone_int_max_length'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Maximum length of international numbers, according to the ITU this is 15'),
|
||||
'#default_value' => $settings['phone_int_max_length'],
|
||||
);
|
||||
}
|
||||
|
||||
if ($field['settings']['country'] == 'ca') {
|
||||
$form['ca_phone_separator'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Separator'),
|
||||
'#default_value' => $settings['ca_phone_separator'],
|
||||
'#size' => 2,
|
||||
);
|
||||
$form['ca_phone_parentheses'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Use parentheses around area code'),
|
||||
'#default_value' => $settings['ca_phone_parentheses'],
|
||||
);
|
||||
}
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_field_validate().
|
||||
*/
|
||||
function phone_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
|
||||
foreach ($items as $delta => $item) {
|
||||
if (isset($item['value']) && $item['value'] != '') {
|
||||
$ccode = $field['settings']['country'];
|
||||
$value = $item['value'];
|
||||
if (!valid_phone_number($ccode, $value)) {
|
||||
$country = phone_country_info($ccode);
|
||||
$errors[$field['field_name']][$langcode][$delta][] = array(
|
||||
'error' => 'phone_invalid_number',
|
||||
'message' => t($country['error'], array('%value' => $value)),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_field_presave().
|
||||
*/
|
||||
function phone_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
|
||||
$ccode = $field['settings']['country'];
|
||||
if (phone_countries($ccode) !== NULL) {
|
||||
foreach ($items as $delta => $item) {
|
||||
if (isset($item['value'])) {
|
||||
$items[$delta]['value'] = format_phone_number($ccode, $item['value'], $instance['settings']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_field_formatter_info().
|
||||
*/
|
||||
function phone_field_formatter_info() {
|
||||
return array(
|
||||
'phone' => array(
|
||||
'label' => t('Default'),
|
||||
'field types' => array('phone'),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_field_formatter_view().
|
||||
*/
|
||||
function phone_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
|
||||
$element = array();
|
||||
foreach ($items as $delta => $item) {
|
||||
$text = '';
|
||||
|
||||
if (isset($item['value'])) {
|
||||
$text = check_plain($item['value']);
|
||||
// iPhone Support
|
||||
if (strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone') !== FALSE) {
|
||||
$text = '<a href="tel:' . $text . '">' . $text . '</a>';
|
||||
}
|
||||
}
|
||||
$element[$delta]['#markup'] = $text;
|
||||
}
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_field_widget_info().
|
||||
*/
|
||||
function phone_field_widget_info() {
|
||||
return array(
|
||||
'phone_textfield' => array(
|
||||
'label' => t('Text field'),
|
||||
'field types' => array('phone'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_field_widget_form().
|
||||
*/
|
||||
function phone_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
|
||||
$element += array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => $element['#title'],
|
||||
'#description' => $element['#description'],
|
||||
'#default_value' => isset($items[$delta]['value']) ? $items[$delta]['value'] : '',
|
||||
'#required' => $element['#required'],
|
||||
'#size' => 17,
|
||||
'#maxlength' => (
|
||||
$field['settings']['country'] == 'int' ?
|
||||
(isset($instance['settings']['phone_int_max_length']) ? $instance['settings']['phone_int_max_length'] : NULL)
|
||||
: NULL
|
||||
),
|
||||
);
|
||||
return array('value' => $element);
|
||||
}
|
||||
|
||||
/**
|
||||
* @} End of "defgroup field_api_hooks".
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup other_hooks Other Hook Implementations
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_content_migrate_field_alter().
|
||||
*
|
||||
* Use this to tweak the conversion of field settings
|
||||
* from the D6 style to the D7 style for specific
|
||||
* situations not handled by basic conversion,
|
||||
* as when field types or settings are changed.
|
||||
*/
|
||||
function phone_content_migrate_field_alter(&$field_value, $instance_value) {
|
||||
module_load_include('inc', 'phone', 'phone.migrate');
|
||||
phone_field_alter($field_value, $instance_value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook token_list
|
||||
*/
|
||||
function phone_token_list($type = 'all') {
|
||||
if ($type == 'field' || $type == 'all') {
|
||||
$tokens['phone']['raw'] = t('Raw phone numbers');
|
||||
$tokens['phone']['formatted'] = t('Formatted phone numbers');
|
||||
return $tokens;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook token_values
|
||||
*/
|
||||
function phone_token_values($type, $object = NULL, $options = array()) {
|
||||
if ($type == 'field') {
|
||||
$item = $object[0];
|
||||
$tokens['raw'] = $item['value'];
|
||||
$tokens['formatted'] = $item['view'];
|
||||
return $tokens;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_simpletest().
|
||||
*/
|
||||
function phone_simpletest() {
|
||||
$dir = drupal_get_path('module', 'phone'). '/tests';
|
||||
$tests = file_scan_directory($dir, '\.test$');
|
||||
return array_keys($tests);
|
||||
}
|
||||
|
||||
/**
|
||||
* @} End of "defgroup field_api_hooks".
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Country supported or not by the module ?
|
||||
*
|
||||
* @param string $countrycode
|
||||
* @return boolean Returns a boolean containting the answer to the question.
|
||||
*/
|
||||
function phone_supported_countrycode($countrycode) {
|
||||
return (phone_country_info($countrycode) !== NULL ? TRUE : FALSE);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a country meta info
|
||||
*
|
||||
* @param string $countrycode
|
||||
* @return array Returns a array containing country metadata
|
||||
*/
|
||||
function phone_country_info($countrycode = NULL) {
|
||||
static $i;
|
||||
|
||||
$countrycode = trim($countrycode);
|
||||
|
||||
if (phone_countries($countrycode) !== FALSE) {
|
||||
$phone_info_function = 'phone_'. $countrycode . '_metadata';
|
||||
module_load_include('inc', 'phone', 'include/phone.'. $countrycode);
|
||||
|
||||
if (function_exists($phone_info_function)) {
|
||||
return $phone_info_function();
|
||||
}
|
||||
}
|
||||
//Country not taken into account yet
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verification for Phone Numbers.
|
||||
*
|
||||
* @param string $countrycode
|
||||
* @param string $phonenumber
|
||||
* @return boolean Returns boolean FALSE if the phone number is not valid.
|
||||
*/
|
||||
function valid_phone_number($countrycode, $phonenumber) {
|
||||
|
||||
$countrycode = trim($countrycode);
|
||||
$phonenumber = trim($phonenumber);
|
||||
|
||||
if (phone_supported_countrycode($countrycode)) {
|
||||
$valid_phone_function = 'valid_'. $countrycode . '_phone_number';
|
||||
module_load_include('inc', 'phone', 'include/phone.'. $countrycode);
|
||||
|
||||
if (function_exists($valid_phone_function)) {
|
||||
return $valid_phone_function($phonenumber);
|
||||
}
|
||||
}
|
||||
//Country not taken into account yet
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formatting for Phone Numbers.
|
||||
*
|
||||
* @param string $countrycode
|
||||
* @param string $phonenumber
|
||||
* @return boolean Returns boolean FALSE if the phone number is not valid.
|
||||
*/
|
||||
function format_phone_number($countrycode, $phonenumber, $field) {
|
||||
|
||||
$countrycode = trim($countrycode);
|
||||
$phonenumber = trim($phonenumber);
|
||||
|
||||
if (phone_supported_countrycode($countrycode)) {
|
||||
$format_phone_function = 'format_'. $countrycode . '_phone_number';
|
||||
module_load_include('inc', 'phone', 'include/phone.'. $countrycode);
|
||||
|
||||
if (function_exists($format_phone_function)) {
|
||||
return $format_phone_function($phonenumber, $field);
|
||||
}
|
||||
}
|
||||
//Country not taken into account yet
|
||||
return FALSE;
|
||||
}
|
||||
|
45
sites/all/modules/contrib/form/phone/tests/phone.au.test
Normal file
45
sites/all/modules/contrib/form/phone/tests/phone.au.test
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
class AUPhoneNumberTestCase extends DrupalWebTestCase {
|
||||
/**
|
||||
* Implementation of getInfo()
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('Australia Phone number test'),
|
||||
'description' => t('Tests various valid and invalid Australia phone numbers for validity'),
|
||||
'group' => t('Phone')
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhoneAUValid() {
|
||||
$this->assertTrue(valid_phone_number('au', '0200-0299'), t('ACT - 0200-0299'));
|
||||
$this->assertTrue(valid_phone_number('au', '2600-2639'), t('ACT - 2600-2639'));
|
||||
$this->assertTrue(valid_phone_number('au', '1000-1999'), t('NSW - 1000-1999'));
|
||||
$this->assertTrue(valid_phone_number('au', '2000-2599'), t('NSW - 2000-2599'));
|
||||
$this->assertTrue(valid_phone_number('au', '2640-2914'), t('NSW - 2640-2914'));
|
||||
$this->assertTrue(valid_phone_number('au', '0900-0999'), t('NT - 0900-0999'));
|
||||
$this->assertTrue(valid_phone_number('au', '0800-0899'), t('NT - 0800-0899'));
|
||||
$this->assertTrue(valid_phone_number('au', '9000-9999'), t('QLD - 9000-9999'));
|
||||
$this->assertTrue(valid_phone_number('au', '4000-4999'), t('QLD - 4000-4999'));
|
||||
$this->assertTrue(valid_phone_number('au', '5000-5999'), t('SA - 5000-599'));
|
||||
$this->assertTrue(valid_phone_number('au', '7800-7999'), t('TAS - 7800-7999'));
|
||||
$this->assertTrue(valid_phone_number('au', '7000-7499'), t('TAS - 7000-7499'));
|
||||
$this->assertTrue(valid_phone_number('au', '8000-8999'), t('VIC - 8000-8999'));
|
||||
$this->assertTrue(valid_phone_number('au', '3000-3999'), t('VIC - 3000-3999'));
|
||||
$this->assertTrue(valid_phone_number('au', '6800-6999'), t('WA - 6800-6999'));
|
||||
$this->assertTrue(valid_phone_number('au', '6000-6799'), t('WA - 6000-6799'));
|
||||
}
|
||||
|
||||
public function testPhoneAUInvalid() {
|
||||
$this->assertFalse(valid_phone_number('au', '0300'), t('Test invalid - 0300'));
|
||||
$this->assertFalse(valid_phone_number('au', '7612'), t('Test invalid - 7612'));
|
||||
$this->assertFalse(valid_phone_number('au', '2915'), t('Test invalid - 2915'));
|
||||
$this->assertFalse(valid_phone_number('au', '2415b'), t('Test invalid - 2415b'));
|
||||
}
|
||||
|
||||
public function testPhoneAUFormatting() {
|
||||
//$this->assertEqual(format_phone_number('au', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
|
||||
}
|
||||
}
|
31
sites/all/modules/contrib/form/phone/tests/phone.be.test
Normal file
31
sites/all/modules/contrib/form/phone/tests/phone.be.test
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
class BEPhoneNumberTestCase extends DrupalWebTestCase {
|
||||
/**
|
||||
* Implementation of getInfo()
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('Belgium Phone number test'),
|
||||
'description' => t('Tests various valid and invalid Belgium phone numbers for validity'),
|
||||
'group' => t('Phone')
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhoneBEValid() {
|
||||
$this->assertTrue(valid_phone_number('be', '023456789'), '"023456789" should be valid');
|
||||
$this->assertTrue(valid_phone_number('be', '0478990011'), '"0478990011" should be valid');
|
||||
$this->assertTrue(valid_phone_number('be', '01 234 56 78'), '"01 234 56 78" should be valid');
|
||||
$this->assertTrue(valid_phone_number('be', '+32 12345678'), '"+32 12345678" should be valid');
|
||||
}
|
||||
|
||||
public function testPhoneBEInvalid() {
|
||||
$this->assertFalse(valid_phone_number('be', '+323456789'), t('Test invalid'));
|
||||
$this->assertFalse(valid_phone_number('be', '02 345 67 89'), t('Test invalid'));
|
||||
}
|
||||
|
||||
public function testPhoneBEFormatting() {
|
||||
//$this->assertEqual(format_phone_number('be', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
|
||||
}
|
||||
}
|
39
sites/all/modules/contrib/form/phone/tests/phone.br.test
Normal file
39
sites/all/modules/contrib/form/phone/tests/phone.br.test
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
class BRPhoneNumberTestCase extends DrupalWebTestCase {
|
||||
/**
|
||||
* Implementation of getInfo()
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('Brazil Phone number test'),
|
||||
'description' => t('Tests various valid and invalid Brazil phone numbers for validity'),
|
||||
'group' => t('Phone')
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhoneBRValid() {
|
||||
$this->assertTrue(valid_phone_number('br', '(11) 1234-5678'), t('Test valid - (11) 1234-5678'));
|
||||
$this->assertTrue(valid_phone_number('br', '1234-5678 '), t('Test valid - 1234-5678'));
|
||||
$this->assertTrue(valid_phone_number('br', '12345678'), t('Test valid - 12345678'));
|
||||
$this->assertTrue(valid_phone_number('br', '+55 11 2222-3333'), t('Test valid - +55 11 2222-3333'));
|
||||
|
||||
$this->assertTrue(valid_phone_number('br', '011 5555-1234'), t('Test valid - 011 5555-1234'));
|
||||
$this->assertTrue(valid_phone_number('br', '(011) 5555 1234'), t('Test valid - (011) 5555 1234'));
|
||||
$this->assertTrue(valid_phone_number('br', '(11) 5555.1234'), t('Test valid - (11) 5555.1234'));
|
||||
$this->assertTrue(valid_phone_number('br', '1155551234'), t('Test valid - 1155551234'));
|
||||
}
|
||||
|
||||
public function testPhoneBRInvalid() {
|
||||
$this->assertFalse(valid_phone_number('br', '123-45678'), t('Test invalid - 123-45678'));
|
||||
|
||||
$this->assertFalse(valid_phone_number('br', '(01) 5555 1234'), t('Test invalid - (01) 5555 1234'));
|
||||
$this->assertFalse(valid_phone_number('br', '(11) 0555.1234'), t('Test invalid - (11) 0555.1234'));
|
||||
$this->assertFalse(valid_phone_number('br', '(11) 5555 abcd'), t('Test invalid - (11) 5555 abcd'));
|
||||
}
|
||||
|
||||
public function testPhoneBRFormatting() {
|
||||
$this->assertEqual(format_br_phone_number('+55 11 2222-3333', null), '+55 (11) 222-333', t('Brazil - +55 (11) 222-333'));
|
||||
}
|
||||
}
|
32
sites/all/modules/contrib/form/phone/tests/phone.ca.test
Normal file
32
sites/all/modules/contrib/form/phone/tests/phone.ca.test
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
class CAPhoneNumberTestCase extends DrupalWebTestCase {
|
||||
/**
|
||||
* Implementation of getInfo()
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('Canada & US Phone number test'),
|
||||
'description' => t('Tests various valid and invalid Canada & US phone numbers for validity'),
|
||||
'group' => t('Phone')
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhoneCAValid() {
|
||||
$this->assertTrue(valid_phone_number('ca', '1-800-555-1212'), t('Test valid - 1-800-555-1212'));
|
||||
$this->assertTrue(valid_phone_number('ca', '800-555-1212'), t('Test valid - 800-555-1212'));
|
||||
$this->assertTrue(valid_phone_number('ca', '(201)223-4567'), t('Test valid - (201)223-4567'));
|
||||
$this->assertTrue(valid_phone_number('ca', '604 543 9245'), t('Test valid - British Columbia 604 543 9245'));
|
||||
|
||||
}
|
||||
|
||||
public function testPhoneCAInvalid() {
|
||||
//$this->assertFalse(valid_phone_number('ca', '021 3012 3456'), t('Test invalid '));
|
||||
}
|
||||
|
||||
public function testPhoneCAFormatting() {
|
||||
//$this->assertEqual(format_phone_number('ca', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
|
||||
|
||||
}
|
||||
}
|
30
sites/all/modules/contrib/form/phone/tests/phone.ch.test
Normal file
30
sites/all/modules/contrib/form/phone/tests/phone.ch.test
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
class CHPhoneNumberTestCase extends DrupalWebTestCase {
|
||||
/**
|
||||
* Implementation of getInfo()
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('Swiss Phone number test'),
|
||||
'description' => t('Tests various valid and invalid Swiss phone numbers for validity'),
|
||||
'group' => t('Phone')
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhoneCHValid() {
|
||||
//$this->assertTrue(valid_phone_number('ch', '04 476 0000'), t('Test valid'));
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function testPhoneCHInvalid() {
|
||||
//$this->assertFalse(valid_phone_number('ch', '021 3012 3456'), t('Test invalid'));
|
||||
|
||||
}
|
||||
|
||||
public function testPhoneCHFormatting() {
|
||||
//$this->assertEqual(format_phone_number('ch', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
|
||||
}
|
||||
}
|
29
sites/all/modules/contrib/form/phone/tests/phone.cl.test
Normal file
29
sites/all/modules/contrib/form/phone/tests/phone.cl.test
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
class CLPhoneNumberTestCase extends DrupalWebTestCase {
|
||||
/**
|
||||
* Implementation of getInfo()
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('Chili Phone number test'),
|
||||
'description' => t('Tests various valid and invalid Chili phone numbers for validity'),
|
||||
'group' => t('Phone')
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhoneCLValid() {
|
||||
$this->assertTrue(valid_phone_number('cl', '(041)245-9848'), t('Test valid'));
|
||||
$this->assertTrue(valid_phone_number('cl', '(063)421-232'), t('Test valid'));
|
||||
}
|
||||
|
||||
public function testPhoneCLInvalid() {
|
||||
$this->assertFalse(valid_phone_number('cl', '0412459848'), t('Test invalid '));
|
||||
$this->assertFalse(valid_phone_number('cl', '063421232'), t('Test invalid '));
|
||||
}
|
||||
|
||||
public function testPhoneCLFormatting() {
|
||||
//$this->assertEqual(format_phone_number('cl', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
|
||||
}
|
||||
}
|
36
sites/all/modules/contrib/form/phone/tests/phone.cn.test
Normal file
36
sites/all/modules/contrib/form/phone/tests/phone.cn.test
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
class CNPhoneNumberTestCase extends DrupalWebTestCase {
|
||||
/**
|
||||
* Implementation of getInfo()
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('China People\'s Republic Phone number test'),
|
||||
'description' => t('Tests various valid and invalid Chinese People\'s Republic phone numbers for validity'),
|
||||
'group' => t('Phone')
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhoneCNValid() {
|
||||
$this->assertTrue(valid_phone_number('cn', '86-755-83998006'), t('Test valid - 86-755-83998006'));
|
||||
$this->assertTrue(valid_phone_number('cn', '86-10-5851 6688'), t('Test valid - 86-10-5851 6688'));
|
||||
$this->assertTrue(valid_phone_number('cn', '86-10-6512 4940'), t('Test valid - 86-10-6512 4940'));
|
||||
$this->assertTrue(valid_phone_number('cn', '+86 21 6103 2200'), t('Test valid - +86 21 6103 2200'));
|
||||
$this->assertTrue(valid_phone_number('cn', '+86 10.85.32.83.23'), t('Test valid - +86 10.85.32.83.23'));
|
||||
$this->assertTrue(valid_phone_number('cn', '755-83998006'), t('Test valid - 755-83998006'));
|
||||
$this->assertTrue(valid_phone_number('cn', '+86-10-5851 6688'), t('Test valid - +86-10-5851 6688'));
|
||||
$this->assertTrue(valid_phone_number('cn', '10.85.32.83.23'), t('Test valid - 10.85.32.83.23'));
|
||||
$this->assertTrue(valid_phone_number('cn', '13900000000'), t('Test valid - 13900000000'));
|
||||
$this->assertTrue(valid_phone_number('cn', '10-5851 6688'), t('Test valid - 10-5851 6688'));
|
||||
}
|
||||
|
||||
public function testPhoneCNInvalid() {
|
||||
//$this->assertFalse(valid_phone_number('cn', '021 3012 3456'), t('Test invalid - 021 3012 3456'));
|
||||
}
|
||||
|
||||
public function testPhoneCNFormatting() {
|
||||
//$this->assertEqual(format_phone_number('cn', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
|
||||
}
|
||||
}
|
27
sites/all/modules/contrib/form/phone/tests/phone.cr.test
Normal file
27
sites/all/modules/contrib/form/phone/tests/phone.cr.test
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
class CRPhoneNumberTestCase extends DrupalWebTestCase {
|
||||
/**
|
||||
* Implementation of getInfo()
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('Costa Rica Phone number test'),
|
||||
'description' => t('Tests various valid and invalid Costa Rica phone numbers for validity'),
|
||||
'group' => t('Phone')
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhoneCRValid() {
|
||||
//$this->assertTrue(valid_phone_number('cr', '04 476 0000'), t('Test valid'));
|
||||
}
|
||||
|
||||
public function testPhoneCRInvalid() {
|
||||
//$this->assertFalse(valid_phone_number('cr', '021 3012 3456'), t('Test invalid '));
|
||||
}
|
||||
|
||||
public function testPhoneCRFormatting() {
|
||||
//$this->assertEqual(format_phone_number('cr', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
|
||||
}
|
||||
}
|
27
sites/all/modules/contrib/form/phone/tests/phone.cs.test
Normal file
27
sites/all/modules/contrib/form/phone/tests/phone.cs.test
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
class CSPhoneNumberTestCase extends DrupalWebTestCase {
|
||||
/**
|
||||
* Implementation of getInfo()
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('Czech Republic Phone number test'),
|
||||
'description' => t('Tests various valid and invalid Czech Republic phone numbers for validity'),
|
||||
'group' => t('Phone')
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhoneCSValid() {
|
||||
$this->assertTrue(valid_phone_number('cs', '+420 999 999 999'), t('Test valid - +420 999 999 999'));
|
||||
}
|
||||
|
||||
public function testPhoneCSInvalid() {
|
||||
//$this->assertFalse(valid_phone_number('cs', '021 3012 3456'), t('Test invalid - 021 3012 3456'));
|
||||
}
|
||||
|
||||
public function testPhoneCSFormatting() {
|
||||
//$this->assertEqual(format_phone_number('cs', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
|
||||
}
|
||||
}
|
27
sites/all/modules/contrib/form/phone/tests/phone.eg.test
Normal file
27
sites/all/modules/contrib/form/phone/tests/phone.eg.test
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
class EGPhoneNumberTestCase extends DrupalWebTestCase {
|
||||
/**
|
||||
* Implementation of getInfo()
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('Egypt Phone number test'),
|
||||
'description' => t('Tests various valid and invalid Egypt phone numbers for validity'),
|
||||
'group' => t('Phone')
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhoneEGValid() {
|
||||
//$this->assertTrue(valid_phone_number('eg', '04 476 0000'), t('Test valid'));
|
||||
}
|
||||
|
||||
public function testPhoneEGInvalid() {
|
||||
//$this->assertFalse(valid_phone_number('eg', '021 3012 3456'), t('Test invalid '));
|
||||
}
|
||||
|
||||
public function testPhoneEGFormatting() {
|
||||
//$this->assertEqual(format_phone_number('eg', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
|
||||
}
|
||||
}
|
32
sites/all/modules/contrib/form/phone/tests/phone.es.test
Normal file
32
sites/all/modules/contrib/form/phone/tests/phone.es.test
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
class ESPhoneNumberTestCase extends DrupalWebTestCase {
|
||||
/**
|
||||
* Implementation of getInfo()
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('Spain Phone number test'),
|
||||
'description' => t('Tests various valid and invalid Spain phone numbers for validity'),
|
||||
'group' => t('Phone')
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhoneESValid() {
|
||||
$this->assertTrue(valid_phone_number('es', '972367087'), t('Test valid - 972367087'));
|
||||
$this->assertTrue(valid_phone_number('es', '97-3770866'), t('Test valid - 97-3770866'));
|
||||
$this->assertTrue(valid_phone_number('es', '972-377086'), t('Test valid - 972-377086'));
|
||||
}
|
||||
|
||||
public function testPhoneESInvalid() {
|
||||
$this->assertFalse(valid_phone_number('es', '9988-989898'), t('Test invalid - 9988-989898'));
|
||||
$this->assertFalse(valid_phone_number('es', '989898988989'), t('Test invalid - 989898988989'));
|
||||
$this->assertFalse(valid_phone_number('es', '9 9898989898'), t('Test invalid - 9 9898989898'));
|
||||
}
|
||||
|
||||
public function testPhoneESFormatting() {
|
||||
//$this->assertEqual(format_phone_number('es', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
|
||||
}
|
||||
}
|
||||
|
115
sites/all/modules/contrib/form/phone/tests/phone.fr.test
Normal file
115
sites/all/modules/contrib/form/phone/tests/phone.fr.test
Normal file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
// Copyright 2009 Thierry GUEGAN http://www.arvoriad.com
|
||||
|
||||
/**
|
||||
/**
|
||||
* Unit tests for Phone module.
|
||||
*/
|
||||
class PhoneFrenchTest extends DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('France Phone number test'),
|
||||
'description' => t('Executes test suite for validating / formatting France phone number.'),
|
||||
'group' => t('Phone')
|
||||
);
|
||||
}
|
||||
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
include_once('./'. drupal_get_path('module', 'phone') .'/phone.fr.inc');
|
||||
}
|
||||
|
||||
|
||||
public function testPhoneFRValid() {
|
||||
// test cleaning phone number
|
||||
$this->assertTrue(valid_phone_number('fr', ' +33 123 45 - (67) 89'), "' +33 123 45 - (67) 89' should be valid");
|
||||
|
||||
$this->assertTrue(valid_phone_number('fr', '+33123456789'), "'+33123456789' should be valid");
|
||||
$this->assertTrue(valid_phone_number('fr', '0123456789'), "'0123456789' should be valid");
|
||||
|
||||
$this->assertTrue(valid_phone_number('fr', '+33223456789'), "'+33223456789' should be valid");
|
||||
$this->assertTrue(valid_phone_number('fr', '0223456789'), "'0223456789' should be valid");
|
||||
|
||||
$this->assertTrue(valid_phone_number('fr', '+33323456789'), "'+33323456789' should be valid");
|
||||
$this->assertTrue(valid_phone_number('fr', '0323456789'), "'0323456789' should be valid");
|
||||
|
||||
$this->assertTrue(valid_phone_number('fr', '+33423456789'), "'+33423456789' should be valid");
|
||||
$this->assertTrue(valid_phone_number('fr', '0423456789'), "'0423456789' should be valid");
|
||||
|
||||
$this->assertTrue(valid_phone_number('fr', '+33523456789'), "'+33523456789' should be valid");
|
||||
$this->assertTrue(valid_phone_number('fr', '0523456789'), "'0523456789' should be valid");
|
||||
|
||||
|
||||
// 06... mobile
|
||||
$this->assertTrue(valid_phone_number('fr', '+33623456789'), "'+33623456789' should be valid");
|
||||
$this->assertTrue(valid_phone_number('fr', '0623456789'), "'0623456789' should be valid");
|
||||
|
||||
// 085... virtual private network
|
||||
$this->assertTrue(valid_phone_number('fr', '+33853456789'), "'+33853456789' should be valid");
|
||||
$this->assertTrue(valid_phone_number('fr', '0853456789'), "'0853456789' should be valid");
|
||||
|
||||
// 087...
|
||||
// 870... 871... 872... 873... 874... 875... 877... 878... 879... assigned
|
||||
foreach (array('870', '871', '872', '873', '874', '875', '877', '878', '879') as $za) {
|
||||
$this->assertTrue(valid_phone_number('fr', '+33'. $za .'123456'), "'+33 $za 1234567' is be valid");
|
||||
$this->assertTrue(valid_phone_number('fr', '0'. $za .'123456'), "'0 $za 1234567' is be valid");
|
||||
}
|
||||
}
|
||||
|
||||
public function testPhoneFRInvalid() {
|
||||
|
||||
$this->assertFalse(valid_phone_number('fr', '+33 123456789a'), "'+33 123456789a' should not be valid because wrong char");
|
||||
$this->assertFalse(valid_phone_number('fr', '+33 1234567a89'), "'+33 1234567a89' should not be valid because wrong char");
|
||||
$this->assertFalse(valid_phone_number('fr', '0 123456789a'), "'0 123456789a' should not be valid because wrong char");
|
||||
$this->assertFalse(valid_phone_number('fr', '0 1234567a89'), "'0 1234567a89' should not be valid because wrong char");
|
||||
|
||||
$this->assertFalse(valid_phone_number('fr', '+33 1234567890'), "'+33 1234567890' should not be valid because too long");
|
||||
$this->assertFalse(valid_phone_number('fr', '+33 12345678'), "'+33 12345678' should not be valid because too short");
|
||||
$this->assertFalse(valid_phone_number('fr', '0 1234567890'), "'0 1234567890' should not be valid because too long");
|
||||
$this->assertFalse(valid_phone_number('fr', '0 12345678'), "'0 12345678' should not be valid because too short");
|
||||
|
||||
|
||||
|
||||
|
||||
// 07... not assigned
|
||||
$this->assertFalse(valid_phone_number('fr', '+33723456789'), "'+33723456789' is unassigned so should not be valid");
|
||||
$this->assertFalse(valid_phone_number('fr', '0723456789'), "'0723456789' is unassigned so should not be valid");
|
||||
|
||||
|
||||
|
||||
// except 0876... not assigned
|
||||
$this->assertFalse(valid_phone_number('fr', '+33876456789'), "'+33873456789' is unassigned so should not be valid");
|
||||
$this->assertFalse(valid_phone_number('fr', '0876456789'), "'0873456789' is unassigned so should not be valid");
|
||||
|
||||
// 80... 81... 82... 83... 84... 86... 88... 89... not assigned
|
||||
foreach (array('80', '81', '82', '83', '84', '86', '88', '89') as $za) {
|
||||
$this->assertFalse(valid_phone_number('fr', '+33'. $za .'1234567'), "'+33'. $za .'1234567' is unassigned so should not be valid");
|
||||
$this->assertFalse(valid_phone_number('fr', '0'. $za .'1234567'), "'0'. $za .'1234567' is unassigned so should not be valid");
|
||||
}
|
||||
|
||||
// 09... not assigned
|
||||
$this->assertFalse(valid_phone_number('fr', '+33923456789'), "'+33923456789' is unassigned so should not be valid");
|
||||
$this->assertFalse(valid_phone_number('fr', '0923456789'), "'0923456789' is unassigned so should not be valid");
|
||||
|
||||
// 00... not assigned
|
||||
$this->assertFalse(valid_phone_number('fr', '+33023456789'), "'+33023456789' is unassigned so should not be valid");
|
||||
$this->assertFalse(valid_phone_number('fr', '0023456789'), "'0023456789' is unassigned so should not be valid");
|
||||
}
|
||||
|
||||
public function testPhoneFRFormatting() {
|
||||
// test cleaning phone number
|
||||
|
||||
$this->assertEqual(format_fr_phone_number('+33 123456789a'), '+33 123456789a', "'+33 123456789a', not valid so just ouptut without formatting");
|
||||
$this->assertEqual(format_fr_phone_number('01234567a8'), '01234567a8', "'01234567a8', not valid so just ouptut without formatting");
|
||||
|
||||
$this->assertEqual(format_fr_phone_number('+33 123456789'), '0123456789', "international --> national");
|
||||
$this->assertEqual(format_fr_phone_number(' +33 123 45 - (67) 89'), '0123456789', "international --> national");
|
||||
|
||||
$add_country_code = array('phone_country_code'=> TRUE);
|
||||
$this->assertEqual(format_fr_phone_number('+33 123456789', $add_country_code), '+33 123456789', "international --> international");
|
||||
$this->assertEqual(format_fr_phone_number(' +33 123 45 - (67) 89', $add_country_code), '+33 123456789', "international --> international");
|
||||
}
|
||||
}
|
38
sites/all/modules/contrib/form/phone/tests/phone.hu.test
Normal file
38
sites/all/modules/contrib/form/phone/tests/phone.hu.test
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
class HUPhoneNumberTestCase extends DrupalWebTestCase {
|
||||
/**
|
||||
* Implementation of getInfo()
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('Hungary Phone number test'),
|
||||
'description' => t('Tests various valid and invalid Hungary phone numbers for validity'),
|
||||
'group' => t('Phone')
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhoneHUValid() {
|
||||
$this->assertTrue(valid_phone_number('hu', '+3611234567'), t('Test valid'));
|
||||
$this->assertTrue(valid_phone_number('hu', '+3676123456'), t('Test valid'));
|
||||
$this->assertTrue(valid_phone_number('hu', '+36301234567'), t('Test valid'));
|
||||
$this->assertTrue(valid_phone_number('hu', '+36 1 1234567'), t('Test valid'));
|
||||
$this->assertTrue(valid_phone_number('hu', '+36 76 123456'), t('Test valid'));
|
||||
$this->assertTrue(valid_phone_number('hu', '+36 30 1234567'), t('Test valid'));
|
||||
$this->assertTrue(valid_phone_number('hu', '+36(1)1234567'), t('Test valid'));
|
||||
$this->assertTrue(valid_phone_number('hu', '+36(76)123456'), t('Test valid'));
|
||||
$this->assertTrue(valid_phone_number('hu', '+36(30)1234567'), t('Test valid'));
|
||||
$this->assertTrue(valid_phone_number('hu', '1/123-4567'), t('Test valid'));
|
||||
$this->assertTrue(valid_phone_number('hu', '76/123-456'), t('Test valid'));
|
||||
$this->assertTrue(valid_phone_number('hu', '30/123-45-67'), t('Test valid'));
|
||||
}
|
||||
|
||||
public function testPhoneHUInvalid() {
|
||||
$this->assertFalse(valid_phone_number('hu', '+0011234567'), t('Test invalid'));
|
||||
}
|
||||
|
||||
public function testPhoneHUFormatting() {
|
||||
//$this->assertEqual(format_phone_number('hu', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
|
||||
}
|
||||
}
|
27
sites/all/modules/contrib/form/phone/tests/phone.il.test
Normal file
27
sites/all/modules/contrib/form/phone/tests/phone.il.test
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
class ILPhoneNumberTestCase extends DrupalWebTestCase {
|
||||
/**
|
||||
* Implementation of getInfo()
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('Israel Phone number test'),
|
||||
'description' => t('Tests various valid and invalid Israel phone numbers for validity'),
|
||||
'group' => t('Phone')
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhoneILValid() {
|
||||
$this->assertTrue(valid_phone_number('il', '1800 999 999'), '"1800 999 999" should be valid');
|
||||
}
|
||||
|
||||
public function testPhoneILInvalid() {
|
||||
//$this->assertFalse(valid_phone_number('il', '021 3012 3456'), t('Test invalid'));
|
||||
}
|
||||
|
||||
public function testPhoneILFormatting() {
|
||||
$this->assertEqual(format_phone_number('il', '1800 999 999', null), '1800 999 999', 'Formatting OK "1800 999 999" --> "1800 999 999"');
|
||||
}
|
||||
}
|
94
sites/all/modules/contrib/form/phone/tests/phone.int.test
Normal file
94
sites/all/modules/contrib/form/phone/tests/phone.int.test
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
//require_once drupal_get_path('module', 'phone') . 'includes/phone.int.inc';
|
||||
|
||||
class PhoneIntTest extends DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'International phone number test',
|
||||
'description' => 'Tests international phone number validation.',
|
||||
'group' => 'Phone',
|
||||
);
|
||||
}
|
||||
public function setUp() {
|
||||
// Enable the phone module.
|
||||
parent::setUp(array('phone'));
|
||||
}
|
||||
|
||||
private function assertConversion($input, $expect = TRUE, $field = array(), $expect_error = FALSE) {
|
||||
$error = FALSE;
|
||||
if (!isset($field['phone_int_max_length'])) {
|
||||
$field['phone_int_max_length'] = '15';
|
||||
}
|
||||
if (!isset($field['phone_default_country_code'])) {
|
||||
$field['phone_default_country_code'] = '1';
|
||||
}
|
||||
if ($expect === FALSE) {
|
||||
$this->assertFalse(valid_phone_number('int', $input, $field, $error));
|
||||
$this->assertIdentical($error, $expect_error);
|
||||
return;
|
||||
}
|
||||
elseif ($expect === TRUE) {
|
||||
$expect = $input;
|
||||
}
|
||||
$this->assertTrue(valid_phone_number('int', $input, $field, $error));
|
||||
$this->assertIdentical($error, FALSE);
|
||||
$result = format_phone_number('int', $input, $field);
|
||||
$this->assertIdentical($result, $expect);
|
||||
}
|
||||
|
||||
public function testBasic() {
|
||||
$this->assertConversion('+1 7329018493');
|
||||
}
|
||||
|
||||
public function testBasicWithThreeCountryCode() {
|
||||
$this->assertConversion('+672 565434');
|
||||
}
|
||||
|
||||
public function testBasicWithFourCountryCode() {
|
||||
$this->assertConversion('+6724 565434', FALSE, array(), array(
|
||||
'Invalid international phone number: Country code "+%cc" is too long; valid country codes are three digits or less.',
|
||||
array('%cc' => '6724')
|
||||
));
|
||||
}
|
||||
|
||||
public function testBasicWithSpaces() {
|
||||
$this->assertConversion('+1 732 901 8493');
|
||||
}
|
||||
|
||||
public function testBasicNormalizeOtherCharacters() {
|
||||
$this->assertConversion('+1 (732) 901-8493', '+1 732 901 8493');
|
||||
}
|
||||
|
||||
public function testRemoveNDD() {
|
||||
$this->assertConversion('+54 0435344', '+54 435344');
|
||||
}
|
||||
|
||||
public function testRemoveNonStandardNDD() {
|
||||
$this->assertConversion('+374 (8) 435344', '+374 435344');
|
||||
}
|
||||
|
||||
public function testAddCountryCode() {
|
||||
$this->assertConversion('732 343 2333', '+1 732 343 2333', array('phone_default_country_code' => '1'));
|
||||
}
|
||||
|
||||
public function testOverlongNumber() {
|
||||
$this->assertConversion('+123 456 789 012 3456', FALSE, array(),
|
||||
'Invalid international phone number: Phone number is too long; international phone numbers are limited to 15 digits.'
|
||||
);
|
||||
}
|
||||
|
||||
public function testOverlongNumberWithoutCountryCode() {
|
||||
$this->assertConversion('456 789 012 3456', FALSE, array('phone_default_country_code' => '123'),
|
||||
'Invalid international phone number: Phone number is too long; international phone numbers are limited to 15 digits.'
|
||||
);
|
||||
}
|
||||
|
||||
public function testLetters() {
|
||||
$this->assertConversion('+1 343 CALL US', FALSE, array(),
|
||||
'Invalid international phone number: Phone number contains invalid characters; only allowed characters are numbers and punctuation.'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
43
sites/all/modules/contrib/form/phone/tests/phone.it.test
Normal file
43
sites/all/modules/contrib/form/phone/tests/phone.it.test
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
class ITPhoneNumberTestCase extends DrupalWebTestCase {
|
||||
/**
|
||||
* Implementation of getInfo()
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('Italia Phone number test'),
|
||||
'description' => t('Tests various valid and invalid Italia phone numbers for validity'),
|
||||
'group' => t('Phone')
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhoneITValid() {
|
||||
$this->assertTrue(valid_phone_number('it', '06/2034567'), t('Test valid - 06/2034567'));
|
||||
$this->assertTrue(valid_phone_number('it', '+39 02/123456'), t('Test valid - +39 02/123456'));
|
||||
$this->assertTrue(valid_phone_number('it', '02-343536'), t('Test valid - 02-343536'));
|
||||
$this->assertTrue(valid_phone_number('it', '02/343536'), t('Test valid - 02/343536'));
|
||||
$this->assertTrue(valid_phone_number('it', '02 343536'), t('Test valid - 02 343536'));
|
||||
$this->assertTrue(valid_phone_number('it', '+393381234567'), t('Test valid - +393381234567'));
|
||||
$this->assertTrue(valid_phone_number('it', '+39 3381234567'), t('Test valid - +39 3381234567'));
|
||||
$this->assertTrue(valid_phone_number('it', '+39 338 1234567'), t('Test valid - +39 338 1234567'));
|
||||
$this->assertTrue(valid_phone_number('it', '+39 338-1234567'), t('Test valid - +39 338-1234567'));
|
||||
$this->assertTrue(valid_phone_number('it', '3381234567'), t('Test valid - 3381234567'));
|
||||
$this->assertTrue(valid_phone_number('it', '3381234567'), t('Test valid - 3381234567'));
|
||||
$this->assertTrue(valid_phone_number('it', '338 1234567'), t('Test valid - 338 1234567'));
|
||||
$this->assertTrue(valid_phone_number('it', '338-1234567'), t('Test valid - 338-1234567'));
|
||||
}
|
||||
|
||||
public function testPhoneITInvalid() {
|
||||
$this->assertFalse(valid_phone_number('it', '02a343536'), t('Test invalid - 02a343536'));
|
||||
$this->assertFalse(valid_phone_number('it', '02+343536'), t('Test invalid - 02+343536'));
|
||||
$this->assertFalse(valid_phone_number('it', '0039 338 1234567'), t('Test invalid - 0039 338 1234567'));
|
||||
$this->assertFalse(valid_phone_number('it', '(338)1234567'), t('Test invalid - (338)1234567'));
|
||||
}
|
||||
|
||||
public function testPhoneITFormatting() {
|
||||
//$this->assertEqual(format_phone_number('it', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
|
||||
}
|
||||
}
|
||||
|
27
sites/all/modules/contrib/form/phone/tests/phone.jo.test
Normal file
27
sites/all/modules/contrib/form/phone/tests/phone.jo.test
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
class JOPhoneNumberTestCase extends DrupalWebTestCase {
|
||||
/**
|
||||
* Implementation of getInfo()
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('Jordania Phone number test'),
|
||||
'description' => t('Tests various valid and invalid Jordania phone numbers for validity'),
|
||||
'group' => t('Phone')
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhoneJOValid() {
|
||||
//$this->assertTrue(valid_phone_number('jo', '04 476 0000'), t('Test valid'));
|
||||
}
|
||||
|
||||
public function testPhoneJOInvalid() {
|
||||
//$this->assertFalse(valid_phone_number('jo', '021 3012 3456'), t('Test invalid'));
|
||||
}
|
||||
|
||||
public function testPhoneJOFormatting() {
|
||||
//$this->assertEqual(format_phone_number('jo', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
|
||||
}
|
||||
}
|
27
sites/all/modules/contrib/form/phone/tests/phone.nl.test
Normal file
27
sites/all/modules/contrib/form/phone/tests/phone.nl.test
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
class NLPhoneNumberTestCase extends DrupalWebTestCase {
|
||||
/**
|
||||
* Implementation of getInfo()
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('Netherland Phone number test'),
|
||||
'description' => t('Tests various valid and invalid Netherland phone numbers for validity'),
|
||||
'group' => t('Phone')
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhoneNLValid() {
|
||||
//$this->assertTrue(valid_phone_number('nl', '04 476 0000'), t('Test valid'));
|
||||
}
|
||||
|
||||
public function testPhoneNLInvalid() {
|
||||
//$this->assertFalse(valid_phone_number('nl', '021 3012 3456'), t('Test invalid '));
|
||||
}
|
||||
|
||||
public function testPhoneNLFormatting() {
|
||||
//$this->assertEqual(format_phone_number('nl', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
|
||||
}
|
||||
}
|
68
sites/all/modules/contrib/form/phone/tests/phone.nz.test
Normal file
68
sites/all/modules/contrib/form/phone/tests/phone.nz.test
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
class NZPhoneNumberTestCase extends DrupalWebTestCase {
|
||||
/**
|
||||
* Implementation of getInfo()
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('New Zealand Phone number test'),
|
||||
'description' => t('Tests various valid and invalid New Zealand phone numbers for validity'),
|
||||
'group' => t('Phone')
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhoneNZValid() {
|
||||
$this->assertTrue(valid_phone_number('nz', '04 476 0000'), t('Test standard regional number 04 476 0000'));
|
||||
$this->assertTrue(valid_phone_number('nz', '+64 4 476 0000'), t('Test international variation of regional +64 4 476 0000'));
|
||||
$this->assertTrue(valid_phone_number('nz', '+6444760000'), t('Test international variation of regional +6444760000'));
|
||||
$this->assertTrue(valid_phone_number('nz', '+649302 0000'), t('Test slightly weird variation of international +649302 0000'));
|
||||
$this->assertTrue(valid_phone_number('nz', '(04) 476 0000'), t('Test bracketed regional (04) 476 0000'));
|
||||
$this->assertTrue(valid_phone_number('nz', '(04) 476-0000'), t('Test hyphenated regional (04) 476-0000'));
|
||||
$this->assertTrue(valid_phone_number('nz', '03 903-1234'), t('Test valid South Island regional 03 903-1234'));
|
||||
$this->assertTrue(valid_phone_number('nz', '021 123 456'), t('Test valid 8-digit Vodafone number 021 739 733'));
|
||||
$this->assertTrue(valid_phone_number('nz', '(021) 123 456'), t('Test bracketed 8-digit Vodafone number (021) 739 733'));
|
||||
$this->assertTrue(valid_phone_number('nz', '+6421123456'), t('Test international Vodafone +6421123456'));
|
||||
$this->assertTrue(valid_phone_number('nz', '021 0101 2345'), t('Test 10-digit valid Vodafone number 021 2102 2345'));
|
||||
$this->assertTrue(valid_phone_number('nz', '+642101012345'), t('Test international version 10-digit Vodafone +642121012345'));
|
||||
$this->assertTrue(valid_phone_number('nz', '027 680 1234'), t('Test valid 9-digit Telecom Mobile number'));
|
||||
$this->assertTrue(valid_phone_number('nz', '+64 27 680 1234'), t('Test valid international version of Telecom 9-digit +64 27 680 1234'));
|
||||
$this->assertTrue(valid_phone_number('nz', '0800 83 83 83'), t('Test valid 0800 83 83 83 Pizza Hut'));
|
||||
$this->assertTrue(valid_phone_number('nz', '0900 87687'), t('Test valid 0900 TROTS'));
|
||||
$this->assertTrue(valid_phone_number('nz', '026 123 4567'), t('Test valid Telecom pager 026 123 4567'));
|
||||
$this->assertTrue(valid_phone_number('nz', '022 123 4567'), t('Test valid NZ Comms mobile 022 123 4567'));
|
||||
$this->assertTrue(valid_phone_number('nz', '22 123 4567'), t('Test slightly naughty lack of STD NZ Comms 22 123 4567'));
|
||||
$this->assertTrue(valid_phone_number('nz', '020 123 4567'), t('Test valid Telecom Mobile Radio 020 123 4567'));
|
||||
$this->assertTrue(valid_phone_number('nz', '029 123 4567'), t('Test valid TelstraClear Mobile Radio 029 123 4567'));
|
||||
$this->assertTrue(valid_phone_number('nz', '+64 24 123 456'), t('Test valid Scott Base +64 24 123 456'));
|
||||
|
||||
}
|
||||
|
||||
public function testPhoneNZInvalid() {
|
||||
$this->assertFalse(valid_phone_number('nz', '021 3012 3456'), t('Test invalid 10-digit Vodafone number in wrong range 021 3012 3456'));
|
||||
$this->assertFalse(valid_phone_number('nz', '04 701 1234'), t('Test invalid Wellington regional number 04 701 1234'));
|
||||
$this->assertFalse(valid_phone_number('nz', '(06) 412 3456'), t('Test invalid Manawatu regional number (06) 412 3456'));
|
||||
$this->assertFalse(valid_phone_number('nz', '04 123 456'), t('Test too short Wellington regional number 04 123 456'));
|
||||
$this->assertFalse(valid_phone_number('nz', '[04] 123 4567'), t('Test invalid character Wellington regional [04] 123 4567'));
|
||||
$this->assertFalse(valid_phone_number('nz', '09 701 2345'), t('Test invalid Auckland regional 09 701 2345'));
|
||||
$this->assertFalse(valid_phone_number('nz', '028 123 4567'), t('Test invalid mobile range 028 123 4567'));
|
||||
$this->assertFalse(valid_phone_number('nz', '027 1234 5678'), t('Test invalid Telecom mobile length 027 1234 5678'));
|
||||
}
|
||||
|
||||
public function testPhoneNZFormatting() {
|
||||
$this->assertEqual(format_phone_number('nz', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
|
||||
$this->assertEqual(format_phone_number('nz', '021123456', null), '(021) 123 456', t('Check 6-digit domestic mobile format'));
|
||||
$this->assertEqual(format_phone_number('nz', '0211234567', null), '(021) 123 4567', t('Check 7-digit domestic mobile format'));
|
||||
$this->assertEqual(format_phone_number('nz', '+64211234567', null), '+64 21 123 4567', t('Check 7-digit international mobile format'));
|
||||
$this->assertEqual(format_phone_number('nz', '02101234567', null), '(021) 0123 4567', t('Check 8-digit domestic mobile format'));
|
||||
$this->assertEqual(format_phone_number('nz', '+642101234567', null), '+64 21 0123 4567', t('Check 8-digit international mobile format'));
|
||||
$this->assertEqual(format_phone_number('nz', '041234567', null), '(04) 123 4567', t('Check regional number format (domestic)'));
|
||||
$this->assertEqual(format_phone_number('nz', '+6441234567', null), '+64 4 123 4567', t('Check regional number format (international)'));
|
||||
$this->assertEqual(format_phone_number('nz', '041234567x1234', null), '(04) 123 4567 x1234', t('Check regional number format with extension (domestic)'));
|
||||
$this->assertEqual(format_phone_number('nz', '+6441234567x1234', null), '+64 4 123 4567 x1234', t('Check regional number format with extension (international)'));
|
||||
$this->assertEqual(format_phone_number('nz', '0800 83 83 83', null), '0800 838383', t('Check 0800 number formatting (6 digit)'));
|
||||
$this->assertEqual(format_phone_number('nz', '0800 123 4567', null), '0800 123 4567', t('Check 0800 number formatting (7 digit)'));
|
||||
$this->assertEqual(format_phone_number('nz', '0800 12345', null), '0800 12345', t('Check 0800 number formatting (5 digit)'));
|
||||
}
|
||||
}
|
63
sites/all/modules/contrib/form/phone/tests/phone.pa.test
Normal file
63
sites/all/modules/contrib/form/phone/tests/phone.pa.test
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
class PhonePanamanianTest extends DrupalWebTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('Panamanian phone'),
|
||||
'description' => t('Executes test suite for validating / formatting Panamanian phone number.'),
|
||||
'group' => t('Phone'),
|
||||
);
|
||||
}
|
||||
|
||||
function testValidatingPanamenianPhoneNumber() {
|
||||
$this->assertTrue(valid_phone_number('pa', '+507 260-4334'), '+507 260-4334 should be valid');
|
||||
$this->assertTrue(valid_phone_number('pa', '+507 2604334'), '+507 2604334 should be valid');
|
||||
$this->assertTrue(valid_phone_number('pa', '+507 260 4334'), '+507 260 4334 should be valid');
|
||||
$this->assertTrue(valid_phone_number('pa', '00507 2603133'), '00507 2603133 should be valid');
|
||||
$this->assertTrue(valid_phone_number('pa', '00507 260-3133'), '00507 260-3133 should be valid');
|
||||
$this->assertTrue(valid_phone_number('pa', '00507 260 4334'), '00507 260 4334 should be valid');
|
||||
$this->assertTrue(valid_phone_number('pa', '260 3133'), '260 3133 should be valid');
|
||||
$this->assertTrue(valid_phone_number('pa', '260-3133'), '260-3133 should be valid');
|
||||
$this->assertTrue(valid_phone_number('pa', '2603133'), '2603133 should be valid');
|
||||
|
||||
//Cellphones
|
||||
$this->assertTrue(valid_phone_number('pa', '+507 6545-4345'), '+507 6545-4345 should be valid');
|
||||
$this->assertTrue(valid_phone_number('pa', '+507 65454345'), '+507 65454345 should be valid');
|
||||
$this->assertTrue(valid_phone_number('pa', '+507 6545 4345'), '+507 6545 4345 should be valid');
|
||||
$this->assertTrue(valid_phone_number('pa', '00507 6545-4345'), '00507 6545-4345 should be valid');
|
||||
$this->assertTrue(valid_phone_number('pa', '00507 6545 4345'), '00507 6545 4345 should be valid');
|
||||
$this->assertTrue(valid_phone_number('pa', '00507 65454345'), '00507 65454345 should be valid');
|
||||
$this->assertTrue(valid_phone_number('pa', '6545-4345'), '6545-4345 should be valid');
|
||||
$this->assertTrue(valid_phone_number('pa', '6545 4345'), '6545 4345 should be valid');
|
||||
$this->assertTrue(valid_phone_number('pa', '65454345'), '65454345 should be valid');
|
||||
|
||||
//Invalid
|
||||
$this->assertFalse(valid_phone_number('pa', '35343'), '35343 should not be valid');
|
||||
$this->assertFalse(valid_phone_number('pa', '320-43'), '320-43 should not be valid');
|
||||
$this->assertTrue(valid_phone_number('pa', '(507) 435-3434'), '(507) 435-3434 should not be valid');
|
||||
}
|
||||
|
||||
function testFormattingPanamenianPhoneNumber() {
|
||||
$this->assertEqual(format_phone_number('pa', '+507 260-4334'), '+507 260-4334', '+507 260-4334 format');
|
||||
$this->assertEqual(format_phone_number('pa', '+507 2604334'), '+507 260-4334', '+507 2604334 format');
|
||||
$this->assertEqual(format_phone_number('pa', '+507 260 4334'), '+507 260-4334', '+507 260 4334 format');
|
||||
$this->assertEqual(format_phone_number('pa', '00507 260-4334'), '+507 260-4334', '00507 260-4334 format');
|
||||
$this->assertEqual(format_phone_number('pa', '00507 2604334'), '+507 260-4334', '00507 2604334 format');
|
||||
$this->assertEqual(format_phone_number('pa', '00507 260 4334'), '+507 260-4334', '00507 260 4334 format');
|
||||
$this->assertEqual(format_phone_number('pa', '260-4334'), '260-4334', '260-4334 format');
|
||||
$this->assertEqual(format_phone_number('pa', '2604334'), '260-4334', '2604334 format');
|
||||
$this->assertEqual(format_phone_number('pa', '260 4334'), '260-4334', '260 4334 format');
|
||||
|
||||
$this->assertEqual(format_phone_number('pa', '260 4334', array('phone_country_code' => 1)), '+507 260-4334', 'add +507 to 260 4334 format');
|
||||
|
||||
//Cellphones
|
||||
$this->assertEqual(format_phone_number('pa', '00507 6464 4334'), '+507 6464-4334', '6464 4334 format');
|
||||
$this->assertEqual(format_phone_number('pa', '00507 6464-4334'), '+507 6464-4334', '00507 6464-4334 format');
|
||||
$this->assertEqual(format_phone_number('pa', '00507 64644334'), '+507 6464-4334', '00507 64644334 format');
|
||||
$this->assertEqual(format_phone_number('pa', '+507 6464 4334'), '+507 6464-4334', '+507 6464 4334 format');
|
||||
$this->assertEqual(format_phone_number('pa', '6464 4334'), '6464-4334', '6464 4334 format');
|
||||
$this->assertEqual(format_phone_number('pa', '64644334'), '6464-4334', '6464-4334 format');
|
||||
$this->assertEqual(format_phone_number('pa', '6464 4334', array('phone_country_code' => 1)), '+507 6464-4334', 'add +507 to 6464 4334 format');
|
||||
}
|
||||
}
|
27
sites/all/modules/contrib/form/phone/tests/phone.ph.test
Normal file
27
sites/all/modules/contrib/form/phone/tests/phone.ph.test
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
class PHPhoneNumberTestCase extends DrupalWebTestCase {
|
||||
/**
|
||||
* Implementation of getInfo()
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('Philippine Phone number test'),
|
||||
'description' => t('Tests various valid and invalid Philippine phone numbers for validity'),
|
||||
'group' => t('Phone')
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhonePHValid() {
|
||||
//$this->assertTrue(valid_phone_number('ph', '04 476 0000'), t('Test standard regional number 04 476 0000'));
|
||||
}
|
||||
|
||||
public function testPhonePHInvalid() {
|
||||
//$this->assertFalse(valid_phone_number('ph', '021 3012 3456'), t('Test invalid 10-digit Vodafone number in wrong range 021 3012 3456'));
|
||||
}
|
||||
|
||||
public function testPhonePHFormatting() {
|
||||
//$this->assertEqual(format_phone_number('ph', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
|
||||
}
|
||||
}
|
31
sites/all/modules/contrib/form/phone/tests/phone.pk.test
Normal file
31
sites/all/modules/contrib/form/phone/tests/phone.pk.test
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
class PKPhoneNumberTestCase extends DrupalWebTestCase {
|
||||
/**
|
||||
* Implementation of getInfo()
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('Pakistan Phone number test'),
|
||||
'description' => t('Tests various valid and invalid Pakistan phone numbers for validity'),
|
||||
'group' => t('Phone')
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhonePKValid() {
|
||||
$this->assertTrue(valid_phone_number('pk', '+92 321 7469854'), t('Test valid'));
|
||||
$this->assertTrue(valid_phone_number('pk', '923217469857'), t('Test valid'));
|
||||
$this->assertTrue(valid_phone_number('pk', '041 2680226'), t('Test valid'));
|
||||
}
|
||||
|
||||
public function testPhonePKInvalid() {
|
||||
$this->assertFalse(valid_phone_number('pk', '00124566'), t('Test invalid'));
|
||||
$this->assertFalse(valid_phone_number('pk', '01 922 745689'), t('Test invalid'));
|
||||
$this->assertFalse(valid_phone_number('pk', '0000000000'), t('Test invalid'));
|
||||
}
|
||||
|
||||
public function testPhonePKFormatting() {
|
||||
//$this->assertEqual(format_phone_number('pk', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
|
||||
}
|
||||
}
|
32
sites/all/modules/contrib/form/phone/tests/phone.pl.test
Normal file
32
sites/all/modules/contrib/form/phone/tests/phone.pl.test
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
class PLPhoneNumberTestCase extends DrupalWebTestCase {
|
||||
/**
|
||||
* Implementation of getInfo()
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('Poland Phone number test'),
|
||||
'description' => t('Tests various valid and invalid Poland phone numbers for validity'),
|
||||
'group' => t('Phone')
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhonePLValid() {
|
||||
$this->assertTrue(valid_phone_number('pl', '+48 500-080-100'), t('Test valid'));
|
||||
$this->assertTrue(valid_phone_number('pl', '500080100'), t('Test valid'));
|
||||
$this->assertTrue(valid_phone_number('pl', '500 080 100'), t('Test valid'));
|
||||
}
|
||||
|
||||
public function testPhonePLInvalid() {
|
||||
$this->assertFalse(valid_phone_number('pl', '+47 100-100-100'), t('Test invalid '));
|
||||
$this->assertFalse(valid_phone_number('pl', '1000-100-100'), t('Test invalid '));
|
||||
$this->assertFalse(valid_phone_number('pl', '1000000000'), t('Test invalid '));
|
||||
}
|
||||
|
||||
public function testPhonePLFormatting() {
|
||||
//$this->assertEqual(format_phone_number('pl', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
|
||||
|
||||
}
|
||||
}
|
33
sites/all/modules/contrib/form/phone/tests/phone.ru.test
Normal file
33
sites/all/modules/contrib/form/phone/tests/phone.ru.test
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
class RUPhoneNumberTestCase extends DrupalWebTestCase {
|
||||
/**
|
||||
* Implementation of getInfo()
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('Russia Phone number test'),
|
||||
'description' => t('Tests various valid and invalid Russia phone numbers for validity'),
|
||||
'group' => t('Phone')
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhoneRUValid() {
|
||||
$this->assertTrue(valid_phone_number('ru', '+7(916)9985670'), t('Test valid'));
|
||||
$this->assertTrue(valid_phone_number('ru', '8-912-268-5440'), t('Test valid'));
|
||||
$this->assertTrue(valid_phone_number('ru', '8905148-3339'), t('Test valid'));
|
||||
$this->assertTrue(valid_phone_number('ru', '8(913)448-51-90'), t('Test valid'));
|
||||
$this->assertTrue(valid_phone_number('ru', '903-345-34-34'), t('Test valid'));
|
||||
$this->assertTrue(valid_phone_number('ru', '903-34-334-34'), t('Test valid'));
|
||||
$this->assertTrue(valid_phone_number('ru', '903-34-33434'), t('Test valid '));
|
||||
}
|
||||
|
||||
public function testPhoneRUInvalid() {
|
||||
$this->assertFalse(valid_phone_number('ru', '+33903-34-33434'), t('Test invalid '));
|
||||
}
|
||||
|
||||
public function testPhoneRUFormatting() {
|
||||
//$this->assertEqual(format_phone_number('ru', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
|
||||
}
|
||||
}
|
43
sites/all/modules/contrib/form/phone/tests/phone.se.test
Normal file
43
sites/all/modules/contrib/form/phone/tests/phone.se.test
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
class SEPhoneNumberTestCase extends DrupalWebTestCase {
|
||||
/**
|
||||
* Implementation of getInfo()
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('Sweden Phone number test'),
|
||||
'description' => t('Tests various valid and invalid Sweden phone numbers for validity'),
|
||||
'group' => t('Phone')
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhoneSEValid() {
|
||||
$this->assertTrue(valid_phone_number('se', '+46 8 123 456 78'), t('Test valid'));
|
||||
$this->assertTrue(valid_phone_number('se', '08-123 456 78'), t('Test valid'));
|
||||
$this->assertTrue(valid_phone_number('se', '0123-456 78'), t('Test valid'));
|
||||
$this->assertTrue(valid_phone_number('se', '031-3224562'), t('Test valid'));
|
||||
$this->assertTrue(valid_phone_number('se', '0737234264'), t('Test valid'));
|
||||
$this->assertTrue(valid_phone_number('se', '073-5647829'), t('Test valid'));
|
||||
$this->assertTrue(valid_phone_number('se', '19740609-7845'), t('Test valid'));
|
||||
$this->assertTrue(valid_phone_number('se', '19811116-7845'), t('Test valid'));
|
||||
$this->assertTrue(valid_phone_number('se', '20010913-7598'), t('Test valid'));
|
||||
}
|
||||
|
||||
public function testPhoneSEInvalid() {
|
||||
$this->assertFalse(valid_phone_number('se', '46 08-123 456 78'), t('Test invalid'));
|
||||
$this->assertFalse(valid_phone_number('se', '08 123 456 78'), t('Test invalid '));
|
||||
$this->assertFalse(valid_phone_number('se', '0123 456 78'), t('Test invalid '));
|
||||
$this->assertFalse(valid_phone_number('se', '34348abc'), t('Test invalid'));
|
||||
$this->assertFalse(valid_phone_number('se', '452643242343432432435643623432'), t('Test invalid '));
|
||||
$this->assertFalse(valid_phone_number('se', '532'), t('Test invalid '));
|
||||
$this->assertFalse(valid_phone_number('se', '21003612-9999'), t('Test invalid '));
|
||||
$this->assertFalse(valid_phone_number('se', '18790505-45458'), t('Test invalid '));
|
||||
$this->assertFalse(valid_phone_number('se', '19740641-5559'), t('Test invalid '));
|
||||
}
|
||||
|
||||
public function testPhoneSEFormatting() {
|
||||
//$this->assertEqual(format_phone_number('se', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
|
||||
}
|
||||
}
|
40
sites/all/modules/contrib/form/phone/tests/phone.sg.test
Normal file
40
sites/all/modules/contrib/form/phone/tests/phone.sg.test
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
class SGPhoneNumberTestCase extends DrupalWebTestCase {
|
||||
/**
|
||||
* Implementation of getInfo()
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('Singapore Phone number test'),
|
||||
'description' => t('Tests various valid and invalid Singapore phone numbers for validity'),
|
||||
'group' => t('Phone')
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhoneSGValid() {
|
||||
$this->assertTrue(valid_phone_number('sg', '61234567'), "'61234567' should be valid");
|
||||
$this->assertTrue(valid_phone_number('sg', '63829324'), "'63829324' should be valid");
|
||||
$this->assertTrue(valid_phone_number('sg', '67654321'), "'67654321' should be valid");
|
||||
$this->assertTrue(valid_phone_number('sg', '+6561234567'), "'+6561234567' should be valid");
|
||||
$this->assertTrue(valid_phone_number('sg', '+6581234567'), "'+6581234567' should be valid");
|
||||
$this->assertTrue(valid_phone_number('sg', '+6591234567'), "'+6591234567' should be valid");
|
||||
$this->assertTrue(valid_phone_number('sg', '+65 61234567'), "'+65 61234567' should be valid");
|
||||
$this->assertTrue(valid_phone_number('sg', '+65 81234567'), "'+65 81234567' should be valid");
|
||||
$this->assertTrue(valid_phone_number('sg', '+65 91234567'), "'+65 91234567' should be valid");
|
||||
$this->assertTrue(valid_phone_number('sg', '61234567'), "'61234567' should be valid");
|
||||
$this->assertTrue(valid_phone_number('sg', '81234567'), "'81234567' should be valid");
|
||||
$this->assertTrue(valid_phone_number('sg', '91234567'), "'91234567' should be valid");
|
||||
}
|
||||
|
||||
public function testPhoneSGInvalid() {
|
||||
$this->assertFalse(valid_phone_number('sg', '6123-4567'), t('Test invalid '));
|
||||
$this->assertFalse(valid_phone_number('sg', '6-CALL-CPY'), t('Test invalid '));
|
||||
$this->assertFalse(valid_phone_number('sg', '6123abcd'), t('Test invalid '));
|
||||
}
|
||||
|
||||
public function testPhoneSGFormatting() {
|
||||
//$this->assertEqual(format_phone_number('sg', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
|
||||
}
|
||||
}
|
43
sites/all/modules/contrib/form/phone/tests/phone.ua.test
Normal file
43
sites/all/modules/contrib/form/phone/tests/phone.ua.test
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
class UAPhoneNumberTestCase extends DrupalWebTestCase {
|
||||
/**
|
||||
* Implementation of getInfo()
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('Ukraine Phone number test'),
|
||||
'description' => t('Tests various valid and invalid Ukraine phone numbers for validity'),
|
||||
'group' => t('Phone')
|
||||
);
|
||||
}
|
||||
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function testPhoneUAValid() {
|
||||
$this->assertTrue(valid_phone_number('ua', '+38-044-283-93-57'), t('Kyiv landline test'));
|
||||
$this->assertTrue(valid_phone_number('ua', '(044)2839357'), t('Kyiv landline test'));
|
||||
$this->assertTrue(valid_phone_number('ua', '+380442839357'), t('Kyiv landline test'));
|
||||
$this->assertTrue(valid_phone_number('ua', '+38 (044)537-28-07'), t('Kyiv landline test'));
|
||||
$this->assertTrue(valid_phone_number('ua', '044 537-28-07'), t('Kyiv landline test'));
|
||||
$this->assertTrue(valid_phone_number('ua', '+38 032 2724042 '), t('Lviv landline test'));
|
||||
$this->assertTrue(valid_phone_number('ua', '+380623621047'), t('Yasinovata landline test'));
|
||||
}
|
||||
|
||||
public function testPhoneUAInvalid() {
|
||||
$this->assertFalse(valid_phone_number('ua', '+380117777777'), t('Test with noexist citycode 011'));
|
||||
$this->assertFalse(valid_phone_number('ua', '+380711234567'), t('Test with noexist citycode 071'));
|
||||
$this->assertFalse(valid_phone_number('ua', '+38044123456'), t('Test with short phone'));
|
||||
$this->assertFalse(valid_phone_number('ua', '044123456'), t('Test with short phone'));
|
||||
$this->assertFalse(valid_phone_number('ua', '+3804412345678'), t('Test with long phone'));
|
||||
$this->assertFalse(valid_phone_number('ua', '04412345678'), t('Test with long phone'));
|
||||
$this->assertFalse(valid_phone_number('ua', '8044223-95-26'), t('Test with obsolete leading 8 notation'));
|
||||
}
|
||||
|
||||
public function testPhoneUAFormatting() {
|
||||
//$this->assertEqual(format_phone_number('ua', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
|
||||
}
|
||||
}
|
41
sites/all/modules/contrib/form/phone/tests/phone.uk.test
Normal file
41
sites/all/modules/contrib/form/phone/tests/phone.uk.test
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
class UKPhoneNumberTestCase extends DrupalWebTestCase {
|
||||
/**
|
||||
* Implementation of getInfo()
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('UK Phone number test'),
|
||||
'description' => t('Tests various valid and invalid UK phone numbers for validity'),
|
||||
'group' => t('Phone')
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhoneUKValid() {
|
||||
$this->assertTrue(valid_phone_number('uk', '01905 23819'), t('Test valid - 01905 23819'));
|
||||
$this->assertTrue(valid_phone_number('uk', '01222 555 555'), t('Test valid - 01222 555 555'));
|
||||
$this->assertTrue(valid_phone_number('uk', '(010) 55555555 #2222'), t('Test valid - (010) 55555555 #2222'));
|
||||
$this->assertTrue(valid_phone_number('uk', '0122 555 5555#222'), t('Test valid - 0122 555 5555#222'));
|
||||
$this->assertTrue(valid_phone_number('uk', '+441970123456'), t('Test valid - +441970123456'));
|
||||
$this->assertTrue(valid_phone_number('uk', '+44(0)1970123456'), t('Test valid - +44(0)1970123456'));
|
||||
$this->assertTrue(valid_phone_number('uk', '+44 1970 123 4562'), t('Test valid - +44 1970 123 456'));
|
||||
$this->assertTrue(valid_phone_number('uk', '+44 (0)1970 123 456'), t('Test valid - +44 (0)1970 123 456'));
|
||||
$this->assertTrue(valid_phone_number('uk', '(01970) 123456 #0001'), t('Test valid - (01970) 123456 #0001'));
|
||||
}
|
||||
|
||||
public function testPhoneUKInvalid() {
|
||||
$this->assertFalse(valid_phone_number('uk', '01222 555 5555'), t('Test invalid - 01222 555 5555'));
|
||||
$this->assertFalse(valid_phone_number('uk', '(010) 55555555 #22'), t('Test invalid - (010) 55555555 #22'));
|
||||
$this->assertFalse(valid_phone_number('uk', '0122 5555 5555#222'), t('Test invalid - 0122 5555 5555#222'));
|
||||
$this->assertFalse(valid_phone_number('uk', '(+441970)123456'), t('Test invalid - (+441970)123456'));
|
||||
$this->assertFalse(valid_phone_number('uk', '+44(1970)123456'), t('Test invalid - +44(1970)123456'));
|
||||
$this->assertFalse(valid_phone_number('uk', '+44 01970 123 456'), t('Test invalid - +44 01970 123 456'));
|
||||
$this->assertFalse(valid_phone_number('uk', '(0197) 0123456 #01'), t('Test invalid - (0197) 0123456 #01'));
|
||||
}
|
||||
|
||||
public function testPhoneUKFormatting() {
|
||||
//$this->assertEqual(format_phone_number('uk', '+6421123456', null), '+64 21 123 456', t('Check international mobile format'));
|
||||
}
|
||||
}
|
46
sites/all/modules/contrib/form/phone/tests/phone.za.test
Normal file
46
sites/all/modules/contrib/form/phone/tests/phone.za.test
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
class ZAPhoneNumberTestCase extends DrupalWebTestCase {
|
||||
/**
|
||||
* Implementation of getInfo()
|
||||
*
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => t('South Africa Phone number test'),
|
||||
'description' => t('Tests various valid and invalid South African phone numbers for validity'),
|
||||
'group' => t('Phone')
|
||||
);
|
||||
}
|
||||
|
||||
public function testPhoneZAValid() {
|
||||
$this->assertTrue(valid_phone_number('za', '+27 11 888-8888'), t('Test valid - +27 11 888-8888'));
|
||||
$this->assertTrue(valid_phone_number('za', '0333872119'), t('Test valid - 0333872119'));
|
||||
$this->assertTrue(valid_phone_number('za', '074 101 2850'), t('Test valid - 074 101 2850'));
|
||||
$this->assertTrue(valid_phone_number('za', '27723376484'), t('Test valid - 27723376484'));
|
||||
$this->assertTrue(valid_phone_number('za', '0723376484'), t('Test valid - 0723376484'));
|
||||
$this->assertTrue(valid_phone_number('za', '0111231234'), t('Test valid - 0111231234'));
|
||||
$this->assertTrue(valid_phone_number('za', '011 123 1234'), t('Test valid - 011 123 1234'));
|
||||
$this->assertTrue(valid_phone_number('za', '011-123-1234'), t('Test valid - 011-123-1234'));
|
||||
$this->assertTrue(valid_phone_number('za', '0821231234'), t('Test valid - 0821231234'));
|
||||
$this->assertTrue(valid_phone_number('za', '082 123 1234'), t('Test valid - 082 123 1234'));
|
||||
$this->assertTrue(valid_phone_number('za', '+27821231234'), t('Test valid - +27821231234'));
|
||||
$this->assertTrue(valid_phone_number('za', '+2782-123-1234'), t('Test valid - +2782-123-1234'));
|
||||
$this->assertTrue(valid_phone_number('za', '+2782 123 1234'), t('Test valid - +2782 123 1234'));
|
||||
$this->assertTrue(valid_phone_number('za', '27111231234'), t('Test valid - 27111231234'));
|
||||
$this->assertTrue(valid_phone_number('za', '2711 123 1234'), t('Test valid - 2711 123 1234'));
|
||||
$this->assertTrue(valid_phone_number('za', '082 123 1234'), t('Test valid - 082 123 1234'));
|
||||
}
|
||||
|
||||
public function testPhoneZAInvalid() {
|
||||
$this->assertFalse(valid_phone_number('za', '9723376484'), t('Test invalid - 9723376484'));
|
||||
$this->assertFalse(valid_phone_number('za', '26723376484'), t('Test invalid - 26723376484'));
|
||||
$this->assertFalse(valid_phone_number('za', '(011)1231234'), t('Test invalid - (011)1231234'));
|
||||
$this->assertFalse(valid_phone_number('za', '(+2711) 123 1234'), t('Test invalid - (+2711) 123 1234'));
|
||||
$this->assertFalse(valid_phone_number('za', '(011) 123-1234'), t('Test invalid - (011) 123-1234'));
|
||||
}
|
||||
|
||||
public function testPhoneZAFormatting() {
|
||||
$this->assertEqual(format_phone_number('za', '082 123 1234', null), '082 123 1234', 'Formatting OK "082 123 1234" --> "082 123 1234"');
|
||||
}
|
||||
}
|
5
sites/all/modules/contrib/form/phone/theme/phone.css
Normal file
5
sites/all/modules/contrib/form/phone/theme/phone.css
Normal file
@@ -0,0 +1,5 @@
|
||||
/* prevent input fields from being set to a percentage, such as 95% */
|
||||
div.form-item input.phone-field-textfield {
|
||||
width: auto;
|
||||
}
|
||||
|
Reference in New Issue
Block a user