Group native and mb string functions into classes
This commit is contained in:
parent
e475fa3f44
commit
2e542c4f95
@ -241,7 +241,7 @@ if (is_array($foreignData['disp_row'])) {
|
||||
|
||||
$val_ordered_current_row++;
|
||||
|
||||
if (PMA_strlen($val_ordered_current_val) <= $cfg['LimitChars']) {
|
||||
if ($GLOBALS['PMA_String']::strlen($val_ordered_current_val) <= $cfg['LimitChars']) {
|
||||
$val_ordered_current_val = htmlspecialchars(
|
||||
$val_ordered_current_val
|
||||
);
|
||||
@ -251,11 +251,11 @@ if (is_array($foreignData['disp_row'])) {
|
||||
$val_ordered_current_val
|
||||
);
|
||||
$val_ordered_current_val = htmlspecialchars(
|
||||
PMA_substr($val_ordered_current_val, 0, $cfg['LimitChars'])
|
||||
$GLOBALS['PMA_String']::substr($val_ordered_current_val, 0, $cfg['LimitChars'])
|
||||
. '...'
|
||||
);
|
||||
}
|
||||
if (PMA_strlen($key_ordered_current_val) <= $cfg['LimitChars']) {
|
||||
if ($GLOBALS['PMA_String']::strlen($key_ordered_current_val) <= $cfg['LimitChars']) {
|
||||
$key_ordered_current_val = htmlspecialchars(
|
||||
$key_ordered_current_val
|
||||
);
|
||||
@ -265,7 +265,7 @@ if (is_array($foreignData['disp_row'])) {
|
||||
$key_ordered_current_val
|
||||
);
|
||||
$key_ordered_current_val = htmlspecialchars(
|
||||
PMA_substr(
|
||||
$GLOBALS['PMA_String']::substr(
|
||||
$key_ordered_current_val, 0, $cfg['LimitChars']
|
||||
) . '...'
|
||||
);
|
||||
|
||||
@ -3657,11 +3657,11 @@ class PMA_DisplayResults
|
||||
|
||||
// if a transform function for blob is set, none of these
|
||||
// replacements will be made
|
||||
if ((PMA_strlen($column) > $GLOBALS['cfg']['LimitChars'])
|
||||
if (($GLOBALS['PMA_String']::strlen($column) > $GLOBALS['cfg']['LimitChars'])
|
||||
&& ($_SESSION['tmp_user_values']['display_text'] == self::DISPLAY_PARTIAL_TEXT)
|
||||
&& ! $this->_isNeedToSyntaxHighlight(strtolower($meta->name))
|
||||
) {
|
||||
$column = PMA_substr($column, 0, $GLOBALS['cfg']['LimitChars'])
|
||||
$column = $GLOBALS['PMA_String']::substr($column, 0, $GLOBALS['cfg']['LimitChars'])
|
||||
. '...';
|
||||
$is_field_truncated = true;
|
||||
}
|
||||
@ -3748,10 +3748,10 @@ class PMA_DisplayResults
|
||||
// Convert to WKT format
|
||||
$wktval = PMA_Util::asWKT($column);
|
||||
|
||||
if ((PMA_strlen($wktval) > $GLOBALS['cfg']['LimitChars'])
|
||||
if (($GLOBALS['PMA_String']::strlen($wktval) > $GLOBALS['cfg']['LimitChars'])
|
||||
&& ($_SESSION['tmp_user_values']['display_text'] == self::DISPLAY_PARTIAL_TEXT)
|
||||
) {
|
||||
$wktval = PMA_substr($wktval, 0, $GLOBALS['cfg']['LimitChars'])
|
||||
$wktval = $GLOBALS['PMA_String']::substr($wktval, 0, $GLOBALS['cfg']['LimitChars'])
|
||||
. '...';
|
||||
$is_field_truncated = true;
|
||||
}
|
||||
@ -3772,11 +3772,11 @@ class PMA_DisplayResults
|
||||
|
||||
$wkbval = $this->_displayBinaryAsPrintable($column, 'binary', 8);
|
||||
|
||||
if ((PMA_strlen($wkbval) > $GLOBALS['cfg']['LimitChars'])
|
||||
if (($GLOBALS['PMA_String']::strlen($wkbval) > $GLOBALS['cfg']['LimitChars'])
|
||||
&& ($_SESSION['tmp_user_values']['display_text'] == self::DISPLAY_PARTIAL_TEXT)
|
||||
) {
|
||||
$wkbval
|
||||
= PMA_substr($wkbval, 0, $GLOBALS['cfg']['LimitChars'])
|
||||
= $GLOBALS['PMA_String']::substr($wkbval, 0, $GLOBALS['cfg']['LimitChars'])
|
||||
. '...';
|
||||
$is_field_truncated = true;
|
||||
}
|
||||
@ -3859,12 +3859,12 @@ class PMA_DisplayResults
|
||||
|
||||
// Cut all fields to $GLOBALS['cfg']['LimitChars']
|
||||
// (unless it's a link-type transformation)
|
||||
if (PMA_strlen($column) > $GLOBALS['cfg']['LimitChars']
|
||||
if ($GLOBALS['PMA_String']::strlen($column) > $GLOBALS['cfg']['LimitChars']
|
||||
&& ($_SESSION['tmp_user_values']['display_text'] == self::DISPLAY_PARTIAL_TEXT)
|
||||
&& gettype($transformation_plugin) == "object"
|
||||
&& ! strpos($transformation_plugin->getName(), 'Link') === true
|
||||
) {
|
||||
$column = PMA_substr($column, 0, $GLOBALS['cfg']['LimitChars'])
|
||||
$column = $GLOBALS['PMA_String']::substr($column, 0, $GLOBALS['cfg']['LimitChars'])
|
||||
. '...';
|
||||
$is_field_truncated = true;
|
||||
}
|
||||
@ -6015,7 +6015,7 @@ class PMA_DisplayResults
|
||||
) {
|
||||
$content = bin2hex($content);
|
||||
if ($hexlength !== null) {
|
||||
$content = PMA_substr($content, $hexlength);
|
||||
$content = $GLOBALS['PMA_String']::substr($content, $hexlength);
|
||||
}
|
||||
} else {
|
||||
$content = htmlspecialchars(
|
||||
|
||||
@ -334,7 +334,7 @@ function PMA_getSqlQueryAndCreateDbBeforeCopy()
|
||||
'SHOW VARIABLES LIKE "lower_case_table_names"', 0, 1
|
||||
);
|
||||
if ($lower_case_table_names === '1') {
|
||||
$_REQUEST['newname'] = PMA_strtolower($_REQUEST['newname']);
|
||||
$_REQUEST['newname'] = $GLOBALS['PMA_String']::strtolower($_REQUEST['newname']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -64,9 +64,9 @@ abstract class SubstringTransformationsPlugin extends TransformationsPlugin
|
||||
|
||||
$newtext = '';
|
||||
if ($options[1] != 'all') {
|
||||
$newtext = PMA_substr($buffer, $options[0], $options[1]);
|
||||
$newtext = $GLOBALS['PMA_String']::substr($buffer, $options[0], $options[1]);
|
||||
} else {
|
||||
$newtext = PMA_substr($buffer, $options[0]);
|
||||
$newtext = $GLOBALS['PMA_String']::substr($buffer, $options[0]);
|
||||
}
|
||||
|
||||
$length = strlen($newtext);
|
||||
|
||||
@ -970,7 +970,7 @@ function PMA_buildForeignDropdown($foreign, $data, $mode)
|
||||
}
|
||||
|
||||
foreach ($foreign as $key => $value) {
|
||||
if (PMA_strlen($value) <= $GLOBALS['cfg']['LimitChars']) {
|
||||
if ($GLOBALS['PMA_String']::strlen($value) <= $GLOBALS['cfg']['LimitChars']) {
|
||||
$vtitle = '';
|
||||
$value = htmlspecialchars($value);
|
||||
} else {
|
||||
|
||||
@ -234,9 +234,9 @@ function PMA_getAllLogItemInfo($result, $dontlimitchars)
|
||||
$odd_row = true;
|
||||
while ($value = $GLOBALS['dbi']->fetchAssoc($result)) {
|
||||
if (! $dontlimitchars
|
||||
&& PMA_strlen($value['Info']) > $GLOBALS['cfg']['LimitChars']
|
||||
&& $GLOBALS['PMA_String']::strlen($value['Info']) > $GLOBALS['cfg']['LimitChars']
|
||||
) {
|
||||
$value['Info'] = PMA_substr(
|
||||
$value['Info'] = $GLOBALS['PMA_String']::substr(
|
||||
$value['Info'], 0, $GLOBALS['cfg']['LimitChars']
|
||||
) . '...';
|
||||
}
|
||||
|
||||
@ -229,7 +229,7 @@ function PMA_SQP_parse($sql)
|
||||
$sql = str_replace("\r\n", "\n", $sql);
|
||||
$sql = str_replace("\r", "\n", $sql);
|
||||
|
||||
$len = PMA_strlen($sql);
|
||||
$len = $GLOBALS['PMA_String']::strlen($sql);
|
||||
if ($len == 0) {
|
||||
return array();
|
||||
}
|
||||
@ -295,7 +295,7 @@ function PMA_SQP_parse($sql)
|
||||
$this_was_quote = false;
|
||||
|
||||
while ($count2 < $len) {
|
||||
$c = PMA_substr($sql, $count2, 1);
|
||||
$c = $GLOBALS['PMA_String']::substr($sql, $count2, 1);
|
||||
$count1 = $count2;
|
||||
|
||||
$previous_was_space = $this_was_space;
|
||||
@ -327,11 +327,11 @@ function PMA_SQP_parse($sql)
|
||||
// MySQL style #
|
||||
// C style /* */
|
||||
// ANSI style --
|
||||
$next_c = PMA_substr($sql, $count2 + 1, 1);
|
||||
$next_c = $GLOBALS['PMA_String']::substr($sql, $count2 + 1, 1);
|
||||
if (($c == '#')
|
||||
|| (($count2 + 1 < $len) && ($c == '/') && ($next_c == '*'))
|
||||
|| (($count2 + 2 == $len) && ($c == '-') && ($next_c == '-'))
|
||||
|| (($count2 + 2 < $len) && ($c == '-') && ($next_c == '-') && ((PMA_substr($sql, $count2 + 2, 1) <= ' ')))
|
||||
|| (($count2 + 2 < $len) && ($c == '-') && ($next_c == '-') && (($GLOBALS['PMA_String']::substr($sql, $count2 + 2, 1) <= ' ')))
|
||||
) {
|
||||
$count2++;
|
||||
$pos = 0;
|
||||
@ -341,24 +341,24 @@ function PMA_SQP_parse($sql)
|
||||
$type = 'mysql';
|
||||
case '-':
|
||||
$type = 'ansi';
|
||||
$pos = PMA_strpos($sql, "\n", $count2);
|
||||
$pos = $GLOBALS['PMA_String']::strpos($sql, "\n", $count2);
|
||||
break;
|
||||
case '/':
|
||||
$type = 'c';
|
||||
$pos = PMA_strpos($sql, '*/', $count2);
|
||||
$pos = $GLOBALS['PMA_String']::strpos($sql, '*/', $count2);
|
||||
$pos += 2;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
} // end switch
|
||||
$count2 = ($pos < $count2) ? $len : $pos;
|
||||
$str = PMA_substr($sql, $count1, $count2 - $count1);
|
||||
$str = $GLOBALS['PMA_String']::substr($sql, $count1, $count2 - $count1);
|
||||
PMA_SQP_arrayAdd($sql_array, 'comment_' . $type, $str, $arraysize);
|
||||
continue;
|
||||
} // end if
|
||||
|
||||
// Checks for something inside quotation marks
|
||||
if (PMA_strpos($quote_list, $c) !== false) {
|
||||
if ($GLOBALS['PMA_String']::strpos($quote_list, $c) !== false) {
|
||||
$startquotepos = $count2;
|
||||
$quotetype = $c;
|
||||
$count2++;
|
||||
@ -366,7 +366,7 @@ function PMA_SQP_parse($sql)
|
||||
$oldpos = 0;
|
||||
do {
|
||||
$oldpos = $pos;
|
||||
$pos = PMA_strpos(' ' . $sql, $quotetype, $oldpos + 1) - 1;
|
||||
$pos = $GLOBALS['PMA_String']::strpos(' ' . $sql, $quotetype, $oldpos + 1) - 1;
|
||||
// ($pos === false)
|
||||
if ($pos < 0) {
|
||||
if ($c == '`') {
|
||||
@ -381,7 +381,7 @@ function PMA_SQP_parse($sql)
|
||||
*
|
||||
* SELECT * FROM `table`
|
||||
*/
|
||||
$pos_quote_separator = PMA_strpos(
|
||||
$pos_quote_separator = $GLOBALS['PMA_String']::strpos(
|
||||
' ' . $sql, $GLOBALS['sql_delimiter'], $oldpos + 1
|
||||
) - 1;
|
||||
if ($pos_quote_separator < 0) {
|
||||
@ -391,8 +391,8 @@ function PMA_SQP_parse($sql)
|
||||
$pos = $len;
|
||||
} else {
|
||||
$len += 1;
|
||||
$sql = PMA_substr($sql, 0, $pos_quote_separator)
|
||||
. '`' . PMA_substr($sql, $pos_quote_separator);
|
||||
$sql = $GLOBALS['PMA_String']::substr($sql, 0, $pos_quote_separator)
|
||||
. '`' . $GLOBALS['PMA_String']::substr($sql, $pos_quote_separator);
|
||||
$sql_array['raw'] = $sql;
|
||||
$pos = $pos_quote_separator;
|
||||
}
|
||||
@ -427,8 +427,8 @@ function PMA_SQP_parse($sql)
|
||||
$pos ++;
|
||||
continue;
|
||||
} elseif (($pos + 1 < $len)
|
||||
&& (PMA_substr($sql, $pos, 1) == $quotetype)
|
||||
&& (PMA_substr($sql, $pos + 1, 1) == $quotetype)
|
||||
&& ($GLOBALS['PMA_String']::substr($sql, $pos, 1) == $quotetype)
|
||||
&& ($GLOBALS['PMA_String']::substr($sql, $pos + 1, 1) == $quotetype)
|
||||
) {
|
||||
$pos = $pos + 2;
|
||||
continue;
|
||||
@ -456,27 +456,27 @@ function PMA_SQP_parse($sql)
|
||||
default:
|
||||
break;
|
||||
} // end switch
|
||||
$data = PMA_substr($sql, $count1, $count2 - $count1);
|
||||
$data = $GLOBALS['PMA_String']::substr($sql, $count1, $count2 - $count1);
|
||||
PMA_SQP_arrayAdd($sql_array, $type, $data, $arraysize);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Checks for brackets
|
||||
if (PMA_strpos($bracket_list, $c) !== false) {
|
||||
if ($GLOBALS['PMA_String']::strpos($bracket_list, $c) !== false) {
|
||||
// All bracket tokens are only one item long
|
||||
$this_was_bracket = true;
|
||||
$count2++;
|
||||
$type_type = '';
|
||||
if (PMA_strpos('([{', $c) !== false) {
|
||||
if ($GLOBALS['PMA_String']::strpos('([{', $c) !== false) {
|
||||
$type_type = 'open';
|
||||
} else {
|
||||
$type_type = 'close';
|
||||
}
|
||||
|
||||
$type_style = '';
|
||||
if (PMA_strpos('()', $c) !== false) {
|
||||
if ($GLOBALS['PMA_String']::strpos('()', $c) !== false) {
|
||||
$type_style = 'round';
|
||||
} elseif (PMA_strpos('[]', $c) !== false) {
|
||||
} elseif ($GLOBALS['PMA_String']::strpos('[]', $c) !== false) {
|
||||
$type_style = 'square';
|
||||
} else {
|
||||
$type_style = 'curly';
|
||||
@ -492,7 +492,7 @@ function PMA_SQP_parse($sql)
|
||||
var_dump(PMA_STR_isSqlIdentifier($c, false));
|
||||
var_dump($c == '@');
|
||||
var_dump($c == '.');
|
||||
var_dump(PMA_STR_isDigit(PMA_substr($sql, $count2 + 1, 1)));
|
||||
var_dump(PMA_STR_isDigit($GLOBALS['PMA_String']::substr($sql, $count2 + 1, 1)));
|
||||
var_dump($previous_was_space);
|
||||
var_dump($previous_was_bracket);
|
||||
var_dump($previous_was_listsep);
|
||||
@ -503,11 +503,11 @@ function PMA_SQP_parse($sql)
|
||||
if (PMA_STR_isSqlIdentifier($c, false)
|
||||
|| $c == '@'
|
||||
|| ($c == '.'
|
||||
&& PMA_STR_isDigit(PMA_substr($sql, $count2 + 1, 1))
|
||||
&& PMA_STR_isDigit($GLOBALS['PMA_String']::substr($sql, $count2 + 1, 1))
|
||||
&& ($previous_was_space || $previous_was_bracket || $previous_was_listsep))
|
||||
) {
|
||||
/* DEBUG
|
||||
echo PMA_substr($sql, $count2);
|
||||
echo $GLOBALS['PMA_String']::substr($sql, $count2);
|
||||
echo '<hr />';
|
||||
*/
|
||||
|
||||
@ -530,7 +530,7 @@ function PMA_SQP_parse($sql)
|
||||
$is_digit
|
||||
&& $c == '0'
|
||||
&& $count2 < $len
|
||||
&& PMA_substr($sql, $count2, 1) == 'x'
|
||||
&& $GLOBALS['PMA_String']::substr($sql, $count2, 1) == 'x'
|
||||
);
|
||||
$is_float_digit = $c == '.';
|
||||
$is_float_digit_exponent = false;
|
||||
@ -560,8 +560,8 @@ function PMA_SQP_parse($sql)
|
||||
unset($pos);
|
||||
}
|
||||
|
||||
while (($count2 < $len) && PMA_STR_isSqlIdentifier(PMA_substr($sql, $count2, 1), ($is_sql_variable || $is_digit))) {
|
||||
$c2 = PMA_substr($sql, $count2, 1);
|
||||
while (($count2 < $len) && PMA_STR_isSqlIdentifier($GLOBALS['PMA_String']::substr($sql, $count2, 1), ($is_sql_variable || $is_digit))) {
|
||||
$c2 = $GLOBALS['PMA_String']::substr($sql, $count2, 1);
|
||||
if ($is_sql_variable && ($c2 == '.')) {
|
||||
$count2++;
|
||||
continue;
|
||||
@ -575,7 +575,7 @@ function PMA_SQP_parse($sql)
|
||||
$debugstr = __('Invalid Identifer')
|
||||
. ' @ ' . ($count1+1) . "\n"
|
||||
. 'STR: ' . htmlspecialchars(
|
||||
PMA_substr($sql, $count1, $count2 - $count1)
|
||||
$GLOBALS['PMA_String']::substr($sql, $count1, $count2 - $count1)
|
||||
);
|
||||
PMA_SQP_throwError($debugstr, $sql);
|
||||
return $sql_array;
|
||||
@ -604,7 +604,7 @@ function PMA_SQP_parse($sql)
|
||||
} // end while
|
||||
|
||||
$l = $count2 - $count1;
|
||||
$str = PMA_substr($sql, $count1, $l);
|
||||
$str = $GLOBALS['PMA_String']::substr($sql, $count1, $l);
|
||||
|
||||
$type = '';
|
||||
if ($is_digit || $is_float_digit || $is_hex_digit) {
|
||||
@ -629,15 +629,15 @@ function PMA_SQP_parse($sql)
|
||||
}
|
||||
|
||||
// Checks for punct
|
||||
if (PMA_strpos($allpunct_list, $c) !== false) {
|
||||
while (($count2 < $len) && PMA_strpos($allpunct_list, PMA_substr($sql, $count2, 1)) !== false) {
|
||||
if ($GLOBALS['PMA_String']::strpos($allpunct_list, $c) !== false) {
|
||||
while (($count2 < $len) && $GLOBALS['PMA_String']::strpos($allpunct_list, $GLOBALS['PMA_String']::substr($sql, $count2, 1)) !== false) {
|
||||
$count2++;
|
||||
}
|
||||
$l = $count2 - $count1;
|
||||
if ($l == 1) {
|
||||
$punct_data = $c;
|
||||
} else {
|
||||
$punct_data = PMA_substr($sql, $count1, $l);
|
||||
$punct_data = $GLOBALS['PMA_String']::substr($sql, $count1, $l);
|
||||
}
|
||||
|
||||
// Special case, sometimes, althought two characters are
|
||||
@ -678,12 +678,12 @@ function PMA_SQP_parse($sql)
|
||||
if (($first == ',') || ($first == ';') || ($first == '.') || ($first == '*')) {
|
||||
$count2 = $count1 + 1;
|
||||
$punct_data = $first;
|
||||
} elseif (($last2 == '/*') || (($last2 == '--') && ($count2 == $len || PMA_substr($sql, $count2, 1) <= ' '))) {
|
||||
} elseif (($last2 == '/*') || (($last2 == '--') && ($count2 == $len || $GLOBALS['PMA_String']::substr($sql, $count2, 1) <= ' '))) {
|
||||
$count2 -= 2;
|
||||
$punct_data = PMA_substr($sql, $count1, $count2 - $count1);
|
||||
$punct_data = $GLOBALS['PMA_String']::substr($sql, $count1, $count2 - $count1);
|
||||
} elseif (($last == '-') || ($last == '+') || ($last == '!')) {
|
||||
$count2--;
|
||||
$punct_data = PMA_substr($sql, $count1, $count2 - $count1);
|
||||
$punct_data = $GLOBALS['PMA_String']::substr($sql, $count1, $count2 - $count1);
|
||||
} elseif ($last != '~') {
|
||||
/**
|
||||
* @todo for negation operator, split in 2 tokens ?
|
||||
@ -706,7 +706,7 @@ function PMA_SQP_parse($sql)
|
||||
$count2++;
|
||||
|
||||
$debugstr = 'C1 C2 LEN: ' . $count1 . ' ' . $count2 . ' ' . $len . "\n"
|
||||
. 'STR: ' . PMA_substr($sql, $count1, $count2 - $count1) . "\n";
|
||||
. 'STR: ' . $GLOBALS['PMA_String']::substr($sql, $count1, $count2 - $count1) . "\n";
|
||||
PMA_SQP_bug($debugstr, $sql);
|
||||
return $sql_array;
|
||||
|
||||
@ -1809,10 +1809,10 @@ function PMA_SQP_analyze($arr)
|
||||
$seen_order_by = true;
|
||||
// Here we assume that the ORDER BY keywords took
|
||||
// exactly 8 characters.
|
||||
// We use PMA_substr() to be charset-safe; otherwise
|
||||
// We use $GLOBALS['PMA_String']::substr() to be charset-safe; otherwise
|
||||
// if the table name contains accents, the unsorted
|
||||
// query would be missing some characters.
|
||||
$unsorted_query = PMA_substr(
|
||||
$unsorted_query = $GLOBALS['PMA_String']::substr(
|
||||
$arr['raw'], 0, $arr[$i]['pos'] - 8
|
||||
);
|
||||
$in_order_by = true;
|
||||
|
||||
@ -22,8 +22,10 @@ if (! defined('PHPMYADMIN')) {
|
||||
if (@function_exists('mb_strlen')) {
|
||||
mb_internal_encoding('utf-8');
|
||||
include './libraries/string_mb.lib.php';
|
||||
$PMA_String = new PMA_MBString();
|
||||
} else {
|
||||
include './libraries/string_native.lib.php';
|
||||
$PMA_String = new PMA_NativeString();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -48,7 +50,7 @@ function PMA_STR_charIsEscaped($string, $pos, $start = 0)
|
||||
{
|
||||
$pos = max(intval($pos), 0);
|
||||
$start = max(intval($start), 0);
|
||||
$len = PMA_strlen($string);
|
||||
$len = $GLOBALS['PMA_String']::strlen($string);
|
||||
// Base case:
|
||||
// Check for string length or invalid input or special case of input
|
||||
// (pos == $start)
|
||||
@ -58,7 +60,7 @@ function PMA_STR_charIsEscaped($string, $pos, $start = 0)
|
||||
|
||||
$pos--;
|
||||
$escaped = false;
|
||||
while ($pos >= $start && PMA_substr($string, $pos, 1) == '\\') {
|
||||
while ($pos >= $start && $GLOBALS['PMA_String']::substr($string, $pos, 1) == '\\') {
|
||||
$escaped = !$escaped;
|
||||
$pos--;
|
||||
} // end while
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Specialized String Functions for phpMyAdmin
|
||||
* Specialized String Class for phpMyAdmin
|
||||
*
|
||||
* Defines a set of function callbacks that have a pure C version available if
|
||||
* the "ctype" extension is available, but otherwise have PHP versions to use
|
||||
@ -16,56 +16,57 @@ if (! defined('PHPMYADMIN')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns length of string depending on current charset.
|
||||
*
|
||||
* @param string $string string to count
|
||||
*
|
||||
* @return int string length
|
||||
*/
|
||||
function PMA_strlen($string)
|
||||
{
|
||||
return mb_strlen($string);
|
||||
}
|
||||
class PMA_MBString {
|
||||
/**
|
||||
* Returns length of string depending on current charset.
|
||||
*
|
||||
* @param string $string string to count
|
||||
*
|
||||
* @return int string length
|
||||
*/
|
||||
public static function strlen($string)
|
||||
{
|
||||
return mb_strlen($string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns substring from string, works depending on current charset.
|
||||
*
|
||||
* @param string $string string to count
|
||||
* @param int $start start of substring
|
||||
* @param int $length length of substring
|
||||
*
|
||||
* @return string the sub string
|
||||
*/
|
||||
function PMA_substr($string, $start, $length = 2147483647)
|
||||
{
|
||||
return mb_substr($string, $start, $length);
|
||||
}
|
||||
/**
|
||||
* Returns substring from string, works depending on current charset.
|
||||
*
|
||||
* @param string $string string to count
|
||||
* @param int $start start of substring
|
||||
* @param int $length length of substring
|
||||
*
|
||||
* @return string the sub string
|
||||
*/
|
||||
public static function substr($string, $start, $length = 2147483647)
|
||||
{
|
||||
return mb_substr($string, $start, $length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns postion of $needle in $haystack or false if not found
|
||||
*
|
||||
* @param string $haystack the string being checked
|
||||
* @param string $needle the string to find in haystack
|
||||
* @param int $offset the search offset
|
||||
*
|
||||
* @return integer position of $needle in $haystack or false
|
||||
*/
|
||||
function PMA_strpos($haystack, $needle, $offset = 0)
|
||||
{
|
||||
return mb_strpos($haystack, $needle, $offset);
|
||||
}
|
||||
/**
|
||||
* Returns postion of $needle in $haystack or false if not found
|
||||
*
|
||||
* @param string $haystack the string being checked
|
||||
* @param string $needle the string to find in haystack
|
||||
* @param int $offset the search offset
|
||||
*
|
||||
* @return integer position of $needle in $haystack or false
|
||||
*/
|
||||
public static function strpos($haystack, $needle, $offset = 0)
|
||||
{
|
||||
return mb_strpos($haystack, $needle, $offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a string lowercase
|
||||
*
|
||||
* @param string $string the string being lowercased
|
||||
*
|
||||
* @return string the lower case string
|
||||
*/
|
||||
function PMA_strtolower($string)
|
||||
{
|
||||
return mb_strtolower($string);
|
||||
/**
|
||||
* Make a string lowercase
|
||||
*
|
||||
* @param string $string the string being lowercased
|
||||
*
|
||||
* @return string the lower case string
|
||||
*/
|
||||
public static function strtolower($string)
|
||||
{
|
||||
return mb_strtolower($string);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Specialized String Functions for phpMyAdmin
|
||||
* Specialized String Class for phpMyAdmin
|
||||
*
|
||||
* Defines a set of function callbacks that have a pure C version available if
|
||||
* the "ctype" extension is available, but otherwise have PHP versions to use
|
||||
@ -16,56 +16,57 @@ if (! defined('PHPMYADMIN')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns length of string depending on current charset.
|
||||
*
|
||||
* @param string $string string to count
|
||||
*
|
||||
* @return int string length
|
||||
*/
|
||||
function PMA_strlen($string)
|
||||
{
|
||||
return strlen($string);
|
||||
}
|
||||
class PMA_NativeString {
|
||||
/**
|
||||
* Returns length of string depending on current charset.
|
||||
*
|
||||
* @param string $string string to count
|
||||
*
|
||||
* @return int string length
|
||||
*/
|
||||
public static function strlen($string)
|
||||
{
|
||||
return strlen($string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns substring from string, works depending on current charset.
|
||||
*
|
||||
* @param string $string string to count
|
||||
* @param int $start start of substring
|
||||
* @param int $length length of substring
|
||||
*
|
||||
* @return string the sub string
|
||||
*/
|
||||
function PMA_substr($string, $start, $length = 2147483647)
|
||||
{
|
||||
return substr($string, $start, $length);
|
||||
}
|
||||
/**
|
||||
* Returns substring from string, works depending on current charset.
|
||||
*
|
||||
* @param string $string string to count
|
||||
* @param int $start start of substring
|
||||
* @param int $length length of substring
|
||||
*
|
||||
* @return string the sub string
|
||||
*/
|
||||
public static function substr($string, $start, $length = 2147483647)
|
||||
{
|
||||
return substr($string, $start, $length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns postion of $needle in $haystack or false if not found
|
||||
*
|
||||
* @param string $haystack the string being checked
|
||||
* @param string $needle the string to find in haystack
|
||||
* @param int $offset the search offset
|
||||
*
|
||||
* @return integer position of $needle in $haystack or false
|
||||
*/
|
||||
function PMA_strpos($haystack, $needle, $offset = 0)
|
||||
{
|
||||
return strpos($haystack, $needle, $offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a string lowercase
|
||||
*
|
||||
* @param string $string the string being lowercased
|
||||
*
|
||||
* @return string the lower case string
|
||||
*/
|
||||
function PMA_strtolower($string)
|
||||
{
|
||||
return strtolower($string);
|
||||
}
|
||||
/**
|
||||
* Returns postion of $needle in $haystack or false if not found
|
||||
*
|
||||
* @param string $haystack the string being checked
|
||||
* @param string $needle the string to find in haystack
|
||||
* @param int $offset the search offset
|
||||
*
|
||||
* @return integer position of $needle in $haystack or false
|
||||
*/
|
||||
public static function strpos($haystack, $needle, $offset = 0)
|
||||
{
|
||||
return strpos($haystack, $needle, $offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a string lowercase
|
||||
*
|
||||
* @param string $string the string being lowercased
|
||||
*
|
||||
* @return string the lower case string
|
||||
*/
|
||||
public static function strtolower($string)
|
||||
{
|
||||
return strtolower($string);
|
||||
}
|
||||
};
|
||||
?>
|
||||
|
||||
@ -18,7 +18,7 @@ class PMA_STR_Sub_Test extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
$this->assertEquals(
|
||||
'čšě',
|
||||
PMA_substr('čšěčščěš', 0, 3)
|
||||
$GLOBALS['PMA_String']::substr('čšěčščěš', 0, 3)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user