Class to implement utility methods. More...
Static Public Member Functions | |
static bool | isLtiMessage () |
Check whether the request received could be an LTI message. | |
static array | getRequestParameters () |
Return GET and POST request parameters (POST parameters take precedence). | |
static void | logError (string $message, bool $showSource=true) |
Log an error message. | |
static void | logInfo (string $message, bool $showSource=false) |
Log an information message. | |
static void | logDebug (string $message, bool $showSource=false) |
Log a debug message. | |
static void | logRequest (bool $debugLevel=false) |
Log a request received. | |
static void | logForm (string $url, array $params, string $method='POST', bool $debugLevel=false) |
Log a form submission. | |
static void | log (string $message, bool $showSource=false) |
Log an error message irrespective of the logging level. | |
static void | setMessage (bool $isError, string $message) |
Set an error or warning message. | |
static array | getMessages (bool $isError) |
Get the system error or warning messages. | |
static string | sendForm (string $url, array $params, string $target='', string $javascript='') |
Generate a web page containing an auto-submitted form of parameters. | |
static never | redirect (string $url, array $params) |
Redirect to a URL with query parameters. | |
static void | setTestCookie (bool $delete=false) |
Set or delete a test cookie. | |
static string | getRandomString (int $length=8) |
Generate a random string. | |
static string | stripHtml (string $html) |
Strip HTML tags from a string. | |
static string | urlEncode (?string $val) |
URL encode a value. | |
static string | valToString (mixed $val, ?string $default='') |
Convert a value to a string. | |
static int float null | valToNumber (mixed $val) |
Convert a value to a numeric. | |
static bool | valToBoolean (mixed $val) |
Convert a value to a boolean. | |
static object null | checkObject (object $obj, string $fullname, bool $required=false, bool $stringValues=false) |
Get the named object element from object. | |
static array | checkArray (object $obj, string $fullname, bool $required=false, bool $notEmpty=false) |
Get the named array element from object. | |
static string | checkString (object $obj, string $fullname, bool $required=false, bool $notEmpty=false, string|array $fixedValue='', bool $overrideStrictMode=false, ?string $default='') |
Get the named string element from object. | |
static int float null | checkNumber (object $obj, string $fullname, bool $required=false, int|false $minimum=false, bool $minimumExclusive=false, bool $overrideStrictMode=false) |
Get the named number element from object. | |
static int null | checkInteger (object $obj, string $fullname, bool $required=false, int|false $minimum=false, bool $minimumExclusive=false, bool $overrideStrictMode=false) |
Get the named integer element from object. | |
static bool null | checkBoolean (object $obj, string $fullname, bool $required=false, ?bool $default=null) |
Get the named boolean element from object. | |
static int | checkDateTime (object $obj, string $fullname, bool $required=false) |
Get the named number element from object. | |
static mixed | jsonDecode (?string $str, bool $associative=false) |
Decode a JSON string. | |
static object | cloneObject (object $obj) |
Clone an object and any objects it contains. | |
Public Attributes | |
const | JWT_CLAIM_PREFIX = 'https://purl.imsglobal.org/spec/lti' |
Prefix for standard JWT message claims. | |
const | MESSAGE_TYPE_MAPPING |
Mapping for standard message types. | |
const | JWT_CLAIM_MAPPING |
Mapping for standard message parameters to JWT claim. | |
const | TEST_COOKIE_NAME = 'celtic_lti_test_cookie' |
Name of test cookie. | |
Static Public Attributes | |
static array | $METHOD_NAMES |
List of supported message types and associated class methods. | |
static array | $requestParameters = null |
GET and POST request parameters. | |
static LogLevel | $logLevel = LogLevel::None |
Current logging level. | |
static bool | $strictMode = false |
Whether full compliance with the LTI specification is required. | |
static bool | $disableFetchedPublicKeysSave = false |
Whether the automatic saving of fetched valid public keys should be disabled. | |
static int | $formSubmissionTimeout = 2 |
Delay (in seconds) before a manual button is displayed in case a browser is blocking a form submission. | |
Class to implement utility methods.
|
static |
Get the named array element from object.
object | $obj | Object containing the element |
string | $fullname | Name of element |
bool | $required | True if the element must be present |
bool | $notEmpty | True if the element must not have an empty value |
Referenced by Groups\get().
|
static |
Get the named boolean element from object.
object | $obj | Object containing the element |
string | $fullname | Name of element (may include a path) |
bool | $required | True if the element must be present |
string | null | $default | Value to return when a conversion is not possible (optional, default is an empty string) |
Referenced by Groups\get(), and FileItem\toJsonldObject().
|
static |
Get the named number element from object.
object | $obj | Object containing the element |
string | $fullname | Name of element (may include a path) |
bool | $required | True if the element must be present |
Referenced by LineItem\get().
|
static |
Get the named integer element from object.
object | $obj | Object containing the element |
string | $fullname | Name of element (may include a path) |
bool | $required | True if the element must be present |
int | false | $minimum | Minimum value (or false is none) |
bool | $minimumExclusive | True if value must exceed the minimum |
bool | $overrideStrictMode | Ignore strict mode setting |
Referenced by Image\toJsonldObject().
|
static |
Get the named number element from object.
object | $obj | Object containing the element |
string | $fullname | Name of element (may include a path) |
bool | $required | True if the element must be present |
int | false | $minimum | Minimum value (or false is none) |
bool | $minimumExclusive | True if value must exceed the minimum |
bool | $overrideStrictMode | Ignore strict mode setting |
Referenced by LineItem\get().
|
static |
Get the named object element from object.
object | $obj | Object containing the element |
string | $fullname | Name of element |
bool | $required | True if the element must be present |
bool | $stringValues | True if the values must be strings |
|
static |
Get the named string element from object.
object | $obj | Object containing the element |
string | $fullname | Name of element (may include a path) |
bool | $required | True if the element must be present |
bool | $notEmpty | True if the element must not have an empty value |
string | $fixedValue | Required value of element (empty string if none) |
bool | $overrideStrictMode | Ignore strict mode setting |
string | null | $default | Value to return when a conversion is not possible (optional, default is an empty string) |
Referenced by Groups\get(), LineItem\get(), and Image\toJsonldObject().
|
static |
Clone an object and any objects it contains.
object | $obj | Object to be cloned |
|
static |
Get the system error or warning messages.
bool | $isError | True if error messages are to be returned |
|
static |
Generate a random string.
The generated string will only comprise letters (upper- and lower-case) and digits.
int | $length | Length of string to be generated (optional, default is 8 characters) |
|
static |
Return GET and POST request parameters (POST parameters take precedence).
|
static |
Check whether the request received could be an LTI message.
References Util\log(), and Util\logInfo().
|
static |
Decode a JSON string.
string | null | $str | The JSON string to be decoded |
bool | $associative | True to return JSON objects as associative arrays |
Referenced by DataConnector_mysqli\deletePlatformNonce(), DataConnector_sql\deletePlatformNonce(), DataConnector_oci8\deleteTool(), DataConnector_pdo\deleteTool(), DataConnector_oci8\getTools(), DataConnector_mysqli\loadResourceLink(), DataConnector_pgsql\loadResourceLink(), DataConnector_sql\loadResourceLink(), DataConnector_oci8\loadTool(), and System\sendMessage().
|
static |
Log an error message irrespective of the logging level.
string | $message | Message to be logged |
bool | $showSource | True if the name and line number of the current file are to be included |
Referenced by Util\isLtiMessage().
|
static |
Log a debug message.
string | $message | Message to be logged |
bool | $showSource | True if the name and line number of the current file are to be included |
Referenced by Util\logRequest().
|
static |
Log an error message.
string | $message | Message to be logged |
bool | $showSource | True if the name and line number of the current file are to be included |
|
static |
Log a form submission.
string | $url | URL to which the form should be submitted |
array | $params | Array of form parameters |
string | $method | HTTP Method used to submit form (optional, default is POST) |
bool | $debugLevel | True if the form details should always be logged (optional, default is false to use current log level) |
|
static |
Log an information message.
string | $message | Message to be logged |
bool | $showSource | True if the name and line number of the current file are to be included |
Referenced by Util\isLtiMessage().
|
static |
Log a request received.
bool | $debugLevel | True if the request details should be logged at the debug level (optional, default is false for information level) |
References Util\logDebug().
|
static |
Redirect to a URL with query parameters.
string | $url | URL to which the form should be submitted |
array | $params | Array of form parameters |
|
static |
Generate a web page containing an auto-submitted form of parameters.
string | $url | URL to which the form should be submitted |
array | $params | Array of form parameters |
string | $target | Name of target (optional) |
string | $javascript | Javascript to be inserted (optional, default is to just auto-submit form) |
|
static |
Set an error or warning message.
bool | $isError | True if the message represents an error |
string | $message | Message |
Referenced by Groups\get(), and ToolSettings\set().
|
static |
Set or delete a test cookie.
bool | $delete | True if the cookie is to be deleted (optional, default is false) |
|
static |
Strip HTML tags from a string.
string | $html | HTML string to be stripped |
|
static |
URL encode a value.
string | null | $val | The value to be encoded |
|
static |
Convert a value to a boolean.
mixed | $val | The value to be converted |
|
static |
Convert a value to a numeric.
mixed | $val | The value to be converted |
|
static |
Convert a value to a string.
mixed | $val | The value to be converted |
string | null | $default | Value to return when a conversion is not possible (optional, default is an empty string) |
Referenced by ToolSettings\set(), and TimePeriod\toJsonldObject().
|
static |
List of supported message types and associated class methods.
const MESSAGE_TYPE_MAPPING |
Mapping for standard message types.
Referenced by System\hasJwt().