00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00034 class ilTestCertificateGUI
00035 {
00043 var $object;
00051 var $ctrl;
00059 var $tree;
00067 var $ilias;
00068
00076 var $tpl;
00077
00085 var $lng;
00086 var $ref_id;
00087
00097 function ilTestCertificateGUI(&$a_object)
00098 {
00099 global $lng, $tpl, $ilCtrl, $ilias, $tree;
00100
00101 include_once "./Modules/Test/classes/class.ilTestCertificate.php";
00102 $this->object = new ilTestCertificate($a_object);
00103 $this->lng =& $lng;
00104 $this->tpl =& $tpl;
00105 $this->ctrl =& $ilCtrl;
00106 $this->ilias =& $ilias;
00107 $this->tree =& $tree;
00108 $this->ref_id = $_GET["ref_id"];
00109 }
00110
00114 function &executeCommand()
00115 {
00116 $cmd = $this->ctrl->getCmd();
00117 $next_class = $this->ctrl->getNextClass($this);
00118
00119 $cmd = $this->getCommand($cmd);
00120 switch($next_class)
00121 {
00122 default:
00123 $ret =& $this->$cmd();
00124 break;
00125 }
00126 return $ret;
00127 }
00128
00136 function getCommand($cmd)
00137 {
00138 return $cmd;
00139 }
00140
00148 function certificateImport()
00149 {
00150 $this->certificateEditor();
00151 }
00152
00160 function certificatePreview()
00161 {
00162 $this->object->createPreview();
00163 $this->certificateEditor();
00164 }
00165
00174 function exportCertificate()
00175 {
00176 $this->object->outCertificates($_GET["g_userfilter"], $_GET["g_passedonly"]);
00177 }
00178
00186 function certificateExportFO()
00187 {
00188 $this->object->deliverExportFileXML();
00189 }
00190
00191
00199 function certificateOutput()
00200 {
00201 $this->object->outCertificate($_GET["active_id"], $_GET["pass"]);
00202 }
00203
00211 function certificateRemoveBackground()
00212 {
00213 $this->object->deleteBackgroundImage();
00214 $this->certificateEditor();
00215 }
00216
00217 function getFormFieldsFromPOST()
00218 {
00219 $form_fields = array(
00220 "pageformat" => ilUtil::stripSlashes($_POST["pageformat"]),
00221 "padding_top" => ilUtil::stripSlashes($_POST["padding_top"]),
00222 "margin_body_top" => ilUtil::stripSlashes($_POST["margin_body_top"]),
00223 "margin_body_right" => ilUtil::stripSlashes($_POST["margin_body_right"]),
00224 "margin_body_bottom" => ilUtil::stripSlashes($_POST["margin_body_bottom"]),
00225 "margin_body_left" => ilUtil::stripSlashes($_POST["margin_body_left"]),
00226 "certificate_text" => ilUtil::stripSlashes($_POST["certificate_text"], FALSE),
00227 "pageheight" => ilUtil::stripSlashes($_POST["pageheight"]),
00228 "pagewidth" => ilUtil::stripSlashes($_POST["pagewidth"]),
00229 "certificate_visibility" => ilUtil::stripSlashes($_POST["certificate_visibility"])
00230 );
00231 return $form_fields;
00232 }
00233
00241 function certificateDelete()
00242 {
00243 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html", "Modules/Test");
00244
00245 $this->tpl->setCurrentBlock("table_header");
00246 $this->tpl->setVariable("TEXT", $this->lng->txt("confirmation"));
00247 $this->tpl->parseCurrentBlock();
00248 $this->tpl->setCurrentBlock("table_row");
00249 $this->tpl->setVariable("CSS_ROW", "tblrow1");
00250 $this->tpl->setVariable("TEXT_CONTENT", $this->lng->txt("certificate_confirm_deletion_text"));
00251 $this->tpl->parseCurrentBlock();
00252 $this->tpl->setCurrentBlock("operation_btn");
00253 $this->tpl->setVariable("BTN_NAME", "certificateDeleteConfirm");
00254 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("yes"));
00255 $this->tpl->parseCurrentBlock();
00256 $this->tpl->setCurrentBlock("operation_btn");
00257 $this->tpl->setVariable("BTN_NAME", "certificateEditor");
00258 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("no"));
00259 $this->tpl->parseCurrentBlock();
00260 }
00261
00269 function certificateDeleteConfirm()
00270 {
00271 $this->object->deleteCertificate();
00272 $this->ctrl->redirect($this, "certificateEditor");
00273 }
00274
00282 function certificateSave()
00283 {
00284 $this->certificateEditor();
00285 }
00286
00294 function certificateUpload()
00295 {
00296 $this->certificateEditor();
00297 }
00298
00306 function certificateEditor()
00307 {
00308 global $ilAccess;
00309 if (!$ilAccess->checkAccess("write", "", $this->ref_id))
00310 {
00311
00312 ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
00313 $this->ctrl->redirectByClass("ilobjtestgui", "infoScreen");
00314 }
00315 $form_fields = array();
00316 if (is_array($_POST))
00317 {
00318 if (count($_POST) > 0)
00319 {
00320
00321
00322
00323 if (strlen($_FILES["certificate_import"]["tmp_name"]))
00324 {
00325 $result = $this->object->importCertificate($_FILES["certificate_import"]["tmp_name"], $_FILES["certificate_import"]["name"]);
00326 if ($result == FALSE)
00327 {
00328 ilUtil::sendInfo($this->lng->txt("certificate_error_import"));
00329 }
00330 else
00331 {
00332 $this->ctrl->redirect($this, "certificateEditor");
00333 }
00334 }
00335
00336
00337 if (strlen($_FILES["background"]["tmp_name"]))
00338 {
00339 $result = $this->object->uploadBackgroundImage($_FILES["background"]["tmp_name"]);
00340 if ($result == FALSE)
00341 {
00342 ilUtil::sendInfo($this->lng->txt("certificate_error_upload_bgimage"));
00343 }
00344 }
00345 $form_fields = $this->getFormFieldsFromPOST();
00346 }
00347 else
00348 {
00349 $form_fields = $this->object->processFO2XHTML();
00350 }
00351 }
00352
00353 if ((strcmp($this->ctrl->getCmd(), "certificateSave") == 0) || (strcmp($this->ctrl->getCmd(), "certificateRemoveBackground") == 0))
00354 {
00355
00356
00357 $result = $this->object->checkCertificateInput($form_fields);
00358 if ($result !== TRUE)
00359 {
00360 ilUtil::sendInfo($result);
00361 }
00362 else
00363 {
00364 $xslfo = $this->object->processXHTML2FO($form_fields);
00365 $this->object->saveCertificateVisibility($form_fields["certificate_visibility"]);
00366 $this->object->saveCertificate($xslfo);
00367 }
00368 }
00369
00370 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_certificate_edit.html", "Modules/Test");
00371
00372 if ($this->object->hasBackgroundImage())
00373 {
00374 $this->tpl->setCurrentBlock("background_exists");
00375 $this->tpl->setVariable("BACKGROUND_THUMBNAIL", $this->object->getBackgroundImagePathWeb() . ".thumb.jpg");
00376 $this->tpl->setVariable("THUMBNAIL_ALT", $this->lng->txt("preview"));
00377 $this->tpl->setVariable("DELETE_BUTTON", $this->lng->txt("delete"));
00378 $this->tpl->parseCurrentBlock();
00379 }
00380
00381 $pageformats = $this->object->getPageFormats();
00382 foreach ($pageformats as $pageformat)
00383 {
00384 $this->tpl->setCurrentBlock("page_format_row");
00385 $this->tpl->setVariable("VALUE_PAGE_FORMAT", $pageformat["value"]);
00386 $this->tpl->setVariable("NAME_PAGE_FORMAT", $pageformat["name"]);
00387 if (strcmp($form_fields["pageformat"], $pageformat["value"]) == 0)
00388 {
00389 $this->tpl->setVariable("SELECTED_PAGE_FORMAT", " selected=\"selected\"");
00390 }
00391 $this->tpl->parseCurrentBlock();
00392 }
00393
00394 if (strcmp($form_fields["pageformat"], "custom") == 0)
00395 {
00396 $this->tpl->setCurrentBlock("custom_format");
00397 $this->tpl->setVariable("TEXT_PAGE_UNIT_DESCRIPTION", $this->lng->txt("certificate_unit_description"));
00398 $this->tpl->setVariable("TEXT_PAGEHEIGHT", $this->lng->txt("certificate_pageheight"));
00399 $this->tpl->setVariable("TEXT_PAGEWIDTH", $this->lng->txt("certificate_pagewidth"));
00400 if (strlen($form_fields["pageheight"]))
00401 {
00402 $this->tpl->setVariable("VALUE_PAGEHEIGHT", " value=\"".$form_fields["pageheight"]."\"");
00403 }
00404 if (strlen($form_fields["pagewidth"]))
00405 {
00406 $this->tpl->setVariable("VALUE_PAGEWIDTH", " value=\"".$form_fields["pagewidth"]."\"");
00407 }
00408 $this->tpl->parseCurrentBlock();
00409 }
00410
00411 $this->tpl->setVariable("TEXT_CERTIFICATE", $this->lng->txt("certificate_edit"));
00412 $this->tpl->setVariable("TEXT_STATUS", $this->lng->txt("certificate_status"));
00413 if ($this->object->isComplete() || $this->object->hasBackgroundImage())
00414 {
00415 $this->tpl->setVariable("DELETE_BUTTON_CERTIFICATE", $this->lng->txt("certificate_delete"));
00416 }
00417 if ($this->object->isComplete())
00418 {
00419 $this->tpl->setVariable("VALUE_STATUS", $this->lng->txt("certificate_status_complete"));
00420 include_once "./Services/Utilities/classes/class.ilUtil.php";
00421 $this->tpl->setVariable("HREF_STATUS_IMAGE", ilUtil::getImagePath("icon_ok.gif"));
00422 $this->tpl->setVariable("ALT_STATUS_IMAGE", $this->lng->txt("certificate_status_complete"));
00423 $this->tpl->setVariable("PREVIEW_BUTTON_CERTIFICATE", $this->lng->txt("certificate_preview"));
00424 $this->tpl->setVariable("PREVIEW_URL", $this->ctrl->getLinkTarget($this, "certificatePreview"));
00425 $this->tpl->setVariable("IMG_PREVIEW", ilUtil::getImagePath("icon_preview.gif"));
00426 $this->tpl->setVariable("IMG_EXPORT", ilUtil::getImagePath("icon_file.gif"));
00427 $this->tpl->setVariable("CERTIFICATE_EXPORT", $this->lng->txt("certificate_export"));
00428 $this->tpl->setVariable("EXPORT_URL", $this->ctrl->getLinkTarget($this, "certificateExportFO"));
00429 }
00430 else
00431 {
00432 $this->tpl->setVariable("VALUE_STATUS", $this->lng->txt("certificate_status_incomplete"));
00433 }
00434
00435 $this->tpl->setVariable("TEXT_CERTIFICATE_IMPORT", $this->lng->txt("import"));
00436
00437 $this->tpl->setVariable("BUTTON_SET_PAGEFORMAT", $this->lng->txt("change"));
00438 $this->tpl->setVariable("TEXT_PAGE_FORMAT", $this->lng->txt("certificate_page_format"));
00439 $this->tpl->setVariable("TEXT_BACKGROUND_IMAGE", $this->lng->txt("certificate_background_image"));
00440 $this->tpl->setVariable("TEXT_UPLOAD", $this->lng->txt("upload"));
00441 $this->tpl->setVariable("TEXT_PADDING_TOP", $this->lng->txt("certificate_padding_top"));
00442 if (strlen($form_fields["padding_top"]) > 0)
00443 {
00444 $this->tpl->setVariable("VALUE_PADDING_TOP", " value=\"".$form_fields["padding_top"]."\"");
00445 }
00446 $this->tpl->setVariable("TEXT_MARGIN_BODY", $this->lng->txt("certificate_margin_body"));
00447 $this->tpl->setVariable("TEXT_MARGIN_BODY_TOP", $this->lng->txt("certificate_top"));
00448 $this->tpl->setVariable("TEXT_MARGIN_BODY_RIGHT", $this->lng->txt("certificate_right"));
00449 $this->tpl->setVariable("TEXT_MARGIN_BODY_BOTTOM", $this->lng->txt("certificate_bottom"));
00450 $this->tpl->setVariable("TEXT_MARGIN_BODY_LEFT", $this->lng->txt("certificate_left"));
00451 if (strlen($form_fields["margin_body_top"]) > 0)
00452 {
00453 $this->tpl->setVariable("VALUE_MARGIN_BODY_TOP", " value=\"".$form_fields["margin_body_top"]."\"");
00454 }
00455 if (strlen($form_fields["margin_body_right"]) > 0)
00456 {
00457 $this->tpl->setVariable("VALUE_MARGIN_BODY_RIGHT", " value=\"".$form_fields["margin_body_right"]."\"");
00458 }
00459 if (strlen($form_fields["margin_body_bottom"]) > 0)
00460 {
00461 $this->tpl->setVariable("VALUE_MARGIN_BODY_BOTTOM", " value=\"".$form_fields["margin_body_bottom"]."\"");
00462 }
00463 if (strlen($form_fields["margin_body_left"]) > 0)
00464 {
00465 $this->tpl->setVariable("VALUE_MARGIN_BODY_LEFT", " value=\"".$form_fields["margin_body_left"]."\"");
00466 }
00467 $this->tpl->setVariable("TEXT_CERTIFICATE_TEXT", $this->lng->txt("certificate_text"));
00468 if (strlen($form_fields["certificate_text"]) > 0)
00469 {
00470 $this->tpl->setVariable("VALUE_CERTIFICATE_TEXT", $form_fields["certificate_text"]);
00471 }
00472 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00473 $this->tpl->setVariable("TEXT_SAVE", $this->lng->txt("save"));
00474 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "certificateSave"));
00475
00476 $this->tpl->setVariable("PH_INTRODUCTION", $this->lng->txt("certificate_ph_introduction"));
00477 $this->tpl->setVariable("PH_USER_FULLNAME", $this->lng->txt("certificate_ph_fullname"));
00478 $this->tpl->setVariable("PH_USER_FIRSTNAME", $this->lng->txt("certificate_ph_firstname"));
00479 $this->tpl->setVariable("PH_USER_LASTNAME", $this->lng->txt("certificate_ph_lastname"));
00480 $this->tpl->setVariable("PH_RESULT_PASSED", $this->lng->txt("certificate_ph_passed"));
00481 $this->tpl->setVariable("PH_RESULT_POINTS", $this->lng->txt("certificate_ph_resultpoints"));
00482 $this->tpl->setVariable("PH_RESULT_PERCENT", $this->lng->txt("certificate_ph_resultpercent"));
00483 $this->tpl->setVariable("PH_USER_TITLE", $this->lng->txt("certificate_ph_title"));
00484 $this->tpl->setVariable("PH_USER_STREET", $this->lng->txt("certificate_ph_street"));
00485 $this->tpl->setVariable("PH_USER_INSTITUTION", $this->lng->txt("certificate_ph_institution"));
00486 $this->tpl->setVariable("PH_USER_DEPARTMENT", $this->lng->txt("certificate_ph_department"));
00487 $this->tpl->setVariable("PH_USER_CITY", $this->lng->txt("certificate_ph_city"));
00488 $this->tpl->setVariable("PH_USER_ZIPCODE", $this->lng->txt("certificate_ph_zipcode"));
00489 $this->tpl->setVariable("PH_USER_COUNTRY", $this->lng->txt("certificate_ph_country"));
00490 $this->tpl->setVariable("PH_MAX_POINTS", $this->lng->txt("certificate_ph_maxpoints"));
00491 $this->tpl->setVariable("PH_RESULT_MARK_SHORT", $this->lng->txt("certificate_ph_markshort"));
00492 $this->tpl->setVariable("PH_RESULT_MARK_LONG", $this->lng->txt("certificate_ph_marklong"));
00493 $this->tpl->setVariable("PH_TEST_TITLE", $this->lng->txt("certificate_ph_testtitle"));
00494 $this->tpl->setVariable("PH_DATE", $this->lng->txt("certificate_ph_date"));
00495 $this->tpl->setVariable("PH_DATETIME", $this->lng->txt("certificate_ph_datetime"));
00496
00497 $this->tpl->setVariable("TEXT_UNIT_DESCRIPTION", $this->lng->txt("certificate_unit_description"));
00498 $this->tpl->setVariable("TEXT_CERTIFICATE_VISIBILITY", $this->lng->txt("certificate_visibility"));
00499 $this->tpl->setVariable("TEXT_CERTIFICATE_VISIBILITY_INTRODUCTION", $this->lng->txt("certificate_visibility_introduction"));
00500 $this->tpl->setVariable("TEXT_VISIBILITY_ALWAYS", $this->lng->txt("certificate_visibility_always"));
00501 $this->tpl->setVariable("TEXT_VISIBILITY_NEVER", $this->lng->txt("certificate_visibility_never"));
00502 $this->tpl->setVariable("TEXT_VISIBILITY_PASSED", $this->lng->txt("certificate_visibility_passed"));
00503 switch ($form_fields["certificate_visibility"])
00504 {
00505 case 1:
00506 $this->tpl->setVariable("CHECKED_CV_1", " checked=\"checked\"");
00507 break;
00508 case 2:
00509 $this->tpl->setVariable("CHECKED_CV_2", " checked=\"checked\"");
00510 break;
00511 case 0:
00512 default:
00513 $this->tpl->setVariable("CHECKED_CV_0", " checked=\"checked\"");
00514 break;
00515 }
00516
00517 include_once "./Services/RTE/classes/class.ilRTE.php";
00518 $rtestring = ilRTE::_getRTEClassname();
00519 include_once "./Services/RTE/classes/class.$rtestring.php";
00520 $rte = new $rtestring();
00521 include_once "./classes/class.ilObject.php";
00522 $obj_id = $_GET["q_id"];
00523 $obj_type = ilObject::_lookupType($_GET["ref_id"], TRUE);
00524
00525 $tags = array(
00526 "br",
00527 "em",
00528 "font",
00529 "li",
00530 "ol",
00531 "p",
00532 "span",
00533 "strong",
00534 "u",
00535 "ul"
00536 );
00537 $rte->addCustomRTESupport($obj_id, $obj_type, $tags);
00538
00539 $this->tpl->parseCurrentBlock();
00540 }
00541
00549 function outCertificate()
00550 {
00551 global $ilUser;
00552
00553 $active_id = $this->object->object->getTestSession()->getActiveId();
00554 $counted_pass = ilObjTest::_getResultPass($active_id);
00555 $this->ctrl->setParameterByClass("iltestcertificategui","active_id", $active_id);
00556 $this->ctrl->setParameterByClass("iltestcertificategui","pass", $counted_pass);
00557 $this->ctrl->redirectByClass("iltestcertificategui", "certificateOutput");
00558 }
00559 }
00560
00561 ?>