PHP Class PKPString, pkp-lib

显示文件 Open project: pkp/pkp-lib Class Usage Examples

Public Methods

Method Description
camelize ( $string, $type = CAMEL_CASE_HEAD_UP ) : string Transform "handler-class" to "HandlerClass" and "my-op" to "myOp".
concatTitleFields ( $fields ) : string Joins two title string fragments (in $fields) either with a space or a colon.
dateformatPHP2JQueryDatepicker ( $phpFormat ) : string Matches each symbol of PHP strftime format string to jQuery Datepicker widget date format.
diff ( $originalString, $editedString ) : array Calculate the differences between two strings and produce an array with three types of entries: added substrings, deleted substrings and unchanged substrings.
encode_mime_header ( $string ) : string
enumerateAlphabetically ( $steps ) : string Get a letter $steps places after 'A'
generateUUID ( ) : string Create a new UUID (version 4)
getHTMLEntities ( ) : string Return an associative array of named->numeric HTML entities Required to support HTML functions without objects in PHP4/PHP5 From php.net: function.get-html-translation-table.php
hasMBString ( ) : boolean Check if server has the mbstring library.
hasPCREUTF8 ( ) : boolean Check if server supports the PCRE_UTF8 modifier.
html2text ( $html ) : string Convert limited HTML into a string.
init ( ) : null Perform initialization required for the string wrapper library.
iterativeExplode ( $delimiters, $input ) : array Iterate over an array of delimiters and see whether it exists in the given input string. If so, then use it to explode the string into an array.
mime_content_type ( $filename, $suggestedExtension = '' ) : string
regexp_grep ( $pattern, $input ) : array
regexp_match ( $pattern, $subject ) : integer
regexp_match_all ( $pattern, $subject, &$matches ) : integer | boolean
regexp_match_get ( $pattern, $subject, &$matches ) : integer | boolean
regexp_quote ( $string, $delimiter = '/' ) : string
regexp_replace ( $pattern, $replacement, $subject, $limit ) : mixed
regexp_replace_callback ( $pattern, $callback, $subject, $limit ) : mixed
regexp_split ( $pattern, $subject, $limit ) : array
stripUnsafeHtml ( $input ) : string Strip unsafe HTML from the input text. Covers XSS attacks like scripts, onclick(.
strlen ( $string ) : integer
strpos ( $haystack, $needle, $offset ) : integer
strrpos ( $haystack, $needle ) : integer
strtolower ( $string ) : string
strtoupper ( $string ) : string
substr ( $string, $start, $length = false ) : string
substr_count ( $haystack, $needle ) : integer
substr_replace ( $string, $replacement, $start, $length = null ) : string
titleCase ( $title ) : string Convert a string to proper title case
trimPunctuation ( $string ) : string Trim punctuation from a string
ucfirst ( $string ) : string
uncamelize ( $string ) : string Transform "HandlerClass" to "handler-class" and "myOp" to "my-op".
utf8_bad_find ( $str ) : string Locates the first bad byte in a UTF-8 string returning it's byte index in the string
utf8_bad_replace ( $str, $replace = '?' ) : string Replace bad bytes with an alternative character - ASCII character
utf8_bad_strip ( $str ) : string Strips out any bad bytes from a UTF-8 string and returns the rest
utf8_compliant ( $str ) : boolean Tests whether a string complies as UTF-8; faster and less strict than utf8_is_valid see lib/phputf8/utils/validation.php for more details
utf8_is_valid ( $str ) : boolean Detect whether a string contains non-ascii multibyte sequences in the UTF-8 range
utf8_normalize ( $str ) : string Normalize a string in an unknown (non-UTF8) encoding into a valid UTF-8 sequence
utf8_strip_ascii_ctrl ( $str ) : string Replace bad bytes with an alternative character - ASCII character
utf8_to_ascii ( $str ) : string US-ASCII transliterations of Unicode text

Method Details

camelize() static public method

Transform "handler-class" to "HandlerClass" and "my-op" to "myOp".
static public camelize ( $string, $type = CAMEL_CASE_HEAD_UP ) : string
$string input string
$type which kind of camel case?
return string the string in camel case

concatTitleFields() static public method

Joins two title string fragments (in $fields) either with a space or a colon.
static public concatTitleFields ( $fields ) : string
$fields array
return string the joined string

dateformatPHP2JQueryDatepicker() public method

Matches each symbol of PHP strftime format string to jQuery Datepicker widget date format.
public dateformatPHP2JQueryDatepicker ( $phpFormat ) : string
$phpFormat string
return string

diff() static public method

The calculation is optimized to identify the common largest substring. The return value is an array of the following format: array( array( diff-type => substring ), array(...) ) whereby diff-type can be one of: -1 = deletion 0 = common substring 1 = addition
static public diff ( $originalString, $editedString ) : array
$originalString string
$editedString string
return array

encode_mime_header() static public method

See also: http://ca.php.net/manual/en/function.encode_mime_header.php
static public encode_mime_header ( $string ) : string
$string string Input MIME header to encode.
return string Encoded MIME header.

enumerateAlphabetically() static public method

Get a letter $steps places after 'A'
static public enumerateAlphabetically ( $steps ) : string
$steps int
return string Letter

generateUUID() public method

Create a new UUID (version 4)
public generateUUID ( ) : string
return string

getHTMLEntities() static public method

Return an associative array of named->numeric HTML entities Required to support HTML functions without objects in PHP4/PHP5 From php.net: function.get-html-translation-table.php
static public getHTMLEntities ( ) : string
return string

hasMBString() static public method

Currently requires PHP >= 4.3.0 (for mb_strtolower, mb_strtoupper, and mb_substr_count)
static public hasMBString ( ) : boolean
return boolean Returns true iff the server supports mbstring functions.

hasPCREUTF8() static public method

Check if server supports the PCRE_UTF8 modifier.
static public hasPCREUTF8 ( ) : boolean
return boolean True iff the server supports the PCRE_UTF8 modifier.

html2text() static public method

Convert limited HTML into a string.
static public html2text ( $html ) : string
$html string
return string

init() static public method

Perform initialization required for the string wrapper library.
static public init ( ) : null
return null

iterativeExplode() static public method

Iterate over an array of delimiters and see whether it exists in the given input string. If so, then use it to explode the string into an array.
static public iterativeExplode ( $delimiters, $input ) : array
$delimiters array
$input string
return array

mime_content_type() static public method

See also: http://ca.php.net/manual/en/function.mime_content_type.php
static public mime_content_type ( $filename, $suggestedExtension = '' ) : string
$filename string Filename to test.
$suggestedExtension string Suggested file extension (used for common misconfigurations)
return string Detected MIME type

regexp_grep() static public method

See also: http://ca.php.net/manual/en/function.regexp_grep.php
static public regexp_grep ( $pattern, $input ) : array
$pattern string Regular expression
$input string Input string
return array

regexp_match() static public method

See also: http://ca.php.net/manual/en/function.regexp_match.php
static public regexp_match ( $pattern, $subject ) : integer
$pattern string Regular expression
$subject string String to apply regular expression to
return integer

regexp_match_all() static public method

See also: http://ca.php.net/manual/en/function.regexp_match_all.php
static public regexp_match_all ( $pattern, $subject, &$matches ) : integer | boolean
$pattern string Regular expression
$subject string String to apply regular expression to
$matches array Reference to receive matches
return integer | boolean Returns number of full matches of given subject, or FALSE if an error occurred.

regexp_match_get() static public method

See also: http://ca.php.net/manual/en/function.regexp_match_get.php
static public regexp_match_get ( $pattern, $subject, &$matches ) : integer | boolean
$pattern string Regular expression
$subject string String to apply regular expression to
$matches array Reference to receive matches
return integer | boolean Returns 1 if the pattern matches given subject, 0 if it does not, or FALSE if an error occurred.

regexp_quote() static public method

See also: http://ca.php.net/manual/en/function.regexp_quote.php
static public regexp_quote ( $string, $delimiter = '/' ) : string
$string string String to quote
$delimiter string Delimiter for regular expression
return string Quoted equivalent of $string

regexp_replace() static public method

See also: http://ca.php.net/manual/en/function.regexp_replace.php
static public regexp_replace ( $pattern, $replacement, $subject, $limit ) : mixed
$pattern string Regular expression
$replacement string String to replace matches in $subject with
$subject string String to apply regular expression to
$limit int Number of replacements to perform, maximum, or -1 for no limit.
return mixed

regexp_replace_callback() static public method

See also: http://ca.php.net/manual/en/function.regexp_replace_callback.php
static public regexp_replace_callback ( $pattern, $callback, $subject, $limit ) : mixed
$pattern string Regular expression
$callback callback PHP callback to generate content to replace matches with
$subject string String to apply regular expression to
$limit int Number of replacements to perform, maximum, or -1 for no limit.
return mixed

regexp_split() static public method

See also: http://ca.php.net/manual/en/function.regexp_split.php
static public regexp_split ( $pattern, $subject, $limit ) : array
$pattern string Regular expression
$subject string String to apply regular expression to
$limit int Number of times to match; -1 for unlimited
return array Resulting string segments

stripUnsafeHtml() static public method

..) attributes, javascript: urls, and special characters.
static public stripUnsafeHtml ( $input ) : string
$input string input string
return string

strlen() static public method

See also: http://ca.php.net/manual/en/function.strlen.php
static public strlen ( $string ) : integer
$string string Input string
return integer String length

strpos() static public method

See also: http://ca.php.net/manual/en/function.strpos.php
static public strpos ( $haystack, $needle, $offset ) : integer
$haystack string Input haystack to search
$needle string Input needle to search for
$offset int Offset at which to begin searching
return integer Position of needle within haystack

strrpos() static public method

See also: http://ca.php.net/manual/en/function.strrpos.php
static public strrpos ( $haystack, $needle ) : integer
$haystack string Haystack to search
$needle string Needle to search haystack for
return integer String position of needle in haystack (starting from end of haystack)

strtolower() static public method

See also: http://ca.php.net/manual/en/function.strtolower.php
static public strtolower ( $string ) : string
$string string Input string
return string Lower case version of input string

strtoupper() static public method

See also: http://ca.php.net/manual/en/function.strtoupper.php
static public strtoupper ( $string ) : string
$string string Input string
return string Upper case version of input string

substr() static public method

See also: http://ca.php.net/manual/en/function.substr.php
static public substr ( $string, $start, $length = false ) : string
$string string Subject to extract substring from
$start int Position to start from
$length int Length to extract, or false for entire string from start position
return string Substring of $string

substr_count() static public method

See also: http://ca.php.net/manual/en/function.substr_count.php
static public substr_count ( $haystack, $needle ) : integer
$haystack string Input string to search
$needle string String to search within $haystack for
return integer Count of number of times $needle appeared in $haystack

substr_replace() static public method

See also: http://ca.php.net/manual/en/function.substr_replace.php
static public substr_replace ( $string, $replacement, $start, $length = null ) : string
$string string Source string to perform replacement upon
$replacement string Replacement to move into $string
$start int Start location for replacement
$length int Number of characters to replace in source string with $replacement
return string String resulting from replacement

titleCase() static public method

Convert a string to proper title case
static public titleCase ( $title ) : string
$title string
return string

trimPunctuation() static public method

Trim punctuation from a string
static public trimPunctuation ( $string ) : string
$string string input string
return string the trimmed string

ucfirst() static public method

See also: http://ca.php.net/manual/en/function.ucfirst.php
static public ucfirst ( $string ) : string
$string string Input string
return string ucfirst version of input string

uncamelize() static public method

Transform "HandlerClass" to "handler-class" and "myOp" to "my-op".
static public uncamelize ( $string ) : string
$string
return string

utf8_bad_find() static public method

Locates the first bad byte in a UTF-8 string returning it's byte index in the string
static public utf8_bad_find ( $str ) : string
$str string input string
return string

utf8_bad_replace() static public method

Replace bad bytes with an alternative character - ASCII character
static public utf8_bad_replace ( $str, $replace = '?' ) : string
$str string input string
$replace string optional
return string

utf8_bad_strip() static public method

Strips out any bad bytes from a UTF-8 string and returns the rest
static public utf8_bad_strip ( $str ) : string
$str string input string
return string

utf8_compliant() static public method

Tests whether a string complies as UTF-8; faster and less strict than utf8_is_valid see lib/phputf8/utils/validation.php for more details
static public utf8_compliant ( $str ) : boolean
$str string input string
return boolean

utf8_is_valid() static public method

Detect whether a string contains non-ascii multibyte sequences in the UTF-8 range
static public utf8_is_valid ( $str ) : boolean
$str string input string
return boolean

utf8_normalize() static public method

Normalize a string in an unknown (non-UTF8) encoding into a valid UTF-8 sequence
static public utf8_normalize ( $str ) : string
$str string input string
return string

utf8_strip_ascii_ctrl() static public method

Replace bad bytes with an alternative character - ASCII character
static public utf8_strip_ascii_ctrl ( $str ) : string
$str string input string
return string

utf8_to_ascii() static public method

US-ASCII transliterations of Unicode text
static public utf8_to_ascii ( $str ) : string
$str string input string
return string