ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
IMSGlobal\LTI\ToolProvider\ContentItem Class Reference

Class to represent a content-item object. More...

+ Collaboration diagram for IMSGlobal\LTI\ToolProvider\ContentItem:

Public Member Functions

 __construct ($type, $placementAdvice=null, $id=null)
 Class constructor. More...
 
 setUrl ($url)
 Set a URL value for the content-item. More...
 
 setMediaType ($mediaType)
 Set a media type value for the content-item. More...
 
 setTitle ($title)
 Set a title value for the content-item. More...
 
 setText ($text)
 Set a link text value for the content-item. More...
 

Static Public Member Functions

static toJson ($items)
 Wrap the content items to form a complete application/vnd.ims.lti.v1.contentitems+json media type instance. More...
 

Data Fields

const LTI_LINK_MEDIA_TYPE = 'application/vnd.ims.lti.v1.ltilink'
 Media type for LTI launch links. More...
 

Detailed Description

Class to represent a content-item object.

Author
Stephen P Vickers svick.nosp@m.ers@.nosp@m.imsgl.nosp@m.obal.nosp@m..org
Date
2016
Version
3.0.2 @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0

Definition at line 14 of file ContentItem.php.

Constructor & Destructor Documentation

◆ __construct()

IMSGlobal\LTI\ToolProvider\ContentItem::__construct (   $type,
  $placementAdvice = null,
  $id = null 
)

Class constructor.

Parameters
string$typeClass type of content-item
ContentItemPlacement$placementAdvicePlacement object for item (optional)
string$idURL of content-item (optional)

Definition at line 29 of file ContentItem.php.

30 {
31
32 $this->{'@type'} = $type;
33 if (is_object($placementAdvice) && (count(get_object_vars($placementAdvice)) > 0)) {
34 $this->placementAdvice = $placementAdvice;
35 }
36 if (!empty($id)) {
37 $this->{'@id'} = $id;
38 }
39
40 }
if(!array_key_exists('StateId', $_REQUEST)) $id
$type

References $id, and $type.

Member Function Documentation

◆ setMediaType()

IMSGlobal\LTI\ToolProvider\ContentItem::setMediaType (   $mediaType)

Set a media type value for the content-item.

Parameters
string$mediaTypeMedia type value

Definition at line 63 of file ContentItem.php.

64 {
65
66 if (!empty($mediaType)) {
67 $this->mediaType = $mediaType;
68 } else {
69 unset($this->mediaType);
70 }
71
72 }

◆ setText()

IMSGlobal\LTI\ToolProvider\ContentItem::setText (   $text)

Set a link text value for the content-item.

Parameters
string$textLink text value

Definition at line 95 of file ContentItem.php.

96 {
97
98 if (!empty($text)) {
99 $this->text = $text;
100 } else if (isset($this->text)) {
101 unset($this->text);
102 }
103
104 }
$text
Definition: errorreport.php:18

References $text.

◆ setTitle()

IMSGlobal\LTI\ToolProvider\ContentItem::setTitle (   $title)

Set a title value for the content-item.

Parameters
string$titleTitle value

Definition at line 79 of file ContentItem.php.

80 {
81
82 if (!empty($title)) {
83 $this->title = $title;
84 } else if (isset($this->title)) {
85 unset($this->title);
86 }
87
88 }

References $title.

◆ setUrl()

IMSGlobal\LTI\ToolProvider\ContentItem::setUrl (   $url)

Set a URL value for the content-item.

Parameters
string$urlURL value

Definition at line 47 of file ContentItem.php.

48 {
49
50 if (!empty($url)) {
51 $this->url = $url;
52 } else {
53 unset($this->url);
54 }
55
56 }
$url

References $url.

◆ toJson()

static IMSGlobal\LTI\ToolProvider\ContentItem::toJson (   $items)
static

Wrap the content items to form a complete application/vnd.ims.lti.v1.contentitems+json media type instance.

Parameters
mixed$itemsAn array of content items or a single item
Returns
string

Definition at line 112 of file ContentItem.php.

113 {
114/*
115 $data = array();
116 if (!is_array($items)) {
117 $data[] = json_encode($items);
118 } else {
119 foreach ($items as $item) {
120 $data[] = json_encode($item);
121 }
122 }
123 $json = '{ "@context" : "http://purl.imsglobal.org/ctx/lti/v1/ContentItem", "@graph" : [' . implode(", ", $data) . '] }';
124*/
125 $obj = new \stdClass();
126 $obj->{'@context'} = 'http://purl.imsglobal.org/ctx/lti/v1/ContentItem';
127 if (!is_array($items)) {
128 $obj->{'@graph'} = array();
129 $obj->{'@graph'}[] = $items;
130 } else {
131 $obj->{'@graph'} = $items;
132 }
133
134 return json_encode($obj);
135
136 }

Field Documentation

◆ LTI_LINK_MEDIA_TYPE

const IMSGlobal\LTI\ToolProvider\ContentItem::LTI_LINK_MEDIA_TYPE = 'application/vnd.ims.lti.v1.ltilink'

Media type for LTI launch links.

Definition at line 20 of file ContentItem.php.


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