ILIAS  release_7 Revision v7.30-3-g800a261c036
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
4include_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('icon'), '', '5%');
41 $this->addColumn($this->lng->txt('search_title_description'), 'title', '30%');
42 $this->addColumn($this->lng->txt('didactic_applicable_for'), 'applicable', '20%');
43 $this->addColumn($this->lng->txt('didactic_scope'), 'scope', '20%');
44 $this->addColumn($this->lng->txt('active'), 'active', '10%');
45 $this->addColumn($this->lng->txt('actions'), '', '15%');
46
47 $this->setTitle($this->lng->txt('didactic_available_templates'));
48
49 if ($ilAccess->checkAccess('write', '', $_REQUEST["ref_id"])) {
50 $this->addMultiCommand('activateTemplates', $this->lng->txt('activate'));
51 $this->addMultiCommand('deactivateTemplates', $this->lng->txt('deactivate'));
52 $this->addMultiCommand('confirmDelete', $this->lng->txt('delete'));
53
54 $this->setSelectAllCheckbox('tpls');
55 }
56
57
58
59 $this->setRowTemplate('tpl.didactic_template_overview_row.html', 'Services/DidacticTemplate');
60 $this->setDefaultOrderField('title');
61 $this->setDefaultOrderDirection('asc');
62 $this->setFormAction($ilCtrl->getFormAction($this->getParentObject()));
63 }
64
65
70 {
72 $tpls->readInactive();
73 $templates = $filter->filter($tpls->getTemplates());
74
75 $counter = 0;
76 foreach ($templates as $tpl) {
77 /* @var $tpl ilDidacticTemplateSetting */
78 $data[$counter]['id'] = $tpl->getId();
79 $data[$counter]['icon'] = $tpl->getIconHandler()->getAbsolutePath();
80 $data[$counter]['title'] = $tpl->getPresentationTitle();
81 $data[$counter]['description'] = $tpl->getPresentationDescription();
82 $data[$counter]['info'] = $tpl->getInfo();
83 $data[$counter]['enabled'] = (int) $tpl->isEnabled();
84 $data[$counter]['assignments'] = $tpl->getAssignments();
85
86 $atxt = '';
87 foreach ($tpl->getAssignments() as $obj_type) {
88 $atxt .= ($this->lng->txt('objs_' . $obj_type) . '<br/>');
89 }
90 $data[$counter]['applicable'] = $atxt;
91 $data[$counter]['automatic_generated'] = $tpl->isAutoGenerated();
92 $data[$counter]['scope'] = (array) $tpl->getEffectiveFrom();
93
94 ++$counter;
95 }
96
97 $this->setData((array) $data);
98 }
99
104 public function fillRow($set)
105 {
106 global $DIC;
107
108 $ilCtrl = $DIC['ilCtrl'];
109 $ilAccess = $DIC['ilAccess'];
110
111 if ($ilAccess->checkAccess('write', '', $_REQUEST["ref_id"])) {
112 $this->tpl->setVariable('VAL_ID', $set['id']);
113 }
114
115 $this->tpl->setVariable('VAL_TITLE', $set['title']);
116 $this->tpl->setVariable('VAL_DESC', $set['description']);
117
118 if (strlen($set['icon'])) {
119 $this->tpl->setVariable('ICON_SRC', $set['icon']);
120 foreach ((array) $set['assignments'] as $obj_type) {
121 $this->tpl->setVariable('ICON_ALT', $this->lng->txt('objs_' . $obj_type));
122 }
123 }
124
125 foreach ((array) explode("\n", $set['info']) as $info) {
126 $trimmed_info = trim($info);
127 if ($trimmed_info) {
128 $this->tpl->setCurrentBlock('info');
129 $this->tpl->setVariable('VAL_INFO', $trimmed_info);
130 $this->tpl->parseCurrentBlock();
131 }
132 }
133
134 if ($set['automatic_generated']) {
135 $this->tpl->setVariable("VAL_AUTOMATIC_GENERATED", $this->lng->txt("didactic_auto_generated"));
136 }
137
138
139 $this->tpl->setVariable(
140 'VAL_IMAGE',
141 $set['enabled'] ?
142 ilUtil::getImagePath('icon_ok.svg') :
143 ilUtil::getImagePath('icon_not_ok.svg')
144 );
145 $this->tpl->setVariable(
146 'VAL_ENABLED_TXT',
147 $set['enabled'] ?
148 $this->lng->txt('active') :
149 $this->lng->txt('inactive')
150 );
151
152
153 $atxt = '';
154 foreach ((array) $set['assignments'] as $obj_type) {
155 $atxt .= ($this->lng->txt('objs_' . $obj_type) . '<br/>');
156 }
157 $this->tpl->setVariable('VAL_APPLICABLE', $atxt);
158
159 $ilCtrl->setParameterByClass(
160 get_class($this->getParentObject()),
161 'tplid',
162 $set['id']
163 );
164
165 if (count($set['scope'])) {
166 $this->tpl->setCurrentBlock('scope_txt');
167 $this->tpl->setVariable('LOCAL_OR_GLOBAL', $this->lng->txt('didactic_scope_list_header'));
168 $this->tpl->parseCurrentBlock();
169
170 foreach ($set['scope'] as $ref_id) {
171 $this->tpl->setCurrentBlock('scope_entry');
172 $this->tpl->setVariable('LINK_HREF', ilLink::_getLink($ref_id));
173 $this->tpl->setVariable('LINK_NAME', ilObject::_lookupTitle(ilObject::_lookupObjId($ref_id)));
174 $this->tpl->parseCurrentBlock();
175 }
176 } else {
177 $this->tpl->setCurrentBlock('scope_txt');
178 $this->tpl->setVariable('LOCAL_OR_GLOBAL', $set['local'] ? $this->lng->txt('meta_local') : $this->lng->txt('meta_global'));
179 $this->tpl->parseCurrentBlock();
180 }
181
182
183 if ($ilAccess->checkAccess('write', '', $_REQUEST["ref_id"])) {
184 include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
185 $actions = new ilAdvancedSelectionListGUI();
186 $actions->setId($set['id']);
187 $actions->setListTitle($this->lng->txt("actions"));
188 // Edit
189 $actions->addItem(
190 $this->lng->txt('settings'),
191 '',
192 $ilCtrl->getLinkTargetByClass(get_class($this->getParentObject()), 'editTemplate')
193 );
194
195 // Copy
196 $actions->addItem(
197 $this->lng->txt('copy'),
198 '',
199 $ilCtrl->getLinkTargetByClass(get_class($this->getParentObject()), 'copyTemplate')
200 );
201
202 if (!$set['automatic_generated']) {
203 // Export
204 $actions->addItem(
205 $this->lng->txt('didactic_do_export'),
206 '',
207 $ilCtrl->getLinkTargetByClass(get_class($this->getParentObject()), 'exportTemplate')
208 );
209 }
210 $this->tpl->setVariable('ACTION_DROPDOWN', $actions->getHTML());
211 } elseif (!$set['automatic_generated']) {
212 //don't use dropdown if just one item is given ...
213 // Export
214 $this->tpl->setCurrentBlock('action_link');
215 $this->tpl->setVariable(
216 'A_LINK',
217 $ilCtrl->getLinkTargetByClass(get_class($this->getParentObject()), 'exportTemplate')
218 );
219 $this->tpl->setVariable('A_TEXT', $this->lng->txt('didactic_do_export'));
220 $this->tpl->parseCurrentBlock();
221 } else {
222 $this->tpl->touchBlock('action_link');
223 }
224 }
225}
An exception for terminatinating execution or to throw for unit testing.
User interface class for advanced drop-down selection lists.
Description of ilDidacticTemplateSettingsTableGUI.
__construct($a_parent_obj, $a_parent_cmd="")
Constructor.
parse(ilDidacticTemplateSettingsTableFilter $filter)
Parse didactic templates.
static getInstance()
Get singelton instance.
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
Class ilTable2GUI.
getParentObject()
Get parent object.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
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.
setData($a_data)
set table data @access public
setRowTemplate($a_template, $a_template_dir="")
Set row template.
addMultiCommand($a_cmd, $a_text)
Add Command button.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
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.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc