FreenetIS
 All Classes Namespaces Functions Variables Pages
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
text Class Reference

Public Member Functions

 widont ($str)
 Prevents widow words by inserting a non-breaking space between the last two words.

Static Public Member Functions

static limit_words ($str, $limit=100, $end_char=NULL)
 Limits a phrase to a given number of words.
static limit_chars ($str, $limit=100, $end_char=NULL, $preserve_words=FALSE)
 Limits a phrase to a given number of characters.
static alternate ()
 Alternates between two or more strings.
static random ($type= 'alnum', $length=8)
 Generates a random string of a given type and length.
static reduce_slashes ($str)
 Reduces multiple slashes in a string to single slashes.
static censor ($str, $badwords, $replacement= '#', $replace_partial_words=FALSE)
 Replaces the given words with a string.
static bytes ($bytes, $force_unit=NULL, $format=NULL, $si=TRUE)
 Returns human readable sizes.
static cs_win2ascii ($s)
static cs_iso2ascii ($s)
static cs_utf2ascii ($s)
static phone_number ($number, $country_code)
 Prints phone number in pretty format.
static starts_with ($str, $start)
 Check if first string starts with second.
static ends_with ($str, $end)
 Check if first string ends with second.
static object_format ($object, $format)
 Pushes object properties into given format string.
static print_in_columns ($data, $columns)
 Prints data in columns seperated by tabulator.
static not_null ($item, $print=FALSE, $replace= '???', $extra_text= '')
 Handle printing of empty inputs.
static highligth ($what, $where)
 Highlight occurences of what in where by span with class highlighted.

Public Attributes

const TAB = "\t"
const EOL = "\n"

Member Function Documentation

static text::alternate ( )
static

Alternates between two or more strings.

Parameters
stringstrings to alternate between
Returns
string
static text::bytes (   $bytes,
  $force_unit = NULL,
  $format = NULL,
  $si = TRUE 
)
static

Returns human readable sizes.

See Also
Based on original functions written by:
Aidan Lister: http://aidanlister.com/repos/v/function.size_readable.php
Quentin Zervaas: http://www.phpriot.com/d/code/strings/filesize-format/
Parameters
integersize in bytes
stringa definitive unit
stringthe return string format
booleanwhether to use SI prefixes or IEC
Returns
string
static text::censor (   $str,
  $badwords,
  $replacement = '#',
  $replace_partial_words = FALSE 
)
static

Replaces the given words with a string.

Parameters
stringphrase to replace words in
arraywords to replace
stringreplacement string
booleanreplace words across word boundries (space, period, etc)
Returns
string
static text::ends_with (   $str,
  $end 
)
static

Check if first string ends with second.

Author
Ondřej Fibich
Parameters
string$strString
string$endEnd
Returns
bool true if first string ends with second
static text::highligth (   $what,
  $where 
)
static

Highlight occurences of what in where by span with class highlighted.

Parameters
string$whatWhat should be highlighted
string$whereWhere it should be highlighted
Returns
string String with hightligthed occurences of what
static text::limit_chars (   $str,
  $limit = 100,
  $end_char = NULL,
  $preserve_words = FALSE 
)
static

Limits a phrase to a given number of characters.

Parameters
stringphrase to limit characters of
integernumber of characters to limit to
stringend character or entity
booleanenable or disable the preservation of words while limiting
Returns
string
static text::limit_words (   $str,
  $limit = 100,
  $end_char = NULL 
)
static

Limits a phrase to a given number of words.

Parameters
stringphrase to limit words of
integernumber of words to limit to
stringend character or entity
Returns
string
static text::not_null (   $item,
  $print = FALSE,
  $replace = '???',
  $extra_text = '' 
)
static

Handle printing of empty inputs.

Author
Michal Kliment
Parameters
string$item
boolean$print
string$replace
string$extra_text
Returns
string
static text::object_format (   $object,
  $format 
)
static

Pushes object properties into given format string.

Author
Ondřej Fibich
Parameters
string$objectObject to push into format
string$formatFormat of ouput with tag in shape: {property}
Returns
string Result string
static text::phone_number (   $number,
  $country_code 
)
static

Prints phone number in pretty format.

Author
Michal Kliment
Parameters
string$number
string$country_code
Returns
string
static text::print_in_columns (   $data,
  $columns 
)
static

Prints data in columns seperated by tabulator.

Author
Michal Kliment
Parameters
array$data
array$columns
Returns
string
static text::random (   $type = 'alnum',
  $length = 8 
)
static

Generates a random string of a given type and length.

Parameters
stringa type of pool, or a string of characters to use as the pool
integerlength of string to return
Returns
string

unique - 40 character unique hash alnum - alpha-numeric characters alpha - alphabetical characters numeric - digit characters, 0-9 nozero - digit characters, 1-9

static text::reduce_slashes (   $str)
static

Reduces multiple slashes in a string to single slashes.

Parameters
stringstring to reduce slashes of
Returns
string
static text::starts_with (   $str,
  $start 
)
static

Check if first string starts with second.

Author
Ondřej Fibich
Parameters
string$strString
string$startStart
Returns
bool true if first string starts with second
text::widont (   $str)

Prevents widow words by inserting a non-breaking space between the last two words.

See Also
http://www.shauninman.com/archive/2006/08/22/widont_wordpress_plugin
Parameters
stringstring to remove widows from
Returns
string

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