SproutCMS

This is the code documentation for the SproutCMS project

Page options:

Inherited members

class Sprout

Useful functions for sprout in general

Functions

NameVisibilityDescription
absRootpublic (static)Returns an absolute URL for the web root of this server
adminEmailspublic (static)Return a list of admins to send emails to.
browserDragdropUploadspublic (static)Return true if the browser supports drag-and-drop uploads.
checkInsertRatepublic (static)Attempts to put the handbrake on a script which is doing malicious inserts to the database
checkRedirectpublic (static)Checks a URL that is to be used for redirection is valid.
colorisedDiffpublic (static)Takes two strings of text (which will be stripped of HTML tags)
condenseArraypublic (static)Condenses an array into a string
determineFilePathpublic (static)Determines the file path for a class, usually for autoloading
etagpublic (static)Set the etag header, and some expiry headers.
extraPagepublic (static)Load the text for an extra page.
formatMysqlDatetimepublic (static)Takes a mysql DATETIME value (will probably also work with a TIME or DATE value)
getMemoryLimitpublic (static)Returns the memory limit in bytes. If there is no limit, returns INT_MAX.
getVersionpublic (static)Returns the current version of sprout
instancepublic (static)Construct a new instance of a class with a given name
ipaddressInArraypublic (static)Check an IP against a list of IP addresses, with logic for CIDR ranges
iterableFirstpublic (static)Gets the first key value pair of an iterable
iterableFirstKeypublic (static)Gets the first key of an iterable
iterableFirstValuepublic (static)Gets the first value of an iterable
lastModifiedpublic (static)Return the last-modified date of all pages on the (sub-)site
linkCheckerpublic (static)Back-end for link-checking tool
moduleInstalledpublic (static)Returns true if the specified module is currently installed, false otherwise
nsClasspublic (static)Gets the full class name (including namespace) for a specified class, with a list of namespaces to search
nsFuncpublic (static)Gets the full name (including namespaced class) for a specified function
nsNewpublic (static)Creates an object of a class specified by a string name, with a list of possible namespaces to lookup if the
passwordComplexitypublic (static) 
randStrpublic (static)Returns a string of random numbers and letters
readableVarpublic (static)Converts a variable into something human readable
removeNspublic (static)Removes the namespaces from a class-like entity,
simpleBacktracepublic (static)Gets a simplified backtrace with fewer elements and no recursion
specialFileLinkspublic (static)Adds classes, analytics and target-blank to file links.
timeAgopublic (static)Returns a time in 'x minutes ago' format.
translateLinkpublic (static)Translate an array which may contain a page_id, filename or url into the final URL to use

public absRoot

unknown Sprout::absRoot ( [ string $protocol ] );

Returns an absolute URL for the web root of this server

Example: 'http://thejosh.info/sprout_test/'

public adminEmails

unknown Sprout::adminEmails ( );

Return a list of admins to send emails to.

The return value is an array of arrays.
The inner arrays contains the keys "name" and "email".

public browserDragdropUploads

unknown Sprout::browserDragdropUploads ( );

Return true if the browser supports drag-and-drop uploads.

public checkInsertRate

bool Sprout::checkInsertRate ( string $table , string $column , string $value , string $limit [, string $time , array $conds ] );

Attempts to put the handbrake on a script which is doing malicious inserts to the database

public checkRedirect

unknown Sprout::checkRedirect ( mixed $text );

Checks a URL that is to be used for redirection is valid.

Will allow remote URLs beginning with 'http://' and local URLs beginning with '/'

public colorisedDiff

unknown Sprout::colorisedDiff ( mixed $orig , mixed $new );

Takes two strings of text (which will be stripped of HTML tags)
and returns HTML which is a table showing the differences
in a nice colourful way

public condenseArray

unknown Sprout::condenseArray ( array $arr );

Condenses an array into a string

public determineFilePath

false|string Sprout::determineFilePath ( string $class );

Determines the file path for a class, usually for autoloading

public etag

void Sprout::etag ( mixed $etag , mixed $expires );

Set the etag header, and some expiry headers.
Checks if the etag matches - if it does, terminates the script with '304 Not Modified'.

ETag should be specified as a string.
Expires should be specified as a number of seconds, after that time the URL will expire.

ETags should be something which is unique for that version of the URL. They should use
something which is collission-resistant, such as MD5. They should vary based on the
Accept-Encoding header, or any other 'accept' headers, if you are supporting them.

public extraPage

unknown Sprout::extraPage ( int $type );

Load the text for an extra page.
Returns NULL on error.

public formatMysqlDatetime

unknown Sprout::formatMysqlDatetime ( mixed $date [, mixed $format ] );

Takes a mysql DATETIME value (will probably also work with a TIME or DATE value)
and formats it according to the format codes specified by the PHP date() function.

The format is optional, if omittted, uses 'd/m/Y g:i a' = '7/11/2010 5:27 pm'

public getMemoryLimit

int Sprout::getMemoryLimit ( );

Returns the memory limit in bytes. If there is no limit, returns INT_MAX.

public getVersion

unknown Sprout::getVersion ( [ bool $git_version ] );

Returns the current version of sprout

public instance

mixed Sprout::instance ( string $class_name [, string|array $base_class_name ] );

Construct a new instance of a class with a given name

public ipaddressInArray

bool Sprout::ipaddressInArray ( mixed $needle , mixed $haystack );

Check an IP against a list of IP addresses, with logic for CIDR ranges

public iterableFirst

array|null Sprout::iterableFirst ( iterable $iter );

Gets the first key value pair of an iterable

This is to replace `reset` which has been deprecated in 7.2. While this lacks the
stateful behaviour of the original (i.e. changing the internal pointer) it does
recreate the most used feature: fetching the first element without knowing its key.

public iterableFirstKey

null|mixed Sprout::iterableFirstKey ( iterable $iter );

Gets the first key of an iterable

public iterableFirstValue

null|mixed Sprout::iterableFirstValue ( iterable $iter );

Gets the first value of an iterable

public lastModified

string|null Sprout::lastModified ( [ string $date_format ] );

Return the last-modified date of all pages on the (sub-)site
Returns NULL on error.

The date is formatted using the php date function.
The default date format is "d/m/Y".

public linkChecker

void Sprout::linkChecker ( );

Back-end for link-checking tool

public moduleInstalled

unknown Sprout::moduleInstalled ( mixed $module_name );

Returns true if the specified module is currently installed, false otherwise

public nsClass

string Sprout::nsClass ( string $class , array $possible_nses );

Gets the full class name (including namespace) for a specified class, with a list of namespaces to search

public nsFunc

string Sprout::nsFunc ( string $func , array $possible_nses );

Gets the full name (including namespaced class) for a specified function

public nsNew

object Sprout::nsNew ( string $class , array $possible_nses );

Creates an object of a class specified by a string name, with a list of possible namespaces to lookup if the
specified class name doesn't contain a namespace

public passwordComplexity

unknown Sprout::passwordComplexity ( mixed $str );

This function does not have a description

public randStr

unknown Sprout::randStr ( [ mixed $length [, mixed $chars ]] );

Returns a string of random numbers and letters

public readableVar

string Sprout::readableVar ( mixed $var );

Converts a variable into something human readable

public removeNs

string Sprout::removeNs ( string $classlike );

Removes the namespaces from a class-like entity,
e.g. Sprout\Helpers\Text => Text

public simpleBacktrace

array Sprout::simpleBacktrace ( array $trace );

Gets a simplified backtrace with fewer elements and no recursion

public specialFileLinks

unknown Sprout::specialFileLinks ( mixed $html );

Adds classes, analytics and target-blank to file links.
Also adds a random string, which prevents caching, solving some problems we were having with some clients.

public timeAgo

unknown Sprout::timeAgo ( int $timediff );

Returns a time in 'x minutes ago' format.

Very small times (0, 1 seconds) are considered 'Just now'.
Times are represneted in seconds, minutes, hours or days.

public translateLink

unknown Sprout::translateLink ( mixed $row );

Translate an array which may contain a page_id, filename or url into the final URL to use