LTI Integration Library 5.0.0-rc2
PHP class library for building LTI integrations
 
Loading...
Searching...
No Matches
Util Class Reference

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 ($message, $showSource=true)
 Log an error message.
 
static void logInfo ($message, $showSource=false)
 Log an information message.
 
static void logDebug ($message, $showSource=false)
 Log a debug message.
 
static void logRequest ($debugLevel=false)
 Log a request received.
 
static void logForm ($url, $params, $method='POST', $debugLevel=false)
 Log a form submission.
 
static void log ($message, $showSource=false)
 Log an error message irrespective of the logging level.
 
static string sendForm ($url, $params, $target='', $javascript='')
 Generate a web page containing an auto-submitted form of parameters.
 
static void redirect ($url, $params)
 Redirect to a URL with query parameters.
 
static void setTestCookie ($delete=false)
 Set or delete a test cookie.
 
static string getRandomString ($length=8)
 Generate a random string.
 
static string stripHtml ($html)
 Strip HTML tags from a string.
 
static object cloneObject ($obj)
 Clone an object and any objects it contains.
 

Public Attributes

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 int $logLevel = self::LOGLEVEL_NONE
 Current logging level.
 
static int $formSubmissionTimeout = 2
 Delay (in seconds) before a manual button is displayed in case a browser is blocking a form submission.
 

Detailed Description

Class to implement utility methods.

Author
Stephen P Vickers steph.nosp@m.en@s.nosp@m.pvsof.nosp@m.twar.nosp@m.eprod.nosp@m.ucts.nosp@m..com
Licence: http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3

Member Function Documentation

◆ cloneObject()

static object cloneObject (   $obj)
static

Clone an object and any objects it contains.

Parameters
object$objObject to be cloned
Returns
object

◆ getRandomString()

static string getRandomString (   $length = 8)
static

Generate a random string.

The generated string will only comprise letters (upper- and lower-case) and digits.

Parameters
int$lengthLength of string to be generated (optional, default is 8 characters)
Returns
string Random string

◆ getRequestParameters()

static array getRequestParameters ( )
static

Return GET and POST request parameters (POST parameters take precedence).

Returns
array

Referenced by Tool\getPlatformToRegister().

◆ isLtiMessage()

static bool isLtiMessage ( )
static

Check whether the request received could be an LTI message.

Returns
bool

◆ log()

static void log (   $message,
  $showSource = false 
)
static

Log an error message irrespective of the logging level.

Parameters
string$messageMessage to be logged
bool$showSourceTrue if the name and line number of the current file are to be included
Returns
void

◆ logDebug()

◆ logError()

static void logError (   $message,
  $showSource = true 
)
static

Log an error message.

Parameters
string$messageMessage to be logged
bool$showSourceTrue if the name and line number of the current file are to be included
Returns
void

Referenced by DataConnector_pdo\executeQuery(), and Platform\fromConsumerKey().

◆ logForm()

static void logForm (   $url,
  $params,
  $method = 'POST',
  $debugLevel = false 
)
static

Log a form submission.

Parameters
string$urlURL to which the form should be submitted
array$paramsArray of form parameters
string$methodHTTP Method used to submit form (optional, default is POST)
bool$debugLevelTrue if the form details should always be logged (optional, default is false to use current log level)
Returns
void

◆ logInfo()

static void logInfo (   $message,
  $showSource = false 
)
static

Log an information message.

Parameters
string$messageMessage to be logged
bool$showSourceTrue if the name and line number of the current file are to be included
Returns
void

◆ logRequest()

static void logRequest (   $debugLevel = false)
static

Log a request received.

Parameters
bool$debugLevelTrue if the request details should be logged at the debug level (optional, default is false for information level)
Returns
void

◆ redirect()

static void redirect (   $url,
  $params 
)
static

Redirect to a URL with query parameters.

Parameters
string$urlURL to which the form should be submitted
array$paramsArray of form parameters
Returns
void

◆ sendForm()

static string sendForm (   $url,
  $params,
  $target = '',
  $javascript = '' 
)
static

Generate a web page containing an auto-submitted form of parameters.

Parameters
string$urlURL to which the form should be submitted
array$paramsArray of form parameters
string$targetName of target (optional)
string$javascriptJavascript to be inserted (optional, default is to just auto-submit form)
Returns
string

◆ setTestCookie()

static void setTestCookie (   $delete = false)
static

Set or delete a test cookie.

Parameters
bool$deleteTrue if the cookie is to be deleted (optional, default is false)
Returns
void

◆ stripHtml()

static string stripHtml (   $html)
static

Strip HTML tags from a string.

Parameters
string$htmlHTML string to be stripped
Returns
string

Member Data Documentation

◆ $formSubmissionTimeout

int $formSubmissionTimeout = 2
static

Delay (in seconds) before a manual button is displayed in case a browser is blocking a form submission.

$formSubmissionTimeout

◆ $logLevel

int $logLevel = self::LOGLEVEL_NONE
static

Current logging level.

$logLevel

Referenced by DataConnector_pdo\executeQuery().

◆ $METHOD_NAMES

$METHOD_NAMES
static
Initial value:
= array(
'basic-lti-launch-request' => 'onLaunch',
'ConfigureLaunchRequest' => 'onConfigure',
'DashboardRequest' => 'onDashboard',
'ContentItemSelectionRequest' => 'onContentItem',
'ContentItemSelection' => 'onContentItem',
'ContentItemUpdateRequest' => 'onContentItemUpdate',
'LtiSubmissionReviewRequest' => 'onSubmissionReview',
'ToolProxyRegistrationRequest' => 'onRegister',
'LtiStartProctoring' => 'onLtiStartProctoring',
'LtiStartAssessment' => 'onLtiStartAssessment',
'LtiEndAssessment' => 'onLtiEndAssessment'
)

List of supported message types and associated class methods.

◆ MESSAGE_TYPE_MAPPING

const MESSAGE_TYPE_MAPPING
Initial value:
= array(
'basic-lti-launch-request' => 'LtiResourceLinkRequest',
'ContentItemSelectionRequest' => 'LtiDeepLinkingRequest',
'ContentItemSelection' => 'LtiDeepLinkingResponse',
'ContentItemUpdateRequest' => 'LtiDeepLinkingUpdateRequest'
)

Mapping for standard message types.


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