ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $ilCtrl, $lng, $ilAccess;
32 
33  $this->addColumn('', 'f', '1px');
34  $lng->loadLanguageModule('search');
35  $lng->loadLanguageModule('meta');
36  $this->addColumn($this->lng->txt('search_title_description'), 'title', '30%');
37  $this->addColumn($this->lng->txt('didactic_applicable_for'), 'applicable', '20%');
38  $this->addColumn($this->lng->txt('didactic_scope'), 'scope', '20%');
39  $this->addColumn($this->lng->txt('active'), 'active', '10%');
40  $this->addColumn($this->lng->txt('actions'), '', '20%');
41 
42  $this->setTitle($this->lng->txt('didactic_available_templates'));
43 
44  if ($ilAccess->checkAccess('write', '', $_REQUEST["ref_id"])) {
45  $this->addMultiCommand('activateTemplates', $this->lng->txt('activate'));
46  $this->addMultiCommand('deactivateTemplates', $this->lng->txt('deactivate'));
47  $this->addMultiCommand('confirmDelete', $this->lng->txt('delete'));
48 
49  $this->setSelectAllCheckbox('tpls');
50  }
51 
52 
53 
54  $this->setRowTemplate('tpl.didactic_template_overview_row.html', 'Services/DidacticTemplate');
55  $this->setDefaultOrderField('title');
56  $this->setDefaultOrderDirection('asc');
57  $this->setFormAction($ilCtrl->getFormAction($this->getParentObject()));
58  }
59 
63  public function parse()
64  {
65  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateSettings.php';
67  $tpls->readInactive();
68 
69  $counter = 0;
70  foreach ($tpls->getTemplates() as $tpl) {
71  /* @var $tpl ilDidacticTemplateSetting */
72  $data[$counter]['id'] = $tpl->getId();
73  $data[$counter]['title'] = $tpl->getPresentationTitle();
74  $data[$counter]['description'] = $tpl->getPresentationDescription();
75  $data[$counter]['info'] = $tpl->getInfo();
76  $data[$counter]['enabled'] = (int) $tpl->isEnabled();
77  $data[$counter]['assignments'] = $tpl->getAssignments();
78 
79  $atxt = '';
80  foreach ($tpl->getAssignments() as $obj_type) {
81  $atxt .= ($this->lng->txt('objs_' . $obj_type) . '<br/>');
82  }
83  $data[$counter]['applicable'] = $atxt;
84  $data[$counter]['automatic_generated'] = $tpl->isAutoGenerated();
85  $data[$counter]['scope'] = (array) $tpl->getEffectiveFrom();
86 
87  ++$counter;
88  }
89 
90  $this->setData((array) $data);
91  }
92 
97  public function fillRow($set)
98  {
99  global $ilCtrl, $ilAccess;
100 
101  // @TODO: Check for system template and hide checkbox
102 
103  if ($ilAccess->checkAccess('write', '', $_REQUEST["ref_id"])) {
104  $this->tpl->setVariable('VAL_ID', $set['id']);
105  }
106 
107  $this->tpl->setVariable('VAL_TITLE', $set['title']);
108  $this->tpl->setVariable('VAL_DESC', $set['description']);
109 
110  foreach ((array) explode("\n", $set['info']) as $info) {
111  $trimmed_info = trim($info);
112  if ($trimmed_info) {
113  $this->tpl->setCurrentBlock('info');
114  $this->tpl->setVariable('VAL_INFO', $trimmed_info);
115  $this->tpl->parseCurrentBlock();
116  }
117  }
118 
119  if ($set['automatic_generated']) {
120  $this->tpl->setVariable("VAL_AUTOMATIC_GENERATED", $this->lng->txt("didactic_auto_generated"));
121  }
122 
123 
124  $this->tpl->setVariable(
125  'VAL_IMAGE',
126  $set['enabled'] ?
127  ilUtil::getImagePath('icon_ok.svg') :
128  ilUtil::getImagePath('icon_not_ok.svg')
129  );
130  $this->tpl->setVariable(
131  'VAL_ENABLED_TXT',
132  $set['enabled'] ?
133  $this->lng->txt('active') :
134  $this->lng->txt('inactive')
135  );
136 
137 
138  $atxt = '';
139  foreach ((array) $set['assignments'] as $obj_type) {
140  $atxt .= ($this->lng->txt('objs_' . $obj_type) . '<br/>');
141  }
142  $this->tpl->setVariable('VAL_APPLICABLE', $atxt);
143 
144  $ilCtrl->setParameterByClass(
145  get_class($this->getParentObject()),
146  'tplid',
147  $set['id']
148  );
149 
150  if (count($set['scope'])) {
151  $this->tpl->setCurrentBlock('scope_txt');
152  $this->tpl->setVariable('LOCAL_OR_GLOBAL', $this->lng->txt('didactic_scope_list_header'));
153  $this->tpl->parseCurrentBlock();
154 
155  foreach ($set['scope'] as $ref_id) {
156  $this->tpl->setCurrentBlock('scope_entry');
157  $this->tpl->setVariable('LINK_HREF', ilLink::_getLink($ref_id));
158  $this->tpl->setVariable('LINK_NAME', ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id)));
159  $this->tpl->parseCurrentBlock();
160  }
161  } else {
162  $this->tpl->setCurrentBlock('scope_txt');
163  $this->tpl->setVariable('LOCAL_OR_GLOBAL', $set['local'] ? $this->lng->txt('meta_local') : $this->lng->txt('meta_global'));
164  $this->tpl->parseCurrentBlock();
165  }
166 
167 
168  if ($ilAccess->checkAccess('write', '', $_REQUEST["ref_id"])) {
169  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
170  $actions = new ilAdvancedSelectionListGUI();
171  $actions->setId($set['id']);
172  $actions->setListTitle($this->lng->txt("actions"));
173  // Edit
174  $actions->addItem(
175  $this->lng->txt('settings'),
176  '',
177  $ilCtrl->getLinkTargetByClass(get_class($this->getParentObject()), 'editTemplate')
178  );
179 
180  // Copy
181  $actions->addItem(
182  $this->lng->txt('copy'),
183  '',
184  $ilCtrl->getLinkTargetByClass(get_class($this->getParentObject()), 'copyTemplate')
185  );
186 
187  // Export
188  $actions->addItem(
189  $this->lng->txt('didactic_do_export'),
190  '',
191  $ilCtrl->getLinkTargetByClass(get_class($this->getParentObject()), 'exportTemplate')
192  );
193  $this->tpl->setVariable('ACTION_DROPDOWN', $actions->getHTML());
194  } else {
195  //don't use dropdown if just one item is given ...
196  // Export
197  $this->tpl->setCurrentBlock('action_link');
198  $this->tpl->setVariable(
199  'A_LINK',
200  $ilCtrl->getLinkTargetByClass(get_class($this->getParentObject()), 'exportTemplate')
201  );
202  $this->tpl->setVariable('A_TEXT', $this->lng->txt('didactic_do_export'));
203  $this->tpl->parseCurrentBlock();
204  }
205  }
206 }
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
Description of ilDidacticTemplateSettingsTableGUI.
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.
$counter
Class ilTable2GUI.
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.
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.
setSelectAllCheckbox($a_select_all_checkbox)
Set the name of the checkbox that should be toggled with a select all button.
$info
Definition: index.php:5