CWIS Developer Documentation
|
Standard utility library. More...
Static Public Member Functions | |
static | GetCallerInfo ($Element=NULL) |
Get info about call to current function. More... | |
static | GetMyCaller () |
Get string with file and line number for call to current function. More... | |
static | CheckMyCaller ($DesiredCaller, $ExceptionMsg=NULL) |
Check the caller of the current function. More... | |
static | GetBacktraceAsString ($IncludeArgs=TRUE) |
Get backtrace as a string. More... | |
static | Pluralize ($Word) |
Pluralize an English word. More... | |
static | Singularize ($Word) |
Singularize an English word. More... | |
static | NeatlyTruncateString ($String, $MaxLength, $BreakAnywhere=FALSE) |
Attempt to truncate a string as neatly as possible with respect to word breaks, punctuation, and HTML tags. More... | |
static | substr () |
Multibyte-aware (if supported in PHP) version of substr(). More... | |
static | strpos () |
Multibyte-aware (if supported in PHP) version of strpos(). More... | |
static | strrpos () |
Multibyte-aware (if supported in PHP) version of strrpos(). More... | |
static | strlen () |
Multibyte-aware (if supported in PHP) version of strlen(). More... | |
static | EncodeStringForCdata ($String) |
Encode string to be written out in XML as CDATA. More... | |
static | SortCompare ($A, $B) |
Perform compare and return value appropriate for sort function callbacks. More... | |
static | GetLatLngForZipCode ($Zip) |
Look up the GPS coordinates for a US ZIP code. More... | |
static | ZipCodeDistance ($ZipA, $ZipB) |
Compute the distance between two US ZIP codes. More... | |
static | ComputeGreatCircleDistance ($LatSrc, $LonSrc, $LatDst, $LonDst) |
Computes the distance in kilometers between two points, assuming a spherical earth. More... | |
static | ComputeBearing ($LatSrc, $LonSrc, $LatDst, $LonDst) |
Computes the initial angle on a course connecting two points, assuming a spherical earth. More... | |
static | ArrayPermutations ($Items, $Perms=array()) |
Return all possible permutations of a given array. More... | |
static | GetUsStatesList () |
Get an array of US state names with their two-letter abbreviations as the index. More... | |
static | AdjustHexColor ($Color, $LAdjust, $SAdjust=0) |
Adjust hexadecimal RGB color by specified amount. More... | |
static | GetConstantName ($ClassName, $Value, $Prefix=NULL) |
Get name (string) for constant. More... | |
static | HexToRgba ($Hex, $Opacity=1) |
Convert a hex color string (e.g., #FF00FF") to a css 'rgba(' format color. More... | |
Public Attributes | |
const | SQL_DATE_FORMAT = "Y-m-d H:i:s" |
Format to feed to date() to get SQL-compatible date/time string. More... | |
Standard utility library.
Definition at line 14 of file StdLib.php.
|
static |
Adjust hexadecimal RGB color by specified amount.
Pass in negative values to reduce luminance or saturation.
string | $Color | Hex RGB color string. |
int | $LAdjust | Percentage amount to adjust luminance. |
int | $SAdjust | Percentage amount to adjust saturation. (OPTIONAL) |
Definition at line 817 of file StdLib.php.
|
static |
Return all possible permutations of a given array.
array | $Items | Array to permutate. |
array | $Perms | Current set of permutations, used internally for recursive calls. (DO NOT USE) |
Definition at line 724 of file StdLib.php.
References $Items.
Referenced by ApplicationFramework\AddCleanUrl().
|
static |
Check the caller of the current function.
In the desired caller parameter, if a file name is specified it should include the ".php" extension but should not have a leading path. In the exception message parameter, the following strings can be used and the appropriate values will be substituted in: FILE% (no leading path), LINE%, FULLFILE% (includes leading path), CLASS%, FUNCTION%, and METHOD% (equivalent to "%CLASS%::%FUNCTION%").
string | $DesiredCaller | String describing desired caller, in the form "Class", "Class::Method", "Function", "File", or "File:Line". |
string | $ExceptionMsg | If specified and the caller was not the desired caller, an exception will be thrown with this message. (OPTIONAL) |
Definition at line 69 of file StdLib.php.
Referenced by Plugin\__construct(), SPTImage\ClearImageSymlinksForResource(), MetadataField\Drop(), SPTImage\GetImageUrlForResource(), Plugin\InstalledVersion(), Plugin\IsInstalled(), and Plugin\IsReady().
|
static |
Computes the initial angle on a course connecting two points, assuming a spherical earth.
int | $LatSrc | Latitude of the source coordinate. |
int | $LonSrc | Longitude of the source coordinate. |
int | $LatDst | Latitude of the destination coordinate. |
int | $LonDst | Longitude of the destination coordinate. |
Definition at line 702 of file StdLib.php.
|
static |
Computes the distance in kilometers between two points, assuming a spherical earth.
int | $LatSrc | Latitude of the source coordinate. |
int | $LonSrc | Longitude of the source coordinate. |
int | $LatDst | Latitude of the destination coordinate. |
int | $LonDst | Longitude of the destination coordinate. |
Definition at line 673 of file StdLib.php.
|
static |
Encode string to be written out in XML as CDATA.
Starting and ending CDATA character sequences are added, and any escaping needed is done by breaking up any CDATA terminator sequences by inserting characters to stop and start the current CDATA section.
string | $String | String to be encoded. |
Definition at line 563 of file StdLib.php.
|
static |
Get backtrace as a string.
bool | $IncludeArgs | If TRUE, arguments will be included in function call information. (OPTIONAL, defaults to TRUE) |
Definition at line 130 of file StdLib.php.
Referenced by MetadataSchema\GetCanonicalFieldIdentifier().
|
static |
Get info about call to current function.
string | $Element | Name of element to return. (OPTIONAL, defaults to returning all elements) |
Definition at line 26 of file StdLib.php.
Referenced by ApplicationFramework\AddCleanUrl().
|
static |
Get name (string) for constant.
If there are multiple constants defined with the same value, the first constant found with a name that matches the prefix (if supplied) is returned.
mixed | $ClassName | Class name or object. |
enum | $Value | Constant value. |
string | $Prefix | Prefix to look for at beginning of name. Needed when there may be multiple constants with the same value. (OPTIONAL) |
Definition at line 856 of file StdLib.php.
References strpos().
Referenced by Resource_Test\testResource().
|
static |
Look up the GPS coordinates for a US ZIP code.
Database of GPS coordinates used was drawn from Census 2010. See the "Zip Code Tabulation Areas" section on https://www.census.gov/geo/maps-data/data/gazetteer2010.html for the original source file. The version used here has been cut down to columns 1, 8, and 9 from that source.
int | $Zip | Zip code to look up. |
Exception | When coordinates file cannot be opened. |
Definition at line 599 of file StdLib.php.
|
static |
Get string with file and line number for call to current function.
Definition at line 44 of file StdLib.php.
Referenced by MetadataSchema\StdNameToFieldMapping().
|
static |
Get an array of US state names with their two-letter abbreviations as the index.
Definition at line 752 of file StdLib.php.
Referenced by FormTool\GetArrayOfUsStates(), and UserEditingUI\GetRequestAccountForm().
|
static |
Convert a hex color string (e.g., #FF00FF") to a css 'rgba(' format color.
string | $Hex | Color to convert. |
float | $Opacity | Opacity (OPTIONAL, default 1). |
Definition at line 888 of file StdLib.php.
References strlen().
|
static |
Attempt to truncate a string as neatly as possible with respect to word breaks, punctuation, and HTML tags.
string | $String | String to truncate |
int | $MaxLength | The maximum length of the truncated string |
bool | $BreakAnywhere | TRUE to break exactly at the maximum length |
Definition at line 239 of file StdLib.php.
Referenced by ItemListUI\Display(), NeatlyTruncateString_Test\testNTS(), SearchParameterSet\TextDescription(), and SavedSearch\TranslateSearchGroupsToTextDescription().
|
static |
Pluralize an English word.
string | $Word | Word to make plural. |
Definition at line 164 of file StdLib.php.
Referenced by CWPlugin\AddMetadataFieldsFromXml(), ItemListUI\Display(), TransportControlsUI\PrintControls(), and Item\SetDatabaseAccessValues().
|
static |
Singularize an English word.
string | $Word | Word to make singular. |
Definition at line 200 of file StdLib.php.
Referenced by CWPlugin\AddMetadataFieldsFromXml(), and MetadataSchema\Create().
|
static |
Perform compare and return value appropriate for sort function callbacks.
mixed | $A | First value to compare. |
mixed | $B | Second value to compare. |
Definition at line 575 of file StdLib.php.
Referenced by ApplicationFramework\HookEvent(), and GlobalSearchEngine\SearchTime().
|
static |
Multibyte-aware (if supported in PHP) version of strlen().
(Consult PHP documentation for arguments and return value.)
Definition at line 550 of file StdLib.php.
Referenced by HexToRgba().
|
static |
Multibyte-aware (if supported in PHP) version of strpos().
(Consult PHP documentation for arguments and return value.)
Definition at line 532 of file StdLib.php.
Referenced by SearchParameterSetEditingUI\DisplayAsRows(), and GetConstantName().
|
static |
Multibyte-aware (if supported in PHP) version of strrpos().
(Consult PHP documentation for arguments and return value.)
Definition at line 541 of file StdLib.php.
|
static |
Multibyte-aware (if supported in PHP) version of substr().
(Consult PHP documentation for arguments and return value.)
Definition at line 523 of file StdLib.php.
Referenced by SearchParameterSetEditingUI\DisplayAsRows(), and Email\Send().
|
static |
Compute the distance between two US ZIP codes.
int | $ZipA | First zip code. |
int | $ZipB | Second zip code. |
Definition at line 646 of file StdLib.php.
const StdLib::SQL_DATE_FORMAT = "Y-m-d H:i:s" |
Format to feed to date() to get SQL-compatible date/time string.
Definition at line 913 of file StdLib.php.
Referenced by ApplicationFramework\GetLock(), Item_Test\testAll(), and Item\UpdateDateValue().