Cts_Common

Summary
Cts_Common
AuthorJaybill McCarthy
Licensehttp://communit.as/docs/license
Static Methods
getTimeZonesArrayTBD
calculateYearsOldCalculates the number of years between a birthdate and now.
calculateAstroSignCalculates a star sign based on a birth date.
getSignArrayGets a list of astrological signs.
getSignBetweenTBD
br2nlConverts XHTML <br /> tags to newline characters (chr 32).
makeParagraphsTBD
sortDataSetSorts a set of data (multidimensional array).
makeTagStringTBD
makeTagArrayTBD
xyagoTBD
convertlinebreaksTBD
quoteIntoTBD
pluralOrSingularTakes a quantity and two noun forms and returns the noun form that suits the quantity.
getGenderArrayGets a list of possible gender choices.
getUsStatesArrayGets a list of states and territories of the United States.
get_timezone_offsetCalculates the offset from the origin timezone to the remote timezone in seconds.
dateDiffInDaysCalculates the number of days between two dates.
makeSeoFriendlyMakes a string suitable for use as an SEO-friendly URL.
makeDummyTextGenerates latin text to the desired character length.
hasCheck to see if an object/array contains a certain key.
getViewState
vnsprintfActs just like PHP’s built-in vsprintf except it can use named keys.
urlFilterTakes a URL and an array of various possible parameters and modified the URL as needed.

Author

Jaybill McCarthy

Static Methods

getTimeZonesArray

static function getTimeZonesArray($choose_one =  null)

TBD

Arguments

choose_oneA string to be used for the default option.  “Choose one...” or something along that line.

Returns

timezonesarray continaing a list of timezones suitable for an html select tag

calculateYearsOld

static function calculateYearsOld($timestamp)

Calculates the number of years between a birthdate and now.

Arguments

timestampA unix timestamp representing a person’s date of birth.

Returns

An age in years as an integer.

calculateAstroSign

static function calculateAstroSign($timestamp)

Calculates a star sign based on a birth date.  Yeah, I know.  You probably won’t ever need this.  One of our early clients did and it’s awesome code so we left it.

Arguments

timestampThe birth date to calculate as a unix timestamp.

Returns

The name of the star sign (string).

getSignArray

static function getSignArray()

Gets a list of astrological signs.

Returns

An array of star signs.

getSignBetween

static function getSignBetween($sign,  
$colname =  "birthday_day")

TBD

Arguments

signTBD
colname (optional)TBD

Returns

TBD

br2nl

static function br2nl($string)

Converts XHTML <br /> tags to newline characters (chr 32).

Arguments

stringAn XHTML string to convert.

Returns

A converted string.

makeParagraphs

static function makeParagraphs($string)

TBD

Arguments

stringTBD

Returns

TBD

sortDataSet

function sortDataSet(&$dataSet)

Sorts a set of data (multidimensional array).

Arguments

&$datasetA multidimensional array (data set) to sort.  Subsequent arguments follow the argument order of array_multisort(), except that you do not pass arrays to the function but keys (string!) of the columns not TBD

Example

sortDataSet(data set, column1[, mixed arg [, mixed ... [, array ...]]])

See Also

  • array_multisort()

makeTagString

static function makeTagString($tags)

TBD

Arguments

tagsTBD

Returns

TBD

makeTagArray

static function makeTagArray($tag_string)

TBD

Arguments

tag_stringTBD

Returns

TBD

xyago

static function xyago($datefrom,  
$dateto =  -1)

TBD

Arguments

datefromTBD
datetoTBD

Returns

TBD

convertlinebreaks

static function convertlinebreaks($text)

TBD

Arguments

textThe string to convert.

Returns TBD

quoteInto

static function quoteInto($text,
$params)

TBD

Arguments

textTBD
paramsTBD

Returns

TBD

pluralOrSingular

static function pluralOrSingular($qty,
$singular,
$plural)

Takes a quantity and two noun forms and returns the noun form that suits the quantity.  Useful when a dynamic quantity is used in a sentence, such as, “There are 2 users online.”

Arguments

qtyThe quantity to compare.
singularThe singular noun form.
pluralThe plural noun form.

Returns

The singular or plural noun form, depending on the quantity given.

getGenderArray

static function getGenderArray()

Gets a list of possible gender choices.

Returns

An array containing three gender choices: male, female, and unspecified.

getUsStatesArray

static function getUsStatesArray($choose_one =  null)

Gets a list of states and territories of the United States.

Arguments

choose_one (optional)A string to place at the beginning of the returned array.

Returns

An array of states.

get_timezone_offset

static function get_timezone_offset($remote_tz,  
$origin_tz =  null)

Calculates the offset from the origin timezone to the remote timezone in seconds.

Arguments

remote_tzThe remote time zone.
origin_tz (optional)The origin time zone.  Defaults to the server’s time zone.

Returns

The number of seconds difference between the given time zones (integer).

dateDiffInDays

static function dateDiffInDays($pastdate,
$futuredate)

Calculates the number of days between two dates.

Arguments

pastdateThe earlier of the dates to compare.
futuredateThe later of the dates to compare.

Returns

The number of days between the two dates (integer).

makeSeoFriendly

static function makeSeoFriendly($value)

Makes a string suitable for use as an SEO-friendly URL.  Lowercases the entire string and replaces spaces with hyphens (dashes).

Arguments

valueThe string to reformat.

Returns

A reformatted version of the input string.

makeDummyText

static function makeDummyText($chars)

Generates latin text to the desired character length.

Arguments

charsThe maximum number of chars to return.  Default is 150.

Returns

A string containing the requested amount of latin copy.

has

static function has($obj,
$key)

Check to see if an object/array contains a certain key.

Arguments

objThe object or array to search in (haystack).
keyThe key to try to find in the object (needle).

Returns

A boolean indicating whether the key does exist (true) or does not (false).

getViewState

static function getViewState($session,
$key,
$default)

Arguments

sessionThe entire current session.
keyThe key to look for in the view state array.
defaultThe view state to use if nothing turns up.

Returns

The view state for the given key, or the default if the key does not exist.

vnsprintf

static function vnsprintf( $format,
array $data)

Acts just like PHP’s built-in vsprintf except it can use named keys.

urlFilter

static function urlFilter( $url,  
array $params =  null)

Takes a URL and an array of various possible parameters and modified the URL as needed.  For instance, if a locale_code is passed in, the code is added to the base of the URL.  This method is only intended to filter local URLs and not any links to URLs outside the application.

Arguments

urlThe URL to be filtered.
paramsAn array of optional params.  Currently the only thing it recognizes is a key of ‘locale_code’.

Returns: string

static function getTimeZonesArray($choose_one =  null)
TBD
static function calculateYearsOld($timestamp)
Calculates the number of years between a birthdate and now.
static function calculateAstroSign($timestamp)
Calculates a star sign based on a birth date.
static function getSignArray()
Gets a list of astrological signs.
static function getSignBetween($sign,  
$colname =  "birthday_day")
TBD
static function br2nl($string)
Converts XHTML br / tags to newline characters (chr 32).
static function makeParagraphs($string)
TBD
function sortDataSet(&$dataSet)
Sorts a set of data (multidimensional array).
static function makeTagString($tags)
TBD
static function makeTagArray($tag_string)
TBD
static function xyago($datefrom,  
$dateto =  -1)
TBD
static function convertlinebreaks($text)
TBD
static function quoteInto($text,
$params)
TBD
static function pluralOrSingular($qty,
$singular,
$plural)
Takes a quantity and two noun forms and returns the noun form that suits the quantity.
static function getGenderArray()
Gets a list of possible gender choices.
static function getUsStatesArray($choose_one =  null)
Gets a list of states and territories of the United States.
static function get_timezone_offset($remote_tz,  
$origin_tz =  null)
Calculates the offset from the origin timezone to the remote timezone in seconds.
static function dateDiffInDays($pastdate,
$futuredate)
Calculates the number of days between two dates.
static function makeSeoFriendly($value)
Makes a string suitable for use as an SEO-friendly URL.
static function makeDummyText($chars)
Generates latin text to the desired character length.
static function has($obj,
$key)
Check to see if an object/array contains a certain key.
static function getViewState($session,
$key,
$default)
static function vnsprintf( $format,
array $data)
Acts just like PHP’s built-in vsprintf except it can use named keys.
static function urlFilter( $url,  
array $params =  null)
Takes a URL and an array of various possible parameters and modified the URL as needed.
Close