CWIS Developer Documentation

- Home
- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Static Public Member Functions | Public Attributes | List of all members
StdLib Class Reference

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...

## 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...

## Detailed Description

Standard utility library.

Definition at line 14 of file StdLib.php.

## Member Function Documentation

static StdLib::AdjustHexColor | ( |  | $Color,
|  |  | $LAdjust,
|  |  | $SAdjust = `0`
| ) |  |
| static

Adjust hexadecimal RGB color by specified amount.

Pass in negative values to reduce luminance or saturation.

Parameters

  string | $Color | Hex RGB color string.
  int | $LAdjust | Percentage amount to adjust luminance.
  int | $SAdjust | Percentage amount to adjust saturation. (OPTIONAL)

Returns
  string Adjusted hex RGB color string.

Definition at line 814 of file StdLib.php.

static StdLib::ArrayPermutations | ( |  | $Items,
|  |  | $Perms = `array()`
| ) |  |
| static

Return all possible permutations of a given array.

Parameters

  array | $Items | Array to permutate.
  array | $Perms | Current set of permutations, used internally for recursive calls. (DO NOT USE)

Returns
  array Array of arrays of permutations.

Definition at line 721 of file StdLib.php.

References $Items.

Referenced by ApplicationFramework\AddCleanUrl().

Here is the caller graph for this function:

static StdLib::CheckMyCaller | ( |  | $DesiredCaller,
|  |  | $ExceptionMsg = `NULL`
| ) |  |
| 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%").

Parameters

  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)

Returns
  bool TRUE if caller matched desired caller, otherwise FALSE.

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().

Here is the caller graph for this function:

static StdLib::ComputeBearing | ( |  | $LatSrc,
|  |  | $LonSrc,
|  |  | $LatDst,
|  |  | $LonDst
| ) |  |
| static

Computes the initial angle on a course connecting two points, assuming a spherical earth.

Parameters

  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.

Returns
  initial angle on a course connecting two points.

Definition at line 699 of file StdLib.php.

static StdLib::ComputeGreatCircleDistance | ( |  | $LatSrc,
|  |  | $LonSrc,
|  |  | $LatDst,
|  |  | $LonDst
| ) |  |
| static

Computes the distance in kilometers between two points, assuming a spherical earth.

Parameters

  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.

Returns
  distance in miles between the two points.

Definition at line 670 of file StdLib.php.

static StdLib::EncodeStringForCdata | ( |  | $String | ) |
| 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.

Parameters

  string | $String | String to be encoded.

Returns
  string Encoded string.

Definition at line 560 of file StdLib.php.

static StdLib::GetBacktraceAsString | ( |  | $IncludeArgs = `TRUE` | ) |
| static

Get backtrace as a string.

Parameters

  bool | $IncludeArgs | If TRUE, arguments will be included in function call information. (OPTIONAL, defaults to TRUE)

Returns
  string Backtrace info string.

Definition at line 128 of file StdLib.php.

Referenced by MetadataSchema\GetCanonicalFieldIdentifier().

Here is the caller graph for this function:

static StdLib::GetCallerInfo | ( |  | $Element = `NULL` | ) |
| static

Get info about call to current function.

Parameters

  string | $Element | Name of element to return. (OPTIONAL, defaults to returning all elements)

Returns
  array Array with the element names "FileName", "FullFileName", "RelativeFileName", and "LineNumber" for the index.

Definition at line 26 of file StdLib.php.

Referenced by ApplicationFramework\AddCleanUrl().

Here is the caller graph for this function:

static StdLib::GetConstantName | ( |  | $ClassName,
|  |  | $Value,
|  |  | $Prefix = `NULL`
| ) |  |
| 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.

Parameters

  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)

Returns
  string Constant name or NULL if no matching value found.

Definition at line 853 of file StdLib.php.

References strpos().

Referenced by Resource_Test\testGetSetClear().

Here is the caller graph for this function:

static StdLib::GetLatLngForZipCode | ( |  | $Zip | ) |
| 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.

Parameters

  int | $Zip | Zip code to look up.

Returns
  array Having members "Lat" and "Lng" on successful lookup, FALSE otherwise

Exceptions

  Exception | When coordinates file cannot be opened.

Definition at line 596 of file StdLib.php.

static StdLib::GetMyCaller | ( |  | ) |
| static

Get string with file and line number for call to current function.

Returns
  string String with caller info in the form "FILE:LINE".

Definition at line 44 of file StdLib.php.

Referenced by MetadataSchema\StdNameToFieldMapping().

Here is the caller graph for this function:

static StdLib::GetUsStatesList | ( |  | ) |
| static

Get an array of US state names with their two-letter abbreviations as the index.

Returns
  Returns an array of US state names with their two-letter abbreviations as the index.

Definition at line 749 of file StdLib.php.

Referenced by FormTool\GetArrayOfUsStates(), and UserEditingUI\GetRequestAccountForm().

Here is the caller graph for this function:

static StdLib::NeatlyTruncateString | ( |  | $String,
|  |  | $MaxLength,
|  |  | $BreakAnywhere = `FALSE`
| ) |  |
| static

Attempt to truncate a string as neatly as possible with respect to word breaks, punctuation, and HTML tags.

Parameters

  string | $String | String to truncate
  int | $MaxLength | The maximum length of the truncated string
  bool | $BreakAnywhere | TRUE to break exactly at the maximum length

Returns
  the (possibly) truncated string

Definition at line 237 of file StdLib.php.

Referenced by ItemListUI\Display(), NeatlyTruncateString_Test\testNTS(), SearchParameterSet\TextDescription(), and SavedSearch\TranslateSearchGroupsToTextDescription().

Here is the caller graph for this function:

static StdLib::Pluralize | ( |  | $Word | ) |
| static

Pluralize an English word.

Parameters

  string | $Word | Word to make plural.

Returns
  string Word in plural form.

Definition at line 162 of file StdLib.php.

Referenced by CWPlugin\AddMetadataFieldsFromXml(), ItemListUI\Display(), TransportControlsUI\PrintControls(), and Item\SetDatabaseAccessValues().

Here is the caller graph for this function:

static StdLib::Singularize | ( |  | $Word | ) |
| static

Singularize an English word.

Parameters

  string | $Word | Word to make singular.

Returns
  string Word in singular form.

Definition at line 198 of file StdLib.php.

Referenced by CWPlugin\AddMetadataFieldsFromXml(), and MetadataSchema\Create().

Here is the caller graph for this function:

static StdLib::SortCompare | ( |  | $A,
|  |  | $B
| ) |  |
| static

Perform compare and return value appropriate for sort function callbacks.

Parameters

  mixed | $A | First value to compare.
  mixed | $B | Second value to compare.

Returns
  int 0 if values are equal, -1 if A is less than B, or 1 if B is greater than A.

Definition at line 572 of file StdLib.php.

Referenced by ApplicationFramework\HookEvent(), and GlobalSearchEngine\SearchTime().

Here is the caller graph for this function:

static StdLib::strlen | ( |  | ) |
| static

Multibyte-aware (if supported in PHP) version of strlen().

(Consult PHP documentation for arguments and return value.)

Definition at line 547 of file StdLib.php.

static StdLib::strpos | ( |  | ) |
| static

Multibyte-aware (if supported in PHP) version of strpos().

(Consult PHP documentation for arguments and return value.)

Definition at line 529 of file StdLib.php.

Referenced by SearchParameterSetEditingUI\DisplayAsRows(), and GetConstantName().

Here is the caller graph for this function:

static StdLib::strrpos | ( |  | ) |
| static

Multibyte-aware (if supported in PHP) version of strrpos().

(Consult PHP documentation for arguments and return value.)

Definition at line 538 of file StdLib.php.

static StdLib::substr | ( |  | ) |
| static

Multibyte-aware (if supported in PHP) version of substr().

(Consult PHP documentation for arguments and return value.)

Definition at line 520 of file StdLib.php.

Referenced by SearchParameterSetEditingUI\DisplayAsRows(), and Email\Send().

Here is the caller graph for this function:

static StdLib::ZipCodeDistance | ( |  | $ZipA,
|  |  | $ZipB
| ) |  |
| static

Compute the distance between two US ZIP codes.

Parameters

  int | $ZipA | First zip code.
  int | $ZipB | Second zip code.

Returns
  double Distance in Km between the two zip codes or FALSE if either zip could not be found

Definition at line 643 of file StdLib.php.

## Member Data Documentation

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 880 of file StdLib.php.

Referenced by ApplicationFramework\GetLock().

The documentation for this class was generated from the following file:

- lib/ScoutLib/StdLib.php