ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilUnitTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once 'Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
5 require_once 'Services/Form/classes/class.ilNumberInputGUI.php';
6 require_once 'Services/Table/classes/class.ilTable2GUI.php';
7 
12 {
16  private $position = 1;
17 
23  public function __construct(ilUnitConfigurationGUI $controller, $default_cmd, assFormulaQuestionUnitCategory $category)
24  {
29  global $DIC;
30  $ilCtrl = $DIC['ilCtrl'];
31  $lng = $DIC['lng'];
32 
33  $this->setId('units_' . $controller->getUniqueId());
34 
35  parent::__construct($controller, $default_cmd);
36 
37  if ($this->getParentObject()->isCRUDContext()) {
38  $this->addColumn('', '', '1%', true);
39  $this->setSelectAllCheckbox('unit_ids[]');
40  $this->addMultiCommand('confirmDeleteUnits', $this->lng->txt('delete'));
41  $this->addCommandButton('saveOrder', $this->lng->txt('un_save_order'));
42  }
43 
44  $this->setTitle(sprintf($this->lng->txt('un_units_of_category_x'), $category->getDisplayString()));
45 
46  $this->addColumn($this->lng->txt('un_sequence'), '');
47  $this->addColumn($this->lng->txt('unit'), '');
48  $this->addColumn($this->lng->txt('baseunit'), '');
49  $this->addColumn($this->lng->txt('factor'), '');
50  $this->addColumn('', '', '1%', true);
51 
52  // Show all units because of sorting
53  $this->setLimit(PHP_INT_MAX);
54 
55  $this->setFormAction($ilCtrl->getFormAction($this->getParentObject(), 'showUnitsOfCategory'));
56 
57  $this->setDefaultOrderDirection('sequence');
58  $this->setDefaultOrderDirection('ASC');
59 
60  $this->setRowTemplate('tpl.unit_row_html', 'Modules/TestQuestionPool');
61  }
62 
66  public function fillRow($row)
67  {
71  global $DIC;
72  $ilCtrl = $DIC['ilCtrl'];
73 
74  if ($this->getParentObject()->isCRUDContext()) {
75  $row['chb'] = ilUtil::formCheckbox(false, 'unit_ids[]', $row['unit_id']);
76 
77  $sequence = new ilNumberInputGUI('', 'sequence[' . $row['unit_id'] . ']');
78  $sequence->setValue($this->position++ * 10);
79  $sequence->setMinValue(0);
80  $sequence->setSize(3);
81  $row['sequence'] = $sequence->render();
82 
84  $action->setId('asl_content_' . $row['unit_id']);
85  $action->setAsynch(false);
86  $action->setListTitle($this->lng->txt('actions'));
87  $ilCtrl->setParameter($this->getParentObject(), 'unit_id', $row['unit_id']);
88  $action->addItem($this->lng->txt('edit'), '', $ilCtrl->getLinkTarget($this->getParentObject(), 'showUnitModificationForm'));
89  $action->addItem($this->lng->txt('delete'), '', $ilCtrl->getLinkTarget($this->getParentObject(), 'confirmDeleteUnit'));
90  $ilCtrl->setParameter($this->getParentObject(), 'unit_id', '');
91  $row['actions'] = $action->getHtml();
92  }
93  if ($row['unit_id'] == $row['baseunit_id']) {
94  $row['baseunit'] = '';
95  }
96  parent::fillRow($row);
97  }
98 }
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
__construct($a_parent_obj, $a_parent_cmd="", $a_template_context="")
ilTable2GUI constructor.
$action
global $DIC
Definition: saml.php:7
Class ilUnitConfigurationGUI .
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.
This class represents a number property in a property form.
addMultiCommand($a_cmd, $a_text)
Add Command button.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
$row
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.
fillRow($a_set)
Standard Version of Fill Row.
Class ilUnitTableGUI.
static formCheckbox($checked, $varname, $value, $disabled=false)
??? public
setLimit($a_limit=0, $a_default_limit=0)