Methods summary
public static
|
#
mbSanitize( mixed $text )
Removes invalid/corrupt multibyte sequences from text.
Removes invalid/corrupt multibyte sequences from text.
|
public static
type
|
#
typeCast( type $value, type $type )
Return a value cast after a named PHP type
Return a value cast after a named PHP type
Parameters
- $value
type $value
- $type
type $type
Returns
type
|
public static
|
#
convertLineBreaks( mixed $text, mixed $allowDouble = true, mixed $allowUnlimited = false )
Converts a record's Description or Background Info to deal with the
discrepancy between MySQL/PHP line breaks and HTML line breaks.
Converts a record's Description or Background Info to deal with the
discrepancy between MySQL/PHP line breaks and HTML line breaks.
|
public static
array
|
#
parseFormula( string $input, array $params = array() )
Parses a "formula" for the flow.
Parses a "formula" for the flow.
If the first character in a string value in X2Flow is the "=" character, it
will be treated as valid PHP code to be executed. This function uses getSafeWords to determine a list of functions which the user can execute in the
code, and strip any which are not allowed. This should generally be used for
mathematical operations, like calculating dynamic date offsets.
Parameters
- $input
string $input The code to be executed
- $params
array $params Optional extra parameters, notably the Model triggering the flow
Returns
array An array with the first element true or false corresponding to whether execution
succeeded, the second, the value returned by the formula.
|
protected static
|
#
getReplacementTokens( string $value, array $params, boolean $renderFlag, boolean $makeLinks )
Parses text for short codes and returns an associative array of them.
Parses text for short codes and returns an associative array of them.
Parameters
- $value
string $value The value to parse
- $params
X2Model
$model The model on which to operate with attribute replacement
- $renderFlag
boolean $renderFlag The render flag to pass to X2Model::getAttribute()
- $makeLinks
boolean $makeLinks If the render flag is set, determines whether to render attributes as
links
|
protected static
|
|
public static
|
#
restoreInsertableAttributes( string $text )
Restore any special characters necessary for insertableAttributes that may be
mangled by HTMLPurifier
Restore any special characters necessary for insertableAttributes that may be
mangled by HTMLPurifier
Parameters
|
public static
String
|
#
timestampAge( mixed $timestamp )
A function to convert a timestamp into a string stated how long ago an object
was created.
A function to convert a timestamp into a string stated how long ago an object
was created.
Parameters
- $timestamp
mixed $timestamp The time that the object was posted.
Returns
String How long ago the object was posted.
|
public static
|
#
formatLongDate( integer $timestamp )
Format a date to be long (September 25, 2011)
Format a date to be long (September 25, 2011)
Parameters
- $timestamp
integer $timestamp Unix time stamp
|
public static
|
|
public static
string
|
#
formatDatePicker( string $width = '' )
Format dates for the date picker.
Format dates for the date picker.
Parameters
- $width
string $width A length keyword, i.e. "medium"
Returns
string
|
public static
|
|
public static
|
#
formatTimeInterval( integer $start, integer $end, mixed $style = null )
Formats a time interval.
Parameters
- $start
integer $start Beginning of the interval
- $end
integer $duration Length of the interval
- $style
|
public static
string
|
#
formatTimePicker( string $width = '', mixed $seconds = false )
Formats time for the time picker.
Formats time for the time picker.
Parameters
- $width
string $width
- $seconds
Returns
string
|
public static
|
#
fullName( type $firstName, type $lastName )
Formats a full name according to the name format settigns
Formats a full name according to the name format settigns
Parameters
- $firstName
type $firstName
- $lastName
type $lastName
|
public static
array
|
#
fullNameSelect( type $firstNameCol, type $lastNameCol, type $as = false )
Generates a column clause using CONCAT based on the full name format as
defined in the general settings
Generates a column clause using CONCAT based on the full name format as
defined in the general settings
Parameters
- $firstNameCol
type $firstNameCol
- $lastNameCol
type $lastNameCol
- $as
type $as
Returns
array An array with the first element being the SQL, the second any parameters to
bind.
|
public static
|
#
formatAMPM( )
Check if am/pm is being used in this locale.
Check if am/pm is being used in this locale.
|
public static
|
|
public static
string
|
#
formatDateEndOfDay( integer $timestamp )
Returns a formatted string for the end of the day.
Returns a formatted string for the end of the day.
Parameters
- $timestamp
integer $timestamp
Returns
string
|
public static
string
|
#
truncateText( string $str, integer $length = 30, boolean $encode = false )
Cuts string short.
Parameters
- $str
string $str String to be truncated.
- $length
integer $length Maximum length of the string
- $encode
boolean $encode Encode HTML special characters if true
Returns
string
|
public static
type
|
#
deCamelCase( type $str )
Converts CamelCased words into first-letter-capitalized, spaced words.
Converts CamelCased words into first-letter-capitalized, spaced words.
Parameters
Returns
type
|
public static
string
|
#
formatDate( integer $date, string $width = 'long', mixed $informal = true )
Locale-dependent date string formatting.
Locale-dependent date string formatting.
Parameters
- $date
integer $date Timestamp
- $width
string $width A length keyword, i.e. "medium"
- $informal
Returns
string
|
public static
|
|
public static
|
#
formatDueDate( mixed $date, mixed $dateWidth = 'long', mixed $timeWidth = 'short' )
|
public static
|
|
public static
boolean
|
#
isToday( mixed $date )
Parameters
- $date
mixed $date timestamp
Returns
boolean
|
public static
|
|
public static
|
|
public static
string
|
#
formatLongDateTime( integer $timestamp )
Returns a formatted string for the date.
Returns a formatted string for the date.
Parameters
- $timestamp
integer $timestamp
Returns
string
|
public static
string
|
#
formatDateTime( type $timestamp )
Formats the date and time for a given timestamp.
Formats the date and time for a given timestamp.
Parameters
- $timestamp
type $timestamp
Returns
string
|
public static
|
#
getPlainAbbrMonthNames( )
Adjust abbreviated months for French locale: The trailing . is removed from
the month names in CDateTimeParser.parseMonth(), resulting in French DateTimes
failing to parse.
Adjust abbreviated months for French locale: The trailing . is removed from
the month names in CDateTimeParser.parseMonth(), resulting in French DateTimes
failing to parse.
|
public static
mixed
|
#
parseDate( string $date )
Obtain a Unix-style integer timestamp for a date format.
Obtain a Unix-style integer timestamp for a date format.
Parameters
Returns
mixed integer or false if parsing fails
|
public static
integer
|
#
parseDateTime( string $date, mixed $dateLength = 'medium', mixed $timeLength = 'short' )
Parses both date and time into a Unix-style integer timestamp.
Parses both date and time into a Unix-style integer timestamp.
Parameters
- $date
string $date
- $dateLength
- $timeLength
Returns
integer
|
public static
String
|
#
parseCurrency( String $str, Boolean $keepCents )
Convert currency to the proper format
Convert currency to the proper format
Parameters
- $str
String $str The currency string
- $keepCents
Boolean $keepCents Whether or not to keep the cents
Returns
String $str The modified currency string.
|
public static
String
|
#
parseEmail( String $str )
Returns the body of an email without any HTML markup.
Returns the body of an email without any HTML markup.
This function will strip out email header tags, opened email tags, and all
HTML markup present in an Email type action so that the Action link can be
properly displayed without looking terrible
Parameters
- $str
String $str Input string to be formatted
Returns
String The formatted string
|
public static
String
|
#
replaceVariables( String $value, X2Model $params, String $type = '', Array $renderFlag = true, boolean $makeLinks = true )
Replace variables in dynamic text blocks.
Replace variables in dynamic text blocks.
This function takes text with dynamic attributes such as {firstName} or
{company.symbol} or {time} and replaces them with appropriate values in the
text. It is possible to directly access attributes of the model, attributes of
related models to the model, or "short codes" which are fixed variables, so to
speak. That is the variable {time} corresponds to a defined piece of code which
returns the current time.
Parameters
- $value
String $value The text which should be searched for dynamic attributes.
- $params
X2Model
$model The model which attributes should be taken from
- $type
String $type Optional, the type of content we're expecting to get. This can determine
if we should render what comes back via the X2ActiveRecord::renderAttribute()
function or just display what we get as is.
- $renderFlag
Array $params Optional extra parameters which may include default values for the
attributes in question.
- $makeLinks
boolean $renderFlag (optional) If true, overrides use of $type parameter to determine if
attribute should be rendered
Returns
String A modified version of $value with attributes replaced.
|
public static
string
|
#
trimText( string $text, integer $limit = 150 )
If text is greater than limit, it gets truncated and suffixed with an
ellipsis
If text is greater than limit, it gets truncated and suffixed with an
ellipsis
Parameters
- $text
string $text
- $limit
integer $limit
Returns
string
|
public static
string
|
#
formatCurrency( float|integer $value )
Parameters
- $value
float|integer $value
Returns
string value formatted as currency using app-wide currency setting
|
public static
|
#
ucwordsSpecific( mixed $string, mixed $delimiters = '', mixed $encoding = NULL )
|
public static
|
|
public static
|
|