Class to implement utility methods. More...
Static Public Member Functions | |
| static | isLtiMessage () |
| Check whether the request received could be an LTI message. | |
| static | getRequestParameters () |
| Return GET and POST request parameters (POST parameters take precedence). | |
| static | logError ($message, $showSource=true) |
| Log an error message. | |
| static | logInfo ($message, $showSource=false) |
| Log an information message. | |
| static | logDebug ($message, $showSource=false) |
| Log a debug message. | |
| static | logRequest ($debugLevel=false) |
| Log a request received. | |
| static | logForm ($url, $params, $method='POST', $debugLevel=false) |
| Log a form submission. | |
| static | log ($message, $showSource=false) |
| Log an error message irrespective of the logging level. | |
| static | sendForm ($url, $params, $target='', $javascript='') |
| Generate a web page containing an auto-submitted form of parameters. | |
| static | redirect ($url, $params) |
| Redirect to a URL with query parameters. | |
| static | setTestCookie ($delete=false) |
| Set or delete a test cookie. | |
| static | getRandomString ($length=8) |
| Generate a random string. | |
| static | stripHtml ($html) |
| Strip HTML tags from a string. | |
| static | jsonDecode ($str, $associative=false) |
| Decode a JSON string. | |
| static | cloneObject ($obj) |
| Clone an object and any objects it contains. | |
Data Fields | |
| const | LTI_VERSION1 = 'LTI-1p0' |
| LTI version 1 for messages. | |
| const | LTI_VERSION1P3 = '1.3.0' |
| LTI version 1.3 for messages. | |
| const | LTI_VERSION2 = 'LTI-2p0' |
| LTI version 2 for messages. | |
| 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 | LOGLEVEL_NONE = 0 |
| No logging. | |
| const | LOGLEVEL_ERROR = 1 |
| Log errors only. | |
| const | LOGLEVEL_INFO = 2 |
| Log error and information messages. | |
| const | LOGLEVEL_DEBUG = 3 |
| Log all messages. | |
| const | TEST_COOKIE_NAME = 'celtic_lti_test_cookie' |
| Name of test cookie. | |
Static Public Attributes | |
| static | $LTI_VERSIONS = array(self::LTI_VERSION1, self::LTI_VERSION1P3, self::LTI_VERSION2) |
| Permitted LTI versions for messages. | |
| static | $METHOD_NAMES |
| List of supported message types and associated class methods. | |
| static | $requestParameters = null |
| GET and POST request parameters. | |
| static | $logLevel = self::LOGLEVEL_NONE |
| Current logging level. | |
| static | $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 |
Clone an object and any objects it contains.
| object | $obj | Object to be cloned |
Definition at line 578 of file Util.php.
References Util\cloneObject().
Referenced by Util\cloneObject().
|
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) |
Definition at line 523 of file Util.php.
Referenced by Tool\doToolProxyService(), DataConnector\getRandomString(), and ResourceLinkShareKey\save().
|
static |
Return GET and POST request parameters (POST parameters take precedence).
Definition at line 233 of file Util.php.
References Util\$requestParameters.
Referenced by Tool\getPlatformConfiguration(), Tool\handleRequest(), Platform\handleRequest(), and Tool\sendRegistration().
|
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 |
Definition at line 560 of file Util.php.
Referenced by System\doServiceRequest(), ToolSettings\get(), AccessToken\get(), System\getMessageClaims(), Tool\getPlatformConfiguration(), DataConnector_mysql\getPlatforms(), DataConnector_mysqli\getPlatforms(), DataConnector_oci\getPlatforms(), DataConnector_pdo\getPlatforms(), DataConnector_pg\getPlatforms(), DataConnector_sqlsrv\getPlatforms(), DataConnector_mysql\getTools(), DataConnector_mysqli\getTools(), DataConnector_oci\getTools(), DataConnector_pdo\getTools(), DataConnector_pg\getTools(), DataConnector_sqlsrv\getTools(), FirebaseClient\load(), SpomkyLabsClient\load(), WebTokenClient\load(), DataConnector_mysql\loadAccessToken(), DataConnector_mysqli\loadAccessToken(), DataConnector_oci\loadAccessToken(), DataConnector_pdo\loadAccessToken(), DataConnector_pg\loadAccessToken(), DataConnector_sqlsrv\loadAccessToken(), DataConnector_mysql\loadContext(), DataConnector_mysqli\loadContext(), DataConnector_oci\loadContext(), DataConnector_pdo\loadContext(), DataConnector_pg\loadContext(), DataConnector_sqlsrv\loadContext(), DataConnector_mysql\loadPlatform(), DataConnector_mysqli\loadPlatform(), DataConnector_oci\loadPlatform(), DataConnector_pdo\loadPlatform(), DataConnector_pg\loadPlatform(), DataConnector_sqlsrv\loadPlatform(), DataConnector_mysql\loadResourceLink(), DataConnector_mysqli\loadResourceLink(), DataConnector_oci\loadResourceLink(), DataConnector_pdo\loadResourceLink(), DataConnector_pg\loadResourceLink(), DataConnector_sqlsrv\loadResourceLink(), DataConnector_mysql\loadTool(), DataConnector_mysqli\loadTool(), DataConnector_oci\loadTool(), DataConnector_pdo\loadTool(), DataConnector_pg\loadTool(), DataConnector_sqlsrv\loadTool(), Service\send(), and Tool\sendRegistration().
|
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 |
Definition at line 348 of file Util.php.
Referenced by Util\logDebug(), Util\logError(), and Util\logInfo().
|
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 |
Definition at line 274 of file Util.php.
References Util\log().
Referenced by ApiToolConsumer\__construct(), ConsumerNonce\__construct(), ToolProvider\__construct(), DataConnector_mysql\__construct(), ContentItemPlacement\__construct(), ContentItemImage\__construct(), ToolConsumer\__construct(), CanvasApiToolProvider\__construct(), ApiToolProvider\__construct(), ContentItem\__construct(), HTTPMessage\__construct(), SpomkyLabsClient\__construct(), DataConnector\deleteConsumerNonce(), DataConnector\deleteToolConsumer(), ResourceLink\doMembershipsService(), DataConnector_pdo\executeQuery(), ResourceLink\fromConsumer(), Context\getConsumer(), ResourceLink\getConsumer(), Service\getConsumer(), ResourceLink\getConsumerId(), Tool\getConsumers(), HttpMessage\getHttpClient(), Jwt\getJwtClient(), Context\getMembership(), ResourceLink\getMembership(), DataConnector\getRandomString(), DataConnector\getToolConsumers(), Context\hasMembershipService(), ResourceLink\hasMembershipService(), DataConnector\loadConsumerNonce(), DataConnector\loadToolConsumer(), Util\logForm(), Util\logRequest(), DataConnector\saveConsumerNonce(), DataConnector\saveToolConsumer(), Tool\sendForm(), Context\setConsumerId(), ResourceLink\setConsumerId(), HttpMessage\setHttpClient(), and Jwt\setJwtClient().
|
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 |
Definition at line 248 of file Util.php.
References Util\log().
Referenced by DataConnector_pdo\executeQuery(), Tool\handleRequest(), Platform\handleRequest(), HttpMessage\send(), and DataConnector\useMemcache().
|
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) |
Definition at line 320 of file Util.php.
References Util\$logLevel, Util\logDebug(), Util\logInfo(), and Util\LOGLEVEL_DEBUG.
Referenced by Util\sendForm().
|
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 |
Definition at line 261 of file Util.php.
References Util\log().
Referenced by Util\logForm(), Util\logRequest(), and HttpMessage\send().
|
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) |
Definition at line 286 of file Util.php.
References Util\$logLevel, OAuthRequest\$POST_INPUT, Util\logDebug(), Util\logInfo(), Util\LOGLEVEL_DEBUG, and Util\LOGLEVEL_INFO.
Referenced by Tool\handleRequest(), and Platform\handleRequest().
|
static |
|
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) |
Definition at line 378 of file Util.php.
References Util\logForm().
Referenced by Tool\onAuthenticate(), Tool\sendForm(), and System\sendMessage().
|
static |
|
static |
|
static |
|
static |
Current logging level.
Definition at line 202 of file Util.php.
Referenced by DataConnector_pdo\executeQuery(), DataConnector\fixPlatformSettings(), DataConnector\fixToolSettings(), Tool\getMessageParameters(), Tool\handleRequest(), Platform\handleRequest(), Util\logForm(), Util\logRequest(), and HttpMessage\send().
|
static |
Permitted LTI versions for messages.
Definition at line 169 of file Util.php.
Referenced by System\checkMessage().
|
static |
List of supported message types and associated class methods.
|
static |
GET and POST request parameters.
Definition at line 195 of file Util.php.
Referenced by Util\getRequestParameters().
| const JWT_CLAIM_MAPPING |
Mapping for standard message parameters to JWT claim.
Definition at line 50 of file Util.php.
Referenced by System\getMessageClaims().
| const JWT_CLAIM_PREFIX = 'https://purl.imsglobal.org/spec/lti' |
Prefix for standard JWT message claims.
Definition at line 35 of file Util.php.
Referenced by System\getMessageClaims().
| const LOGLEVEL_DEBUG = 3 |
Log all messages.
Definition at line 159 of file Util.php.
Referenced by DataConnector_pdo\executeQuery(), DataConnector\fixPlatformSettings(), DataConnector\fixToolSettings(), Tool\getMessageParameters(), Tool\handleRequest(), Platform\handleRequest(), Util\logForm(), and Util\logRequest().
| const LOGLEVEL_ERROR = 1 |
Log errors only.
Definition at line 149 of file Util.php.
Referenced by DataConnector_pdo\executeQuery().
| const LOGLEVEL_INFO = 2 |
Log error and information messages.
Definition at line 154 of file Util.php.
Referenced by Util\logRequest().
| const LOGLEVEL_NONE = 0 |
| const LTI_VERSION1 = 'LTI-1p0' |
LTI version 1 for messages.
Definition at line 20 of file Util.php.
Referenced by System\parseRoles().
| const LTI_VERSION1P3 = '1.3.0' |
LTI version 1.3 for messages.
Definition at line 25 of file Util.php.
Referenced by Tool\getPlatformToRegister(), System\parseRoles(), System\signMessage(), and Item\toJson().
| const LTI_VERSION2 = 'LTI-2p0' |
LTI version 2 for messages.
Definition at line 30 of file Util.php.
Referenced by System\parseRoles().
| const MESSAGE_TYPE_MAPPING |
Mapping for standard message types.
Definition at line 40 of file Util.php.
Referenced by Tool\getConfiguration(), and System\getMessageClaims().
| const TEST_COOKIE_NAME = 'celtic_lti_test_cookie' |