Open Journal Systems  2.4.4
 All Classes Namespaces Functions Variables Groups Pages
String Class Reference

Public Member Functions

 camelize ($string, $type=CAMEL_CASE_HEAD_UP)
 
 code2utf ($num)
 
 diff ($originalString, $editedString)
 
 encode_mime_header ($string)
 
 enumerateAlphabetically ($steps)
 
 fputcsv (&$handle, $fields=array(), $delimiter= ',', $enclosure= '"')
 
 getHTMLEntities ()
 
 hasMBString ()
 
 hasPCREUTF8 ()
 
 html2text ($html)
 
 html2utf ($str)
 
 init ()
 
 iterativeExplode ($delimiters, $input)
 
 mail ($to, $subject, $message, $additional_headers= '', $additional_parameters= '')
 
 mime_content_type ($filename)
 
 regexp_grep ($pattern, $input)
 
 regexp_match ($pattern, $subject)
 
 regexp_match_all ($pattern, $subject, &$matches)
 
 regexp_match_get ($pattern, $subject, &$matches)
 
 regexp_quote ($string, $delimiter= '/')
 
 regexp_replace ($pattern, $replacement, $subject, $limit=-1)
 
 regexp_replace_callback ($pattern, $callback, $subject, $limit=-1)
 
 regexp_split ($pattern, $subject, $limit=-1)
 
 stripUnsafeHtml ($input)
 
 strlen ($string)
 
 strpos ($haystack, $needle, $offset=0)
 
 strrpos ($haystack, $needle)
 
 strtolower ($string)
 
 strtoupper ($string)
 
 substr ($string, $start, $length=false)
 
 substr_count ($haystack, $needle)
 
 substr_replace ($string, $replacement, $start, $length=null)
 
 titleCase ($title)
 
 trimPunctuation ($string)
 
 ucfirst ($string)
 
 uncamelize ($string)
 
 utf2html ($str)
 
 utf8_bad_find ($str)
 
 utf8_bad_replace ($str, $replace= '?')
 
 utf8_bad_strip ($str)
 
 utf8_compliant ($str)
 
 utf8_is_valid ($str)
 
 utf8_normalize ($str)
 
 utf8_strip_ascii_ctrl ($str)
 
 utf8_to_ascii ($str)
 

Detailed Description

String manipulation wrapper class.

Definition at line 56 of file String.inc.php.

Member Function Documentation

String::camelize (   $string,
  $type = CAMEL_CASE_HEAD_UP 
)

Transform "handler-class" to "HandlerClass" and "my-op" to "myOp".

Parameters
$stringinput string
$typewhich kind of camel case?
Returns
string the string in camel case

Definition at line 902 of file String.inc.php.

Referenced by MetadataProperty\getId(), PKPComponentRouter\getRequestedComponent(), and PKPComponentRouter\getRequestedOp().

String::code2utf (   $num)

Returns the UTF-8 string corresponding to the unicode value Does not require any multibyte PHP libraries (from php.net, courtesy - roman.nosp@m.s@vo.nosp@m.id.lv)

Parameters
$numint
Returns
string

Definition at line 633 of file String.inc.php.

String::diff (   $originalString,
  $editedString 
)

Calculate the differences between two strings and produce an array with three types of entries: added substrings, deleted substrings and unchanged substrings.

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

Parameters
$string1string
$string2string
Returns
array

Definition at line 959 of file String.inc.php.

Referenced by Nlm30CitationDemultiplexerFilter\_filterConfidenceScore(), CitationForm\fetch(), and StringTest\testDiff().

String::encode_mime_header (   $string)
String::enumerateAlphabetically (   $steps)

Get a letter $steps places after 'A'

Parameters
$stepsint

Definition at line 1087 of file String.inc.php.

Referenced by SectionEditorAction\emailEditorDecisionComment().

String::fputcsv ( $handle,
  $fields = array(),
  $delimiter = ',',
  $enclosure = '"' 
)

Wrapper around fputcsv for systems that may or may not support it (i.e. PHP before 5.1.0); see PHP documentation for fputcsv.

Definition at line 805 of file String.inc.php.

Referenced by CounterReportPlugin\_report(), and SubscriptionReportPlugin\display().

String::getHTMLEntities ( )

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

Returns
string

Definition at line 708 of file String.inc.php.

Referenced by XMLParser\parse().

String::hasMBString ( )

Check if server has the mbstring library. Currently requires PHP >= 4.3.0 (for mb_strtolower, mb_strtoupper, and mb_substr_count)

Returns
boolean

Definition at line 93 of file String.inc.php.

Referenced by InstallForm\display().

String::hasPCREUTF8 ( )

Check if server supports the PCRE_UTF8 modifier.

Returns
boolean

Definition at line 122 of file String.inc.php.

String::html2utf (   $str)

Convert numeric HTML entities in a string to UTF-8 encoded characters This is a native alternative to the buggy html_entity_decode() using UTF8

Parameters
$strstring input string
Returns
string

Definition at line 691 of file String.inc.php.

Referenced by SubscriptionReportPlugin\_html2text(), Core\cleanVar(), and Transcoder\trans().

String::init ( )

Perform initialization required for the string wrapper library.

Definition at line 60 of file String.inc.php.

String::iterativeExplode (   $delimiters,
  $input 
)

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.

Parameters
$delimitersarray
$inputstring
Returns
array

Definition at line 879 of file String.inc.php.

Referenced by PersonStringNlm30NameSchemaFilter\_parsePersonsString(), and ParaciteRawCitationNlm30CitationSchemaFilter\process().

String::mail (   $to,
  $subject,
  $message,
  $additional_headers = '',
  $additional_parameters = '' 
)
See Also
http://ca.php.net/manual/en/function.mail.php

Definition at line 292 of file String.inc.php.

Referenced by Mail\send().

String::regexp_grep (   $pattern,
  $input 
)
String::regexp_quote (   $string,
  $delimiter = '/' 
)
String::regexp_replace_callback (   $pattern,
  $callback,
  $subject,
  $limit = -1 
)
String::regexp_split (   $pattern,
  $subject,
  $limit = -1 
)
String::stripUnsafeHtml (   $input)

Strip unsafe HTML from the input text. Covers XSS attacks like scripts, onclick(...) attributes, javascript: urls, and special characters.

Parameters
$inputstring input string
Returns
string

Definition at line 410 of file String.inc.php.

Referenced by CommentHandler\setupTemplate().

String::strpos (   $haystack,
  $needle,
  $offset = 0 
)
String::strrpos (   $haystack,
  $needle 
)
String::substr_count (   $haystack,
  $needle 
)
String::substr_replace (   $string,
  $replacement,
  $start,
  $length = null 
)
String::titleCase (   $title)

Convert a string to proper title case

Parameters
$titlestring
Returns
string

Definition at line 854 of file String.inc.php.

Referenced by ParaciteRawCitationNlm30CitationSchemaFilter\process(), and StringTest\testTitleCase().

String::ucfirst (   $string)
String::uncamelize (   $string)

Transform "HandlerClass" to "handler-class" and "myOp" to "my-op".

Parameters
$string

Definition at line 922 of file String.inc.php.

Referenced by PKPComponentRouter\url().

String::utf2html (   $str)

Convert UTF-8 encoded characters in a string to escaped HTML entities This is a helper function for transcoding into HTML or XML for output

Parameters
$strstring input string
Returns
string

Definition at line 647 of file String.inc.php.

Referenced by ArticleXMLGalley\getHTMLContents().

String::utf8_bad_find (   $str)

Locates the first bad byte in a UTF-8 string returning it's byte index in the string

Parameters
$strstring input string
Returns
string

Definition at line 541 of file String.inc.php.

Referenced by XMLParser\parse().

String::utf8_bad_replace (   $str,
  $replace = '?' 
)

Replace bad bytes with an alternative character - ASCII character

Parameters
$strstring input string
$replacestring optional
Returns
string

Definition at line 562 of file String.inc.php.

String::utf8_bad_strip (   $str)

Strips out any bad bytes from a UTF-8 string and returns the rest

Parameters
$strstring input string
Returns
string

Definition at line 551 of file String.inc.php.

Referenced by Core\cleanVar(), and XMLParser\parse().

String::utf8_compliant (   $str)

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

Parameters
$strstring input string
Returns
boolean

Definition at line 531 of file String.inc.php.

Referenced by Citation\_cleanCitationString(), WebService\call(), XMLParser\parse(), and ParaciteRawCitationNlm30CitationSchemaFilter\process().

String::utf8_is_valid (   $str)

Detect whether a string contains non-ascii multibyte sequences in the UTF-8 range

Parameters
$strstring input string
Returns
boolean

Definition at line 520 of file String.inc.php.

Referenced by Core\cleanVar().

String::utf8_normalize (   $str)

Normalize a string in an unknown (non-UTF8) encoding into a valid UTF-8 sequence

Parameters
$strstring input string
Returns
string

Definition at line 582 of file String.inc.php.

Referenced by Citation\_cleanCitationString(), WebService\call(), Core\cleanVar(), XMLParser\parse(), and ParaciteRawCitationNlm30CitationSchemaFilter\process().

String::utf8_strip_ascii_ctrl (   $str)

Replace bad bytes with an alternative character - ASCII character

Parameters
$strstring input string
Returns
string

Definition at line 572 of file String.inc.php.

Referenced by Core\cleanVar(), and XMLParser\parse().

String::utf8_to_ascii (   $str)

US-ASCII transliterations of Unicode text

Parameters
$strstring input string
Returns
string

Definition at line 621 of file String.inc.php.

Referenced by ParaciteRawCitationNlm30CitationSchemaFilter\process().


The documentation for this class was generated from the following file: