class Output

Traits

This is a trait convienence methods to access the session from the launch object

Properties

$launch A reference to our containing launch
$buffer

Methods

session_get($key, $default = null)

Get a key from the session

session_put($key, $value)

Set a key in the session

session_forget($key)

Forget a key in the session

session_flush()

Flush the session

ltiRawPostArray()

Return the original $_POST array

ltiParameter($varname, $default = false)

Pull a keyed variable from the original LTI post data in the current session with default

ltiParameterUpdate($varname, $value)

Update a keyed variable from the original LTI post data in the current session with default

ltiRawParameter($varname, $default = false)

Pull a keyed variable from the original LTI post data in the current session with default

ltiCustomGet($varname, $default = false)

Pull out a custom variable from the LTIX session. Do not include the "custom_" prefix - this is automatic.

static 
headerJson()

Set the JSON header

flashMessages()

No description

header()

Start the header material of a normal Tsugi Page

headerData()

Set the header variables for a Tsugi Page

bodyStart($checkpost = true)

Finish the head and start the body of a Tsugi HTML page.

false|string
splashPage($title, $msg, bool $link = false)

Outputs a splash page used if the tool is not configured or instructor has never been there before.

pageTitle($title, $show_help = false, $show_settings = false)

No description

modalString($title, $msg, $id)

No description

helpModal($help_title = "Help", $help_msg = '<em>No help for this page.</em>')

No description

helpButton()

No description

static 
templateInclude($name)

templateInclude - Include a handlebars template, dealing with i18n

static 
templateProcess($template)

templateProcess - Process a handlebars template, dealing with i18n

footerStart()

No description

static 
getUtilUrl($path)

getUtilUrl - Get a URL in the utility script space - does not add session

static 
handleHeartBeat($cookie)

Handle the heartbeat calls. This is UI code basically.

footerEnd()

No description

footer()

No description

doAnalytics()

No description

welcomeUserCourse()

Welcome the user to the course

exitButton($text = false)

Emit a properly styled done button for use in the launched frame/window

closeButton($text = false)

Emit a properly styled close button for use in own popup

togglePre($title, $html)

No description

togglePreScript()

No description

returnMenuSet($return_url)

No description

closeMenuSet()

No description

defaultMenuSet()

No description

setAppHeader($head)

Set header Content for any Tsugi-generated pages.

setAppFooter($foot)

Set footer Content for any Tsugi-generated pages.

topNavSession($menuset)

Store the top navigation in the session

topNav($tool_menu = false)

Emit the top navigation block and optionally the tool navigation

menuNav($set, $is_tool_menu = false)

No description

static 
embeddedMenu($url, $profile_email, $user_email)

The embedded menu - for now just one button.

dumpDebugArray($debug_log)

Dump a debug array with messages and optional detail

getSpinnerUrl()

Get a fully-qualified URL for the spinner.

getDefaultIcon()

Get a fully-qualified URL for the default icon image.

getScreenOverlay($show = true)

Return the text for a full-screen loader

embedYouTube($id, $title)

Embed a YouTube video using the standard pattern

static 
doRedirect($location)

Redirect to a local URL, adding session if necessary

static 
getLocalStatic()

Gets an absolute static path to the specified file

static 
noCacheHeader()

No description

static 
maxCacheHeader($max_age = 604800)

No description

static 
displaySize($size)

No description

static 
safe_var_cleanup($x, $depth)

No description

static 
safe_var_dump($x)

No description

static 
safe_print_r($x)

No description

static 
htmlError($message, $detail, $next = false)

No description

static 
jsonError($message, $detail = "")

No description

static 
jsonAuthError($message, $detail = "")

No description

static 
jsonOutput($json_data)

No description

static 
json_encode_string_value($json_string)

No description

static 
xmlError($message, $detail = "", $code = 400)

No description

static 
xmlAuthError($message, $detail = "")

No description

static 
xmlOutput($xml_data)

No description

static 
noBuffer()

No description

static 
get_theme()

Retrieves or generates a theme based on optional specs (base color, dark mode flag).

static 
adjust_theme($theme)

Adjust the theme from various places based on the following low-to-high precedence

static 
output_theme_css($theme)

No description

Details

in SessionTrait at line 17
session_get($key, $default = null)

Get a key from the session

Parameters

$key
$default

in SessionTrait at line 24
session_put($key, $value)

Set a key in the session

Parameters

$key
$value

in SessionTrait at line 31
session_forget($key)

Forget a key in the session

Parameters

$key

in SessionTrait at line 38
session_flush()

Flush the session

in SessionTrait at line 45
ltiRawPostArray()

Return the original $_POST array

in SessionTrait at line 53
ltiParameter($varname, $default = false)

Pull a keyed variable from the original LTI post data in the current session with default

Parameters

$varname
$default

in SessionTrait at line 61
ltiParameterUpdate($varname, $value)

Update a keyed variable from the original LTI post data in the current session with default

Parameters

$varname
$value

in SessionTrait at line 70
ltiRawParameter($varname, $default = false)

Pull a keyed variable from the original LTI post data in the current session with default

Parameters

$varname
$default

in SessionTrait at line 79
ltiCustomGet($varname, $default = false)

Pull out a custom variable from the LTIX session. Do not include the "custom_" prefix - this is automatic.

Parameters

$varname
$default

at line 71
static headerJson()

Set the JSON header

at line 76
flashMessages()

at line 122
header()

Start the header material of a normal Tsugi Page

This outputs everything but does not close the tag so the tool can add its own head material before calling bodyStart().

If this class is set to buffer, the output is returned in a string instead of being printed to the response.

at line 217
headerData()

Set the header variables for a Tsugi Page

If this class is set to buffer, the output is returned in a string instead of being printed to the response.

at line 285
bodyStart($checkpost = true)

Finish the head and start the body of a Tsugi HTML page.

By default this demands that we are in a GET request. It is a fatal error to call this code if we are responding to a POST request unless this behavior is overidden.

Parameters

$checkpost (optional, boolean) This can be set to false to emit the body start even for a POST request.

at line 340
false|string splashPage($title, $msg, bool $link = false)

Outputs a splash page used if the tool is not configured or instructor has never been there before.

Parameters

$title Title of the tool
$msg Content of splash page messag
bool $link Set to href if want user to be able to click button to go to home

Return Value

false|string

at line 363
pageTitle($title, $show_help = false, $show_settings = false)

Parameters

$title
$show_help
$show_settings

at line 380
modalString($title, $msg, $id)

Parameters

$title
$msg
$id

at line 401
helpModal($help_title = "Help", $help_msg = '<em>No help for this page.</em>')

Parameters

$help_title
$help_msg

at line 407
helpButton()

at line 418
static templateInclude($name)

templateInclude - Include a handlebars template, dealing with i18n

Deprecated - Moved to HandleBars

Parameters

$name

at line 427
static templateProcess($template)

templateProcess - Process a handlebars template, dealing with i18n

Deprecated - Moved to HandleBars

Parameters

$template

at line 431
footerStart()

at line 540
static getUtilUrl($path)

getUtilUrl - Get a URL in the utility script space - does not add session

Parameters

$path
  • The path of the file - should start with a slash.

at line 575
static handleHeartBeat($cookie)

Handle the heartbeat calls. This is UI code basically.

Make sure when you call this, you have handled whether the session is cookie based or not and included config.php appropriately

if ( isset($_GET[session_name()]) ) { $cookie = false; } else { define('COOKIE_SESSION', true); $cookie = true; }

require_once "../config.php";

\Tsugi\UI\Output::handleHeartBeat($cookie);

Parameters

$cookie

at line 618
footerEnd()

at line 637
doAnalytics()

at line 656
welcomeUserCourse()

Welcome the user to the course

at line 692
exitButton($text = false)

Emit a properly styled done button for use in the launched frame/window

This is a bit tricky because custom settings can control the "Done" behavior. These settings can come from one of three places: (1) in the link settings, (2) from a custom parameter named 'done', or (3) from a GET parameter done=

The value for this is a URL, "_close", or "_return".

TODO: Implement _return

Parameters

$text

at line 718
closeButton($text = false)

Emit a properly styled close button for use in own popup

Parameters

$text

at line 725
togglePre($title, $html)

Parameters

$title
$html

at line 738
togglePreScript()

at line 752
returnMenuSet($return_url)

Parameters

$return_url

at line 760
closeMenuSet()

at line 768
defaultMenuSet()

at line 810
setAppHeader($head)

Set header Content for any Tsugi-generated pages.

Parameters

$head

at line 819
setAppFooter($foot)

Set footer Content for any Tsugi-generated pages.

Parameters

$foot

at line 828
topNavSession($menuset)

Store the top navigation in the session

Parameters

$menuset

at line 844
topNav($tool_menu = false)

Emit the top navigation block and optionally the tool navigation

Priority order: (1) Navigation in the session (2) If we are launched via LTI w/o a session

Parameters

$tool_menu

at line 969
menuNav($set, $is_tool_menu = false)

Parameters

$set
$is_tool_menu

at line 1035
static embeddedMenu($url, $profile_email, $user_email)

The embedded menu - for now just one button.

..

Parameters

$url
$profile_email
$user_email

at line 1089
dumpDebugArray($debug_log)

Dump a debug array with messages and optional detail

This kind of debug array comes back from some of the grade calls. We loop through printing the messages and put the detail into a togglable pre tag is present.

Parameters

$debug_log

at line 1110
getSpinnerUrl()

Get a fully-qualified URL for the spinner.

at line 1118
getDefaultIcon()

Get a fully-qualified URL for the default icon image.

at line 1133
getScreenOverlay($show = true)

Return the text for a full-screen loader

echo($OUTPUT->getScreenOverlay(false)); ...

Parameters

$show

at line 1146
embedYouTube($id, $title)

Embed a YouTube video using the standard pattern

Parameters

$id
$title

at line 1162
static doRedirect($location)

Redirect to a local URL, adding session if necessary

Note that this is only needed for AJAX and header() calls as <form> and <a href tags are properly handled already by the PHP built-in "don't use cookies for session" support.

Parameters

$location

at line 1182
static getLocalStatic()

Gets an absolute static path to the specified file

at line 1188
static noCacheHeader()

at line 1194
static maxCacheHeader($max_age = 604800)

Parameters

$max_age

at line 1198
static displaySize($size)

Parameters

$size

at line 1203
static safe_var_cleanup($x, $depth)

Parameters

$x
$depth

at line 1219
static safe_var_dump($x)

Parameters

$x

at line 1227
static safe_print_r($x)

Parameters

$x

at line 1235
static htmlError($message, $detail, $next = false)

Parameters

$message
$detail
$next

at line 1294
static jsonError($message, $detail = "")

Parameters

$message
$detail

at line 1300
static jsonAuthError($message, $detail = "")

Parameters

$message
$detail

at line 1306
static jsonOutput($json_data)

Parameters

$json_data

at line 1312
static json_encode_string_value($json_string)

Parameters

$json_string

at line 1316
static xmlError($message, $detail = "", $code = 400)

Parameters

$message
$detail
$code

at line 1331
static xmlAuthError($message, $detail = "")

Parameters

$message
$detail

at line 1335
static xmlOutput($xml_data)

Parameters

$xml_data

at line 1341
static noBuffer()

at line 1351
static get_theme()

Retrieves or generates a theme based on optional specs (base color, dark mode flag).

$TSUGI_LAUNCH theme data is provided, it will override the $CFG data. Otherwise, $CFG theme data will be used (either a theme_base or legacy theme data) If $CFG and $TSUGI_LAUNCH theme data aren't provided, regular defaults will be used.

at line 1454
static adjust_theme($theme)

Adjust the theme from various places based on the following low-to-high precedence

(4) From a Key Setting (3) From a Context Setting (2) From a Link Setting (1) From a custom launch variable prefixed by "tsugi_theme_"

Parameters

$theme

at line 1461
static output_theme_css($theme)

Parameters

$theme