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 string | checkUrl (object $obj, string $fullname, bool $required=false) |
Get the named filly-qualified URL 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 |
References checkString().
Referenced by checkObject(), and ceLTIc\LTI\Service\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 ceLTIc\LTI\Service\Groups\get(), ceLTIc\LTI\Service\LineItem\get(), and ceLTIc\LTI\Content\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 ceLTIc\LTI\Service\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 checkNumber(), and ceLTIc\LTI\Content\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 |
References checkInteger().
Referenced by ceLTIc\LTI\Service\LineItem\get(), and ceLTIc\LTI\Content\LineItem\toJsonObject().
|
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 |
References checkArray().
|
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 | null | $notEmpty | True if the element must not have an empty value (use null to issue a warning message when it does) |
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 checkArray(), ceLTIc\LTI\Service\Groups\get(), ceLTIc\LTI\Service\LineItem\get(), and ceLTIc\LTI\Content\LineItem\toJsonObject().
|
static |
Get the named filly-qualified URL 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 ceLTIc\LTI\Content\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) |
Referenced by ceLTIc\LTI\ResourceLinkShareKey\__construct(), and ceLTIc\LTI\Tool\findService().
|
static |
Return GET and POST request parameters (POST parameters take precedence).
References log(), and logDebug().
Referenced by ceLTIc\LTI\Tool\getMessageParameters(), and ceLTIc\LTI\Platform\getTools().
|
static |
|
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 ceLTIc\LTI\DataConnector\DataConnector_mysqli\deletePlatformNonce(), ceLTIc\LTI\DataConnector\DataConnector_sql\deletePlatformNonce(), ceLTIc\LTI\DataConnector\DataConnector_oci8\deleteTool(), ceLTIc\LTI\DataConnector\DataConnector_pdo\deleteTool(), ceLTIc\LTI\Jwt\FirebaseClient\getJWKS(), ceLTIc\LTI\Jwt\WebTokenClient\getLastPayload(), ceLTIc\LTI\Jwt\FirebaseClient\getPayload(), ceLTIc\LTI\DataConnector\DataConnector_oci8\getTools(), ceLTIc\LTI\ApiHook\canvas\CanvasApi\isConfigured(), ceLTIc\LTI\DataConnector\DataConnector_mysqli\loadResourceLink(), ceLTIc\LTI\DataConnector\DataConnector_pgsql\loadResourceLink(), ceLTIc\LTI\DataConnector\DataConnector_sql\loadResourceLink(), ceLTIc\LTI\DataConnector\DataConnector_oci8\loadTool(), ceLTIc\LTI\System\sendMessage(), and ceLTIc\LTI\Jwt\WebTokenClient\verifySignature().
|
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 getRequestParameters(), and 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 |
References logInfo().
Referenced by ceLTIc\LTI\Http\HttpMessage\__construct(), ceLTIc\LTI\Service\LineItem\deleteLineItem(), ceLTIc\LTI\Jwt\FirebaseClient\getClaim(), ceLTIc\LTI\Jwt\WebTokenClient\getClaim(), getRequestParameters(), logError(), and 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 |
References ceLTIc\LTI\OAuth\OAuthRequest\$POST_INPUT, logDebug(), logInfo(), and ceLTIc\LTI\OAuth\OAuthUtil\parse_parameters().
Referenced by ceLTIc\LTI\Jwt\FirebaseClient\verify().
|
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 isLtiMessage(), logDebug(), and logError().
|
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 logDebug().
Referenced by ceLTIc\LTI\Tool\getMessageParameters().
|
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) |
Referenced by ceLTIc\LTI\Tool\onLtiEndAssessment().
|
static |
Set an error or warning message.
bool | $isError | True if the message represents an error |
string | $message | Message |
Referenced by ceLTIc\LTI\Service\Groups\get(), ceLTIc\LTI\Service\ToolSettings\set(), and valToNumber().
|
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 |
References setMessage().
|
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 ceLTIc\LTI\Service\ToolSettings\set(), and ceLTIc\LTI\Content\TimePeriod\toJsonldObject().
|
static |
Whether the automatic saving of fetched valid public keys should be disabled.
|
static |
Delay (in seconds) before a manual button is displayed in case a browser is blocking a form submission.
|
static |
|
static |
List of supported message types and associated class methods.
|
static |
GET and POST request parameters.
|
static |
Whether full compliance with the LTI specification is required.
Referenced by ceLTIc\LTI\Tool\getMessageParameters(), ceLTIc\LTI\Service\ToolSettings\set(), ceLTIc\LTI\Content\TimePeriod\toJsonldObject(), and ceLTIc\LTI\Content\Image\toJsonObject().
const ceLTIc\LTI\Util::JWT_CLAIM_MAPPING |
Mapping for standard message parameters to JWT claim.
const ceLTIc\LTI\Util::JWT_CLAIM_PREFIX = 'https://purl.imsglobal.org/spec/lti' |
Prefix for standard JWT message claims.
const ceLTIc\LTI\Util::MESSAGE_TYPE_MAPPING |
Mapping for standard message types.
Referenced by ceLTIc\LTI\System\hasJwt().
const ceLTIc\LTI\Util::TEST_COOKIE_NAME = 'celtic_lti_test_cookie' |
Name of test cookie.