Ejemplo n.º 1
0
 /**
  * @param ilUnitConfigurationGUI         $controller
  * @param string                         $default_cmd
  * @param assFormulaQuestionUnitCategory $category
  */
 public function __construct(ilUnitConfigurationGUI $controller, $default_cmd, assFormulaQuestionUnitCategory $category)
 {
     /**
      * @var $ilCtrl ilCtrl
      * @var $lng    ilLanguage
      */
     global $ilCtrl, $lng;
     $this->setId('units_' . $controller->getUniqueId());
     parent::__construct($controller, $default_cmd);
     if ($this->getParentObject()->isCRUDContext()) {
         $this->addColumn('', '', '1%', true);
         $this->setSelectAllCheckbox('unit_ids[]');
         $this->addMultiCommand('confirmDeleteUnits', $this->lng->txt('delete'));
         $this->addCommandButton('saveOrder', $this->lng->txt('un_save_order'));
     }
     $this->setTitle(sprintf($this->lng->txt('un_units_of_category_x'), $category->getDisplayString()));
     $this->addColumn($this->lng->txt('un_sequence'), '');
     $this->addColumn($this->lng->txt('unit'), '');
     $this->addColumn($this->lng->txt('baseunit'), '');
     $this->addColumn($this->lng->txt('factor'), '');
     $this->addColumn('', '', '1%', true);
     // Show all units because of sorting
     $this->setLimit(PHP_INT_MAX);
     $this->setFormAction($ilCtrl->getFormAction($this->getParentObject(), 'showUnitsOfCategory'));
     $this->setDefaultOrderDirection('sequence');
     $this->setDefaultOrderDirection('ASC');
     $this->setRowTemplate('tpl.unit_row_html', 'Modules/TestQuestionPool');
 }
 /**
  * @param assFormulaQuestionUnitCategory $cat
  * @return ilPropertyFormGUI
  */
 protected function initUnitCategoryForm(assFormulaQuestionUnitCategory $cat = null)
 {
     if ($this->unit_cat_form instanceof ilPropertyFormGUI) {
         return $this->unit_cat_form;
     }
     $this->unit_cat_form = new ilPropertyFormGUI();
     $title = new ilTextInputGUI($this->lng->txt('title'), 'category_name');
     $title->setRequired(true);
     $this->unit_cat_form->addItem($title);
     if (null === $cat) {
         $this->unit_cat_form->setTitle($this->lng->txt('new_category'));
         $this->unit_cat_form->setFormAction($this->ctrl->getFormAction($this, 'addCategory'));
         $this->unit_cat_form->addCommandButton('addCategory', $this->lng->txt('save'));
     } else {
         $this->ctrl->setParameter($this, 'category_id', $cat->getId());
         $this->unit_cat_form->addCommandButton('saveCategory', $this->lng->txt('save'));
         $this->unit_cat_form->setFormAction($this->ctrl->getFormAction($this, 'saveCategory'));
         $this->unit_cat_form->setTitle(sprintf($this->lng->txt('selected_category'), $cat->getDisplayString()));
     }
     $this->unit_cat_form->addCommandButton($this->getUnitCategoryOverviewCommand(), $this->lng->txt('cancel'));
     return $this->unit_cat_form;
 }