ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  $this->addColumn($this->lng->txt('search_title_description'),'title','40%');
36  $this->addColumn($this->lng->txt('didactic_applicable_for'),'applicable','20%');
37  $this->addColumn($this->lng->txt('active'),'active','20%');
38  $this->addColumn($this->lng->txt('actions'),'','20%');
39 
40  $this->setTitle($this->lng->txt('didactic_available_templates'));
41 
42  if($ilAccess->checkAccess('write','',$_REQUEST["ref_id"]))
43  {
44  $this->addMultiCommand('activateTemplates', $this->lng->txt('activate'));
45  $this->addMultiCommand('deactivateTemplates', $this->lng->txt('deactivate'));
46  $this->addMultiCommand('confirmDelete',$this->lng->txt('delete'));
47 
48  $this->setSelectAllCheckbox('tpls');
49  }
50 
51 
52 
53  $this->setRowTemplate('tpl.didactic_template_overview_row.html','Services/DidacticTemplate');
54  $this->setDefaultOrderField('title');
55  $this->setDefaultOrderDirection('asc');
56  $this->setFormAction($ilCtrl->getFormAction($this->getParentObject()));
57  }
58 
62  public function parse()
63  {
64  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateSettings.php';
66  $tpls->readInactive();
67 
68  $counter = 0;
69  foreach($tpls->getTemplates() as $tpl)
70  {
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  $data[$counter]['automatic_generated'] = $tpl->isAutoGenerated();
79 
80  ++$counter;
81  }
82 
83  $this->setData((array) $data);
84  }
85 
90  public function fillRow($set)
91  {
92  global $ilCtrl, $ilAccess;
93 
94  // @TODO: Check for system template and hide checkbox
95 
96  if($ilAccess->checkAccess('write','',$_REQUEST["ref_id"]))
97  {
98  $this->tpl->setVariable('VAL_ID',$set['id']);
99  }
100 
101  $this->tpl->setVariable('VAL_TITLE', $set['title']);
102  $this->tpl->setVariable('VAL_DESC', $set['description']);
103 
104  foreach((array) explode("\n", $set['info']) as $info)
105  {
106  $trimmed_info = trim($info);
107  if($trimmed_info)
108  {
109  $this->tpl->setCurrentBlock('info');
110  $this->tpl->setVariable('VAL_INFO',$trimmed_info);
111  $this->tpl->parseCurrentBlock();
112  }
113  }
114 
115  if($set['automatic_generated'])
116  {
117  $this->tpl->setVariable("VAL_AUTOMATIC_GENERATED", $this->lng->txt("didactic_auto_generated"));
118  }
119 
120 
121  $this->tpl->setVariable('VAL_IMAGE',
122  $set['enabled'] ?
123  ilUtil::getImagePath('icon_ok.svg') :
124  ilUtil::getImagePath('icon_not_ok.svg')
125  );
126  $this->tpl->setVariable('VAL_ENABLED_TXT',
127  $set['enabled'] ?
128  $this->lng->txt('active') :
129  $this->lng->txt('inactive')
130  );
131 
132 
133  $atxt = '';
134  foreach((array) $set['assignments'] as $obj_type)
135  {
136  $atxt .= ($this->lng->txt('objs_'.$obj_type).'<br/>');
137  }
138  $this->tpl->setVariable('VAL_APPLICABLE', $atxt);
139 
140  $ilCtrl->setParameterByClass(
141  get_class($this->getParentObject()),
142  'tplid',
143  $set['id']
144  );
145 
146  if($ilAccess->checkAccess('write','',$_REQUEST["ref_id"]))
147  {
148  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
149  $actions = new ilAdvancedSelectionListGUI();
150  $actions->setId($set['id']);
151  $actions->setListTitle($this->lng->txt("actions"));
152  // Edit
153  $actions->addItem(
154  $this->lng->txt('settings'),
155  '',
156  $ilCtrl->getLinkTargetByClass(get_class($this->getParentObject()),'editTemplate')
157  );
158 
159  // Copy
160  $actions->addItem(
161  $this->lng->txt('copy'),
162  '',
163  $ilCtrl->getLinkTargetByClass(get_class($this->getParentObject()),'copyTemplate')
164  );
165 
166  // Export
167  $actions->addItem(
168  $this->lng->txt('didactic_do_export'),
169  '',
170  $ilCtrl->getLinkTargetByClass(get_class($this->getParentObject()),'exportTemplate')
171  );
172  $this->tpl->setVariable('ACTION_DROPDOWN', $actions->getHTML());
173  }
174  else
175  {
176  //don't use dropdown if just one item is given ...
177  // Export
178  $this->tpl->setCurrentBlock('action_link');
179  $this->tpl->setVariable(
180  'A_LINK',
181  $ilCtrl->getLinkTargetByClass(get_class($this->getParentObject()),'exportTemplate')
182  );
183  $this->tpl->setVariable('A_TEXT', $this->lng->txt('didactic_do_export'));
184  $this->tpl->parseCurrentBlock();
185  }
186 
187  }
188 }
189 ?>
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
Description of ilDidacticTemplateSettingsTableGUI.
static getInstance()
Get singelton instance.
__construct($a_parent_obj, $a_parent_cmd="")
Constructor.
getParentObject()
Get parent object.
setId($a_val)
Set id.
global $tpl
Definition: ilias.php:8
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
$info
Definition: example_052.php:80
Class ilTable2GUI.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
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.
global $lng
Definition: privfeed.php:17
setSelectAllCheckbox($a_select_all_checkbox)
Set the name of the checkbox that should be toggled with a select all button.
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.