src/UI/Output.php
function topNav($menu_set=false) {
        global $CFG, $LAUNCH;
        $sess_key = 'tsugi_top_nav_'.$CFG->wwwroot;
        $launch_return_url = $LAUNCH->ltiRawParameter('launch_presentation_return_url', false);

        $same_host = false;
        if ( $CFG->apphome && startsWith($launch_return_url, $CFG->apphome) ) $same_host = true;
        if ( $CFG->wwwroot && startsWith($launch_return_url, $CFG->wwwroot) ) $same_host = true;

        // Canvas bug: launch_target is iframe even in new window (2017-01-10)
        $launch_target = LTIX::ltiRawParameter('launch_presentation_document_target', false);
        if ( $menu_set === false && $this->session_get($sess_key) ) {
            $menu_set = \Tsugi\UI\MenuSet::import($this->session_get($sess_key));
        } else if ( $menu_set === true ) {
            $menu_set = self::defaultMenuSet();
        } else if ( $same_host && $launch_return_url ) {
            // If we are in an iframe we will be hidden
            $menu_set = self::returnMenuSet($launch_return_url);
        } else if ( $launch_target !== false && strtolower($launch_target) == 'window' ) {
            $menu_set = self::closeMenuSet();
        // Since Coursers sets precious little
        } else if ( $LAUNCH->isCoursera() ) {
            $menu_set = self::closeMenuSet();
        // Since canvas does not set launch_target properly
        } else if ( $launch_target !== false && ( $LAUNCH->isCanvas() || $LAUNCH->isCoursera() ) ) {
            $menu_set = self::closeMenuSet();
        } else if ( $launch_return_url !== false ) {
            $menu_set = self::returnMenuSet($launch_return_url);
        }

        // Always put something out if we are an outer page - in an iframe, it will be hidden
        if ( $menu_set === false && defined('COOKIE_SESSION') ) {
            $menu_set = self::defaultMenuSet();
        }

        if ( $menu_set === false ) {
            $menu_set = self::closeMenuSet();
        }

        $menu_txt = self::menuNav($menu_set);
        if ( $this->buffer ) return $menu_txt;
        echo($menu_txt);
    }
function topNav($menu_set=false) {
        global $CFG, $LAUNCH;
        $sess_key = 'tsugi_top_nav_'.$CFG->wwwroot;
        $launch_return_url = $LAUNCH->ltiRawParameter('launch_presentation_return_url', false);

        $same_host = false;
        if ( $CFG->apphome && startsWith($launch_return_url, $CFG->apphome) ) $same_host = true;
        if ( $CFG->wwwroot && startsWith($launch_return_url, $CFG->wwwroot) ) $same_host = true;

        // Canvas bug: launch_target is iframe even in new window (2017-01-10)
        $launch_target = LTIX::ltiRawParameter('launch_presentation_document_target', false);
        if ( $menu_set === false && $this->session_get($sess_key) ) {
            $menu_set = \Tsugi\UI\MenuSet::import($this->session_get($sess_key));
        } else if ( $menu_set === true ) {
            $menu_set = self::defaultMenuSet();
        } else if ( $same_host && $launch_return_url ) {
            // If we are in an iframe we will be hidden
            $menu_set = self::returnMenuSet($launch_return_url);
        } else if ( $launch_target !== false && strtolower($launch_target) == 'window' ) {
            $menu_set = self::closeMenuSet();
        // Since Coursers sets precious little
        } else if ( $LAUNCH->isCoursera() ) {
            $menu_set = self::closeMenuSet();
        // Since canvas does not set launch_target properly
        } else if ( $launch_target !== false && ( $LAUNCH->isCanvas() || $LAUNCH->isCoursera() ) ) {
            $menu_set = self::closeMenuSet();
        } else if ( $launch_return_url !== false ) {
            $menu_set = self::returnMenuSet($launch_return_url);
        }

        // Always put something out if we are an outer page - in an iframe, it will be hidden
        if ( $menu_set === false && defined('COOKIE_SESSION') ) {
            $menu_set = self::defaultMenuSet();
        }

        if ( $menu_set === false ) {
            $menu_set = self::closeMenuSet();
        }

        $menu_txt = self::menuNav($menu_set);
        if ( $this->buffer ) return $menu_txt;
        echo($menu_txt);
    }
function topNav ( $ menu_set = false ) { global $ CFG , $ LAUNCH ; $ sess_key = 'tsugi_top_nav_' . $ CFG -> wwwroot ; $ launch_return_url = $ LAUNCH -> ltiRawParameter ( 'launch_presentation_return_url' , false ) ; $ same_host = false ; if ( $ CFG -> apphome && startsWith ( $ launch_return_url , $ CFG -> apphome ) ) $ same_host = true ; if ( $ CFG -> wwwroot && startsWith ( $ launch_return_url , $ CFG -> wwwroot ) ) $ same_host = true ; // Canvas bug: launch_target is iframe even in new window (2017-01-10) $ launch_target = LTIX :: ltiRawParameter ( 'launch_presentation_document_target' , false ) ; if ( $ menu_set === false && $ this -> session_get ( $ sess_key ) ) { $ menu_set = \ Tsugi \ UI \ MenuSet :: import ( $ this -> session_get ( $ sess_key ) ) ; } else if ( $ menu_set === true ) { $ menu_set = self :: defaultMenuSet ( ) ; } else if ( $ same_host && $ launch_return_url ) { // If we are in an iframe we will be hidden $ menu_set = self :: returnMenuSet ( $ launch_return_url ) ; } else if ( $ launch_target !== false && strtolower ( $ launch_target ) == 'window' ) { $ menu_set = self :: closeMenuSet ( ) ; // Since Coursers sets precious little } else if ( $ LAUNCH -> isCoursera ( ) ) { $ menu_set = self :: closeMenuSet ( ) ; // Since canvas does not set launch_target properly } else if ( $ launch_target !== false && ( $ LAUNCH -> isCanvas ( ) || $ LAUNCH -> isCoursera ( ) ) ) { $ menu_set = self :: closeMenuSet ( ) ; } else if ( $ launch_return_url !== false ) { $ menu_set = self :: returnMenuSet ( $ launch_return_url ) ; } // Always put something out if we are an outer page - in an iframe, it will be hidden if ( $ menu_set === false && defined ( 'COOKIE_SESSION' ) ) { $ menu_set = self :: defaultMenuSet ( ) ; } if ( $ menu_set === false ) { $ menu_set = self :: closeMenuSet ( ) ; } $ menu_txt = self :: menuNav ( $ menu_set ) ; if ( $ this -> buffer ) return $ menu_txt ; echo ( $ menu_txt ) ; }
Emit the top navigation block

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