Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • None
  • system
    • base
    • caching
    • console
    • db
      • ar
      • schema
    • validators
    • web
      • actions
      • auth
      • helpers
      • widgets
        • captcha
        • pagers
  • zii
    • widgets
      • grid

Classes

  • AccountsGridViewProfileWidget
  • ActionMenu
  • ActionsGridViewProfileWidget
  • ActionsQuickCreateRelationshipBehavior
  • ActiveDateRangeInput
  • ApplicationConfigBehavior
  • Attachments
  • ChatBox
  • CommonControllerBehavior
  • ContactMapInlineTags
  • ContactsGridViewProfileWidget
  • CronForm
  • CSaveRelationsBehavior
  • DateRangeInputsWidget
  • DocsGridViewProfileWidget
  • DocViewer
  • DocViewerProfileWidget
  • EButtonColumnWithClearFilters
  • EmailDeliveryBehavior
  • EmailProgressControl
  • EncryptedFieldsBehavior
  • EventsChartProfileWidget
  • FileUploader
  • FontPickerInput
  • Formatter
  • FormView
  • GridViewWidget
  • History
  • IframeWidget
  • ImportExportBehavior
  • InlineActionForm
  • InlineEmailAction
  • InlineEmailForm
  • InlineEmailModelBehavior
  • InlineQuotes
  • JSONEmbeddedModelFieldsBehavior
  • JSONFieldsDefaultValuesBehavior
  • LeadRoutingBehavior
  • LeftWidget
  • LoginThemeHelper
  • LoginThemeHelperBase
  • MarketingGridViewProfileWidget
  • MediaBox
  • MessageBox
  • MobileFormatter
  • MobileFormLayoutRenderer
  • MobileLayoutRenderer
  • MobileLoginThemeHelper
  • MobileViewLayoutRenderer
  • ModelFileUploader
  • NewWebLeadsGridViewProfileWidget
  • NormalizedJSONFieldsBehavior
  • NoteBox
  • OnlineUsers
  • OpportunitiesGridViewProfileWidget
  • Panel
  • ProfileDashboardManager
  • ProfileGridViewWidget
  • ProfileLayoutEditor
  • ProfilesGridViewProfileWidget
  • Publisher
  • PublisherActionTab
  • PublisherCalendarEventTab
  • PublisherCallTab
  • PublisherCommentTab
  • PublisherEventTab
  • PublisherSmallCalendarEventTab
  • PublisherTab
  • PublisherTimeTab
  • QuickContact
  • QuickCreateRelationshipBehavior
  • QuotesGridViewProfileWidget
  • RecordAliasesWidget
  • RecordViewLayoutManager
  • RecordViewWidgetManager
  • RememberPagination
  • Reminders
  • ResponseBehavior
  • ResponsiveHtml
  • SearchIndexBehavior
  • ServicesGridViewProfileWidget
  • SmallCalendar
  • SmartActiveDataProvider
  • SmartDataProviderBehavior
  • SmartSort
  • SocialForm
  • SortableWidgetManager
  • SortableWidgets
  • TagBehavior
  • TagCloud
  • TemplatesGridViewProfileWidget
  • TimeZone
  • TopContacts
  • TopSites
  • TransformedFieldStorageBehavior
  • TranslationLogger
  • TwitterFeed
  • TwoColumnSortableWidgetManager
  • UpdaterBehavior
  • UpdatesForm
  • UserIdentity
  • UsersChartProfileWidget
  • WorkflowBehavior
  • X2ActiveGridView
  • X2ActiveGridViewForSortableWidgets
  • X2AssetManager
  • X2AuthManager
  • X2ChangeLogBehavior
  • X2ClientScript
  • X2Color
  • X2DateUtil
  • X2FixtureManager
  • X2FlowFormatter
  • X2GridView
  • X2GridViewBase
  • X2GridViewForSortableWidgets
  • X2GridViewSortableWidgetsBehavior
  • X2LeadsGridViewProfileWidget
  • X2LinkableBehavior
  • X2ListView
  • X2PillBox
  • X2ProgressBar
  • X2SmartSearchModelBehavior
  • X2TimestampBehavior
  • X2TranslationBehavior
  • X2UrlRule
  • X2WebModule
  • X2Widget
  • X2WidgetList
  • Overview
  • Package
  • Class
  • Tree

Class Formatter

Consolidated class for common string formatting and parsing functions.

Direct known subclasses

MobileFormatter, X2FlowFormatter
Package: application\components
Located at x2engine/protected/components/Formatter.php
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
# castReplacementTokenTypes( array $codes, array $codeTypes )
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

$text
string
$text
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
# yiiDateFormatToJQueryDateFormat( mixed $format )

Converts a yii date format string to a jquery ui date format string For each of the format string specifications, see: http://www.yiiframework.com/doc/api/1.1/CDateTimeParser http://api.jqueryui.com/datepicker/

Converts a yii date format string to a jquery ui date format string For each of the format string specifications, see: http://www.yiiframework.com/doc/api/1.1/CDateTimeParser http://api.jqueryui.com/datepicker/

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
# secondsToHours( mixed $seconds )
public static
# formatTimeInterval( integer $start, integer $end, mixed $style = null )

Formats a time interval.

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
# formatFeedTimestamp( mixed $timestamp )
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.

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

$str
type
$str

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
# formatTime( mixed $date, mixed $width = 'medium' )
public static
# formatDueDate( mixed $date, mixed $dateWidth = 'long', mixed $timeWidth = 'short' )
public static
# formatCompleteDate( mixed $date )
public static boolean
# isToday( mixed $date )

Parameters

$date
mixed
$date timestamp

Returns

boolean
public static
# isThisYear( mixed $date )
public static
# formatDateDynamic( mixed $date )
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

$date
string
$date

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
# isFormula( mixed $val )
public static
# isShortcode( mixed $val )
X2CRM Documentation API documentation generated by ApiGen 2.8.0