Source for file Lang.php
Documentation is available at Lang.php
* Validates the HTML attribute lang, effectively a language code.
* @note Built according to RFC 3066, which obsoleted RFC 1766
public function validate($string, $config, $context) {
if (!$string) return false;
$num_subtags =
count($subtags);
if ($num_subtags ==
0) return false; // sanity check
// process primary subtag : $subtags[0]
$length =
strlen($subtags[0]);
if (! ($subtags[0] ==
'x' ||
$subtags[0] ==
'i') ) {
$new_string =
$subtags[0];
if ($num_subtags ==
1) return $new_string;
// process second subtag : $subtags[1]
$length =
strlen($subtags[1]);
if ($length ==
0 ||
($length ==
1 &&
$subtags[1] !=
'x') ||
$length >
8 ||
!ctype_alnum($subtags[1])) {
$new_string .=
'-' .
$subtags[1];
if ($num_subtags ==
2) return $new_string;
// process all other subtags, index 2 and up
for ($i =
2; $i <
$num_subtags; $i++
) {
$length =
strlen($subtags[$i]);
if ($length ==
0 ||
$length >
8 ||
!ctype_alnum($subtags[$i])) {
$new_string .=
'-' .
$subtags[$i];
Documentation generated on Thu, 19 Jun 2008 18:49:39 -0400 by phpDocumentor 1.4.2