/**
  * 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());
             }
         }
     }
 }
 /**
  * Init image form
  */
 function initImageForm()
 {
     global $lng, $ilCtrl;
     include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
     $this->form_gui = new ilPropertyFormGUI();
     $this->form_gui->setTitle($lng->txt("sty_add_image"));
     $file_input = new ilImageFileInputGUI($lng->txt("sty_image_file"), "image_file");
     $file_input->setRequired(true);
     $this->form_gui->addItem($file_input);
     $this->form_gui->addCommandButton("uploadImage", $lng->txt("upload"));
     $this->form_gui->addCommandButton("cancelUpload", $lng->txt("cancel"));
     $this->form_gui->setFormAction($ilCtrl->getFormAction($this));
 }
 /**
  * Edit settings.
  */
 public function settings()
 {
     global $lng, $ilAccess;
     $this->tabs_gui->setTabActive('settings');
     $form_settings = new ilSetting("certificate");
     include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
     $form = new ilPropertyFormGUI();
     $form->setFormAction($this->ctrl->getFormAction($this));
     $form->setTitle($this->lng->txt('certificate_settings'));
     $active = new ilCheckboxInputGUI($this->lng->txt("active"), "active");
     $active->setChecked($form_settings->get("active"));
     $form->addItem($active);
     $info = new ilNonEditableValueGUI($this->lng->txt("info"), "info");
     $info->setValue($this->lng->txt("certificate_usage"));
     $form->addItem($info);
     $bgimage = new ilImageFileInputGUI($this->lng->txt("certificate_background_image"), "background");
     $bgimage->setRequired(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 (strlen($this->object->hasBackgroundImage())) {
         $bgimage->setImage($this->object->getBackgroundImageThumbPathWeb());
     }
     $bgimage->setInfo($this->lng->txt("default_background_info"));
     $form->addItem($bgimage);
     $format = new ilSelectInputGUI($this->lng->txt("certificate_page_format"), "pageformat");
     $defaultformats = array("a4" => $this->lng->txt("certificate_a4"), "a4landscape" => $this->lng->txt("certificate_a4_landscape"), "a5" => $this->lng->txt("certificate_a5"), "a5landscape" => $this->lng->txt("certificate_a5_landscape"), "letter" => $this->lng->txt("certificate_letter"), "letterlandscape" => $this->lng->txt("certificate_letter_landscape"));
     $format->setOptions($defaultformats);
     $format->setValue($form_settings->get("pageformat"));
     $format->setInfo($this->lng->txt("certificate_page_format_info"));
     $form->addItem($format);
     if ($ilAccess->checkAccess('write', '', $this->object->getRefId())) {
         $form->addCommandButton('save', $this->lng->txt('save'));
     }
     $this->tpl->setContent($form->getHTML());
     if (strcmp($this->ctrl->getCmd(), "save") == 0) {
         if ($_POST["background_delete"]) {
             $this->object->deleteBackgroundImage();
         }
     }
 }
 /**
  * Initializes SmiliesEditForm and returns it.
  *
  * @global ilCtrl2 $ilCtrl
  * @global ilLanguage $lng
  * @return ilPropertyFormGUI
  */
 public function initSmiliesEditForm($form_data)
 {
     global $ilCtrl, $lng;
     include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
     $this->form_gui = new ilPropertyFormGUI();
     $this->form_gui->setValuesByArray($form_data);
     $table_nav = $_REQUEST["_table_nav"] ? "&_table_nav=" . $_REQUEST["_table_nav"] : "";
     $ilCtrl->saveParameter($this->gui, 'smiley_id');
     $this->form_gui->setFormAction($ilCtrl->getFormAction($this->gui, 'smiley-updateSmiliesObject') . $table_nav);
     $sec_l = new ilFormSectionHeaderGUI();
     $sec_l->setTitle($lng->txt('chatroom_edit_smiley'));
     $this->form_gui->addItem($sec_l);
     include_once "Modules/Chatroom/classes/class.ilChatroomSmiliesCurrentSmileyFormElement.php";
     $inp = new ilChatroomSmiliesCurrentSmileyFormElement($lng->txt('chatroom_current_smiley_image_path'), 'chatroom_current_smiley_image_path');
     $inp->setValue($form_data['chatroom_current_smiley_image_path']);
     $this->form_gui->addItem($inp);
     $inp = new ilImageFileInputGUI($lng->txt('chatroom_image_path'), 'chatroom_image_path');
     $inp->setRequired(false);
     $inp->setInfo($lng->txt('chatroom_smiley_image_only_if_changed'));
     $this->form_gui->addItem($inp);
     $inp = new ilTextAreaInputGUI($lng->txt('chatroom_smiley_keywords'), 'chatroom_smiley_keywords');
     $inp->setValue($form_data['chatroom_smiley_keywords']);
     $inp->setUseRte(false);
     $inp->setRequired(true);
     $inp->setInfo($lng->txt('chatroom_smiley_keywords_one_per_line_note'));
     $this->form_gui->addItem($inp);
     $inp = new ilHiddenInputGUI('chatroom_smiley_id');
     $this->form_gui->addItem($inp);
     $this->form_gui->addCommandButton('smiley-updateSmiliesObject', $lng->txt('submit'));
     $this->form_gui->addCommandButton('smiley', $lng->txt('cancel'));
     return $this->form_gui;
 }
 /**
  * Init form
  */
 protected function initForm()
 {
     $title = $this->signature->getId() ? $this->pl->txt('edit_signature') : $this->pl->txt('add_new_signature');
     $this->setTitle($title);
     $this->setFormAction($this->ctrl->getFormAction($this->parent_gui));
     $item = new ilTextInputGUI($this->pl->txt('first_name'), 'first_name');
     $item->setValue($this->signature->getFirstName());
     $item->setRequired(true);
     $this->addItem($item);
     $item = new ilTextInputGUI($this->pl->txt('last_name'), 'last_name');
     $item->setValue($this->signature->getLastName());
     $item->setRequired(true);
     $this->addItem($item);
     // If the signature is a rasterized image, we display it base64 encoded
     $is_vector = in_array(strtolower($this->signature->getSuffix()), array('svg'));
     if ($is_vector) {
         $item = new ilFileInputGUI($this->pl->txt('signature_file'), 'signature_file');
     } else {
         $item = new ilImageFileInputGUI($this->pl->txt('signature_file'), 'signature_file');
     }
     $item->setSuffixes(array('jpeg', 'jpg', 'gif', 'bmp', 'png', 'svg'));
     $signature_file = $this->signature->getFilePath(true);
     if (is_file($signature_file) && !$is_vector) {
         $item->setValue($signature_file);
         $base64 = base64_encode(file_get_contents($signature_file));
         $suffix = $this->signature->getSuffix();
         $item->setImage("data:image/{$suffix};base64,{$base64}");
     }
     $item->setFilename($signature_file);
     $item->setInfo($this->pl->txt('signature_file_info'));
     $item->setRequired(!is_file($signature_file));
     $item->setValue($this->signature->getFilePath(true));
     $this->addItem($item);
     $command = $this->signature->getId() ? 'updateSignature' : 'createSignature';
     $this->addCommandButton($command, $this->lng->txt('save'));
 }