ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilDidacticTemplateSettingsTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once './Services/Table/classes/class.ilTable2GUI.php';
5 
13 {
14 
20  public function __construct($a_parent_obj, $a_parent_cmd = "")
21  {
22  parent::__construct($a_parent_obj, $a_parent_cmd);
23  $this->setId('tbl_didactic_tpl_settings');
24  }
25 
29  public function init()
30  {
31  global $DIC;
32 
33  $ilCtrl = $DIC['ilCtrl'];
34  $lng = $DIC['lng'];
35  $ilAccess = $DIC['ilAccess'];
36 
37  $this->addColumn('', 'f', '1px');
38  $lng->loadLanguageModule('search');
39  $lng->loadLanguageModule('meta');
40  $this->addColumn($this->lng->txt('search_title_description'), 'title', '30%');
41  $this->addColumn($this->lng->txt('didactic_applicable_for'), 'applicable', '20%');
42  $this->addColumn($this->lng->txt('didactic_scope'), 'scope', '20%');
43  $this->addColumn($this->lng->txt('active'), 'active', '10%');
44  $this->addColumn($this->lng->txt('actions'), '', '20%');
45 
46  $this->setTitle($this->lng->txt('didactic_available_templates'));
47 
48  if ($ilAccess->checkAccess('write', '', $_REQUEST["ref_id"])) {
49  $this->addMultiCommand('activateTemplates', $this->lng->txt('activate'));
50  $this->addMultiCommand('deactivateTemplates', $this->lng->txt('deactivate'));
51  $this->addMultiCommand('confirmDelete', $this->lng->txt('delete'));
52 
53  $this->setSelectAllCheckbox('tpls');
54  }
55 
56 
57 
58  $this->setRowTemplate('tpl.didactic_template_overview_row.html', 'Services/DidacticTemplate');
59  $this->setDefaultOrderField('title');
60  $this->setDefaultOrderDirection('asc');
61  $this->setFormAction($ilCtrl->getFormAction($this->getParentObject()));
62  }
63 
67  public function parse()
68  {
69  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateSettings.php';
71  $tpls->readInactive();
72 
73  $counter = 0;
74  foreach ($tpls->getTemplates() as $tpl) {
75  /* @var $tpl ilDidacticTemplateSetting */
76  $data[$counter]['id'] = $tpl->getId();
77 
78  if ($tpl->isAutoGenerated()) {
79  $data[$counter]['title'] = $this->lng->txt($tpl->getTitle());
80  } else {
81  $data[$counter]['title'] = $tpl->getTitle();
82  }
83  $data[$counter]['description'] = $tpl->getPresentationDescription();
84  $data[$counter]['info'] = $tpl->getInfo();
85  $data[$counter]['enabled'] = (int) $tpl->isEnabled();
86  $data[$counter]['assignments'] = $tpl->getAssignments();
87 
88  $atxt = '';
89  foreach ($tpl->getAssignments() as $obj_type) {
90  $atxt .= ($this->lng->txt('objs_' . $obj_type) . '<br/>');
91  }
92  $data[$counter]['applicable'] = $atxt;
93  $data[$counter]['automatic_generated'] = $tpl->isAutoGenerated();
94  $data[$counter]['scope'] = (array) $tpl->getEffectiveFrom();
95 
96  ++$counter;
97  }
98 
99  $this->setData((array) $data);
100  }
101 
106  public function fillRow($set)
107  {
108  global $DIC;
109 
110  $ilCtrl = $DIC['ilCtrl'];
111  $ilAccess = $DIC['ilAccess'];
112 
113  // @TODO: Check for system template and hide checkbox
114 
115  if ($ilAccess->checkAccess('write', '', $_REQUEST["ref_id"])) {
116  $this->tpl->setVariable('VAL_ID', $set['id']);
117  }
118 
119  $this->tpl->setVariable('VAL_TITLE', $set['title']);
120  $this->tpl->setVariable('VAL_DESC', $set['description']);
121 
122  foreach ((array) explode("\n", $set['info']) as $info) {
123  $trimmed_info = trim($info);
124  if ($trimmed_info) {
125  $this->tpl->setCurrentBlock('info');
126  $this->tpl->setVariable('VAL_INFO', $trimmed_info);
127  $this->tpl->parseCurrentBlock();
128  }
129  }
130 
131  if ($set['automatic_generated']) {
132  $this->tpl->setVariable("VAL_AUTOMATIC_GENERATED", $this->lng->txt("didactic_auto_generated"));
133  }
134 
135 
136  $this->tpl->setVariable(
137  'VAL_IMAGE',
138  $set['enabled'] ?
139  ilUtil::getImagePath('icon_ok.svg') :
140  ilUtil::getImagePath('icon_not_ok.svg')
141  );
142  $this->tpl->setVariable(
143  'VAL_ENABLED_TXT',
144  $set['enabled'] ?
145  $this->lng->txt('active') :
146  $this->lng->txt('inactive')
147  );
148 
149 
150  $atxt = '';
151  foreach ((array) $set['assignments'] as $obj_type) {
152  $atxt .= ($this->lng->txt('objs_' . $obj_type) . '<br/>');
153  }
154  $this->tpl->setVariable('VAL_APPLICABLE', $atxt);
155 
156  $ilCtrl->setParameterByClass(
157  get_class($this->getParentObject()),
158  'tplid',
159  $set['id']
160  );
161 
162  if (count($set['scope'])) {
163  $this->tpl->setCurrentBlock('scope_txt');
164  $this->tpl->setVariable('LOCAL_OR_GLOBAL', $this->lng->txt('didactic_scope_list_header'));
165  $this->tpl->parseCurrentBlock();
166 
167  foreach ($set['scope'] as $ref_id) {
168  $this->tpl->setCurrentBlock('scope_entry');
169  $this->tpl->setVariable('LINK_HREF', ilLink::_getLink($ref_id));
170  $this->tpl->setVariable('LINK_NAME', ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id)));
171  $this->tpl->parseCurrentBlock();
172  }
173  } else {
174  $this->tpl->setCurrentBlock('scope_txt');
175  $this->tpl->setVariable('LOCAL_OR_GLOBAL', $set['local'] ? $this->lng->txt('meta_local') : $this->lng->txt('meta_global'));
176  $this->tpl->parseCurrentBlock();
177  }
178 
179 
180  if ($ilAccess->checkAccess('write', '', $_REQUEST["ref_id"])) {
181  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
182  $actions = new ilAdvancedSelectionListGUI();
183  $actions->setId($set['id']);
184  $actions->setListTitle($this->lng->txt("actions"));
185  // Edit
186  $actions->addItem(
187  $this->lng->txt('settings'),
188  '',
189  $ilCtrl->getLinkTargetByClass(get_class($this->getParentObject()), 'editTemplate')
190  );
191 
192  // Copy
193  $actions->addItem(
194  $this->lng->txt('copy'),
195  '',
196  $ilCtrl->getLinkTargetByClass(get_class($this->getParentObject()), 'copyTemplate')
197  );
198 
199  // Export
200  $actions->addItem(
201  $this->lng->txt('didactic_do_export'),
202  '',
203  $ilCtrl->getLinkTargetByClass(get_class($this->getParentObject()), 'exportTemplate')
204  );
205  $this->tpl->setVariable('ACTION_DROPDOWN', $actions->getHTML());
206  } else {
207  //don't use dropdown if just one item is given ...
208  // Export
209  $this->tpl->setCurrentBlock('action_link');
210  $this->tpl->setVariable(
211  'A_LINK',
212  $ilCtrl->getLinkTargetByClass(get_class($this->getParentObject()), 'exportTemplate')
213  );
214  $this->tpl->setVariable('A_TEXT', $this->lng->txt('didactic_do_export'));
215  $this->tpl->parseCurrentBlock();
216  }
217  }
218 }
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
Description of ilDidacticTemplateSettingsTableGUI.
global $DIC
Definition: saml.php:7
static getInstance()
Get singelton instance.
__construct($a_parent_obj, $a_parent_cmd="")
Constructor.
static _lookupTitle($a_id)
lookup object title
getParentObject()
Get parent object.
setId($a_val)
Set id.
global $ilCtrl
Definition: ilias.php:18
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
Class ilTable2GUI.
setSelectAllCheckbox($a_select_all_checkbox, $a_select_all_on_top=false)
Set the name of the checkbox that should be toggled with a select all button.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static _lookupObjId($a_id)
addMultiCommand($a_cmd, $a_text)
Add Command button.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
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.
$info
Definition: index.php:5