ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
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;
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  $this->addMultiCommand('activateTemplates', $this->lng->txt('activate'));
43  $this->addMultiCommand('deactivateTemplates', $this->lng->txt('deactivate'));
44  $this->addMultiCommand('confirmDelete',$this->lng->txt('delete'));
45 
46 
47 
48  $this->setRowTemplate('tpl.didactic_template_overview_row.html','Services/DidacticTemplate');
49  $this->setDefaultOrderField('title');
50  $this->setDefaultOrderDirection('asc');
51  $this->setFormAction($ilCtrl->getFormAction($this->getParentObject()));
52  $this->setSelectAllCheckbox('tpls');
53  }
54 
58  public function parse()
59  {
60  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateSettings.php';
62  $tpls->readInactive();
63 
64  $counter = 0;
65  foreach($tpls->getTemplates() as $tpl)
66  {
67  /* @var $tpl ilDidacticTemplateSetting */
68  $data[$counter]['id'] = $tpl->getId();
69  $data[$counter]['title'] = $tpl->getTitle();
70  $data[$counter]['description'] = $tpl->getDescription();
71  $data[$counter]['info'] = $tpl->getInfo();
72  $data[$counter]['enabled'] = (int) $tpl->isEnabled();
73  $data[$counter]['assignments'] = $tpl->getAssignments();
74 
75  ++$counter;
76  }
77 
78  $this->setData((array) $data);
79  }
80 
85  public function fillRow($set)
86  {
87  global $ilCtrl;
88 
89  // @TODO: Check for system template and hide checkbox
90  $this->tpl->setVariable('VAL_ID',$set['id']);
91  $this->tpl->setVariable('VAL_TITLE', $set['title']);
92  $this->tpl->setVariable('VAL_DESC', $set['description']);
93 
94  foreach((array) explode("\n", $set['info']) as $info)
95  {
96  $trimmed_info = trim($info);
97  if($trimmed_info)
98  {
99  $this->tpl->setCurrentBlock('info');
100  $this->tpl->setVariable('VAL_INFO',$trimmed_info);
101  $this->tpl->parseCurrentBlock();
102  }
103  }
104 
105 
106  $this->tpl->setVariable('VAL_IMAGE',
107  $set['enabled'] ?
108  ilUtil::getImagePath('icon_ok.png') :
109  ilUtil::getImagePath('icon_not_ok.png')
110  );
111  $this->tpl->setVariable('VAL_ENABLED_TXT',
112  $set['enabled'] ?
113  $this->lng->txt('active') :
114  $this->lng->txt('inactive')
115  );
116 
117 
118  $atxt = '';
119  foreach((array) $set['assignments'] as $obj_type)
120  {
121  $atxt .= ($this->lng->txt('objs_'.$obj_type).'<br/>');
122  }
123  $this->tpl->setVariable('VAL_APPLICABLE', $atxt);
124 
125  $ilCtrl->setParameterByClass(
126  get_class($this->getParentObject()),
127  'tplid',
128  $set['id']
129  );
130 
131  // Edit
132  $this->tpl->setCurrentBlock('action_link');
133  $this->tpl->setVariable(
134  'A_LINK',
135  $ilCtrl->getLinkTargetByClass(get_class($this->getParentObject()),'editTemplate')
136  );
137  $this->tpl->setVariable('A_TEXT',$this->lng->txt('edit'));
138  $this->tpl->parseCurrentBlock();
139 
140  // Copy
141  $this->tpl->setCurrentBlock('action_link');
142  $this->tpl->setVariable(
143  'A_LINK',
144  $ilCtrl->getLinkTargetByClass(get_class($this->getParentObject()),'copyTemplate')
145  );
146  $this->tpl->setVariable('A_TEXT', $this->lng->txt('copy'));
147  $this->tpl->parseCurrentBlock();
148 
149  // Export
150  $this->tpl->setCurrentBlock('action_link');
151  $this->tpl->setVariable(
152  'A_LINK',
153  $ilCtrl->getLinkTargetByClass(get_class($this->getParentObject()),'exportTemplate')
154  );
155  $this->tpl->setVariable('A_TEXT', $this->lng->txt('didactic_do_export'));
156  $this->tpl->parseCurrentBlock();
157  }
158 }
159 ?>