24 include_once(
"./Services/Certificate/classes/class.ilCertificate.php");
94 include_once
"./Services/Certificate/classes/class.ilCertificate.php";
100 $this->tree =&
$tree;
101 $this->ref_id =
$_GET[
"ref_id"];
102 $this->lng->loadLanguageModule(
"certificate");
110 $cmd = $this->ctrl->getCmd();
111 $next_class = $this->ctrl->getNextClass($this);
144 $this->
object->createPreview();
152 $this->
object->deliverExportFileXML();
160 $this->
object->deleteBackgroundImage();
170 include_once(
"./Services/Utilities/classes/class.ilConfirmationGUI.php");
172 $cgui->setFormAction($this->ctrl->getFormAction($this,
"certificateEditor"));
173 $cgui->setHeaderText($this->lng->txt(
"certificate_confirm_deletion_text"));
174 $cgui->setCancel($this->lng->txt(
"no"),
"certificateEditor");
175 $cgui->setConfirm($this->lng->txt(
"yes"),
"certificateDeleteConfirm");
177 $this->tpl->setContent($cgui->getHTML());
185 $this->
object->deleteCertificate();
186 $this->ctrl->redirect($this,
"certificateEditor");
210 $form_fields = array(
222 $this->
object->getAdapter()->addFormFieldsFromPOST($form_fields);
231 $form_fields = $this->
object->getFormFieldsFromFO();
232 $form_fields[
"active"] = $this->
object->readActive();
233 $this->
object->getAdapter()->addFormFieldsFromObject($form_fields);
244 $form_fields = array();
245 if (strcmp($this->ctrl->getCmd(),
"certificateSave") == 0)
253 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
255 $form->setFormAction($this->ctrl->getFormAction($this));
256 $form->setTitle($this->lng->txt(
"certificate_edit"));
257 $form->setMultipart(TRUE);
258 $form->setTableWidth(
"100%");
259 $form->setId(
"certificate");
263 $form->addItem($active);
265 $import =
new ilFileInputGUI($this->lng->txt(
"import"),
"certificate_import");
267 $import->setSuffixes(array(
"zip"));
269 if (strlen($_FILES[
"certificate_import"][
"tmp_name"]))
271 if ($import->checkInput())
273 $result = $this->
object->importCertificate($_FILES[
"certificate_import"][
"tmp_name"], $_FILES[
"certificate_import"][
"name"]);
276 $import->setAlert($this->lng->txt(
"certificate_error_import"));
280 $this->ctrl->redirect($this,
"certificateEditor");
284 $form->addItem($import);
286 $pageformat =
new ilSelectInputGUI($this->lng->txt(
"certificate_page_format"),
"pageformat");
287 $pageformats = $this->
object->getPageFormats();
288 $pageformat->
setValue($form_fields[
"pageformat"]);
290 foreach ($pageformats as $format)
292 $options[$format[
"value"]] = $format[
"name"];
294 $pageformat->setRequired(TRUE);
295 $pageformat->setOptions($options);
296 if (strcmp($this->ctrl->getCmd(),
"certificateSave") == 0) $pageformat->checkInput();
298 if (strcmp($form_fields[
"pageformat"],
"custom") == 0)
300 $pageheight =
new ilTextInputGUI($this->lng->txt(
"certificate_pageheight"),
"pageheight");
301 $pageheight->
setValue($form_fields[
"pageheight"]);
302 $pageheight->setSize(6);
303 $pageheight->setValidationRegexp(
"/[0123456789\\.](cm|mm|in|pt|pc|px|em)/is");
304 $pageheight->setInfo($this->lng->txt(
"certificate_unit_description"));
305 if (strcmp($this->ctrl->getCmd(),
"certificateSave") == 0) $pageheight->checkInput();
306 $pageformat->addSubitem($pageheight);
308 $pagewidth =
new ilTextInputGUI($this->lng->txt(
"certificate_pagewidth"),
"pagewidth");
309 $pagewidth->
setValue($form_fields[
"pagewidth"]);
310 $pagewidth->setSize(6);
311 $pagewidth->setValidationRegexp(
"/[0123456789\\.](cm|mm|in|pt|pc|px|em)/is");
312 $pagewidth->setInfo($this->lng->txt(
"certificate_unit_description"));
313 if (strcmp($this->ctrl->getCmd(),
"certificateSave") == 0) $pagewidth->checkInput();
314 $pageformat->addSubitem($pagewidth);
316 $form->addItem($pageformat);
318 $bgimage =
new ilImageFileInputGUI($this->lng->txt(
"certificate_background_image"),
"background");
320 $bgimage->setUseCache(
false);
324 if (strlen($_FILES[
"background"][
"tmp_name"]))
326 if ($bgimage->checkInput())
328 $result = $this->
object->uploadBackgroundImage($_FILES[
"background"][
"tmp_name"]);
331 $bgimage->setAlert($this->lng->txt(
"certificate_error_upload_bgimage"));
336 if (!$this->object->hasBackgroundImage())
338 include_once
"./Services/Certificate/classes/class.ilObjCertificateSettingsAccess.php";
346 $bgimage->setImage($this->object->getBackgroundImageThumbPathWeb());
348 $form->addItem($bgimage);
350 $padding_top =
new ilTextInputGUI($this->lng->txt(
"certificate_padding_top"),
"padding_top");
352 $padding_top->setValue($form_fields[
"padding_top"]);
353 $padding_top->setSize(6);
354 $padding_top->setValidationRegexp(
"/[0123456789\\.](cm|mm|in|pt|pc|px|em)/is");
355 $padding_top->setInfo($this->lng->txt(
"certificate_unit_description"));
356 if (strcmp($this->ctrl->getCmd(),
"certificateSave") == 0) $padding_top->checkInput();
357 $form->addItem($padding_top);
359 $rect =
new ilCSSRectInputGUI($this->lng->txt(
"certificate_margin_body"),
"margin_body");
361 $rect->setUseUnits(TRUE);
362 $rect->setTop($form_fields[
"margin_body_top"]);
363 $rect->setBottom($form_fields[
"margin_body_bottom"]);
364 $rect->setLeft($form_fields[
"margin_body_left"]);
365 $rect->setRight($form_fields[
"margin_body_right"]);
366 $rect->setInfo($this->lng->txt(
"certificate_unit_description"));
367 if (strcmp($this->ctrl->getCmd(),
"certificateSave") == 0) $rect->checkInput();
368 $form->addItem($rect);
370 $certificate =
new ilTextAreaInputGUI($this->lng->txt(
"certificate_text"),
"certificate_text");
372 $certificate->setValue($form_fields[
"certificate_text"]);
373 $certificate->setRequired(TRUE);
374 $certificate->setRows(20);
375 $certificate->setCols(80);
378 $common_desc_tpl =
new ilTemplate(
"tpl.common_desc.html",
true,
true,
"Services/Certificate");
381 $common_desc_tpl->setCurrentBlock(
"cert_field");
382 $common_desc_tpl->setVariable(
"PH", $f[
"ph"]);
383 $common_desc_tpl->setVariable(
"PH_TXT", $f[
"name"]);
384 $common_desc_tpl->parseCurrentBlock();
386 $common_desc = $common_desc_tpl->get();
389 $certificate->setInfo($this->object->getAdapter()->getCertificateVariablesDescription().$common_desc);
390 $certificate->setUseRte(TRUE,
'3.4.7');
403 $certificate->setRteTags($tags);
404 if (strcmp($this->ctrl->getCmd(),
"certificateSave") == 0) $certificate->checkInput();
405 $form->addItem($certificate);
407 $this->
object->getAdapter()->addAdditionalFormElements($form, $form_fields);
409 if ($ilAccess->checkAccess(
"write",
"",
$_GET[
"ref_id"]))
411 if ($this->object->isComplete() || $this->
object->hasBackgroundImage())
413 $form->addCommandButton(
"certificatePreview", $this->lng->txt(
"certificate_preview"));
414 $form->addCommandButton(
"certificateExportFO", $this->lng->txt(
"certificate_export"));
415 $form->addCommandButton(
"certificateDelete", $this->lng->txt(
"delete"));
417 $form->addCommandButton(
"certificateSave", $this->lng->txt(
"save"));
420 $this->tpl->setVariable(
"ADM_CONTENT", $form->getHTML());
422 if (strcmp($this->ctrl->getCmd(),
"certificateSave") == 0)
424 if (
$_POST[
"background_delete"])
426 $this->
object->deleteBackgroundImage();
428 if ($form->checkInput())
432 $xslfo = $this->
object->processXHTML2FO($form_fields);
433 $this->
object->getAdapter()->saveFormFields($form_fields);
434 $this->
object->saveCertificate($xslfo);
435 $this->
object->writeActive($form_fields[
"active"]);
437 $this->ctrl->redirect($this,
"certificateEditor");