FORMfields


FORMfields.FfHelper

Class FfHelper

FfHelper

public class FfHelper

FfHelper contains common helper functions used by FORMfields.

Since:
FORMfields v2.0

Method Summary
string

arrayToString(array value)

Returns the array as a comma separated list.

array

array_combine(array keys, array values)

Returns an array indexed by keys and containing values.

string

escapeCommas(string value)

A static function that replaces all commas with escaped commas "\,".

string

escapeDoubleQuotes(string value)

A static function that replaces all double quotes with escaped quotes '\"'.

array

genArray(int start, int end, boolean pad)

Returns an array of indices starting at start and ending at end.

string

htmlify(string text, boolean convertNewLines)

HTMLifys the text by converting all URLs and email addresses to hyperlinks.

array

parseTabDeliminatedFile(mixed filename)

Returns an array of arrays of data from the tab delimited file.

void

pluralize(mixed word, mixed count)

Returns the word as a pluralized word if count is greater than 1.

string

printSimpleFfPageFooter()

Returns the footer (everything after and including the closing body tag) of a very basic W3C compliant web page.

string

printSimpleFfPageHeader()

Returns the header (everything up to and including the body tag) of a very basic W3C compliant web page.

void

scandir(mixed dir)

Returns an array of files in the specified directory.

array

stringToArray(string value)

Converts a comma separated list to an array of strings

void

stripos(mixed haystack, mixed needle)

Returns the position of needle in haystack.

the

toString(mixed value)

Returns the value as a string.

string

wordWrap(string str, int width, mixed br, boolean cut, string break)

A static method that enhances PHP's wordwrap function by: 1 - Not considering HTML tags as characters 2 - Considering encoded UTF-8 characters, like "请" as a single character.

Method Detail

arrayToString

public string arrayToString(array value)

Returns the array as a comma separated list. Note: all commas in the array element strings are escaped.

Parameters:
value - an array of strings
Returns:
the array as a comma separated list
Since:
FORMfields v2.0

array_combine

public array array_combine(array keys, array values)

Returns an array indexed by keys and containing values.

Parameters:
keys - array of keys
values - array of values
Returns:
an array indexed by keys and containing values
Since:
FORMfields v2.0
Deprecated:
as this function is now in FfRecentFunctions. Will be removed in the next release of FORMfields.

escapeCommas

public string escapeCommas(string value)

A static function that replaces all commas with escaped commas "\,". This method is useful for escaping commas within a comma separated list.

Parameters:
value - a value to escape
Returns:
the value comma escaped
Since:
FORMfields v2.0

escapeDoubleQuotes

public string escapeDoubleQuotes(string value)

A static function that replaces all double quotes with escaped quotes '\"'. This method is useful for escaping quotes within a string that will be passed to eval().

Parameters:
value - a value to escape
Returns:
the value double quote escaped
Since:
FORMfields v3.0

genArray

public array genArray(int start, int end, boolean pad)

Returns an array of indices starting at start and ending at end.

Parameters:
start - a positive number
end - a positive number greater than start
pad - true or null if the values in the array should be padded to the left of the largest value
Returns:
an array of integers starting at start and ending at end
Since:
FORMfields v2.0

htmlify

public string htmlify(string text, boolean convertNewLines)

HTMLifys the text by converting all URLs and email addresses to hyperlinks.

Parameters:
text - the text to HTMLify
convertNewLines - true if new lines "\n" should be converted into "
"
Returns:
the HTMLified text
Since:
FORMfields v3.0

parseTabDeliminatedFile

public array parseTabDeliminatedFile(mixed filename)

Returns an array of arrays of data from the tab delimited file.

Returns:
an array of arrays of data from the tab delimited file
Since:
FORMfields v2.0
Deprecated:
as deliminated should be delimited and this functionality has now been moved to FfParseHelper. Will be removed in the next release of FORMfields.

pluralize

public void pluralize(mixed word, mixed count)

Returns the word as a pluralized word if count is greater than 1. This method is good for descriptions that reference dynamic amounts where you don't wish to use "(s)". Note: this method doesn't work for any more complicated pluralization like adding "es".

Since:
FORMfields v3.0

printSimpleFfPageFooter

public string printSimpleFfPageFooter()

Returns the footer (everything after and including the closing body tag) of a very basic W3C compliant web page.

Returns:
the footer of a very basic W3C compliant web page
Since:
FORMfields v3.0

printSimpleFfPageHeader

public string printSimpleFfPageHeader()

Returns the header (everything up to and including the body tag) of a very basic W3C compliant web page.

Returns:
the header of a very basic W3C compliant web page
Since:
FORMfields v3.0

scandir

public void scandir(mixed dir)

Returns an array of files in the specified directory.

Since:
FORMfields v2.0
Deprecated:
as this function is now in FfRecentFunctions. Will be removed in the next release of FORMfields.

stringToArray

public array stringToArray(string value)

Converts a comma separated list to an array of strings

Parameters:
value - a comma separated list where the commas in the individual values are escaped
Returns:
the comma separated list as an array of strings without escaped commas
Since:
FORMfields v2.0

stripos

public void stripos(mixed haystack, mixed needle)

Returns the position of needle in haystack.

Since:
FORMfields v2.0
Deprecated:
as this function is now in FfRecentFunctions. Will be removed in the next release of FORMfields.

toString

public the toString(mixed value)

Returns the value as a string. If the value is a string already, the value is returned. Otherwise, the array of strings is converted into a comma separated list where the elements are NOT comma escaped.

Parameters:
value - either a string or array of strings
Returns:
value as a comma separated list that is not comma escaped
Since:
FORMfields v2.0

wordWrap

public string wordWrap(string str, int width, mixed br, boolean cut, string break)

A static method that enhances PHP's wordwrap function by: 1 - Not considering HTML tags as characters 2 - Considering encoded UTF-8 characters, like "请" as a single character.

Parameters:
str - the string to wrap
width - the column number to wrap by. Defaulted to 75
break - the break character to insert. Defaulted to "\n".
cut - true if the string should always be wrapped at the specified width
Returns:
the string wrapped at the specified column number
Since:
FORMfields v3.0

FORMfields