PHP Class PKPString, pkp-lib

Afficher le fichier Open project: pkp/pkp-lib Class Usage Examples

Méthodes publiques

Méthode 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 méthode

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?
Résultat string the string in camel case

concatTitleFields() static public méthode

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

dateformatPHP2JQueryDatepicker() public méthode

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

diff() static public méthode

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
Résultat array

encode_mime_header() static public méthode

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.
Résultat string Encoded MIME header.

enumerateAlphabetically() static public méthode

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

generateUUID() public méthode

Create a new UUID (version 4)
public generateUUID ( ) : string
Résultat string

getHTMLEntities() static public méthode

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
Résultat string

hasMBString() static public méthode

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

hasPCREUTF8() static public méthode

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

html2text() static public méthode

Convert limited HTML into a string.
static public html2text ( $html ) : string
$html string
Résultat string

init() static public méthode

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

iterativeExplode() static public méthode

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
Résultat array

mime_content_type() static public méthode

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)
Résultat string Detected MIME type

regexp_grep() static public méthode

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
Résultat array

regexp_match() static public méthode

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
Résultat integer

regexp_match_all() static public méthode

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
Résultat integer | boolean Returns number of full matches of given subject, or FALSE if an error occurred.

regexp_match_get() static public méthode

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
Résultat 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 méthode

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
Résultat string Quoted equivalent of $string

regexp_replace() static public méthode

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.
Résultat mixed

regexp_replace_callback() static public méthode

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.
Résultat mixed

regexp_split() static public méthode

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
Résultat array Resulting string segments

stripUnsafeHtml() static public méthode

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

strlen() static public méthode

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

strpos() static public méthode

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
Résultat integer Position of needle within haystack

strrpos() static public méthode

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
Résultat integer String position of needle in haystack (starting from end of haystack)

strtolower() static public méthode

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

strtoupper() static public méthode

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

substr() static public méthode

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
Résultat string Substring of $string

substr_count() static public méthode

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
Résultat integer Count of number of times $needle appeared in $haystack

substr_replace() static public méthode

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
Résultat string String resulting from replacement

titleCase() static public méthode

Convert a string to proper title case
static public titleCase ( $title ) : string
$title string
Résultat string

trimPunctuation() static public méthode

Trim punctuation from a string
static public trimPunctuation ( $string ) : string
$string string input string
Résultat string the trimmed string

ucfirst() static public méthode

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

uncamelize() static public méthode

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

utf8_bad_find() static public méthode

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
Résultat string

utf8_bad_replace() static public méthode

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

utf8_bad_strip() static public méthode

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
Résultat string

utf8_compliant() static public méthode

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
Résultat boolean

utf8_is_valid() static public méthode

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
Résultat boolean

utf8_normalize() static public méthode

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
Résultat string

utf8_strip_ascii_ctrl() static public méthode

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

utf8_to_ascii() static public méthode

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