ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilLTIConsumerTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-20016 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
13 {
14  protected $editable = true;
15 
16  public function __construct($a_parent_obj, $a_parent_cmd)
17  {
18  global $ilCtrl, $lng;
19 
20  $this->setId("ltioconsumer");
21 
22  parent::__construct($a_parent_obj, $a_parent_cmd);
23 
24  $this->setLimit(9999);
25 
26  $this->setTitle($lng->txt("lti_object_consumer"));
27 
28  $this->addColumn($lng->txt("active"), "active");
29  $this->addColumn($lng->txt("title"), "title");
30  $this->addColumn($lng->txt("description"), "description");
31  $this->addColumn($lng->txt("prefix"), "prefix");
32  $this->addColumn($lng->txt("in_use"), "language");
33  $this->addColumn($lng->txt("objects"), "objects");
34  $this->addColumn($lng->txt("role"), "role");
35  $this->addColumn($lng->txt("actions"), "");
36 
37  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
38  $this->setRowTemplate("tpl.lti_consumer_list_row.html", "Services/LTI");
39  $this->setDefaultOrderField("title");
40 
41  $this->getItems();
42  }
43 
49  public function setEditable($a_status)
50  {
51  $this->editable = $a_status;
52  }
53 
57  public function isEditable()
58  {
59  return $this->editable;
60  }
61 
65  public function getItems()
66  {
67  $dataConnector = new ilLTIDataConnector();
68 
69  $consumer_data = $dataConnector->getGlobalToolConsumerSettings();
70  $result = array();
71  foreach ($consumer_data as $cons) {
72  $result[] = array(
73  "id" => $cons->getExtConsumerId(),
74  "title" => $cons->getTitle(),
75  "description" => $cons->getDescription(),
76  "prefix" => $cons->getPrefix(),
77  "language" => $cons->getLanguage(),
78  "role" => $cons->getRole(),
79  "active" => $cons->getActive()
80  );
81  }
82 
83  $this->setData($result);
84  }
85 
89  protected function fillRow($a_set)
90  {
91  global $lng, $ilCtrl;
92 
93  $ilCtrl->setParameter($this->getParentObject(), "cid", $a_set["id"]);
94 
95  $this->tpl->setVariable("TXT_TITLE", $a_set["title"]);
96  $this->tpl->setVariable("TXT_DESCRIPTION", $a_set["description"]);
97  $this->tpl->setVariable("TXT_PREFIX", $a_set["prefix"]);
98  $this->tpl->setVariable("TXT_KEY", $a_set["key"]);
99  $this->tpl->setVariable("TXT_SECRET", $a_set["secret"]);
100  $this->tpl->setVariable("TXT_LANGUAGE", $a_set["language"]);
101  $obj_types = $this->parent_obj->object->getActiveObjectTypes($a_set["id"]);
102  if ($obj_types) {
103  foreach ($obj_types as $obj_type) {
104  $this->tpl->setCurrentBlock("objects");
105  $this->tpl->setVariable("OBJECTS", $GLOBALS['DIC']->language()->txt('objs_' . $obj_type));
106  $this->tpl->parseCurrentBlock();
107  }
108  } else {
109  $this->tpl->setVariable("NO_OBJECTS", "-");
110  }
111 
112  $role = ilObjectFactory::getInstanceByObjId($a_set['role'], false);
113  if ($role instanceof ilObjRole) {
114  $this->tpl->setVariable('TXT_ROLE', $role->getTitle());
115  } else {
116  $this->tpl->setVariable('TXT_ROLE', '');
117  }
118 
119  if ($a_set["active"]) {
120  $this->tpl->setVariable("TXT_ACTIVE", $lng->txt('active'));
121  $label_status = $lng->txt("deactivate");
122  } else {
123  $this->tpl->setVariable("TXT_ACTIVE", $lng->txt('inactive'));
124  $label_status = $lng->txt("activate");
125  }
126 
127  if ($this->isEditable()) {
129  $list->setId($a_set["id"]);
130  $list->setListTitle($lng->txt("actions"));
131 
132  $edit_url = $ilCtrl->getLinkTarget($this->getParentObject(), "editConsumer");
133  $delete_url = $ilCtrl->getLinkTarget($this->getParentObject(), "deleteLTIConsumer");
134  $status_url = $ilCtrl->getLinkTarget($this->getParentObject(), "changeStatusLTIConsumer");
135  $list->addItem($lng->txt("edit"), "", $edit_url);
136  $list->addItem($lng->txt("delete"), "", $delete_url);
137  $list->addItem($label_status, "", $status_url);
138 
139  $this->tpl->setVariable("ACTION", $list->getHTML());
140  }
141  }
142 }
Class ilObjRole.
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
$result
Class to represent an LTI Data Connector for ILIAS.
fillRow($a_set)
Fill a single data row.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
setEditable($a_status)
Set editable.
getParentObject()
Get parent object.
setId($a_val)
Set id.
__construct($a_parent_obj, $a_parent_cmd)
global $ilCtrl
Definition: ilias.php:18
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
Class ilTable2GUI.
TableGUI class for LTI consumer listing.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
setRowTemplate($a_template, $a_template_dir="")
Set row template.
Create styles array
The data for the language used.
User interface class for advanced drop-down selection lists.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
isEditable()
Check if write permission given.
setLimit($a_limit=0, $a_default_limit=0)