/**
  * Init category mapping form 
  * @return
  */
 protected function initCategoryMappingForm($a_mode = 'add')
 {
     global $ilDB;
     if (is_object($this->form)) {
         return true;
     }
     include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
     include_once './Services/WebServices/ECS/classes/class.ilECSCategoryMappingRule.php';
     $this->form = new ilPropertyFormGUI();
     if ($a_mode == 'add') {
         $this->form->setTitle($this->lng->txt('ecs_new_category_mapping'));
         $this->form->setFormAction($this->ctrl->getFormAction($this, 'categoryMapping'));
         $this->form->addCommandButton('addCategoryMapping', $this->lng->txt('save'));
         $this->form->addCommandButton('categoryMapping', $this->lng->txt('cancel'));
     } else {
         $this->form->setTitle($this->lng->txt('ecs_edit_category_mapping'));
         $this->form->setFormAction($this->ctrl->getFormAction($this, 'editCategoryMapping'));
         $this->form->addCommandButton('updateCategoryMapping', $this->lng->txt('save'));
         $this->form->addCommandButton('categoryMapping', $this->lng->txt('cancel'));
     }
     $imp = new ilCustomInputGUI($this->lng->txt('ecs_import_id'), 'import_id');
     $imp->setRequired(true);
     $tpl = new ilTemplate('tpl.ecs_import_id_form.html', true, true, 'Services/WebServices/ECS');
     $tpl->setVariable('SIZE', 5);
     $tpl->setVariable('MAXLENGTH', 11);
     $tpl->setVariable('POST_VAR', 'import_id');
     $tpl->setVariable('PROPERTY_VALUE', $this->rule->getContainerId());
     if ($this->settings->getImportId()) {
         $tpl->setVariable('COMPLETE_PATH', $this->buildPath($this->rule->getContainerId()));
     }
     $imp->setHTML($tpl->get());
     $imp->setInfo($this->lng->txt('ecs_import_id_info'));
     $this->form->addItem($imp);
     include_once './Services/WebServices/ECS/classes/class.ilECSCategoryMapping.php';
     $select = new ilSelectInputGUI($this->lng->txt('ecs_attribute_name'), 'field');
     $select->setValue($this->rule->getFieldName());
     $select->setRequired(true);
     $select->setOptions(ilECSCategoryMapping::getPossibleFields());
     $this->form->addItem($select);
     //	Value
     $value = new ilRadioGroupInputGUI($this->lng->txt('ecs_cat_mapping_type'), 'type');
     $value->setValue($this->rule->getMappingType());
     $value->setRequired(true);
     $fixed = new ilRadioOption($this->lng->txt('ecs_cat_mapping_fixed'), ilECSCategoryMappingRule::TYPE_FIXED);
     $fixed->setInfo($this->lng->txt('ecs_cat_mapping_fixed_info'));
     $fixed_val = new ilTextInputGUI($this->lng->txt('ecs_cat_mapping_values'), 'mapping_value');
     $fixed_val->setValue($this->rule->getMappingValue());
     $fixed_val->setMaxLength(255);
     $fixed_val->setSize(40);
     $fixed_val->setRequired(true);
     $fixed->addSubItem($fixed_val);
     $value->addOption($fixed);
     $duration = new ilRadioOption($this->lng->txt('ecs_cat_mapping_duration'), ilECSCategoryMappingRule::TYPE_DURATION);
     $duration->setInfo($this->lng->txt('ecs_cat_mapping_duration_info'));
     $dur_start = new ilDateTimeInputGUI($this->lng->txt('from'), 'dur_begin');
     $dur_start->setDate($this->rule->getDateRangeStart());
     $duration->addSubItem($dur_start);
     $dur_end = new ilDateTimeInputGUI($this->lng->txt('to'), 'dur_end');
     $dur_end->setDate($this->rule->getDateRangeEnd());
     $duration->addSubItem($dur_end);
     $value->addOption($duration);
     $type = new ilRadioOption($this->lng->txt('ecs_cat_mapping_by_type'), ilECSCategoryMappingRule::TYPE_BY_TYPE);
     $type->setInfo($this->lng->txt('ecs_cat_mapping_by_type_info'));
     $options = ilECSUtils::getPossibleRemoteTypes(true);
     $types = new ilSelectInputGUI($this->lng->txt('type'), 'by_type');
     $types->setOptions($options);
     $types->setValue($this->rule->getByType());
     $types->setRequired(true);
     $type->addSubitem($types);
     $value->addOption($type);
     $this->form->addItem($value);
 }
예제 #2
0
 /**
  * Shows the certificate editor for ILIAS tests
  */
 public function certificateEditor()
 {
     global $ilAccess;
     $form_fields = array();
     if (strcmp($this->ctrl->getCmd(), "certificateSave") == 0) {
         $form_fields = $this->getFormFieldsFromPOST();
     } else {
         $form_fields = $this->getFormFieldsFromFO();
     }
     include_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
     $form = new ilPropertyFormGUI();
     $form->setPreventDoubleSubmission(false);
     $form->setFormAction($this->ctrl->getFormAction($this));
     $form->setTitle($this->lng->txt("certificate_edit"));
     $form->setMultipart(TRUE);
     $form->setTableWidth("100%");
     $form->setId("certificate");
     $active = new ilCheckboxInputGUI($this->lng->txt("active"), "active");
     $active->setChecked($form_fields["active"]);
     $form->addItem($active);
     $import = new ilFileInputGUI($this->lng->txt("import"), "certificate_import");
     $import->setRequired(FALSE);
     $import->setSuffixes(array("zip"));
     // handle the certificate import
     if (strlen($_FILES["certificate_import"]["tmp_name"])) {
         if ($import->checkInput()) {
             $result = $this->object->importCertificate($_FILES["certificate_import"]["tmp_name"], $_FILES["certificate_import"]["name"]);
             if ($result == FALSE) {
                 $import->setAlert($this->lng->txt("certificate_error_import"));
             } else {
                 $this->ctrl->redirect($this, "certificateEditor");
             }
         }
     }
     $form->addItem($import);
     $pageformat = new ilRadioGroupInputGUI($this->lng->txt("certificate_page_format"), "pageformat");
     $pageformats = $this->object->getPageFormats();
     $pageformat->setValue($form_fields["pageformat"]);
     foreach ($pageformats as $format) {
         $option = new ilRadioOption($format["name"], $format["value"]);
         if (strcmp($format["value"], "custom") == 0) {
             $pageheight = new ilTextInputGUI($this->lng->txt("certificate_pageheight"), "pageheight");
             $pageheight->setValue($form_fields["pageheight"]);
             $pageheight->setSize(6);
             $pageheight->setValidationRegexp("/[0123456789\\.](cm|mm|in|pt|pc|px|em)/is");
             $pageheight->setInfo($this->lng->txt("certificate_unit_description"));
             $pageheight->setRequired(true);
             $option->addSubitem($pageheight);
             $pagewidth = new ilTextInputGUI($this->lng->txt("certificate_pagewidth"), "pagewidth");
             $pagewidth->setValue($form_fields["pagewidth"]);
             $pagewidth->setSize(6);
             $pagewidth->setValidationRegexp("/[0123456789\\.](cm|mm|in|pt|pc|px|em)/is");
             $pagewidth->setInfo($this->lng->txt("certificate_unit_description"));
             $pagewidth->setRequired(true);
             $option->addSubitem($pagewidth);
         }
         $pageformat->addOption($option);
     }
     $pageformat->setRequired(true);
     if (strcmp($this->ctrl->getCmd(), "certificateSave") == 0) {
         $pageformat->checkInput();
     }
     $form->addItem($pageformat);
     $bgimage = new ilImageFileInputGUI($this->lng->txt("certificate_background_image"), "background");
     $bgimage->setRequired(FALSE);
     $bgimage->setUseCache(false);
     if (count($_POST)) {
         // handle the background upload
         if (strlen($_FILES["background"]["tmp_name"])) {
             if ($bgimage->checkInput()) {
                 $result = $this->object->uploadBackgroundImage($_FILES["background"]["tmp_name"]);
                 if ($result == FALSE) {
                     $bgimage->setAlert($this->lng->txt("certificate_error_upload_bgimage"));
                 }
             }
         }
     }
     if (!$this->object->hasBackgroundImage()) {
         include_once "./Services/Certificate/classes/class.ilObjCertificateSettingsAccess.php";
         if (ilObjCertificateSettingsAccess::hasBackgroundImage()) {
             $bgimage->setImage(ilObjCertificateSettingsAccess::getBackgroundImageThumbPathWeb());
         }
     } else {
         $bgimage->setImage($this->object->getBackgroundImageThumbPathWeb());
     }
     $form->addItem($bgimage);
     $padding_top = new ilTextInputGUI($this->lng->txt("certificate_padding_top"), "padding_top");
     $padding_top->setRequired(TRUE);
     $padding_top->setValue($form_fields["padding_top"]);
     $padding_top->setSize(6);
     $padding_top->setValidationRegexp("/[0123456789\\.](cm|mm|in|pt|pc|px|em)/is");
     $padding_top->setInfo($this->lng->txt("certificate_unit_description"));
     if (strcmp($this->ctrl->getCmd(), "certificateSave") == 0) {
         $padding_top->checkInput();
     }
     $form->addItem($padding_top);
     $rect = new ilCSSRectInputGUI($this->lng->txt("certificate_margin_body"), "margin_body");
     $rect->setRequired(TRUE);
     $rect->setUseUnits(TRUE);
     $rect->setTop($form_fields["margin_body_top"]);
     $rect->setBottom($form_fields["margin_body_bottom"]);
     $rect->setLeft($form_fields["margin_body_left"]);
     $rect->setRight($form_fields["margin_body_right"]);
     $rect->setInfo($this->lng->txt("certificate_unit_description"));
     if (strcmp($this->ctrl->getCmd(), "certificateSave") == 0) {
         $rect->checkInput();
     }
     $form->addItem($rect);
     $certificate = new ilTextAreaInputGUI($this->lng->txt("certificate_text"), "certificate_text");
     $certificate->removePlugin('ilimgupload');
     $certificate->setValue($form_fields["certificate_text"]);
     $certificate->setRequired(TRUE);
     $certificate->setRows(20);
     $certificate->setCols(80);
     // fraunhpatch start
     $common_desc_tpl = new ilTemplate("tpl.common_desc.html", true, true, "Services/Certificate");
     foreach (ilCertificate::getCustomCertificateFields() as $f) {
         $common_desc_tpl->setCurrentBlock("cert_field");
         $common_desc_tpl->setVariable("PH", $f["ph"]);
         $common_desc_tpl->setVariable("PH_TXT", $f["name"]);
         $common_desc_tpl->parseCurrentBlock();
     }
     $common_desc = $common_desc_tpl->get();
     // fraunhpatch start
     $certificate->setInfo($this->object->getAdapter()->getCertificateVariablesDescription() . $common_desc);
     $certificate->setUseRte(TRUE, '3.4.7');
     $tags = array("br", "em", "font", "li", "ol", "p", "span", "strong", "u", "ul");
     $certificate->setRteTags($tags);
     if (strcmp($this->ctrl->getCmd(), "certificateSave") == 0) {
         $certificate->checkInput();
     }
     $form->addItem($certificate);
     $this->object->getAdapter()->addAdditionalFormElements($form, $form_fields);
     if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) {
         if ($this->object->isComplete() || $this->object->hasBackgroundImage()) {
             $form->addCommandButton("certificatePreview", $this->lng->txt("certificate_preview"));
             $form->addCommandButton("certificateExportFO", $this->lng->txt("certificate_export"));
             $form->addCommandButton("certificateDelete", $this->lng->txt("delete"));
         }
         $form->addCommandButton("certificateSave", $this->lng->txt("save"));
     }
     $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
     if (strcmp($this->ctrl->getCmd(), "certificateSave") == 0) {
         if ($_POST["background_delete"]) {
             $this->object->deleteBackgroundImage();
         }
         if ($form->checkInput()) {
             try {
                 $xslfo = $this->object->processXHTML2FO($form_fields);
                 $this->object->getAdapter()->saveFormFields($form_fields);
                 $this->object->saveCertificate($xslfo);
                 $this->object->writeActive($form_fields["active"]);
                 ilUtil::sendSuccess($this->lng->txt("saved_successfully"), TRUE);
                 $this->ctrl->redirect($this, "certificateEditor");
             } catch (Exception $e) {
                 ilUtil::sendFailure($e->getMessage());
             }
         }
     }
 }