Tsugi

Output
in package
uses SessionTrait

Table of Contents

Constants

FLASH_ERROR  : mixed = 'error'
Session key for error flash messages (must match U::FLASH_ERROR)
FLASH_SUCCESS  : mixed = 'success'
Session key for success flash messages (must match U::FLASH_SUCCESS)
SUPPRESS_SITE_NAV  : mixed = 'TSUGI_OUTPUT_SUPPRESS_SITE_NAV'

Properties

$buffer  : mixed
$launch  : mixed
A reference to our containing launch
$menuOverride  : MenuSet|false
When set, topNav() renders this menu and skips the course and site menus.

Methods

adjust_theme()  : mixed
Adjust the theme from various places based on the following low-to-high precedence
avatarMenuTrigger()  : mixed
Avatar (or fallback image) used as the logged-in account dropdown trigger.
bodyStart()  : mixed
Finish the head and start the body of a Tsugi HTML page.
clearTopNavSession()  : mixed
Drop cached top-nav exports (e.g. after login/logout).
closeButton()  : mixed
Emit a properly styled close button for use in own popup
closeMenuSet()  : mixed
defaultMenuSet()  : mixed
displaySize()  : mixed
doRedirect()  : mixed
Redirect to a local URL, adding session if necessary
dumpDebugArray()  : mixed
Dump a debug array with messages and optional detail
embedYouTube()  : mixed
Embed a YouTube video using the standard pattern
enableSiteNav()  : mixed
exitButton()  : mixed
Emit a properly styled done button for use in the launched frame/window
flashMessages()  : mixed
footer()  : mixed
footerEnd()  : mixed
footerScriptLinks()  : mixed
Return script tags for jQuery, Bootstrap, jQuery UI, timeago, handlebars, tmpl, tsugiscripts.
footerStart()  : mixed
get_theme()  : mixed
Retrieves or generates a theme based on optional specs (base color, dark mode flag).
getDefaultIcon()  : mixed
Get a fully-qualified URL for the default icon image.
getFontAwesomeLinks()  : mixed
Return FontAwesome stylesheet link(s). FontAwesome 5 uses all.css + v4-shims; older versions use font-awesome.min.css.
getLocalStatic()  : mixed
Gets an absolute static path to the specified file
getScreenOverlay()  : mixed
Return the text for a full-screen loader
getSpinnerUrl()  : mixed
Get a fully-qualified URL for the spinner.
getThemeCss()  : mixed
getUtilUrl()  : mixed
getUtilUrl - Get a URL in the utility script space - does not add session
handleHeartBeat()  : mixed
Handle the heartbeat calls. This is UI code basically.
header()  : mixed
Start the header material of a normal Tsugi Page
headerCss()  : mixed
Return all shared stylesheet links and inline CSS for the page header.
headerData()  : mixed
Set the header variables for a Tsugi Page
headerJson()  : mixed
Set the JSON header
headerStart()  : mixed
Return doctype, html, head opening, meta, title, tsugiscripts_head.
helpButton()  : mixed
helpModal()  : mixed
htmlError()  : mixed
Display an HTML error dialog. Redirect destination is determined client-side from TSUGI_browser_session() (TSUGI_SESSION_DATA) when available: (a) launch_presentation_error_return_url, (b) launch_presentation_return_url, (c) $CFG->launcherror if configured. No return URL: dialog with no button.
json_encode_string_value()  : mixed
jsonAuthError()  : mixed
jsonError()  : mixed
jsonOutput()  : mixed
ltiCustomGet()  : mixed
Pull out a custom variable from the LTIX session. Do not include the "custom_" prefix - this is automatic.
ltiParameter()  : mixed
Pull a keyed variable from the original LTI post data in the current session with default
ltiParameterUpdate()  : mixed
Update a keyed variable from the original LTI post data in the current session with default
ltiRawParameter()  : mixed
Pull a keyed variable from the original LTI post data in the current session with default
ltiRawPostArray()  : mixed
Return the original $_POST array
maxCacheHeader()  : mixed
menuNav()  : mixed
modalString()  : mixed
navbarAlignCss()  : mixed
Desktop vertical centering for the main nav.
noBuffer()  : mixed
noCacheHeader()  : mixed
output_theme_css()  : mixed
pageTitle()  : mixed
returnMenuSet()  : mixed
safe_print_r()  : mixed
safe_var_cleanup()  : mixed
safe_var_dump()  : mixed
setAppFooter()  : mixed
Set footer Content for any Tsugi-generated pages.
setAppHeader()  : mixed
Set header Content for any Tsugi-generated pages.
splashPage()  : false|string
Outputs a splash page used if the tool is not configured or instructor has never been there before.
suppressSiteNav()  : mixed
templateInclude()  : mixed
templateInclude - Include a handlebars template, dealing with i18n
templateProcess()  : mixed
templateProcess - Process a handlebars template, dealing with i18n
themeDefaultsPreservingFont()  : array<string, mixed>
Theme::defaults() rebuilds the array and drops extras such as font-url.
togglePre()  : mixed
togglePreScript()  : mixed
topNav()  : mixed
Emit the top navigation block and optionally the tool navigation
topNavSession()  : mixed
Store the top navigation in the session
welcomeUserCourse()  : mixed
Welcome the user to the course
xmlAuthError()  : mixed
xmlError()  : mixed
xmlOutput()  : mixed
dropSiteLessonsEntries()  : array<string|int, mixed>
dropSiteLessonsFromMenuSet()  : mixed
Site chrome shows Lessons only when hasSiteLessons() is true (lessons path plus a Google-wide context_title).
extractLiClassesFromNavAttr()  : mixed
Pull data-tsugi-li-class="a b" off the anchor attribute string (not rendered on &lt;a&gt;) and return a sanitized class list for the parent &lt;li&gt;.
isSiteLessonsNavEntry()  : mixed
recurseNav()  : mixed

Constants

FLASH_ERROR

Session key for error flash messages (must match U::FLASH_ERROR)

public mixed FLASH_ERROR = 'error'

FLASH_SUCCESS

Session key for success flash messages (must match U::FLASH_SUCCESS)

public mixed FLASH_SUCCESS = 'success'

SUPPRESS_SITE_NAV

public mixed SUPPRESS_SITE_NAV = 'TSUGI_OUTPUT_SUPPRESS_SITE_NAV'

Properties

$buffer

public mixed $buffer = false

$launch

A reference to our containing launch

public mixed $launch

$menuOverride

When set, topNav() renders this menu and skips the course and site menus.

public MenuSet|false $menuOverride = false

Methods

adjust_theme()

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

public static adjust_theme(mixed &$theme) : mixed

(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 : mixed

avatarMenuTrigger()

Avatar (or fallback image) used as the logged-in account dropdown trigger.

public static avatarMenuTrigger() : mixed

Matches the dj4e/buildmenu.php img trigger, with equal width/height so border-radius: 50% is a circle. referrerpolicy is required for Google user-content photos, which otherwise often 403 and render as a blank oval.

bodyStart()

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

public bodyStart([mixed $checkpost = true ]) : mixed

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 : mixed = true

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

clearTopNavSession()

Drop cached top-nav exports (e.g. after login/logout).

public static clearTopNavSession() : mixed

closeButton()

Emit a properly styled close button for use in own popup

public closeButton([mixed $text = false ]) : mixed
Parameters
$text : mixed = false

closeMenuSet()

public closeMenuSet() : mixed

defaultMenuSet()

public defaultMenuSet() : mixed

displaySize()

public static displaySize(mixed $size) : mixed
Parameters
$size : mixed

doRedirect()

Redirect to a local URL, adding session if necessary

public static doRedirect(mixed $location) : mixed

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 : mixed

dumpDebugArray()

Dump a debug array with messages and optional detail

public dumpDebugArray(mixed $debug_log) : mixed

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 : mixed

embedYouTube()

Embed a YouTube video using the standard pattern

public embedYouTube(mixed $id, mixed $title) : mixed
Parameters
$id : mixed
$title : mixed

enableSiteNav()

public enableSiteNav() : mixed

exitButton()

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

public exitButton([mixed $text = false ]) : mixed

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 : mixed = false

flashMessages()

public flashMessages() : mixed
public footer() : mixed

footerEnd()

public footerEnd() : mixed

Return script tags for jQuery, Bootstrap, jQuery UI, timeago, handlebars, tmpl, tsugiscripts.

public static footerScriptLinks() : mixed

Used by footerStart() and htmlError().

footerStart()

public footerStart() : mixed

get_theme()

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

public static get_theme() : mixed

$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.

getDefaultIcon()

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

public getDefaultIcon() : mixed

Return FontAwesome stylesheet link(s). FontAwesome 5 uses all.css + v4-shims; older versions use font-awesome.min.css.

public static getFontAwesomeLinks() : mixed

getLocalStatic()

Gets an absolute static path to the specified file

public static getLocalStatic() : mixed

getScreenOverlay()

Return the text for a full-screen loader

public getScreenOverlay([mixed $show = true ]) : mixed

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

<script> showOverlay(); setTimeout(function() { hideOverlay();} , 5000); </script>
Parameters
$show : mixed = true

getSpinnerUrl()

Get a fully-qualified URL for the spinner.

public getSpinnerUrl() : mixed

getThemeCss()

public static getThemeCss(mixed $theme) : mixed
Parameters
$theme : mixed

getUtilUrl()

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

public static getUtilUrl(mixed $path) : mixed
Parameters
$path : mixed
  • The path of the file - should start with a slash.

handleHeartBeat()

Handle the heartbeat calls. This is UI code basically.

public static handleHeartBeat(mixed $cookie) : mixed

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 : mixed

header()

Start the header material of a normal Tsugi Page

public header() : mixed

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.

headerCss()

Return all shared stylesheet links and inline CSS for the page header.

public static headerCss() : mixed

Used by header() and htmlError().

headerData()

Set the header variables for a Tsugi Page

public headerData() : mixed

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

headerJson()

Set the JSON header

public static headerJson() : mixed

headerStart()

Return doctype, html, head opening, meta, title, tsugiscripts_head.

public static headerStart() : mixed

Callers add headerData (if applicable), headerCss, then close head. Used by header() and htmlError().

helpButton()

public helpButton() : mixed

helpModal()

public helpModal([mixed $help_title = "Help" ][, mixed $help_msg = 'No help for this page.' ]) : mixed
Parameters
$help_title : mixed = "Help"
$help_msg : mixed = 'No help for this page.'

htmlError()

Display an HTML error dialog. Redirect destination is determined client-side from TSUGI_browser_session() (TSUGI_SESSION_DATA) when available: (a) launch_presentation_error_return_url, (b) launch_presentation_return_url, (c) $CFG->launcherror if configured. No return URL: dialog with no button.

public static htmlError(string $message, string $msg[, string|false $extra = false ]) : mixed
Parameters
$message : string

Dialog title

$msg : string

Error message (displayed as "Detail: ...", used in URL params)

$extra : string|false = false

Optional extra detail for URL params (trimmed, max 200 chars)

json_encode_string_value()

public static json_encode_string_value(mixed $json_string) : mixed
Parameters
$json_string : mixed

jsonAuthError()

public static jsonAuthError(mixed $message[, mixed $detail = "" ]) : mixed
Parameters
$message : mixed
$detail : mixed = ""

jsonError()

public static jsonError(mixed $message[, mixed $detail = "" ]) : mixed
Parameters
$message : mixed
$detail : mixed = ""

jsonOutput()

public static jsonOutput(mixed $json_data) : mixed
Parameters
$json_data : mixed

ltiCustomGet()

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

public ltiCustomGet(mixed $varname[, mixed $default = false ]) : mixed
Parameters
$varname : mixed
$default : mixed = false

ltiParameter()

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

public ltiParameter(mixed $varname[, mixed $default = false ]) : mixed
Parameters
$varname : mixed
$default : mixed = false

ltiParameterUpdate()

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

public ltiParameterUpdate(mixed $varname, mixed $value) : mixed
Parameters
$varname : mixed
$value : mixed

ltiRawParameter()

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

public ltiRawParameter(mixed $varname[, mixed $default = false ]) : mixed
Parameters
$varname : mixed
$default : mixed = false

ltiRawPostArray()

Return the original $_POST array

public ltiRawPostArray() : mixed

maxCacheHeader()

public static maxCacheHeader([mixed $max_age = 604800 ]) : mixed
Parameters
$max_age : mixed = 604800

menuNav()

public menuNav(mixed $set[, mixed $is_tool_menu = false ]) : mixed
Parameters
$set : mixed
$is_tool_menu : mixed = false

modalString()

public modalString(mixed $title, mixed $msg, mixed $id) : mixed
Parameters
$title : mixed
$msg : mixed
$id : mixed

navbarAlignCss()

Desktop vertical centering for the main nav.

public static navbarAlignCss() : mixed

tsugi2.css already flex-centers the right cluster (avatar + widgets). Course nav also puts widgets in navbar-main, and often has only Home plus the avatar. Those two layouts were top-aligned against a taller right cluster. Do not apply this under 768px — the hamburger row already lines up.

noBuffer()

public static noBuffer() : mixed

noCacheHeader()

public static noCacheHeader() : mixed

output_theme_css()

public static output_theme_css(mixed $theme) : mixed
Parameters
$theme : mixed

pageTitle()

public pageTitle(mixed $title[, mixed $show_help = false ][, mixed $show_settings = false ]) : mixed
Parameters
$title : mixed
$show_help : mixed = false
$show_settings : mixed = false

returnMenuSet()

public returnMenuSet(mixed $return_url) : mixed
Parameters
$return_url : mixed

safe_print_r()

public static safe_print_r(mixed $x) : mixed
Parameters
$x : mixed

safe_var_cleanup()

public static safe_var_cleanup(mixed &$x, mixed $depth) : mixed
Parameters
$x : mixed
$depth : mixed

safe_var_dump()

public static safe_var_dump(mixed $x) : mixed
Parameters
$x : mixed

setAppFooter()

Set footer Content for any Tsugi-generated pages.

public setAppFooter(mixed $foot) : mixed
Parameters
$foot : mixed

setAppHeader()

Set header Content for any Tsugi-generated pages.

public setAppHeader(mixed $head) : mixed
Parameters
$head : mixed

splashPage()

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

public splashPage(mixed $title, mixed $msg[, bool $link = false ]) : false|string
Parameters
$title : mixed

Title of the tool

$msg : mixed

Content of splash page messag

$link : bool = false

Set to href if want user to be able to click button to go to home

Return values
false|string

suppressSiteNav()

public suppressSiteNav() : mixed

templateInclude()

templateInclude - Include a handlebars template, dealing with i18n

public static templateInclude(mixed $name) : mixed

Deprecated - Moved to HandleBars

Parameters
$name : mixed

templateProcess()

templateProcess - Process a handlebars template, dealing with i18n

public static templateProcess(mixed $template) : mixed

Deprecated - Moved to HandleBars

Parameters
$template : mixed

themeDefaultsPreservingFont()

Theme::defaults() rebuilds the array and drops extras such as font-url.

public static themeDefaultsPreservingFont(array<string, mixed> $theme) : array<string, mixed>
Parameters
$theme : array<string, mixed>
Return values
array<string, mixed>

togglePre()

public togglePre(mixed $title, mixed $html) : mixed
Parameters
$title : mixed
$html : mixed

togglePreScript()

public togglePreScript() : mixed

topNav()

Emit the top navigation block and optionally the tool navigation

public topNav([mixed $tool_menu = false ]) : mixed

On /courses/{id}/… the menu is the course manifest navigation, never $CFG->top_menu_callback / buildmenu.php.

Priority order on cookie-session pages (admin, login, site): (1) $CFG->top_menu_callback when set (site-owned menu builder) (2) $CFG->defaultmenu when set (3) Navigation stored via $OUTPUT->topNavSession() (legacy site nav.php pattern) (4) defaultMenuSet()

On LTI tool pages: (1) Navigation cached in the session (LTI / tool continuity) (2) LTI launch-specific fallbacks

Parameters
$tool_menu : mixed = false

topNavSession()

Store the top navigation in the session

public topNavSession(mixed $menuset) : mixed
Parameters
$menuset : mixed

welcomeUserCourse()

Welcome the user to the course

public welcomeUserCourse() : mixed

xmlAuthError()

public static xmlAuthError(mixed $message[, mixed $detail = "" ]) : mixed
Parameters
$message : mixed
$detail : mixed = ""

xmlError()

public static xmlError(mixed $message[, mixed $detail = "" ][, mixed $code = 400 ]) : mixed
Parameters
$message : mixed
$detail : mixed = ""
$code : mixed = 400

xmlOutput()

public static xmlOutput(mixed $xml_data) : mixed
Parameters
$xml_data : mixed

dropSiteLessonsEntries()

private dropSiteLessonsEntries(mixed $entries) : array<string|int, mixed>
Parameters
$entries : mixed
Return values
array<string|int, mixed>

dropSiteLessonsFromMenuSet()

Site chrome shows Lessons only when hasSiteLessons() is true (lessons path plus a Google-wide context_title).

private dropSiteLessonsFromMenuSet(mixed $menu_set) : mixed

Course-mounted /courses/{id}/ navigation is left unchanged.

Parameters
$menu_set : mixed

extractLiClassesFromNavAttr()

Pull data-tsugi-li-class="a b" off the anchor attribute string (not rendered on &lt;a&gt;) and return a sanitized class list for the parent &lt;li&gt;.

private extractLiClassesFromNavAttr(mixed &$attr_str) : mixed
Parameters
$attr_str : mixed

isSiteLessonsNavEntry()

private isSiteLessonsNavEntry(mixed $entry) : mixed
Parameters
$entry : mixed

recurseNav()

private recurseNav(mixed $entry, mixed $depth[, mixed $is_tool_nav = false ]) : mixed
Parameters
$entry : mixed
$depth : mixed
$is_tool_nav : mixed = false

        
On this page

Search results