本文整理汇总了PHP中PMA_Util::containsNonPrintableAscii方法的典型用法代码示例。如果您正苦于以下问题:PHP PMA_Util::containsNonPrintableAscii方法的具体用法?PHP PMA_Util::containsNonPrintableAscii怎么用?PHP PMA_Util::containsNonPrintableAscii使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PMA_Util
的用法示例。
在下文中一共展示了PMA_Util::containsNonPrintableAscii方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _displayBinaryAsPrintable
/**
* Display binary columns as hex string if requested
* otherwise escape the contents using the best possible way
*
* @param string $content String to parse
* @param string $binary_or_blob binary' or 'blob'
* @param int $hexlength optional, get substring
*
* @return String Displayable version of the binary string
*
* @access private
*
* @see _getDataCellForGeometryColumns
* _getDataCellForNonNumericAndNonBlobColumns
* _handleNonPrintableContents
*/
private function _displayBinaryAsPrintable($content, $binary_or_blob, $hexlength = null)
{
if ($binary_or_blob === 'binary' && $_SESSION['tmpval']['display_binary_as_hex']) {
$content = bin2hex($content);
if ($hexlength !== null) {
$content = $GLOBALS['PMA_String']->substr($content, $hexlength);
}
} elseif (PMA_Util::containsNonPrintableAscii($content)) {
if (PMA_PHP_INT_VERSION < 50400) {
$content = htmlspecialchars(PMA_Util::replaceBinaryContents($content));
} else {
// The ENT_SUBSTITUTE option is available for PHP >= 5.4.0
$content = htmlspecialchars(PMA_Util::replaceBinaryContents($content), ENT_SUBSTITUTE);
}
}
return $content;
}
示例2: testContainsNonPrintableAscii
/**
* Test for containsNonPrintableAscii
*
* @param string $str Value
* @param bool $res Expected value
*
* @return void
*
* @dataProvider dataProvider
*/
public function testContainsNonPrintableAscii($str, $res)
{
$this->assertEquals($res, PMA_Util::containsNonPrintableAscii($str));
}
示例3: _displayBinaryAsPrintable
/**
* Display binary fields as hex string for PHP <5.4,
* otherwise escape the contents if it may be displayed as hex
*
* @param string $content String to parse
* @param string $binary_or_blob 'binary' or 'blob'
* @param int $hexlength optional, get substring
*
* @return Displayable version of the binary string
*
* @access private
*
* @see _getDataCellForGeometryColumns
* _getDataCellForNonNumericAndNonBlobColumns
* _handleNonPrintableContents
*/
private function _displayBinaryAsPrintable($content, $binary_or_blob, $hexlength = null)
{
if (PMA_PHP_INT_VERSION < 50400 || $binary_or_blob === 'binary' && $_SESSION['tmp_user_values']['display_binary_as_hex'] && PMA_Util::containsNonPrintableAscii($content)) {
$content = bin2hex($content);
if ($hexlength !== null) {
$content = PMA_substr($content, $hexlength);
}
} else {
$content = htmlspecialchars(PMA_Util::replaceBinaryContents($content), ENT_SUBSTITUTE);
}
return $content;
}
示例4: _getDataCellForNonNumericAndNonBlobColumns
/**
* Get data cell for non numeric and non blob type fields
*
* @param string $column the relavent column in data row
* @param string $class the html class for column
* @param object $meta the meta-information about the field
* @param array $map the list of relations
* @param array $_url_params the parameters for generate url
* @param boolean $condition_field the column should highlighted
* or not
* @param string $transformation_plugin the name of transformation function
* @param string $default_function the default transformation function
* @param string $transform_options the transformation parameters
* @param boolean $is_field_truncated the condition for blob data
* replacements
* @param array $analyzed_sql the analyzed query
* @param integer &$dt_result the link id associated to the query
* which results have to be displayed
* @param integer $col_index the column index
*
* @return string $cell the prepared data cell, html content
*
* @access private
*
* @see _getTableBody()
*/
private function _getDataCellForNonNumericAndNonBlobColumns($column, $class, $meta, $map, $_url_params, $condition_field, $transformation_plugin, $default_function, $transform_options, $is_field_truncated, $analyzed_sql, &$dt_result, $col_index)
{
$is_analyse = $this->__get('_is_analyse');
$field_flags = PMA_DBI_field_flags($dt_result, $col_index);
if (stristr($field_flags, self::BINARY_FIELD) && ($GLOBALS['cfg']['ProtectBinary'] == 'all' || $GLOBALS['cfg']['ProtectBinary'] == 'noblob')) {
$class = str_replace('grid_edit', '', $class);
}
if (!isset($column) || is_null($column)) {
$cell = $this->_buildNullDisplay($class, $condition_field, $meta);
} elseif ($column != '') {
// Cut all fields to $GLOBALS['cfg']['LimitChars']
// (unless it's a link-type transformation)
if (PMA_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']) . '...';
$is_field_truncated = true;
}
$formatted = false;
if (isset($meta->_type) && $meta->_type === MYSQLI_TYPE_BIT) {
$column = PMA_Util::printableBitValue($column, $meta->length);
// some results of PROCEDURE ANALYSE() are reported as
// being BINARY but they are quite readable,
// so don't treat them as BINARY
} elseif (stristr($field_flags, self::BINARY_FIELD) && $meta->type == self::STRING_FIELD && !(isset($is_analyse) && $is_analyse)) {
if ($_SESSION['tmp_user_values']['display_binary']) {
// user asked to see the real contents of BINARY
// fields
if ($_SESSION['tmp_user_values']['display_binary_as_hex'] && PMA_Util::containsNonPrintableAscii($column)) {
$column = bin2hex($column);
} else {
$column = htmlspecialchars(PMA_Util::replaceBinaryContents($column));
}
} else {
// we show the BINARY message and field's size
// (or maybe use a transformation)
$column = $this->_handleNonPrintableContents(self::BINARY_FIELD, $column, $transformation_plugin, $transform_options, $default_function, $meta, $_url_params);
$formatted = true;
}
}
if ($formatted) {
$cell = $this->_buildValueDisplay($class, $condition_field, $column);
} else {
// transform functions may enable no-wrapping:
$function_nowrap = 'applyTransformationNoWrap';
$bool_nowrap = $default_function != $transformation_plugin && function_exists($transformation_plugin->{$function_nowrap}()) ? $transformation_plugin->{$function_nowrap}($transform_options) : false;
// do not wrap if date field type
$nowrap = preg_match('@DATE|TIME@i', $meta->type) || $bool_nowrap ? ' nowrap' : '';
$where_comparison = ' = \'' . PMA_Util::sqlAddSlashes($column) . '\'';
$cell = $this->_getRowData($class, $condition_field, $analyzed_sql, $meta, $map, $column, $transformation_plugin, $default_function, $nowrap, $where_comparison, $transform_options, $is_field_truncated);
}
} else {
$cell = $this->_buildEmptyDisplay($class, $condition_field, $meta);
}
return $cell;
}