src/Util/LTI.php
public static function getLtiLinkJSON($url, $title=false, $text=false,
        $icon=false, $fa_icon=false, $custom=false )
    {
        $return = '{
            "@context" : "http://purl.imsglobal.org/ctx/lti/v1/ContentItem",
                "@graph" : [
                { "@type" : "LtiLinkItem",
                    "@id" : ":item2",
                    "title" : "A cool tool hosted in the Tsugi environment.",
                    "mediaType" : "application/vnd.ims.lti.v1.ltilink",
                    "text" : "For more information on how to build and host powerful LTI-based Tools quickly, see www.tsugi.org",
                    "url" : "http://www.tsugi.org/",
                    "placementAdvice" : {
	                "presentationDocumentTarget" : "window",
	                "displayHeight" : 1024,
	                "displayWidth" : 800
                    },
                    "icon" : {
                        "@id" : "https://static.tsugi.org/img/default-icon.png",
                        "fa_icon" : "fa-magic",
                        "width" : 64,
                        "height" : 64
                    }
                }
            ]
        }';

        $json = json_decode($return);
        $json->{'@graph'}[0]->url = $url;
        if ( $title ) $json->{'@graph'}[0]->{'title'} = $title;
        if ( $text ) $json->{'@graph'}[0]->{'text'} = $text;
        if ( $icon ) $json->{'@graph'}[0]->{'icon'}->{'@id'} = $icon;
        if ( $fa_icon ) $json->{'@graph'}[0]->icon->fa_icon = $fa_icon;
        if ( $custom ) $json->{'@graph'}[0]->custom = $custom;
        return $json;
    }
public static function getLtiLinkJSON($url, $title=false, $text=false,
        $icon=false, $fa_icon=false, $custom=false )
    {
        $return = '{
            "@context" : "http://purl.imsglobal.org/ctx/lti/v1/ContentItem",
                "@graph" : [
                { "@type" : "LtiLinkItem",
                    "@id" : ":item2",
                    "title" : "A cool tool hosted in the Tsugi environment.",
                    "mediaType" : "application/vnd.ims.lti.v1.ltilink",
                    "text" : "For more information on how to build and host powerful LTI-based Tools quickly, see www.tsugi.org",
                    "url" : "http://www.tsugi.org/",
                    "placementAdvice" : {
	                "presentationDocumentTarget" : "window",
	                "displayHeight" : 1024,
	                "displayWidth" : 800
                    },
                    "icon" : {
                        "@id" : "https://static.tsugi.org/img/default-icon.png",
                        "fa_icon" : "fa-magic",
                        "width" : 64,
                        "height" : 64
                    }
                }
            ]
        }';

        $json = json_decode($return);
        $json->{'@graph'}[0]->url = $url;
        if ( $title ) $json->{'@graph'}[0]->{'title'} = $title;
        if ( $text ) $json->{'@graph'}[0]->{'text'} = $text;
        if ( $icon ) $json->{'@graph'}[0]->{'icon'}->{'@id'} = $icon;
        if ( $fa_icon ) $json->{'@graph'}[0]->icon->fa_icon = $fa_icon;
        if ( $custom ) $json->{'@graph'}[0]->custom = $custom;
        return $json;
    }
public static function getLtiLinkJSON ( $ url , $ title = false , $ text = false , $ icon = false , $ fa_icon = false , $ custom = false ) { $ return = '{
            "@context" : "http://purl.imsglobal.org/ctx/lti/v1/ContentItem",
                "@graph" : [
                { "@type" : "LtiLinkItem",
                    "@id" : ":item2",
                    "title" : "A cool tool hosted in the Tsugi environment.",
                    "mediaType" : "application/vnd.ims.lti.v1.ltilink",
                    "text" : "For more information on how to build and host powerful LTI-based Tools quickly, see www.tsugi.org",
                    "url" : "http://www.tsugi.org/",
                    "placementAdvice" : {
	                "presentationDocumentTarget" : "window",
	                "displayHeight" : 1024,
	                "displayWidth" : 800
                    },
                    "icon" : {
                        "@id" : "https://static.tsugi.org/img/default-icon.png",
                        "fa_icon" : "fa-magic",
                        "width" : 64,
                        "height" : 64
                    }
                }
            ]
        }' ; $ json = json_decode ( $ return ) ; $ json -> { '@graph' } [ 0 ] -> url = $ url ; if ( $ title ) $ json -> { '@graph' } [ 0 ] -> { 'title' } = $ title ; if ( $ text ) $ json -> { '@graph' } [ 0 ] -> { 'text' } = $ text ; if ( $ icon ) $ json -> { '@graph' } [ 0 ] -> { 'icon' } -> { '@id' } = $ icon ; if ( $ fa_icon ) $ json -> { '@graph' } [ 0 ] -> icon -> fa_icon = $ fa_icon ; if ( $ custom ) $ json -> { '@graph' } [ 0 ] -> custom = $ custom ; return $ json ; }
getLtiLinkJson - Get a JSON object for an LTI Link Content Item Return

@param url The launch URL of the tool that is about to be placed
@param title A plain text title of the content-item.
@param text A plain text description of the content-item.
@param icon An image URL of an icon
@param fa_icon The class name of a FontAwesome icon
getLtiLinkJson - Get a JSON object for an LTI Link Content Item Return