ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 $ilCtrl, $lng;
30 
31  $this->setId('units_' . $controller->getUniqueId());
32 
33  parent::__construct($controller, $default_cmd);
34 
35  if($this->getParentObject()->isCRUDContext())
36  {
37  $this->addColumn('', '', '1%', true);
38  $this->setSelectAllCheckbox('unit_ids[]');
39  $this->addMultiCommand('confirmDeleteUnits', $this->lng->txt('delete'));
40  $this->addCommandButton('saveOrder', $this->lng->txt('un_save_order'));
41  }
42 
43  $this->setTitle(sprintf($this->lng->txt('un_units_of_category_x'), $category->getDisplayString()));
44 
45  $this->addColumn($this->lng->txt('un_sequence'), '');
46  $this->addColumn($this->lng->txt('unit'), '');
47  $this->addColumn($this->lng->txt('baseunit'), '');
48  $this->addColumn($this->lng->txt('factor'), '');
49  $this->addColumn('', '', '1%', true);
50 
51  // Show all units because of sorting
52  $this->setLimit(PHP_INT_MAX);
53 
54  $this->setFormAction($ilCtrl->getFormAction($this->getParentObject(), 'showUnitsOfCategory'));
55 
56  $this->setDefaultOrderDirection('sequence');
57  $this->setDefaultOrderDirection('ASC');
58 
59  $this->setRowTemplate('tpl.unit_row_html', 'Modules/TestQuestionPool');
60  }
61 
65  public function fillRow(array $row)
66  {
70  global $ilCtrl;
71 
72  if($this->getParentObject()->isCRUDContext())
73  {
74  $row['chb'] = ilUtil::formCheckbox(false, 'unit_ids[]', $row['unit_id']);
75 
76  $sequence = new ilNumberInputGUI('', 'sequence[' . $row['unit_id'] . ']');
77  $sequence->setValue($this->position++ * 10);
78  $sequence->setMinValue(0);
79  $sequence->setSize(3);
80  $row['sequence'] = $sequence->render();
81 
82  $action = new ilAdvancedSelectionListGUI();
83  $action->setId('asl_content_' . $row['unit_id']);
84  $action->setAsynch(false);
85  $action->setListTitle($this->lng->txt('actions'));
86  $ilCtrl->setParameter($this->getParentObject(), 'unit_id', $row['unit_id']);
87  $action->addItem($this->lng->txt('edit'), '', $ilCtrl->getLinkTarget($this->getParentObject(), 'showUnitModificationForm'));
88  $action->addItem($this->lng->txt('delete'), '', $ilCtrl->getLinkTarget($this->getParentObject(), 'confirmDeleteUnit'));
89  $ilCtrl->setParameter($this->getParentObject(), 'unit_id', '');
90  $row['actions'] = $action->getHtml();
91  }
92  if($row['unit_id'] == $row['baseunit_id'])
93  {
94  $row['baseunit'] = '';
95  }
96  parent::fillRow($row);
97  }
98 }