function initForm($a_mode)
 {
     global $ilCtrl, $lng, $ilSetting;
     include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
     $form_gui = new ilPropertyFormGUI();
     $form_gui->setFormAction($ilCtrl->getFormAction($this));
     $form_gui->setTitle($lng->txt("cont_ed_pglprop"));
     // title
     $title_input = new ilTextInputGUI($lng->txt("title"), "pgl_title");
     $title_input->setSize(50);
     $title_input->setMaxLength(128);
     $title_input->setValue($this->layout_object->title);
     $title_input->setTitle($lng->txt("title"));
     $title_input->setRequired(true);
     // description
     $desc_input = new ilTextAreaInputGUI($lng->txt("description"), "pgl_desc");
     $desc_input->setValue($this->layout_object->description);
     $desc_input->setRows(3);
     $desc_input->setCols(37);
     $desc_input->setTitle($lng->txt("description"));
     $desc_input->setRequired(false);
     // modules
     $mods = new ilCheckboxGroupInputGUI($this->lng->txt("modules"), "module");
     // $mods->setRequired(true);
     $mods->setValue($this->layout_object->getModules());
     foreach (ilPageLayout::getAvailableModules() as $mod_id => $mod_caption) {
         $mod = new ilCheckboxOption($mod_caption, $mod_id);
         $mods->addOption($mod);
     }
     $form_gui->addItem($title_input);
     $form_gui->addItem($desc_input);
     $form_gui->addItem($mods);
     // style
     $fixed_style = $ilSetting->get("fixed_content_style_id");
     $style_id = $this->layout_object->getStyleId();
     if ($fixed_style > 0) {
         $st = new ilNonEditableValueGUI($lng->txt("cont_current_style"));
         $st->setValue(ilObject::_lookupTitle($fixed_style) . " (" . $this->lng->txt("global_fixed") . ")");
         $form_gui->addItem($st);
     } else {
         include_once "./Services/Style/classes/class.ilObjStyleSheet.php";
         $st_styles = ilObjStyleSheet::_getStandardStyles(true, false);
         $st_styles[0] = $this->lng->txt("default");
         ksort($st_styles);
         $style_sel = new ilSelectInputGUI($lng->txt("obj_sty"), "style_id");
         $style_sel->setOptions($st_styles);
         $style_sel->setValue($style_id);
         $form_gui->addItem($style_sel);
     }
     $form_gui->addCommandButton("updateProperties", $lng->txt($a_mode));
     return $form_gui;
 }
 /**
  * FORM NewsItem: Init form.
  *
  * @param	int	$a_mode	Form Edit Mode (IL_FORM_EDIT | IL_FORM_CREATE)
  */
 public function initFormNewsItem($a_mode)
 {
     global $lng, $ilTabs;
     $ilTabs->clearTargets();
     //$this->setTabs();
     $lng->loadLanguageModule("news");
     include "Services/Form/classes/class.ilPropertyFormGUI.php";
     $this->form_gui = new ilPropertyFormGUI();
     // Property Title
     $text_input = new ilTextInputGUI($lng->txt("news_news_item_title"), "news_title");
     $text_input->setInfo("");
     $text_input->setRequired(true);
     $text_input->setMaxLength(200);
     $this->form_gui->addItem($text_input);
     // Property Content
     $text_area = new ilTextAreaInputGUI($lng->txt("news_news_item_content"), "news_content");
     $text_area->setInfo("");
     $text_area->setRequired(false);
     $this->form_gui->addItem($text_area);
     // Property Visibility
     $radio_group = new ilRadioGroupInputGUI($lng->txt("news_news_item_visibility"), "news_visibility");
     $radio_option = new ilRadioOption($lng->txt("news_visibility_users"), "users");
     $radio_group->addOption($radio_option);
     $radio_option = new ilRadioOption($lng->txt("news_visibility_public"), "public");
     $radio_group->addOption($radio_option);
     $radio_group->setInfo($lng->txt("news_news_item_visibility_info"));
     $radio_group->setRequired(false);
     $radio_group->setValue("users");
     $this->form_gui->addItem($radio_group);
     // Property ContentLong
     $text_area = new ilTextAreaInputGUI($lng->txt("news_news_item_content_long"), "news_content_long");
     $text_area->setInfo($lng->txt("news_news_item_content_long_info"));
     $text_area->setRequired(false);
     $text_area->setCols("40");
     $text_area->setRows("8");
     $text_area->setUseRte(true);
     $this->form_gui->addItem($text_area);
     // save and cancel commands
     if (in_array($a_mode, array(IL_FORM_CREATE, IL_FORM_RE_CREATE))) {
         $this->form_gui->addCommandButton("saveNewsItem", $lng->txt("save"));
         $this->form_gui->addCommandButton("cancelSaveNewsItem", $lng->txt("cancel"));
     } else {
         $this->form_gui->addCommandButton("updateNewsItem", $lng->txt("save"));
         $this->form_gui->addCommandButton("cancelUpdateNewsItem", $lng->txt("cancel"));
     }
     $this->form_gui->setTitle($lng->txt("news_news_item_head"));
     $this->form_gui->setFormAction($this->ctrl->getFormAction($this));
     $this->form_gui->setTitleIcon(ilUtil::getImagePath("icon_news.png"));
     $news_set = new ilSetting("news");
     if (!$news_set->get("enable_rss_for_internal")) {
         $this->form_gui->removeItemByPostVar("news_visibility");
     } else {
         $nv = $this->form_gui->getItemByPostVar("news_visibility");
         if (is_object($nv)) {
             $nv->setValue(ilNewsItem::_getDefaultVisibilityForRefId($_GET["ref_id"]));
         }
     }
 }
 public function InvoiceNumberObject()
 {
     include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
     $invObj = new ilUserDefinedInvoiceNumber();
     $this->tpl->addBlockfile('ADM_CONTENT', 'adm_content', 'tpl.main_view.html', 'Services/Payment');
     $this->tpl->addJavaScript('Services/Mail/js/ilMailComposeFunctions.js');
     $form_gui = new ilPropertyFormGUI();
     $form_gui->setFormAction($this->ctrl->getFormAction($this, 'saveInvoiceNumber'));
     $form_gui->setTitle($this->lng->txt('invoice_number_setting'));
     // invoice_type
     $radio_group = new ilRadioGroupInputGUI($this->lng->txt('invoice_number'), 'ud_invoice_number');
     $radio_option_1 = new ilRadioOption($this->lng->txt('ilias_invoice_number'), '0');
     $radio_group->addOption($radio_option_1);
     $radio_option_2 = new ilRadioOption($this->lng->txt('userdefined_invoice_number'), '1');
     $radio_group->addOption($radio_option_2);
     $radio_group->setRequired(true);
     $radio_group->setValue($invObj->getUDInvoiceNumberActive(), '0');
     $radio_group->setPostVar('ud_invoice_number');
     $form_gui->addItem($radio_group);
     // incremental current value
     $cur_num = new ilNonEditableValueGUI($this->lng->txt('incremental_current_value'), 'inc_current_value');
     $cur_num->setValue(ilUserDefinedInvoiceNumber::_getIncCurrentValue(), 1);
     $radio_option_2->addSubItem($cur_num);
     // incremental start value
     $inc_num = new ilNumberInputGUI($this->lng->txt('incremental_start_value'), 'inc_start_value');
     $inc_num->setValue($this->error != "" && isset($_POST['incremental_start_value']) ? ilUtil::prepareFormOutput($_POST['incremental_start_value'], true) : ilUtil::prepareFormOutput($invObj->getIncStartValue(), true));
     $inc_num->setInfo($this->lng->txt('incremental_start_value_info'));
     $radio_option_2->addSubItem($inc_num);
     // reset period of current value
     $sel_reset = new ilSelectInputGUI($this->lng->txt('invoice_number_reset_period'), 'inc_reset_period');
     $sel_reset->setValue($this->error != "" && isset($_POST['inc_reset_period']) ? $_POST['inc_reset_period'] : $invObj->getIncResetPeriod());
     $reset_options = array(1 => $this->lng->txt('yearly'), 2 => $this->lng->txt('monthly'));
     $sel_reset->setOptions($reset_options);
     $radio_option_2->addSubItem($sel_reset);
     // invoice_number_text
     $inp = new ilTextAreaInputGUI($this->lng->txt('invoice_number_text'), 'invoice_number_text');
     $inp->setValue($this->error != "" && isset($_POST['invoice_number_text']) ? ilUtil::prepareFormOutput($_POST['invoice_number_text'], true) : ilUtil::prepareFormOutput($invObj->getInvoiceNumberText(), true));
     $inp->setRequired(false);
     $inp->setCols(60);
     $inp->setRows(3);
     $radio_option_2->addSubItem($inp);
     // PLACEHOLDERS
     $prop = new ilInvoiceNumberPlaceholdersPropertyGUI();
     $radio_option_2->addSubItem($prop);
     $form_gui->addCommandButton('saveInvoiceNumber', $this->lng->txt('save'));
     $this->tpl->setVariable('FORM', $form_gui->getHTML());
 }
 /**
  * Creates the output of the feedback page for a single choice question
  *
  * @access public
  */
 function feedback($checkonly = false)
 {
     $save = strcmp($this->ctrl->getCmd(), "saveFeedback") == 0 ? TRUE : FALSE;
     include_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
     $form = new ilPropertyFormGUI();
     $form->setFormAction($this->ctrl->getFormAction($this));
     $form->setTitle($this->lng->txt('feedback_answers'));
     $form->setTableWidth("98%");
     $form->setId("feedback");
     $complete = new ilTextAreaInputGUI($this->lng->txt("feedback_complete_solution"), "feedback_complete");
     $complete->setValue($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(1)));
     $complete->setRequired(false);
     $complete->setRows(10);
     $complete->setCols(80);
     if (!$this->getPreventRteUsage()) {
         $complete->setUseRte(true);
     }
     include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
     $complete->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("assessment"));
     $complete->addPlugin("latex");
     $complete->addButton("latex");
     $complete->addButton("pastelatex");
     $complete->setRTESupport($this->object->getId(), "qpl", "assessment", null, false, '3.4.7');
     $form->addItem($complete);
     $incomplete = new ilTextAreaInputGUI($this->lng->txt("feedback_incomplete_solution"), "feedback_incomplete");
     $incomplete->setValue($this->object->prepareTextareaOutput($this->object->getFeedbackGeneric(0)));
     $incomplete->setRequired(false);
     $incomplete->setRows(10);
     $incomplete->setCols(80);
     if (!$this->getPreventRteUsage()) {
         $incomplete->setUseRte(true);
     }
     include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
     $incomplete->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("assessment"));
     $incomplete->addPlugin("latex");
     $incomplete->addButton("latex");
     $incomplete->addButton("pastelatex");
     $incomplete->setRTESupport($this->object->getId(), "qpl", "assessment", null, false, '3.4.7');
     $form->addItem($incomplete);
     if (!$this->getSelfAssessmentEditingMode()) {
         foreach ($this->object->getErrorData() as $index => $answer) {
             $caption = $ordinal = $index + 1;
             $caption .= '. <br />"' . $answer->text_wrong . '" =&gt; ';
             $caption .= '"' . $answer->text_correct . '"';
             $caption .= '</i>';
             $answerobj = new ilTextAreaInputGUI($this->object->prepareTextareaOutput($caption, true), "feedback_answer_{$index}");
             $answerobj->setValue($this->object->prepareTextareaOutput($this->object->getFeedbackSingleAnswer($index)));
             $answerobj->setRequired(false);
             $answerobj->setRows(10);
             $answerobj->setCols(80);
             $answerobj->setUseRte(true);
             include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
             $answerobj->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("assessment"));
             $answerobj->addPlugin("latex");
             $answerobj->addButton("latex");
             $answerobj->addButton("pastelatex");
             $answerobj->setRTESupport($this->object->getId(), "qpl", "assessment", null, false, '3.4.7');
             $form->addItem($answerobj);
         }
     }
     global $ilAccess;
     if ($ilAccess->checkAccess("write", "", $_GET['ref_id']) || $this->getSelfAssessmentEditingMode()) {
         $form->addCommandButton("saveFeedback", $this->lng->txt("save"));
     }
     if ($save) {
         $form->setValuesByPost();
         $errors = !$form->checkInput();
         $form->setValuesByPost();
         // again, because checkInput now performs the whole stripSlashes handling and we need this if we don't want to have duplication of backslashes
     }
     if (!$checkonly) {
         $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
     }
     return $errors;
 }
예제 #5
0
 /**
  * Allows to add suggested solutions for questions
  *
  * @access public
  */
 public function suggestedsolution()
 {
     global $ilUser;
     global $ilAccess;
     if ($_POST["deleteSuggestedSolution"] == 1) {
         $this->object->deleteSuggestedSolutions();
         ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
         $this->ctrl->redirect($this, "suggestedsolution");
     }
     $save = is_array($_POST["cmd"]) && array_key_exists("suggestedsolution", $_POST["cmd"]) ? TRUE : FALSE;
     $output = "";
     $solution_array = $this->object->getSuggestedSolution(0);
     $options = array("lm" => $this->lng->txt("obj_lm"), "st" => $this->lng->txt("obj_st"), "pg" => $this->lng->txt("obj_pg"), "git" => $this->lng->txt("glossary_term"), "file" => $this->lng->txt("fileDownload"), "text" => $this->lng->txt("solutionText"));
     if (strcmp($_POST["solutiontype"], "file") == 0 && strcmp($solution_array["type"], "file") != 0) {
         $solution_array = array("type" => "file");
     } elseif (strcmp($_POST["solutiontype"], "text") == 0 && strcmp($solution_array["type"], "text") != 0) {
         $solution_array = array("type" => "text", "value" => $this->getSolutionOutput(0, NULL, FALSE, FALSE, TRUE, FALSE, TRUE));
     }
     if ($save && strlen($_POST["filename"])) {
         $solution_array["value"]["filename"] = $_POST["filename"];
     }
     if ($save && strlen($_POST["solutiontext"])) {
         $solution_array["value"] = $_POST["solutiontext"];
     }
     include_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
     if (count($solution_array)) {
         $form = new ilPropertyFormGUI();
         $form->setFormAction($this->ctrl->getFormAction($this));
         $form->setTitle($this->lng->txt("solution_hint"));
         $form->setMultipart(TRUE);
         $form->setTableWidth("100%");
         $form->setId("suggestedsolutiondisplay");
         // suggested solution output
         include_once "./Modules/TestQuestionPool/classes/class.ilSolutionTitleInputGUI.php";
         $title = new ilSolutionTitleInputGUI($this->lng->txt("showSuggestedSolution"), "solutiontype");
         $template = new ilTemplate("tpl.il_as_qpl_suggested_solution_input_presentation.html", TRUE, TRUE, "Modules/TestQuestionPool");
         if (strlen($solution_array["internal_link"])) {
             $href = assQuestion::_getInternalLinkHref($solution_array["internal_link"]);
             $template->setCurrentBlock("preview");
             $template->setVariable("TEXT_SOLUTION", $this->lng->txt("suggested_solution"));
             $template->setVariable("VALUE_SOLUTION", " <a href=\"{$href}\" target=\"content\">" . $this->lng->txt("view") . "</a> ");
             $template->parseCurrentBlock();
         } elseif (strcmp($solution_array["type"], "file") == 0 && is_array($solution_array["value"])) {
             $href = $this->object->getSuggestedSolutionPathWeb() . $solution_array["value"]["name"];
             $template->setCurrentBlock("preview");
             $template->setVariable("TEXT_SOLUTION", $this->lng->txt("suggested_solution"));
             $template->setVariable("VALUE_SOLUTION", " <a href=\"{$href}\" target=\"content\">" . ilUtil::prepareFormOutput(strlen($solution_array["value"]["filename"]) ? $solution_array["value"]["filename"] : $solution_array["value"]["name"]) . "</a> ");
             $template->parseCurrentBlock();
         }
         $template->setVariable("TEXT_TYPE", $this->lng->txt("type"));
         $template->setVariable("VALUE_TYPE", $options[$solution_array["type"]]);
         $title->setHtml($template->get());
         $deletesolution = new ilCheckboxInputGUI("", "deleteSuggestedSolution");
         $deletesolution->setOptionTitle($this->lng->txt("deleteSuggestedSolution"));
         $title->addSubItem($deletesolution);
         $form->addItem($title);
         if (strcmp($solution_array["type"], "file") == 0) {
             // file
             $file = new ilFileInputGUI($this->lng->txt("fileDownload"), "file");
             $file->setRequired(TRUE);
             $file->enableFileNameSelection("filename");
             //$file->setSuffixes(array("doc","xls","png","jpg","gif","pdf"));
             if ($_FILES["file"]["tmp_name"] && $file->checkInput()) {
                 if (!file_exists($this->object->getSuggestedSolutionPath())) {
                     ilUtil::makeDirParents($this->object->getSuggestedSolutionPath());
                 }
                 $res = ilUtil::moveUploadedFile($_FILES["file"]["tmp_name"], $_FILES["file"]["name"], $this->object->getSuggestedSolutionPath() . $_FILES["file"]["name"]);
                 if ($res) {
                     ilUtil::renameExecutables($this->object->getSuggestedSolutionPath());
                     // remove an old file download
                     if (is_array($solution_array["value"])) {
                         @unlink($this->object->getSuggestedSolutionPath() . $solution_array["value"]["name"]);
                     }
                     $file->setValue($_FILES["file"]["name"]);
                     $this->object->saveSuggestedSolution("file", "", 0, array("name" => $_FILES["file"]["name"], "type" => $_FILES["file"]["type"], "size" => $_FILES["file"]["size"], "filename" => $_POST["filename"]));
                     $originalexists = $this->object->_questionExistsInPool($this->object->original_id);
                     if (($_GET["calling_test"] || isset($_GET['calling_consumer']) && (int) $_GET['calling_consumer']) && $originalexists && assQuestion::_isWriteable($this->object->original_id, $ilUser->getId())) {
                         return $this->originalSyncForm("suggestedsolution");
                     } else {
                         ilUtil::sendSuccess($this->lng->txt("suggested_solution_added_successfully"), TRUE);
                         $this->ctrl->redirect($this, "suggestedsolution");
                     }
                 } else {
                     // BH: $res as info string? wtf? it holds a bool or something else!!?
                     ilUtil::sendInfo($res);
                 }
             } else {
                 if (is_array($solution_array["value"])) {
                     $file->setValue($solution_array["value"]["name"]);
                     $file->setFilename(strlen($solution_array["value"]["filename"]) ? $solution_array["value"]["filename"] : $solution_array["value"]["name"]);
                 }
             }
             $form->addItem($file);
             $hidden = new ilHiddenInputGUI("solutiontype");
             $hidden->setValue("file");
             $form->addItem($hidden);
         } else {
             if (strcmp($solution_array["type"], "text") == 0) {
                 $question = new ilTextAreaInputGUI($this->lng->txt("solutionText"), "solutiontext");
                 $question->setValue($this->object->prepareTextareaOutput($solution_array["value"]));
                 $question->setRequired(TRUE);
                 $question->setRows(10);
                 $question->setCols(80);
                 $question->setUseRte(TRUE);
                 $question->addPlugin("latex");
                 $question->addButton("latex");
                 $question->setRTESupport($this->object->getId(), "qpl", "assessment");
                 $hidden = new ilHiddenInputGUI("solutiontype");
                 $hidden->setValue("text");
                 $form->addItem($hidden);
                 $form->addItem($question);
             }
         }
         if ($ilAccess->checkAccess("write", "", $_GET['ref_id'])) {
             $form->addCommandButton("suggestedsolution", $this->lng->txt("save"));
         }
         if ($save) {
             if ($form->checkInput()) {
                 switch ($solution_array["type"]) {
                     case "file":
                         $this->object->saveSuggestedSolution("file", "", 0, array("name" => $solution_array["value"]["name"], "type" => $solution_array["value"]["type"], "size" => $solution_array["value"]["size"], "filename" => $_POST["filename"]));
                         break;
                     case "text":
                         $this->object->saveSuggestedSolution("text", "", 0, $solution_array["value"]);
                         break;
                 }
                 $originalexists = $this->object->_questionExistsInPool($this->object->original_id);
                 if (($_GET["calling_test"] || isset($_GET['calling_consumer']) && (int) $_GET['calling_consumer']) && $originalexists && assQuestion::_isWriteable($this->object->original_id, $ilUser->getId())) {
                     return $this->originalSyncForm("suggestedsolution");
                 } else {
                     ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
                     $this->ctrl->redirect($this, "suggestedsolution");
                 }
             }
         }
         $output = $form->getHTML();
     }
     $savechange = strcmp($this->ctrl->getCmd(), "saveSuggestedSolution") == 0 ? TRUE : FALSE;
     $changeoutput = "";
     if ($ilAccess->checkAccess("write", "", $_GET['ref_id'])) {
         $formchange = new ilPropertyFormGUI();
         $formchange->setFormAction($this->ctrl->getFormAction($this));
         $formchange->setTitle(count($solution_array) ? $this->lng->txt("changeSuggestedSolution") : $this->lng->txt("addSuggestedSolution"));
         $formchange->setMultipart(FALSE);
         $formchange->setTableWidth("100%");
         $formchange->setId("suggestedsolution");
         $solutiontype = new ilRadioGroupInputGUI($this->lng->txt("suggestedSolutionType"), "solutiontype");
         foreach ($options as $opt_value => $opt_caption) {
             $solutiontype->addOption(new ilRadioOption($opt_caption, $opt_value));
         }
         if (count($solution_array)) {
             $solutiontype->setValue($solution_array["type"]);
         }
         $solutiontype->setRequired(TRUE);
         $formchange->addItem($solutiontype);
         $formchange->addCommandButton("saveSuggestedSolution", $this->lng->txt("select"));
         if ($savechange) {
             $formchange->checkInput();
         }
         $changeoutput = $formchange->getHTML();
     }
     $this->tpl->setVariable("ADM_CONTENT", $changeoutput . $output);
 }
 public function initAssignmentForm($a_mode = "create")
 {
     global $lng, $ilCtrl, $ilSetting;
     // init form
     include_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
     $this->form = new ilPropertyFormGUI();
     $this->form->setTitle($a_mode == "edit" ? $this->txt("edit_assignment") : $this->txt("new_assignment"));
     $this->form->setFormAction($ilCtrl->getFormAction($this));
     // title
     $title = new ilTextInputGUI($this->txt("title"), "title");
     $title->setMaxLength(200);
     $title->setRequired(true);
     $this->form->addItem($title);
     // start time y/n
     $check_start_time = new ilCheckboxInputGUI($this->txt("start_time"), "start_time_cb");
     $this->form->addItem($check_start_time);
     // start time
     $start_time = new ilDateTimeInputGUI("", "start_time");
     $start_time->setShowTime(true);
     $check_start_time->addSubItem($start_time);
     // Deadline
     $deadline = new ilDateTimeInputGUI($this->txt("deadline"), "deadline");
     $deadline->setShowTime(true);
     $deadline->setRequired(true);
     $this->form->addItem($deadline);
     // mandatory
     $mandatory = new ilCheckboxInputGUI($this->txt("mandatory"), "mandatory");
     $mandatory->setInfo($this->txt("mandatory_info"));
     $mandatory->setChecked(true);
     $this->form->addItem($mandatory);
     // Work Instructions
     $instruction = new ilTextAreaInputGUI($this->txt("instruction"), "instruction");
     $instruction->setCols(39);
     $instruction->setRows(4);
     $instruction->setRequired(true);
     $this->form->addItem($instruction);
     // files
     if ($a_mode == "create") {
         $files = new ilFileWizardInputGUI($this->txt('files'), 'files');
         $files->setFilenames(array(0 => ''));
         $this->form->addItem($files);
         $this->form->addCommandButton("saveAssignment", $lng->txt("save"));
         $this->form->addCommandButton("listAssignments", $lng->txt("cancel"));
     } else {
         $this->form->addCommandButton("updateAssignment", $lng->txt("save"));
         $this->form->addCommandButton("listAssignments", $lng->txt("cancel"));
     }
 }
예제 #7
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());
             }
         }
     }
 }
 /**
  * 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;
 }
예제 #9
0
 public function showForm()
 {
     global $rbacsystem, $ilUser, $ilCtrl, $lng, $ilTabs;
     $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.mail_new.html", "Services/Mail");
     $this->tpl->setTitle($this->lng->txt("mail"));
     $this->lng->loadLanguageModule("crs");
     if (ilMailFormCall::isRefererStored()) {
         $ilTabs->setBackTarget($lng->txt('back'), $ilCtrl->getLinkTarget($this, 'cancelMail'));
     }
     switch ($_GET["type"]) {
         case 'reply':
             if ($_SESSION['mail_id']) {
                 $_GET['mail_id'] = $_SESSION['mail_id'];
             }
             $mailData = $this->umail->getMail($_GET["mail_id"]);
             $mailData["m_subject"] = $this->umail->formatReplySubject();
             $mailData["m_message"] = $this->umail->formatReplyMessage();
             $mailData["m_message"] = $this->umail->prependSignature();
             // NO ATTACHMENTS FOR REPLIES
             $mailData["attachments"] = array();
             //$mailData["rcp_cc"] = $this->umail->formatReplyRecipientsForCC();
             $mailData["rcp_cc"] = '';
             $mailData["rcp_to"] = $this->umail->formatReplyRecipient();
             $_SESSION["mail_id"] = "";
             break;
         case 'search_res':
             $mailData = $this->umail->getSavedData();
             /*if($_SESSION["mail_search_results"])
             		{
             			$mailData = $this->umail->appendSearchResult($_SESSION["mail_search_results"],$_SESSION["mail_search"]);
             		}
             		unset($_SESSION["mail_search"]);
             		unset($_SESSION["mail_search_results"]);*/
             if ($_SESSION["mail_search_results_to"]) {
                 $mailData = $this->umail->appendSearchResult($_SESSION["mail_search_results_to"], 'to');
             }
             if ($_SESSION["mail_search_results_cc"]) {
                 $mailData = $this->umail->appendSearchResult($_SESSION["mail_search_results_cc"], 'cc');
             }
             if ($_SESSION["mail_search_results_bcc"]) {
                 $mailData = $this->umail->appendSearchResult($_SESSION["mail_search_results_bcc"], 'bc');
             }
             unset($_SESSION["mail_search_results_to"]);
             unset($_SESSION["mail_search_results_cc"]);
             unset($_SESSION["mail_search_results_bcc"]);
             break;
         case 'attach':
             $mailData = $this->umail->getSavedData();
             break;
         case 'draft':
             $_SESSION["draft"] = $_GET["mail_id"];
             $mailData = $this->umail->getMail($_GET["mail_id"]);
             break;
         case 'forward':
             $mailData = $this->umail->getMail($_GET["mail_id"]);
             $mailData["rcp_to"] = $mailData["rcp_cc"] = $mailData["rcp_bcc"] = '';
             $mailData["m_subject"] = $this->umail->formatForwardSubject();
             $mailData["m_message"] = $this->umail->prependSignature();
             if (count($mailData["attachments"])) {
                 if ($error = $this->mfile->adoptAttachments($mailData["attachments"], $_GET["mail_id"])) {
                     ilUtil::sendInfo($error);
                 }
             }
             break;
         case 'new':
             if ($_GET['rcp_to']) {
                 // Note: For security reasons, ILIAS only allows Plain text strings in E-Mails.
                 $mailData["rcp_to"] = ilUtil::securePlainString($_GET['rcp_to']);
             } else {
                 if ($_SESSION['rcp_to']) {
                     $mailData["rcp_to"] = $_SESSION['rcp_to'];
                 }
             }
             if ($_GET['rcp_cc']) {
                 // Note: For security reasons, ILIAS only allows Plain text strings in E-Mails.
                 $mailData["rcp_cc"] = ilUtil::securePlainString($_GET['rcp_cc']);
             } else {
                 if ($_SESSION['rcp_cc']) {
                     $mailData["rcp_cc"] = $_SESSION['rcp_cc'];
                 }
             }
             if ($_GET['rcp_bcc']) {
                 // Note: For security reasons, ILIAS only allows Plain text strings in E-Mails.
                 $mailData["rcp_bcc"] = ilUtil::securePlainString($_GET['rcp_bcc']);
             } else {
                 if ($_SESSION['rcp_bcc']) {
                     $mailData["rcp_bcc"] = $_SESSION['rcp_bcc'];
                 }
             }
             $mailData['m_message'] = '';
             if (strlen($sig = ilMailFormCall::getSignature())) {
                 $mailData['m_message'] = $sig;
                 $mailData['m_message'] .= chr(13) . chr(10) . chr(13) . chr(10);
             }
             $mailData['m_message'] .= $this->umail->appendSignature();
             $_SESSION['rcp_to'] = '';
             $_SESSION['rcp_cc'] = '';
             $_SESSION['rcp_bcc'] = '';
             break;
         case 'role':
             if (is_array($_POST['roles'])) {
                 // Note: For security reasons, ILIAS only allows Plain text strings in E-Mails.
                 $mailData['rcp_to'] = ilUtil::securePlainString(implode(',', $_POST['roles']));
             } elseif (is_array($_SESSION['mail_roles'])) {
                 $mailData['rcp_to'] = ilUtil::securePlainString(implode(',', $_SESSION['mail_roles']));
             }
             $mailData['m_message'] = '';
             if (strlen($sig = ilMailFormCall::getSignature())) {
                 $mailData['m_message'] = $sig;
                 $mailData['m_message'] .= chr(13) . chr(10) . chr(13) . chr(10);
             }
             $mailData['m_message'] .= $_POST["additional_message_text"] . chr(13) . chr(10) . $this->umail->appendSignature();
             $_POST["additional_message_text"] = "";
             $_SESSION['mail_roles'] = "";
             break;
         case 'address':
             $mailData["rcp_to"] = urldecode($_GET["rcp"]);
             break;
         default:
             // GET DATA FROM POST
             $mailData = $_POST;
             // strip slashes
             foreach ($mailData as $key => $value) {
                 if (is_string($value)) {
                     // Note: For security reasons, ILIAS only allows Plain text strings in E-Mails.
                     $mailData[$key] = ilUtil::securePlainString($value);
                 }
             }
             break;
     }
     include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
     $form_gui = new ilPropertyFormGUI();
     $form_gui->setTitle($this->lng->txt('compose'));
     $form_gui->setOpenTag(false);
     $this->tpl->setVariable('FORM_ACTION', $this->ctrl->getFormAction($this, 'sendMessage'));
     $this->tpl->setVariable('BUTTON_TO', $lng->txt("search_recipients"));
     $this->tpl->setVariable('BUTTON_COURSES_TO', $lng->txt("mail_my_courses"));
     $this->tpl->setVariable('BUTTON_GROUPS_TO', $lng->txt("mail_my_groups"));
     $this->tpl->setVariable('BUTTON_MAILING_LISTS_TO', $lng->txt("mail_my_mailing_lists"));
     $dsDataLink = $ilCtrl->getLinkTarget($this, 'lookupRecipientAsync', '', true);
     // RECIPIENT
     $inp = new ilTextInputGUI($this->lng->txt('mail_to'), 'rcp_to');
     $inp->setRequired(true);
     $inp->setSize(50);
     $inp->setValue($mailData["rcp_to"]);
     $inp->setDataSource($dsDataLink, ",");
     $inp->setMaxLength(null);
     $form_gui->addItem($inp);
     // CC
     $inp = new ilTextInputGUI($this->lng->txt('cc'), 'rcp_cc');
     $inp->setSize(50);
     $inp->setValue($mailData["rcp_cc"]);
     $inp->setDataSource($dsDataLink, ",");
     $inp->setMaxLength(null);
     $form_gui->addItem($inp);
     // BCC
     $inp = new ilTextInputGUI($this->lng->txt('bc'), 'rcp_bcc');
     $inp->setSize(50);
     $inp->setValue($mailData["rcp_bcc"]);
     $inp->setDataSource($dsDataLink, ",");
     $inp->setMaxLength(null);
     $form_gui->addItem($inp);
     // SUBJECT
     $inp = new ilTextInputGUI($this->lng->txt('subject'), 'm_subject');
     $inp->setSize(50);
     $inp->setRequired(true);
     $inp->setValue($mailData["m_subject"]);
     $form_gui->addItem($inp);
     // Attachments
     include_once 'Services/Mail/classes/class.ilMailFormAttachmentFormPropertyGUI.php';
     $att = new ilMailFormAttachmentPropertyGUI($this->lng->txt($mailData["attachments"] ? 'edit' : 'add'));
     if (is_array($mailData["attachments"]) && count($mailData["attachments"])) {
         foreach ($mailData["attachments"] as $data) {
             if (is_file($this->mfile->getMailPath() . '/' . $ilUser->getId() . "_" . $data)) {
                 $hidden = new ilHiddenInputGUI('attachments[]');
                 $form_gui->addItem($hidden);
                 $size = filesize($this->mfile->getMailPath() . '/' . $ilUser->getId() . "_" . $data);
                 $label = $data . " [" . ilFormat::formatSize($size) . "]";
                 $att->addItem($label);
                 $hidden->setValue(urlencode($data));
             }
         }
     }
     $form_gui->addItem($att);
     // ONLY IF SYSTEM MAILS ARE ALLOWED
     if ($rbacsystem->checkAccess("system_message", $this->umail->getMailObjectReferenceId())) {
         $chb = new ilCheckboxInputGUI($this->lng->txt('type'), 'm_type[]');
         $chb->setOptionTitle($this->lng->txt('system_message'));
         $chb->setValue('system');
         $chb->setChecked(false);
         if (is_array($mailData["m_type"]) and in_array('system', $mailData["m_type"])) {
             $chb->setChecked(true);
         }
         $form_gui->addItem($chb);
     }
     // MESSAGE
     $inp = new ilTextAreaInputGUI($this->lng->txt('message_content'), 'm_message');
     //$inp->setValue(htmlspecialchars($mailData["m_message"], false));
     $inp->setValue($mailData["m_message"]);
     $inp->setRequired(false);
     $inp->setCols(60);
     $inp->setRows(10);
     // PLACEHOLDERS
     $chb = new ilCheckboxInputGUI($this->lng->txt('activate_serial_letter_placeholders'), 'use_placeholders');
     $chb->setOptionTitle($this->lng->txt('activate_serial_letter_placeholders'));
     $chb->setValue(1);
     $chb->setChecked(false);
     $form_gui->addItem($inp);
     include_once 'Services/Mail/classes/class.ilMailFormPlaceholdersPropertyGUI.php';
     $prop = new ilMailFormPlaceholdersPropertyGUI();
     $chb->addSubItem($prop);
     if ($mailData['use_placeholders']) {
         $chb->setChecked(true);
     }
     $form_gui->addItem($chb);
     $form_gui->addCommandButton('sendMessage', $this->lng->txt('send_mail'));
     $form_gui->addCommandButton('saveDraft', $this->lng->txt('save_message'));
     if (ilMailFormCall::isRefererStored()) {
         $form_gui->addCommandButton('cancelMail', $this->lng->txt('cancel'));
     }
     $this->tpl->parseCurrentBlock();
     $this->tpl->setVariable('FORM', $form_gui->getHTML());
     $this->tpl->addJavaScript('Services/Mail/js/ilMailComposeFunctions.js');
     $this->tpl->show();
 }
 function initMailRatersForm($appr_id, array $rec_ids)
 {
     include_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
     $form = new ilPropertyFormGUI();
     $form->setFormAction($this->ctrl->getFormAction($this, "mailRatersAction"));
     $form->setTitle($this->lng->txt('compose'));
     $all_data = $this->object->getRatersData($appr_id);
     $rec_data = array();
     foreach ($rec_ids as $rec_id) {
         if (isset($all_data[$rec_id])) {
             $rec_data[] = $all_data[$rec_id]["lastname"] . ", " . $all_data[$rec_id]["firstname"] . " (" . $all_data[$rec_id]["email"] . ")";
         }
     }
     sort($rec_data);
     $rec = new ilCustomInputGUI($this->lng->txt('recipients'));
     $rec->setHTML(implode("<br />", $rec_data));
     $form->addItem($rec);
     $subject = new ilTextInputGUI($this->lng->txt('subject'), 'subject');
     $subject->setSize(50);
     $subject->setRequired(true);
     $form->addItem($subject);
     $existingdata = $this->object->getExternalCodeRecipients();
     $existingcolumns = array();
     if (count($existingdata)) {
         $first = array_shift($existingdata);
         foreach ($first as $key => $value) {
             if (strcmp($key, 'code') != 0 && strcmp($key, 'email') != 0 && strcmp($key, 'sent') != 0) {
                 array_push($existingcolumns, '[' . $key . ']');
             }
         }
     }
     $mailmessage_u = new ilTextAreaInputGUI($this->lng->txt('survey_360_rater_message_content_registered'), 'message_u');
     $mailmessage_u->setRequired(true);
     $mailmessage_u->setCols(80);
     $mailmessage_u->setRows(10);
     $form->addItem($mailmessage_u);
     $mailmessage_a = new ilTextAreaInputGUI($this->lng->txt('survey_360_rater_message_content_anonymous'), 'message_a');
     $mailmessage_a->setRequired(true);
     $mailmessage_a->setCols(80);
     $mailmessage_a->setRows(10);
     $mailmessage_a->setInfo(sprintf($this->lng->txt('message_content_info'), join($existingcolumns, ', ')));
     $form->addItem($mailmessage_a);
     $recf = new ilHiddenInputGUI("rtr_id");
     $recf->setValue(implode(";", $rec_ids));
     $form->addItem($recf);
     $form->addCommandButton("mailRatersAction", $this->lng->txt("send"));
     $form->addCommandButton("editRaters", $this->lng->txt("cancel"));
     $subject->setValue(sprintf($this->lng->txt('survey_360_rater_subject_default'), $this->object->getTitle()));
     $mailmessage_u->setValue($this->lng->txt('survey_360_rater_message_content_registered_default'));
     $mailmessage_a->setValue($this->lng->txt('survey_360_rater_message_content_anonymous_default'));
     return $form;
 }
 /**
  * Creates an output of the edit form for the question
  *
  * @access public
  */
 public function editQuestion($checkonly = FALSE)
 {
     include_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
     $form = new ilPropertyFormGUI();
     $form->setFormAction($this->ctrl->getFormAction($this));
     $form->setTitle($this->lng->txt($this->getQuestionType()));
     $form->setMultipart(FALSE);
     $form->setTableWidth("100%");
     $form->setId("multiplechoice");
     // title
     $title = new ilTextInputGUI($this->lng->txt("title"), "title");
     $title->setValue($this->object->getTitle());
     $title->setRequired(TRUE);
     $form->addItem($title);
     // label
     $label = new ilTextInputGUI($this->lng->txt("label"), "label");
     $label->setValue($this->object->label);
     $label->setInfo($this->lng->txt("label_info"));
     $label->setRequired(false);
     $form->addItem($label);
     // author
     $author = new ilTextInputGUI($this->lng->txt("author"), "author");
     $author->setValue($this->object->getAuthor());
     $author->setRequired(TRUE);
     $form->addItem($author);
     // description
     $description = new ilTextInputGUI($this->lng->txt("description"), "description");
     $description->setValue($this->object->getDescription());
     $description->setRequired(FALSE);
     $form->addItem($description);
     // questiontext
     $question = new ilTextAreaInputGUI($this->lng->txt("question"), "question");
     $question->setValue($this->object->prepareTextareaOutput($this->object->getQuestiontext()));
     $question->setRequired(TRUE);
     $question->setRows(10);
     $question->setCols(80);
     $question->setUseRte(TRUE);
     include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
     $question->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("survey"));
     $question->addPlugin("latex");
     $question->addButton("latex");
     $question->addButton("pastelatex");
     $question->setRTESupport($this->object->getId(), "spl", "survey", null, false, "3.4.7");
     $form->addItem($question);
     // subtype
     $subtype = new ilRadioGroupInputGUI($this->lng->txt("subtype"), "type");
     $subtype->setRequired(false);
     $subtype->setValue($this->object->getSubtype());
     $subtypes = array("0" => "matrix_subtype_sr", "1" => "matrix_subtype_mr");
     foreach ($subtypes as $idx => $st) {
         $subtype->addOption(new ilRadioOption($this->lng->txt($st), $idx));
     }
     $form->addItem($subtype);
     // obligatory
     $shuffle = new ilCheckboxInputGUI($this->lng->txt("obligatory"), "obligatory");
     $shuffle->setValue(1);
     $shuffle->setChecked($this->object->getObligatory());
     $shuffle->setRequired(FALSE);
     $form->addItem($shuffle);
     $header = new ilFormSectionHeaderGUI();
     $header->setTitle($this->lng->txt("matrix_appearance"));
     $form->addItem($header);
     // column separators
     $column_separators = new ilCheckboxInputGUI($this->lng->txt("matrix_column_separators"), "column_separators");
     $column_separators->setValue(1);
     $column_separators->setInfo($this->lng->txt("matrix_column_separators_description"));
     $column_separators->setChecked($this->object->getColumnSeparators());
     $column_separators->setRequired(false);
     $form->addItem($column_separators);
     // row separators
     $row_separators = new ilCheckboxInputGUI($this->lng->txt("matrix_row_separators"), "row_separators");
     $row_separators->setValue(1);
     $row_separators->setInfo($this->lng->txt("matrix_row_separators_description"));
     $row_separators->setChecked($this->object->getRowSeparators());
     $row_separators->setRequired(false);
     $form->addItem($row_separators);
     // neutral column separators
     $neutral_column_separator = new ilCheckboxInputGUI($this->lng->txt("matrix_neutral_column_separator"), "neutral_column_separator");
     $neutral_column_separator->setValue(1);
     $neutral_column_separator->setInfo($this->lng->txt("matrix_neutral_column_separator_description"));
     $neutral_column_separator->setChecked($this->object->getNeutralColumnSeparator());
     $neutral_column_separator->setRequired(false);
     $form->addItem($neutral_column_separator);
     $header = new ilFormSectionHeaderGUI();
     $header->setTitle($this->lng->txt("matrix_columns"));
     $form->addItem($header);
     // Answers
     include_once "./Modules/SurveyQuestionPool/classes/class.ilCategoryWizardInputGUI.php";
     $columns = new ilCategoryWizardInputGUI("", "columns");
     $columns->setRequired(false);
     $columns->setAllowMove(true);
     $columns->setShowWizard(true);
     $columns->setShowNeutralCategory(true);
     $columns->setDisabledScale(false);
     $columns->setNeutralCategoryTitle($this->lng->txt('matrix_neutral_answer'));
     $columns->setCategoryText($this->lng->txt('matrix_standard_answers'));
     $columns->setShowSavePhrase(true);
     if (!$this->object->getColumnCount()) {
         $this->object->columns->addCategory("");
     }
     $columns->setValues($this->object->getColumns());
     $form->addItem($columns);
     $header = new ilFormSectionHeaderGUI();
     $header->setTitle($this->lng->txt("matrix_column_settings"));
     $form->addItem($header);
     // bipolar adjectives
     $bipolar = new ilCustomInputGUI($this->lng->txt("matrix_bipolar_adjectives"));
     $bipolar->setInfo($this->lng->txt("matrix_bipolar_adjectives_description"));
     // left pole
     $bipolar1 = new ilTextInputGUI($this->lng->txt("matrix_left_pole"), "bipolar1");
     $bipolar1->setValue($this->object->getBipolarAdjective(0));
     $bipolar1->setRequired(false);
     $bipolar->addSubItem($bipolar1);
     // right pole
     $bipolar2 = new ilTextInputGUI($this->lng->txt("matrix_right_pole"), "bipolar2");
     $bipolar2->setValue($this->object->getBipolarAdjective(1));
     $bipolar2->setRequired(false);
     $bipolar->addSubItem($bipolar2);
     $form->addItem($bipolar);
     $header = new ilFormSectionHeaderGUI();
     $header->setTitle($this->lng->txt("matrix_rows"));
     $form->addItem($header);
     // matrix rows
     include_once "./Modules/SurveyQuestionPool/classes/class.ilMatrixRowWizardInputGUI.php";
     $rows = new ilMatrixRowWizardInputGUI("", "rows");
     $rows->setRequired(false);
     $rows->setAllowMove(true);
     $rows->setLabelText($this->lng->txt('label'));
     $rows->setUseOtherAnswer(true);
     if ($this->object->getRowCount() == 0) {
         $this->object->getRows()->addCategory("");
     }
     $rows->setValues($this->object->getRows());
     $form->addItem($rows);
     $this->addCommandButtons($form);
     $errors = false;
     if ($this->isSaveCommand(array("wizardcolumns", "savePhrasecolumns"))) {
         $form->setValuesByPost();
         $errors = !$form->checkInput();
         $form->setValuesByPost();
         // again, because checkInput now performs the whole stripSlashes handling and we need this if we don't want to have duplication of backslashes
         if ($errors) {
             $checkonly = false;
         }
     }
     if (!$checkonly) {
         $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
     }
     return $errors;
 }
예제 #12
0
 function addBasicQuestionFormProperties($form)
 {
     // title
     $title = new ilTextInputGUI($this->lng->txt("title"), "title");
     $title->setValue($this->object->getTitle());
     $title->setRequired(TRUE);
     $form->addItem($title);
     if (!$this->object->getSelfAssessmentEditingMode()) {
         // author
         $author = new ilTextInputGUI($this->lng->txt("author"), "author");
         $author->setValue($this->object->getAuthor());
         $author->setRequired(TRUE);
         $form->addItem($author);
         // description
         $description = new ilTextInputGUI($this->lng->txt("description"), "comment");
         $description->setValue($this->object->getComment());
         $description->setRequired(FALSE);
         $form->addItem($description);
     } else {
         // author as hidden field
         $hi = new ilHiddenInputGUI("author");
         $author = ilUtil::prepareFormOutput($this->object->getAuthor());
         if (trim($author) == "") {
             $author = "-";
         }
         $hi->setValue($author);
         $form->addItem($hi);
     }
     // questiontext
     $question = new ilTextAreaInputGUI($this->lng->txt("question"), "question");
     $question->setValue($this->object->prepareTextareaOutput($this->object->getQuestion()));
     $question->setRequired(TRUE);
     $question->setRows(10);
     $question->setCols(80);
     if (!$this->object->getSelfAssessmentEditingMode()) {
         if ($this->object->getAdditionalContentEditingMode() == assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT) {
             $question->setUseRte(TRUE);
             include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
             $question->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("assessment"));
             $question->addPlugin("latex");
             $question->addButton("latex");
             $question->addButton("pastelatex");
             $question->setRTESupport($this->object->getId(), "qpl", "assessment");
         }
     } else {
         $question->setRteTags(self::getSelfAssessmentTags());
         $question->setUseTagsForRteOnly(false);
     }
     $form->addItem($question);
     $tpl = new ilTemplate("tpl.il_as_qpl_cloze_gap_button_code.html", TRUE, TRUE, "Modules/TestQuestionPool");
     $tpl->setVariable('INSERT_GAP', $this->lng->txt('insert_gap'));
     $tpl->setVariable('CREATE_GAPS', $this->lng->txt('create_gaps'));
     $tpl->parseCurrentBlock();
     $button = new ilCustomInputGUI('&nbsp;', '');
     $button->setHtml($tpl->get());
     $form->addItem($button);
     if (!$this->object->getSelfAssessmentEditingMode()) {
         // duration
         $duration = new ilDurationInputGUI($this->lng->txt("working_time"), "Estimated");
         $duration->setShowHours(TRUE);
         $duration->setShowMinutes(TRUE);
         $duration->setShowSeconds(TRUE);
         $ewt = $this->object->getEstimatedWorkingTime();
         $duration->setHours($ewt["h"]);
         $duration->setMinutes($ewt["m"]);
         $duration->setSeconds($ewt["s"]);
         $duration->setRequired(FALSE);
         $form->addItem($duration);
     } else {
         // number of tries
         if (strlen($this->object->getNrOfTries())) {
             $nr_tries = $this->object->getNrOfTries();
         } else {
             $nr_tries = $this->object->getDefaultNrOfTries();
         }
         /*if ($nr_tries <= 0)
         		{
         			$nr_tries = 1;
         		}*/
         if ($nr_tries < 0) {
             $nr_tries = 0;
         }
         $ni = new ilNumberInputGUI($this->lng->txt("qst_nr_of_tries"), "nr_of_tries");
         $ni->setValue($nr_tries);
         //$ni->setMinValue(1);
         $ni->setMinValue(0);
         $ni->setSize(5);
         $ni->setMaxLength(5);
         $ni->setRequired(true);
         $form->addItem($ni);
     }
 }
 /**
  * add type specific input fields to a form  
  * 
  * @param object	form, property or radio option
  * @param array		(assoc) input values
  * @param string	configuration level ("type" or "object")
  * @param string	parent field value
  * @param string	parent option value
  * @param int		maximum recursion depth
  */
 function addFormElements($a_object, $a_values = array(), $a_level = "object", $a_parentfield = '', $a_parentvalue = '', $a_maxdepth = "3")
 {
     // recursion end
     if ($a_maxdepth == 0) {
         return;
     }
     foreach ($this->getInputFields($a_level, $a_parentfield, $a_parentvalue) as $field) {
         $value = $a_values['field_' . $field->field_name];
         $value = $value ? $value : $field->default;
         switch ($field->field_type) {
             case self::FIELDTYPE_HEADER:
                 $item = new ilFormSectionHeaderGUI();
                 $item->setTitle($field->title);
                 break;
             case self::FIELDTYPE_DESCRIPTION:
                 $item = new ilCustomInputGUI($field->title);
                 $item->setHtml(nl2br($field->description));
                 break;
             case self::FIELDTYPE_TEXT:
                 $item = new ilTextInputGUI($field->title, 'field_' . $field->field_name);
                 $item->setInfo($field->description);
                 $item->setRequired($field->required ? true : false);
                 $item->setSize($field->size);
                 $item->setValue($value);
                 break;
             case self::FIELDTYPE_TEXTAREA:
                 $item = new ilTextAreaInputGUI($field->title, 'field_' . $field->field_name);
                 $item->setInfo($field->description);
                 $item->setRequired($field->required ? true : false);
                 $item->setUseRte($field->richtext ? true : false);
                 $item->setRows($field->rows);
                 $item->setCols($field->cols);
                 $item->setValue($value);
                 break;
             case self::FIELDTYPE_PASSWORD:
                 $item = new ilPasswordInputGUI($field->title, 'field_' . $field->field_name);
                 $item->setInfo($field->description);
                 $item->setRequired($field->required ? true : false);
                 $item->setValue($value);
                 break;
             case self::FIELDTYPE_CHECKBOX:
                 $item = new ilCheckboxInputGUI($field->title, 'field_' . $field->field_name);
                 $item->setInfo($field->description);
                 if ($value) {
                     $item->setChecked(true);
                 }
                 break;
             case self::FIELDTYPE_RADIO:
                 $item = new ilRadioGroupInputGUI($field->title, 'field_' . $field->field_name);
                 $item->setInfo($field->description);
                 $item->setValue($value);
                 foreach ($field->options as $option) {
                     $ropt = new ilRadioOption($option->title, $option->value);
                     $ropt->setInfo($option->description);
                     // add the sub items to the option
                     $item->addOption($ropt);
                     $this->addFormElements($ropt, $a_values, $a_level, $field->field_name, $option->value, $a_maxdepth - 1);
                 }
                 break;
             default:
                 continue 2;
         }
         // add the item to the form or to the parent item
         if (is_a($a_object, 'ilPropertyFormGUI')) {
             $a_object->addItem($item);
         } else {
             $a_object->addSubItem($item);
         }
         // add the sub items to the item
         if (is_a($item, 'ilSubEnabledFormPropertyGUI')) {
             $this->addFormElements($item, $a_level, $a_values, $field->field_name, '', $a_maxdepth - 1);
         }
     }
 }
예제 #14
0
 private function initTopicCreateForm()
 {
     /**
      * @var $ilUser ilObjUser
      * @var $rbacsystem ilRbacSystem
      * @var $ilias ILIAS
      * @var $ilSetting ilSetting
      */
     global $ilUser, $rbacsystem, $ilias, $ilSetting;
     $this->create_topic_form_gui = new ilPropertyFormGUI();
     $this->create_topic_form_gui->setTitle($this->lng->txt('forums_new_thread'));
     $this->create_topic_form_gui->setTitleIcon(ilUtil::getImagePath('icon_frm.svg'));
     $this->create_topic_form_gui->setTableWidth('100%');
     // form action
     $this->create_topic_form_gui->setFormAction($this->ctrl->getFormAction($this, 'addThread'));
     if ($this->objProperties->isAnonymized() == 1) {
         $alias_gui = new ilTextInputGUI($this->lng->txt('forums_your_name'), 'alias');
         $alias_gui->setInfo($this->lng->txt('forums_use_alias'));
         $alias_gui->setMaxLength(255);
         $alias_gui->setSize(50);
         $this->create_topic_form_gui->addItem($alias_gui);
     } else {
         $alias_gui = new ilNonEditableValueGUI($this->lng->txt('forums_your_name'), 'alias');
         $alias_gui->setValue($ilUser->getLogin());
         $this->create_topic_form_gui->addItem($alias_gui);
     }
     // topic
     $subject_gui = new ilTextInputGUI($this->lng->txt('forums_thread'), 'subject');
     $subject_gui->setMaxLength(255);
     $subject_gui->setSize(50);
     $subject_gui->setRequired(true);
     $this->create_topic_form_gui->addItem($subject_gui);
     // message
     $post_gui = new ilTextAreaInputGUI($this->lng->txt('forums_the_post'), 'message');
     $post_gui->setCols(50);
     $post_gui->setRows(15);
     $post_gui->setRequired(true);
     $post_gui->setUseRte(true);
     $post_gui->addPlugin('latex');
     $post_gui->addButton('latex');
     $post_gui->addButton('pastelatex');
     $post_gui->addPlugin('ilfrmquote');
     //$post_gui->addPlugin('code');
     $post_gui->removePlugin('advlink');
     $post_gui->usePurifier(true);
     $post_gui->setRTERootBlockElement('');
     $post_gui->setRTESupport($ilUser->getId(), 'frm~', 'frm_post', 'tpl.tinymce_frm_post.html', false, '3.4.7');
     $post_gui->disableButtons(array('charmap', 'undo', 'redo', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', 'anchor', 'fullscreen', 'cut', 'copy', 'paste', 'pastetext', 'formatselect'));
     // purifier
     require_once 'Services/Html/classes/class.ilHtmlPurifierFactory.php';
     $post_gui->setPurifier(ilHtmlPurifierFactory::_getInstanceByType('frm_post'));
     $this->create_topic_form_gui->addItem($post_gui);
     // file
     $fi = new ilFileWizardInputGUI($this->lng->txt('forums_attachments_add'), 'userfile');
     $fi->setFilenames(array(0 => ''));
     $this->create_topic_form_gui->addItem($fi);
     include_once 'Services/Mail/classes/class.ilMail.php';
     $umail = new ilMail($ilUser->getId());
     // catch hack attempts
     if ($rbacsystem->checkAccess('internal_mail', $umail->getMailObjectReferenceId()) && !$this->objProperties->isAnonymized()) {
         // direct notification
         $dir_notification_gui = new ilCheckboxInputGUI($this->lng->txt('forum_direct_notification'), 'notify');
         $dir_notification_gui->setInfo($this->lng->txt('forum_notify_me_directly'));
         $dir_notification_gui->setValue(1);
         $this->create_topic_form_gui->addItem($dir_notification_gui);
         if ($ilias->getSetting('forum_notification') != 0) {
             // gen. notification
             $gen_notification_gui = new ilCheckboxInputGUI($this->lng->txt('forum_general_notification'), 'notify_posts');
             $gen_notification_gui->setInfo($this->lng->txt('forum_notify_me_generally'));
             $gen_notification_gui->setValue(1);
             $this->create_topic_form_gui->addItem($gen_notification_gui);
         }
     }
     require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
     if ($ilUser->isAnonymous() && !$ilUser->isCaptchaVerified() && ilCaptchaUtil::isActiveForForum()) {
         require_once 'Services/Captcha/classes/class.ilCaptchaInputGUI.php';
         $captcha = new ilCaptchaInputGUI($this->lng->txt('cont_captcha_code'), 'captcha_code');
         $captcha->setRequired(true);
         $this->create_topic_form_gui->addItem($captcha);
     }
     $this->create_topic_form_gui->addCommandButton('addThread', $this->lng->txt('create'));
     $this->create_topic_form_gui->addCommandButton('showThreads', $this->lng->txt('cancel'));
 }
 /**
  * Creates an output of the edit form for the question
  *
  * @access public
  */
 public function editQuestion($checkonly = FALSE)
 {
     $save = $this->isSaveCommand();
     $this->getQuestionTemplate();
     include_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
     $form = new ilPropertyFormGUI();
     $form->setFormAction($this->ctrl->getFormAction($this));
     $form->setTitle($this->outQuestionType());
     $form->setMultipart(FALSE);
     $form->setTableWidth("100%");
     $form->setId("orderinghorizontal");
     $this->addBasicQuestionFormProperties($form);
     // ordertext
     $ordertext = new ilTextAreaInputGUI($this->lng->txt("ordertext"), "ordertext");
     $ordertext->setValue($this->object->prepareTextareaOutput($this->object->getOrderText()));
     $ordertext->setRequired(TRUE);
     $ordertext->setInfo(sprintf($this->lng->txt("ordertext_info"), $this->object->separator));
     $ordertext->setRows(10);
     $ordertext->setCols(80);
     $form->addItem($ordertext);
     // textsize
     $textsize = new ilNumberInputGUI($this->lng->txt("textsize"), "textsize");
     $textsize->setValue($this->object->getTextSize());
     $textsize->setInfo($this->lng->txt("textsize_info"));
     $textsize->setSize(6);
     $textsize->setMinValue(10);
     $textsize->setRequired(FALSE);
     $form->addItem($textsize);
     // points
     $points = new ilNumberInputGUI($this->lng->txt("points"), "points");
     // mbecker: Fix for mantis bug 7866: Predefined values schould make sense.
     // This implements a default value of "1" for this question type.
     if ($this->object->getPoints() == null) {
         $points->setValue("1");
     } else {
         $points->setValue($this->object->getPoints());
     }
     $points->setRequired(TRUE);
     $points->setSize(3);
     $points->setMinValue(0.0);
     $points->setMinvalueShouldBeGreater(true);
     $form->addItem($points);
     $this->addQuestionFormCommandButtons($form);
     $errors = false;
     if ($save) {
         $form->setValuesByPost();
         $errors = !$form->checkInput();
         $form->setValuesByPost();
         // again, because checkInput now performs the whole stripSlashes handling and we need this if we don't want to have duplication of backslashes
         if ($errors) {
             $checkonly = false;
         }
     }
     if (!$checkonly) {
         $this->tpl->setVariable("QUESTION_DATA", $form->getHTML());
     }
     return $errors;
 }
예제 #16
0
 public function initNewsForm($a_mode = 'create', $view = 'news')
 {
     global $ilTabs, $rbacreview, $ilUser;
     if (!$rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID)) {
         $this->ilErr->raiseError($this->lng->txt('permission_denied'), $this->ilErr->MESSAGE);
     }
     if ($view == 'archive') {
         $ilTabs->setSubTabActive('archive');
     } else {
         $ilTabs->setSubTabActive('news');
     }
     //		include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
     $this->form_gui = new ilPropertyFormGUI();
     $this->form_gui->setTitle($this->lng->txt('shopnews_settings'));
     $this->form_gui->setTitleIcon(ilUtil::getImagePath('icon_news.png'));
     // Property Title
     $text_input = new ilTextInputGUI($this->lng->txt('news_news_item_title'), 'news_title');
     $text_input->setInfo('');
     $text_input->setRequired(true);
     $text_input->setMaxLength(200);
     $text_input->setSize(93);
     $this->form_gui->addItem($text_input);
     // Property Content
     $text_area = new ilTextAreaInputGUI($this->lng->txt('news_news_item_content'), 'news_content');
     $text_area->setInfo('');
     $text_area->setRequired(false);
     $text_area->setCols(90);
     $text_area->setRows(10);
     $this->form_gui->addItem($text_area);
     // Property Visibility
     $radio_group = new ilRadioGroupInputGUI($this->lng->txt('news_news_item_visibility'), 'news_visibility');
     $radio_option = new ilRadioOption($this->lng->txt('news_visibility_users'), 'users');
     $radio_group->addOption($radio_option);
     $radio_option = new ilRadioOption($this->lng->txt('news_visibility_public'), 'public');
     $radio_group->addOption($radio_option);
     $radio_group->setInfo($this->lng->txt('news_news_item_visibility_info'));
     $radio_group->setRequired(false);
     $radio_group->setValue('users');
     $this->form_gui->addItem($radio_group);
     // save and cancel commands
     if ($a_mode == 'create') {
         $this->form_gui->addCommandButton('saveNews', $this->lng->txt('save'));
         $this->form_gui->addCommandButton('showNews', $this->lng->txt('cancel'));
         $this->form_gui->setFormAction($this->ctrl->getFormAction($this, 'saveNews'));
     } else {
         $this->ctrl->setParameter($this, 'news_id', $this->oCurrentNewsItem->getId());
         if ($view == 'archive') {
             $this->form_gui->addCommandButton('updateArchiveNews', $this->lng->txt('save'));
             $this->form_gui->addCommandButton('showArchive', $this->lng->txt('cancel'));
             $this->form_gui->setFormAction($this->ctrl->getFormAction($this, 'updateArchiveNews'));
         } else {
             $this->form_gui->addCommandButton('updateNews', $this->lng->txt('save'));
             $this->form_gui->addCommandButton('showNews', $this->lng->txt('cancel'));
             $this->form_gui->setFormAction($this->ctrl->getFormAction($this, 'updateNews'));
         }
     }
     $this->form_gui->setTitle($this->lng->txt('news_news_item_head'));
     $this->tpl->setVariable('ADM_CONTENT', $this->form_gui->getHtml());
 }
예제 #17
0
 protected function initEditForm()
 {
     include_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
     $form = new ilPropertyFormGUI();
     $form->setFormAction($this->ctrl->getFormAction($this, "save"));
     $form->setTitle($this->lng->txt($this->getQuestionType()));
     $form->setMultipart(FALSE);
     $form->setTableWidth("100%");
     // $form->setId("essay");
     // title
     $title = new ilTextInputGUI($this->lng->txt("title"), "title");
     $title->setRequired(TRUE);
     $form->addItem($title);
     // label
     $label = new ilTextInputGUI($this->lng->txt("label"), "label");
     $label->setInfo($this->lng->txt("label_info"));
     $label->setRequired(false);
     $form->addItem($label);
     // author
     $author = new ilTextInputGUI($this->lng->txt("author"), "author");
     $author->setRequired(TRUE);
     $form->addItem($author);
     // description
     $description = new ilTextInputGUI($this->lng->txt("description"), "description");
     $description->setRequired(FALSE);
     $form->addItem($description);
     // questiontext
     $question = new ilTextAreaInputGUI($this->lng->txt("question"), "question");
     $question->setRequired(TRUE);
     $question->setRows(10);
     $question->setCols(80);
     $question->setUseRte(TRUE);
     include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
     $question->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("survey"));
     $question->addPlugin("latex");
     $question->addButton("latex");
     $question->addButton("pastelatex");
     $question->setRTESupport($this->object->getId(), "spl", "survey");
     $form->addItem($question);
     // obligatory
     $shuffle = new ilCheckboxInputGUI($this->lng->txt("obligatory"), "obligatory");
     $shuffle->setValue(1);
     $shuffle->setRequired(FALSE);
     $form->addItem($shuffle);
     $this->addFieldsToEditForm($form);
     $this->addCommandButtons($form);
     // values
     $title->setValue($this->object->getTitle());
     $label->setValue($this->object->label);
     $author->setValue($this->object->getAuthor());
     $description->setValue($this->object->getDescription());
     $question->setValue($this->object->prepareTextareaOutput($this->object->getQuestiontext()));
     $shuffle->setChecked($this->object->getObligatory());
     return $form;
 }
 protected function initHeadingForm($a_question_id = null)
 {
     $survey_questions = $this->object->getSurveyQuestions();
     include_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
     $form = new ilPropertyFormGUI();
     $form->setFormAction($this->ctrl->getFormAction($this, ""));
     // heading
     $heading = new ilTextAreaInputGUI($this->lng->txt("heading"), "heading");
     $heading->setRows(10);
     $heading->setCols(80);
     $heading->setUseRte(TRUE);
     include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
     $heading->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("survey"));
     $heading->removePlugin(ilRTE::ILIAS_IMG_MANAGER_PLUGIN);
     $heading->setRTESupport($this->object->getId(), "svy", "survey");
     $heading->setRequired(true);
     $form->addItem($heading);
     $insertbefore = new ilSelectInputGUI($this->lng->txt("insert"), "insertbefore");
     $options = array();
     foreach ($survey_questions as $key => $value) {
         $options[$key] = $this->lng->txt("before") . ": \"" . $value["title"] . "\"";
     }
     $insertbefore->setOptions($options);
     $insertbefore->setRequired(true);
     $form->addItem($insertbefore);
     $form->addCommandButton("saveHeading", $this->lng->txt("save"));
     $form->addCommandButton("questions", $this->lng->txt("cancel"));
     if ($a_question_id) {
         $form->setTitle($this->lng->txt("edit_heading"));
         $heading->setValue($this->object->prepareTextareaOutput($survey_questions[$a_question_id]["heading"]));
         $insertbefore->setValue($a_question_id);
         $insertbefore->setDisabled(true);
     } else {
         $form->setTitle($this->lng->txt("add_heading"));
     }
     return $form;
 }
 /**
  * builds and returns a form property gui object with the given label and postvar
  * that is addable to property forms
  * depending on the given flag "asNonEditable" it returns a ...
  * - non editable gui
  * - textarea input gui
  * 
  * @final
  * @access protected
  * @param string $label
  * @param string $postVar
  * @param boolean $asNonEditable
  * @return ilTextAreaInputGUI|ilNonEditableValueGUI $formProperty
  */
 protected final function buildFeedbackContentFormProperty($label, $postVar, $asNonEditable)
 {
     if ($asNonEditable) {
         require_once 'Services/Form/classes/class.ilNonEditableValueGUI.php';
         $property = new ilNonEditableValueGUI($label, $postVar, true);
     } else {
         require_once 'Services/Form/classes/class.ilTextAreaInputGUI.php';
         require_once 'Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php';
         $property = new ilTextAreaInputGUI($label, $postVar);
         $property->setRequired(false);
         $property->setRows(10);
         $property->setCols(80);
         if (!$this->questionOBJ->getPreventRteUsage()) {
             $property->setUseRte(true);
             $property->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("assessment"));
             $property->addPlugin("latex");
             $property->addButton("latex");
             $property->addButton("pastelatex");
         }
         $property->setRTESupport($this->questionOBJ->getId(), "qpl", "assessment");
     }
     return $property;
 }
 /**
  * Creates an output of the edit form for the question
  *
  * @access public
  */
 public function editQuestion($checkonly = FALSE)
 {
     include_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
     $form = new ilPropertyFormGUI();
     $form->setFormAction($this->ctrl->getFormAction($this));
     $form->setTitle($this->lng->txt($this->getQuestionType()));
     $form->setMultipart(FALSE);
     $form->setTableWidth("100%");
     $form->setId("multiplechoice");
     // title
     $title = new ilTextInputGUI($this->lng->txt("title"), "title");
     $title->setValue($this->object->getTitle());
     $title->setRequired(TRUE);
     $form->addItem($title);
     // label
     $label = new ilTextInputGUI($this->lng->txt("label"), "label");
     $label->setValue($this->object->label);
     $label->setInfo($this->lng->txt("label_info"));
     $label->setRequired(false);
     $form->addItem($label);
     // author
     $author = new ilTextInputGUI($this->lng->txt("author"), "author");
     $author->setValue($this->object->getAuthor());
     $author->setRequired(TRUE);
     $form->addItem($author);
     // description
     $description = new ilTextInputGUI($this->lng->txt("description"), "description");
     $description->setValue($this->object->getDescription());
     $description->setRequired(FALSE);
     $form->addItem($description);
     // questiontext
     $question = new ilTextAreaInputGUI($this->lng->txt("question"), "question");
     $question->setValue($this->object->prepareTextareaOutput($this->object->getQuestiontext()));
     $question->setRequired(TRUE);
     $question->setRows(10);
     $question->setCols(80);
     $question->setUseRte(TRUE);
     include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
     $question->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("survey"));
     $question->addPlugin("latex");
     $question->addButton("latex");
     $question->addButton("pastelatex");
     $question->setRTESupport($this->object->getId(), "spl", "survey", null, false, "3.4.7");
     $form->addItem($question);
     // obligatory
     $shuffle = new ilCheckboxInputGUI($this->lng->txt("obligatory"), "obligatory");
     $shuffle->setValue(1);
     $shuffle->setChecked($this->object->getObligatory());
     $shuffle->setRequired(FALSE);
     $form->addItem($shuffle);
     // orientation
     $orientation = new ilRadioGroupInputGUI($this->lng->txt("orientation"), "orientation");
     $orientation->setRequired(false);
     $orientation->setValue($this->object->getOrientation());
     $orientation->addOption(new ilRadioOption($this->lng->txt('vertical'), 0));
     $orientation->addOption(new ilRadioOption($this->lng->txt('horizontal'), 1));
     $form->addItem($orientation);
     // minimum answers
     $minanswers = new ilCheckboxInputGUI($this->lng->txt("use_min_answers"), "use_min_answers");
     $minanswers->setValue(1);
     $minanswers->setOptionTitle($this->lng->txt("use_min_answers_option"));
     $minanswers->setChecked($this->object->use_min_answers);
     $minanswers->setRequired(FALSE);
     $nranswers = new ilNumberInputGUI($this->lng->txt("nr_min_answers"), "nr_min_answers");
     $nranswers->setSize(5);
     $nranswers->setDecimals(0);
     $nranswers->setRequired(false);
     $nranswers->setMinValue(1);
     $nranswers->setValue($this->object->nr_min_answers);
     $minanswers->addSubItem($nranswers);
     $nrmaxanswers = new ilNumberInputGUI($this->lng->txt("nr_max_answers"), "nr_max_answers");
     $nrmaxanswers->setSize(5);
     $nrmaxanswers->setDecimals(0);
     $nrmaxanswers->setRequired(false);
     $nrmaxanswers->setMinValue(1);
     $nrmaxanswers->setValue($this->object->nr_max_answers);
     $minanswers->addSubItem($nrmaxanswers);
     $form->addItem($minanswers);
     // Answers
     include_once "./Modules/SurveyQuestionPool/classes/class.ilCategoryWizardInputGUI.php";
     $answers = new ilCategoryWizardInputGUI($this->lng->txt("answers"), "answers");
     $answers->setRequired(false);
     $answers->setAllowMove(true);
     $answers->setShowWizard(false);
     $answers->setShowSavePhrase(false);
     $answers->setUseOtherAnswer(true);
     $answers->setShowNeutralCategory(true);
     $answers->setNeutralCategoryTitle($this->lng->txt('svy_neutral_answer'));
     if (!$this->object->getCategories()->getCategoryCount()) {
         $this->object->getCategories()->addCategory("");
     }
     $answers->setValues($this->object->getCategories());
     $answers->setDisabledScale(false);
     $form->addItem($answers);
     $this->addCommandButtons($form);
     $errors = false;
     if ($this->isSaveCommand()) {
         $form->setValuesByPost();
         $errors = !$form->checkInput();
         $form->setValuesByPost();
         // again, because checkInput now performs the whole stripSlashes handling and we need this if we don't want to have duplication of backslashes
         if ($nranswers->getValue() > $answers->getCategoryCount()) {
             $nrmaxanswers->setAlert($this->lng->txt('err_minvalueganswers'));
             if (!$errors) {
                 ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
             }
             $errors = true;
         }
         if ($nrmaxanswers->getValue() > 0 && ($nrmaxanswers->getValue() > $answers->getCategoryCount() || $nrmaxanswers->getValue() < $nranswers->getValue())) {
             $nrmaxanswers->setAlert($this->lng->txt('err_maxvaluegeminvalue'));
             if (!$errors) {
                 ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
             }
             $errors = true;
         }
         if ($errors) {
             $checkonly = false;
         }
     }
     if (!$checkonly) {
         $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
     }
     return $errors;
 }
예제 #21
0
 protected function initQuestionForm($a_read_only = false)
 {
     global $lng, $ilCtrl;
     include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
     $form = new ilPropertyFormGUI();
     $form->setFormAction($ilCtrl->getFormAction($this, "saveQuestion"));
     $form->setTitle($lng->txt("obj_poll"));
     $question = new ilTextAreaInputGUI($lng->txt("poll_question"), "question");
     $question->setRequired(true);
     $question->setCols(40);
     $question->setRows(2);
     $question->setValue($this->object->getQuestion());
     $question->setDisabled($a_read_only);
     $form->addItem($question);
     $dimensions = " (" . ilObjPoll::getImageSize() . "px)";
     $img = new ilImageFileInputGUI($lng->txt("poll_image") . $dimensions, "image");
     $img->setDisabled($a_read_only);
     $form->addItem($img);
     // show existing file
     $file = $this->object->getImageFullPath(true);
     if ($file) {
         $img->setImage($file);
     }
     $anonymous = new ilRadioGroupInputGUI($lng->txt("poll_mode"), "mode");
     $anonymous->setRequired(true);
     $option = new ilRadioOption($lng->txt("poll_mode_anonymous"), 0);
     $option->setInfo($lng->txt("poll_mode_anonymous_info"));
     $anonymous->addOption($option);
     $option = new ilRadioOption($lng->txt("poll_mode_personal"), 1);
     $option->setInfo($lng->txt("poll_mode_personal_info"));
     $anonymous->addOption($option);
     $anonymous->setValue($this->object->getNonAnonymous());
     $anonymous->setDisabled($a_read_only);
     $form->addItem($anonymous);
     $nanswers = new ilNumberInputGUI($lng->txt("poll_max_number_of_answers"), "nanswers");
     $nanswers->setRequired(true);
     $nanswers->setMinValue(1);
     $nanswers->setSize(3);
     $nanswers->setValue($this->object->getMaxNumberOfAnswers());
     $nanswers->setDisabled($a_read_only);
     $form->addItem($nanswers);
     $answers = new ilTextInputGUI($lng->txt("poll_answers"), "answers");
     $answers->setRequired(true);
     $answers->setMulti(true, true);
     $answers->setDisabled($a_read_only);
     $form->addItem($answers);
     $multi_answers = array();
     foreach ($this->object->getAnswers() as $idx => $item) {
         if (!$idx) {
             $answers->setValue($item["answer"]);
         }
         $multi_answers[] = $item["answer"];
     }
     $answers->setMultiValues($multi_answers);
     if (!$a_read_only) {
         $form->addCommandButton("saveQuestion", $lng->txt("save"));
     }
     return $form;
 }
 public function populateQuestionSpecificFormPart(\ilPropertyFormGUI $form)
 {
     // ordertext
     $ordertext = new ilTextAreaInputGUI($this->lng->txt("ordertext"), "ordertext");
     $ordertext->setValue($this->object->prepareTextareaOutput($this->object->getOrderText()));
     $ordertext->setRequired(TRUE);
     $ordertext->setInfo(sprintf($this->lng->txt("ordertext_info"), $this->object->separator));
     $ordertext->setRows(10);
     $ordertext->setCols(80);
     $form->addItem($ordertext);
     // textsize
     $textsize = new ilNumberInputGUI($this->lng->txt("textsize"), "textsize");
     $textsize->setValue($this->object->getTextSize());
     $textsize->setInfo($this->lng->txt("textsize_info"));
     $textsize->setSize(6);
     $textsize->setMinValue(10);
     $textsize->setRequired(FALSE);
     $form->addItem($textsize);
     // points
     $points = new ilNumberInputGUI($this->lng->txt("points"), "points");
     $points->allowDecimals(true);
     // mbecker: Fix for mantis bug 7866: Predefined values schould make sense.
     // This implements a default value of "1" for this question type.
     if ($this->object->getPoints() == null) {
         $points->setValue("1");
     } else {
         $points->setValue($this->object->getPoints());
     }
     $points->setRequired(TRUE);
     $points->setSize(3);
     $points->setMinValue(0.0);
     $points->setMinvalueShouldBeGreater(true);
     $form->addItem($points);
 }
 function initAddPageLayoutForm()
 {
     global $lng, $ilCtrl;
     $lng->loadLanguageModule("content");
     include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
     $form_gui = new ilPropertyFormGUI();
     $form_gui->setFormAction($ilCtrl->getFormAction($this));
     $form_gui->setTitle($lng->txt("sty_create_pgl"));
     include_once "Services/Form/classes/class.ilRadioMatrixInputGUI.php";
     $title_input = new ilTextInputGUI($lng->txt("title"), "pgl_title");
     $title_input->setSize(50);
     $title_input->setMaxLength(128);
     $title_input->setValue($this->layout_object->title);
     $title_input->setTitle($lng->txt("title"));
     $title_input->setRequired(true);
     $desc_input = new ilTextAreaInputGUI($lng->txt("description"), "pgl_desc");
     $desc_input->setValue($this->layout_object->description);
     $desc_input->setRows(3);
     $desc_input->setCols(37);
     // special page?
     $options = array("0" => $lng->txt("cont_layout_template"), "1" => $lng->txt("cont_special_page"));
     $si = new ilSelectInputGUI($this->lng->txt("type"), "special_page");
     $si->setOptions($options);
     // modules
     $mods = new ilCheckboxGroupInputGUI($this->lng->txt("modules"), "module");
     // $mods->setRequired(true);
     foreach (ilPageLayout::getAvailableModules() as $mod_id => $mod_caption) {
         $mod = new ilCheckboxOption($mod_caption, $mod_id);
         $mods->addOption($mod);
     }
     $ttype_input = new ilSelectInputGUI($lng->txt("sty_based_on"), "pgl_template");
     $arr_templates = ilPageLayout::getLayouts();
     $arr_templates1 = ilPageLayout::getLayouts(false, true);
     foreach ($arr_templates1 as $v) {
         $arr_templates[] = $v;
     }
     $options = array();
     $options['-1'] = $lng->txt("none");
     foreach ($arr_templates as $templ) {
         $templ->readObject();
         $key = $templ->getId();
         $value = $templ->getTitle();
         $options[$key] = $value;
     }
     $ttype_input->setOptions($options);
     $ttype_input->setValue(-1);
     $ttype_input->setRequired(true);
     $desc_input->setTitle($lng->txt("description"));
     $desc_input->setRequired(false);
     $form_gui->addItem($title_input);
     $form_gui->addItem($desc_input);
     $form_gui->addItem($si);
     $form_gui->addItem($mods);
     $form_gui->addItem($ttype_input);
     $form_gui->addCommandButton("createPg", $lng->txt("save"));
     $form_gui->addCommandButton("cancelCreate", $lng->txt("cancel"));
     return $form_gui;
 }
 /**
  * @param $tpl
  */
 function buildform($tpl)
 {
     require_once "Services/Form/classes/class.ilPropertyFormGUI.php";
     $form = new ilPropertyFormGUI();
     $form->setTitle("Mitglieder einschreiben");
     $form->setDescription("Bitte geben Sie eine durch Kommata getrennte Liste von E-Mail-Adressen an.");
     require_once "Services/Form/classes/class.ilTextAreaInputGUI.php";
     $textarea = new ilTextAreaInputGUI('E-Mail-Adresse', 'emails');
     $textarea->setRequired(true);
     $textarea->setRows(20);
     $form->addItem($textarea);
     //$form->addCommandButton('TODO', 'Speichern');
     $this->ctrl->saveParameter($this, 'ref_id');
     $form->addCommandButton('save', 'Speichern');
     $form->setFormAction($this->ctrl->getFormAction($this));
     return $form;
 }
 /**
  * builds the questions hints form
  * 
  * @access	private
  * @global	ilCtrl				$ilCtrl
  * @global	ilLanguage			$lng
  * @return	ilPropertyFormGUI	$form
  */
 private function buildForm(ilAssQuestionHint $questionHint = null)
 {
     global $ilCtrl, $lng;
     require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
     require_once 'Services/Form/classes/class.ilTextAreaInputGUI.php';
     require_once 'Services/Form/classes/class.ilNumberInputGUI.php';
     require_once 'Services/Form/classes/class.ilHiddenInputGUI.php';
     $form = new ilPropertyFormGUI();
     $form->setTableWidth('100%');
     if (!$this->questionOBJ->isAdditionalContentEditingModePageObject()) {
         // form input: hint text
         $areaInp = new ilTextAreaInputGUI($lng->txt('tst_question_hints_form_label_hint_text'), 'hint_text');
         $areaInp->setRequired(true);
         $areaInp->setRows(10);
         $areaInp->setCols(80);
         if (!$this->questionOBJ->getPreventRteUsage()) {
             $areaInp->setUseRte(true);
         }
         include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
         $areaInp->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("assessment"));
         $areaInp->setRTESupport($this->questionOBJ->getId(), 'qpl', 'assessment');
         $areaInp->addPlugin("latex");
         $areaInp->addButton("latex");
         $areaInp->addButton("pastelatex");
         $form->addItem($areaInp);
     }
     // form input: hint points
     $numInp = new ilNumberInputGUI($lng->txt('tst_question_hints_form_label_hint_points'), 'hint_points');
     $numInp->allowDecimals(true);
     $numInp->setRequired(true);
     $numInp->setSize(3);
     $form->addItem($numInp);
     if ($questionHint instanceof ilAssQuestionHint) {
         // build form title for an existing hint
         $form->setTitle(sprintf($lng->txt('tst_question_hints_form_header_edit'), $questionHint->getIndex(), $this->questionOBJ->getTitle()));
         // hidden input: hint id
         $hiddenInp = new ilHiddenInputGUI('hint_id');
         $form->addItem($hiddenInp);
         // init values
         require_once 'Services/Utilities/classes/class.ilUtil.php';
         if (!$this->questionOBJ->isAdditionalContentEditingModePageObject()) {
             $areaInp->setValue(ilUtil::prepareTextareaOutput($questionHint->getText(), true));
         }
         $numInp->setValue($questionHint->getPoints());
         $hiddenInp->setValue($questionHint->getId());
     } else {
         // build form title for a new hint
         $form->setTitle(sprintf($lng->txt('tst_question_hints_form_header_create'), $this->questionOBJ->getTitle()));
     }
     if ($this->questionOBJ->isAdditionalContentEditingModePageObject()) {
         if ($questionHint instanceof ilAssQuestionHint) {
             $saveCmdLabel = $lng->txt('tst_question_hints_form_cmd_save_points');
         } else {
             $saveCmdLabel = $lng->txt('tst_question_hints_form_cmd_save_points_and_edit_page');
         }
     } else {
         $saveCmdLabel = $lng->txt('tst_question_hints_form_cmd_save');
     }
     $form->setFormAction($ilCtrl->getFormAction($this));
     $form->addCommandButton(self::CMD_CANCEL_FORM, $lng->txt('cancel'));
     $form->addCommandButton(self::CMD_SAVE_FORM, $saveCmdLabel);
     return $form;
 }
 /**
  * Init add cast item form.
  */
 function initAddCastItemForm($a_mode = "create")
 {
     global $lng, $ilCtrl, $ilTabs;
     $this->checkPermission("write");
     $ilTabs->activateTab("edit_content");
     $lng->loadLanguageModule("mcst");
     $news_set = new ilSetting("news");
     $enable_internal_rss = $news_set->get("enable_rss_for_internal");
     include "Services/Form/classes/class.ilPropertyFormGUI.php";
     $this->form_gui = new ilPropertyFormGUI();
     $this->form_gui->setMultipart(true);
     // Property Title
     $text_input = new ilTextInputGUI($lng->txt("title"), "title");
     $text_input->setMaxLength(200);
     $this->form_gui->addItem($text_input);
     // Property Content
     $text_area = new ilTextAreaInputGUI($lng->txt("description"), "description");
     $text_area->setRequired(false);
     $this->form_gui->addItem($text_area);
     // Property Visibility
     if ($enable_internal_rss) {
         $radio_group = new ilRadioGroupInputGUI($lng->txt("access_scope"), "visibility");
         $radio_option = new ilRadioOption($lng->txt("access_users"), "users");
         $radio_group->addOption($radio_option);
         $radio_option = new ilRadioOption($lng->txt("access_public"), "public");
         $radio_group->addOption($radio_option);
         $radio_group->setInfo($lng->txt("mcst_visibility_info"));
         $radio_group->setRequired(true);
         $radio_group->setValue($this->object->getDefaultAccess() == 0 ? "users" : "public");
         $this->form_gui->addItem($radio_group);
     }
     // Duration
     $dur = new ilDurationInputGUI($lng->txt("mcst_duration"), "duration");
     $dur->setInfo($lng->txt("mcst_duration_info"));
     $dur->setShowDays(false);
     $dur->setShowHours(true);
     $dur->setShowSeconds(true);
     $this->form_gui->addItem($dur);
     foreach (ilObjMediaCast::$purposes as $purpose) {
         if ($purpose == "VideoAlternative" && $a_mode == "create") {
             continue;
         }
         $section = new ilFormSectionHeaderGUI();
         $section->setTitle($lng->txt("mcst_" . strtolower($purpose) . "_title"));
         $this->form_gui->addItem($section);
         if ($a_mode != "create") {
             $value = new ilHiddenInputGUI("value_" . $purpose);
             $label = new ilNonEditableValueGUI($lng->txt("value"));
             $label->setPostVar("label_value_" . $purpose);
             $label->setInfo($lng->txt("mcst_current_value_info"));
             $this->form_gui->addItem($label);
             $this->form_gui->addItem($value);
         }
         $file = new ilFileInputGUI($lng->txt("file"), "file_" . $purpose);
         $file->setSuffixes($this->purposeSuffixes[$purpose]);
         $this->form_gui->addItem($file);
         $text_input = new ilRegExpInputGUI($lng->txt("url"), "url_" . $purpose);
         $text_input->setPattern("/https?\\:\\/\\/.+/i");
         $text_input->setInfo($lng->txt("mcst_reference_info"));
         $this->form_gui->addItem($text_input);
         if ($purpose != "Standard") {
             $clearCheckBox = new ilCheckboxInputGUI();
             $clearCheckBox->setPostVar("delete_" . $purpose);
             $clearCheckBox->setTitle($lng->txt("mcst_clear_purpose_title"));
             $this->form_gui->addItem($clearCheckBox);
         } else {
             // mime type selection
             $mimeTypeSelection = new ilSelectInputGUI();
             $mimeTypeSelection->setPostVar("mimetype_" . $purpose);
             $mimeTypeSelection->setTitle($lng->txt("mcst_mimetype"));
             $mimeTypeSelection->setInfo($lng->txt("mcst_mimetype_info"));
             $options = array("" => $lng->txt("mcst_automatic_detection"));
             $options = array_merge($options, $this->mimeTypes);
             $mimeTypeSelection->setOptions($options);
             $this->form_gui->addItem($mimeTypeSelection);
             // preview picure
             $pp = new ilImageFileInputGUI($lng->txt("mcst_preview_picture"), "preview_pic");
             $pp->setSuffixes(array("png", "jpeg", "jpg"));
             $pp->setInfo($lng->txt("mcst_preview_picture_info") . " mp4, mp3, png, jp(e)g, gif");
             $this->form_gui->addItem($pp);
         }
     }
     // save/cancel button
     if ($a_mode == "create") {
         $this->form_gui->setTitle($lng->txt("mcst_add_new_item"));
         $this->form_gui->addCommandButton("saveCastItem", $lng->txt("save"));
     } else {
         $this->form_gui->setTitle($lng->txt("mcst_edit_item"));
         $this->form_gui->addCommandButton("updateCastItem", $lng->txt("save"));
     }
     $this->form_gui->addCommandButton("listItems", $lng->txt("cancel"));
     $this->form_gui->setFormAction($ilCtrl->getFormAction($this, "saveCastItem"));
 }
예제 #27
0
 /**
  * @param $form ilPropertyFormGUI
  * @return \ilPropertyFormGUI|void
  */
 public function populateQuestionSpecificFormPart(ilPropertyFormGUI $form)
 {
     // errortext
     $errortext = new ilTextAreaInputGUI($this->lng->txt("errortext"), "errortext");
     $errortext->setValue($this->object->getErrorText());
     $errortext->setRequired(TRUE);
     $errortext->setInfo($this->lng->txt("errortext_info"));
     $errortext->setRows(10);
     $errortext->setCols(80);
     $form->addItem($errortext);
     if (!$this->object->getSelfAssessmentEditingMode()) {
         // textsize
         $textsize = new ilNumberInputGUI($this->lng->txt("textsize"), "textsize");
         $textsize->setValue(strlen($this->object->getTextSize()) ? $this->object->getTextSize() : 100.0);
         $textsize->setInfo($this->lng->txt("textsize_errortext_info"));
         $textsize->setSize(6);
         $textsize->setSuffix("%");
         $textsize->setMinValue(10);
         $textsize->setRequired(true);
         $form->addItem($textsize);
     }
 }
예제 #28
0
 /**
  * Add standard fields to form
  */
 function addStandardFieldsToForm($a_form, $a_user = NULL, array $custom_fields = NULL)
 {
     global $ilSetting, $lng, $rbacreview, $ilias;
     // custom registration settings
     if (self::$mode == self::MODE_REGISTRATION) {
         include_once 'Services/Registration/classes/class.ilRegistrationSettings.php';
         $registration_settings = new ilRegistrationSettings();
         self::$user_field["username"]["group"] = "login_data";
         self::$user_field["password"]["group"] = "login_data";
         self::$user_field["language"]["default"] = $lng->lang_key;
         // different position for role
         $roles = self::$user_field["roles"];
         unset(self::$user_field["roles"]);
         self::$user_field["roles"] = $roles;
         self::$user_field["roles"]["group"] = "settings";
     }
     $fields = $this->getStandardFields();
     $current_group = "";
     $custom_fields_done = false;
     foreach ($fields as $f => $p) {
         // next group? -> diplay subheader
         if ($p["group"] != $current_group && ilUserProfile::userSettingVisible($f)) {
             if (is_array($custom_fields) && !$custom_fields_done) {
                 // should be appended to "other" or at least before "settings"
                 if ($current_group == "other" || $p["group"] == "settings") {
                     // add "other" subheader
                     if ($current_group != "other") {
                         $sh = new ilFormSectionHeaderGUI();
                         $sh->setTitle($lng->txt("other"));
                         $a_form->addItem($sh);
                     }
                     foreach ($custom_fields as $custom_field) {
                         $a_form->addItem($custom_field);
                     }
                     $custom_fields_done = true;
                 }
             }
             $sh = new ilFormSectionHeaderGUI();
             $sh->setTitle($lng->txt($p["group"]));
             $a_form->addItem($sh);
             $current_group = $p["group"];
         }
         $m = "";
         if (isset($p["method"])) {
             $m = $p["method"];
         }
         $lv = isset($p["lang_var"]) && $p["lang_var"] != "" ? $p["lang_var"] : $f;
         switch ($p["input"]) {
             case "login":
                 if ((int) $ilSetting->get('allow_change_loginname') || self::$mode == self::MODE_REGISTRATION) {
                     $val = new ilTextInputGUI($lng->txt('username'), 'username');
                     if ($a_user) {
                         $val->setValue($a_user->getLogin());
                     }
                     $val->setMaxLength(32);
                     $val->setSize(40);
                     $val->setRequired(true);
                 } else {
                     // user account name
                     $val = new ilNonEditableValueGUI($lng->txt("username"), 'ne_un');
                     if ($a_user) {
                         $val->setValue($a_user->getLogin());
                     }
                 }
                 $a_form->addItem($val);
                 break;
             case "text":
                 if (ilUserProfile::userSettingVisible($f)) {
                     $ti = new ilTextInputGUI($lng->txt($lv), "usr_" . $f);
                     if ($a_user) {
                         $ti->setValue($a_user->{$m}());
                     }
                     $ti->setMaxLength($p["maxlength"]);
                     $ti->setSize($p["size"]);
                     $ti->setRequired($ilSetting->get("require_" . $f));
                     if (!$ti->getRequired() || $ti->getValue()) {
                         $ti->setDisabled($ilSetting->get("usr_settings_disable_" . $f));
                     }
                     $a_form->addItem($ti);
                 }
                 break;
             case "sel_country":
                 if (ilUserProfile::userSettingVisible($f)) {
                     include_once "./Services/Form/classes/class.ilCountrySelectInputGUI.php";
                     $ci = new ilCountrySelectInputGUI($lng->txt($lv), "usr_" . $f);
                     if ($a_user) {
                         $ci->setValue($a_user->{$m}());
                     }
                     $ci->setRequired($ilSetting->get("require_" . $f));
                     if (!$ci->getRequired() || $ci->getValue()) {
                         $ci->setDisabled($ilSetting->get("usr_settings_disable_" . $f));
                     }
                     $a_form->addItem($ci);
                 }
                 break;
             case "birthday":
                 if (ilUserProfile::userSettingVisible($f)) {
                     $bi = new ilBirthdayInputGUI($lng->txt($lv), "usr_" . $f);
                     include_once "./Services/Calendar/classes/class.ilDateTime.php";
                     $date = null;
                     if ($a_user && strlen($a_user->{$m}())) {
                         $date = new ilDateTime($a_user->{$m}(), IL_CAL_DATE);
                         $bi->setDate($date);
                     }
                     $bi->setShowEmpty(true);
                     $bi->setStartYear(1900);
                     $bi->setRequired($ilSetting->get("require_" . $f));
                     if (!$bi->getRequired() || $date) {
                         $bi->setDisabled($ilSetting->get("usr_settings_disable_" . $f));
                     }
                     $a_form->addItem($bi);
                 }
                 break;
             case "radio":
                 if (ilUserProfile::userSettingVisible($f)) {
                     $rg = new ilRadioGroupInputGUI($lng->txt($lv), "usr_" . $f);
                     if ($a_user) {
                         $rg->setValue($a_user->{$m}());
                     }
                     foreach ($p["values"] as $k => $v) {
                         $op = new ilRadioOption($lng->txt($v), $k);
                         $rg->addOption($op);
                     }
                     $rg->setRequired($ilSetting->get("require_" . $f));
                     if (!$rg->getRequired() || $rg->getValue()) {
                         $rg->setDisabled($ilSetting->get("usr_settings_disable_" . $f));
                     }
                     $a_form->addItem($rg);
                 }
                 break;
             case "picture":
                 if (ilUserProfile::userSettingVisible("upload") && $a_user) {
                     $ii = new ilImageFileInputGUI($lng->txt("personal_picture"), "userfile");
                     $ii->setDisabled($ilSetting->get("usr_settings_disable_upload"));
                     $upload = $a_form->getFileUpload("userfile");
                     if ($upload["name"]) {
                         $ii->setPending($upload["name"]);
                     } else {
                         $im = ilObjUser::_getPersonalPicturePath($a_user->getId(), "small", true, true);
                         if ($im != "") {
                             $ii->setImage($im);
                             $ii->setAlt($lng->txt("personal_picture"));
                         }
                     }
                     // ilinc link as info
                     if (ilUserProfile::userSettingVisible("upload") and $ilSetting->get("ilinc_active")) {
                         include_once './Modules/ILinc/classes/class.ilObjiLincUser.php';
                         $ilinc_user = new ilObjiLincUser($a_user);
                         if ($ilinc_user->id) {
                             include_once './Modules/ILinc/classes/class.ilnetucateXMLAPI.php';
                             $ilincAPI = new ilnetucateXMLAPI();
                             $ilincAPI->uploadPicture($ilinc_user);
                             $response = $ilincAPI->sendRequest("uploadPicture");
                             // return URL to user's personal page
                             $url = trim($response->data['url']['cdata']);
                             $desc = $lng->txt("ilinc_upload_pic_text") . " " . '<a href="' . $url . '">' . $lng->txt("ilinc_upload_pic_linktext") . '</a>';
                             $ii->setInfo($desc);
                         }
                     }
                     $a_form->addItem($ii);
                 }
                 break;
             case "roles":
                 if (self::$mode == self::MODE_DESKTOP) {
                     if (ilUserProfile::userSettingVisible("roles")) {
                         $global_roles = $rbacreview->getGlobalRoles();
                         foreach ($global_roles as $role_id) {
                             if (in_array($role_id, $rbacreview->assignedRoles($a_user->getId()))) {
                                 $roleObj = $ilias->obj_factory->getInstanceByObjId($role_id);
                                 $role_names .= $roleObj->getTitle() . ", ";
                                 unset($roleObj);
                             }
                         }
                         $dr = new ilNonEditableValueGUI($lng->txt("default_roles"), "ne_dr");
                         $dr->setValue(substr($role_names, 0, -2));
                         $a_form->addItem($dr);
                     }
                 } else {
                     if (self::$mode == self::MODE_REGISTRATION) {
                         if ($registration_settings->roleSelectionEnabled()) {
                             include_once "./Services/AccessControl/classes/class.ilObjRole.php";
                             $options = array();
                             foreach (ilObjRole::_lookupRegisterAllowed() as $role) {
                                 $options[$role["id"]] = $role["title"];
                             }
                             // registration form validation will take care of missing field / value
                             if ($options) {
                                 if (sizeof($options) > 1) {
                                     $ta = new ilSelectInputGUI($lng->txt('default_role'), "usr_" . $f);
                                     $ta->setOptions($options);
                                     $ta->setRequired($ilSetting->get("require_" . $f));
                                     if (!$ta->getRequired()) {
                                         $ta->setDisabled($ilSetting->get("usr_settings_disable_" . $f));
                                     }
                                 } else {
                                     $ta = new ilHiddenInputGUI("usr_" . $f);
                                     $ta->setValue(array_shift(array_keys($options)));
                                 }
                                 $a_form->addItem($ta);
                             }
                         }
                     }
                 }
                 break;
             case "email":
                 if (ilUserProfile::userSettingVisible($f)) {
                     $em = new ilEMailInputGUI($lng->txt($lv), "usr_" . $f);
                     if ($a_user) {
                         $em->setValue($a_user->{$m}());
                     }
                     $em->setRequired($ilSetting->get("require_" . $f));
                     if (!$em->getRequired() || $em->getValue()) {
                         $em->setDisabled($ilSetting->get("usr_settings_disable_" . $f));
                     }
                     if (self::MODE_REGISTRATION == self::$mode) {
                         $em->setRetype(true);
                     }
                     $a_form->addItem($em);
                 }
                 break;
             case "textarea":
                 if (ilUserProfile::userSettingVisible($f)) {
                     $ta = new ilTextAreaInputGUI($lng->txt($lv), "usr_" . $f);
                     if ($a_user) {
                         $ta->setValue($a_user->{$m}());
                     }
                     $ta->setRows($p["rows"]);
                     $ta->setCols($p["cols"]);
                     $ta->setRequired($ilSetting->get("require_" . $f));
                     if (!$ta->getRequired() || $ta->getValue()) {
                         $ta->setDisabled($ilSetting->get("usr_settings_disable_" . $f));
                     }
                     $a_form->addItem($ta);
                 }
                 break;
             case "messenger":
                 if (ilUserProfile::userSettingVisible("instant_messengers")) {
                     $im_arr = $p["types"];
                     foreach ($im_arr as $im_name) {
                         $im = new ilTextInputGUI($lng->txt("im_" . $im_name), "usr_im_" . $im_name);
                         if ($a_user) {
                             $im->setValue($a_user->getInstantMessengerId($im_name));
                         }
                         $im->setMaxLength($p["maxlength"]);
                         $im->setSize($p["size"]);
                         $im->setRequired($ilSetting->get("require_" . "instant_messengers"));
                         if (!$im->getRequired() || $im->getValue()) {
                             $im->setDisabled($ilSetting->get("usr_settings_disable_" . "instant_messengers"));
                         }
                         $a_form->addItem($im);
                     }
                 }
                 break;
             case "password":
                 if (self::$mode == self::MODE_REGISTRATION) {
                     if (!$registration_settings->passwordGenerationEnabled()) {
                         $ta = new ilPasswordInputGUI($lng->txt($lv), "usr_" . $f);
                         $ta->setRequired(true);
                         // $ta->setDisabled($ilSetting->get("usr_settings_disable_".$f));
                     } else {
                         $ta = new ilNonEditableValueGUI($lng->txt($lv));
                         $ta->setValue($lng->txt("reg_passwd_via_mail"));
                     }
                     $a_form->addItem($ta);
                 }
                 break;
             case "language":
                 if (ilUserProfile::userSettingVisible($f)) {
                     $ta = new ilSelectInputGUI($lng->txt($lv), "usr_" . $f);
                     if ($a_user) {
                         $ta->setValue($a_user->{$m}());
                     }
                     $options = array();
                     $lng->loadLanguageModule("meta");
                     foreach ($lng->getInstalledLanguages() as $lang_key) {
                         $options[$lang_key] = $lng->txt("meta_l_" . $lang_key);
                     }
                     asort($options);
                     // #9728
                     $ta->setOptions($options);
                     $ta->setRequired($ilSetting->get("require_" . $f));
                     if (!$ta->getRequired() || $ta->getValue()) {
                         $ta->setDisabled($ilSetting->get("usr_settings_disable_" . $f));
                     }
                     $a_form->addItem($ta);
                 }
                 break;
             case "multitext":
                 if (ilUserProfile::userSettingVisible($f)) {
                     $ti = new ilTextInputGUI($lng->txt($lv), "usr_" . $f);
                     $ti->setMulti(true);
                     if ($a_user) {
                         $ti->setValue($a_user->{$m}());
                     }
                     $ti->setMaxLength($p["maxlength"]);
                     $ti->setSize($p["size"]);
                     $ti->setRequired($ilSetting->get("require_" . $f));
                     if (!$ti->getRequired() || $ti->getValue()) {
                         $ti->setDisabled($ilSetting->get("usr_settings_disable_" . $f));
                     }
                     if ($this->ajax_href) {
                         // add field to ajax call
                         $ti->setDataSource($this->ajax_href . "&f=" . $f);
                     }
                     $a_form->addItem($ti);
                 }
                 break;
         }
     }
     // append custom fields as "other"
     if (is_array($custom_fields) && !$custom_fields_done) {
         // add "other" subheader
         if ($current_group != "other") {
             $sh = new ilFormSectionHeaderGUI();
             $sh->setTitle($lng->txt("other"));
             $a_form->addItem($sh);
         }
         foreach ($custom_fields as $custom_field) {
             $a_form->addItem($custom_field);
         }
     }
 }
예제 #29
0
 protected function initAssignmentTextForm(ilExAssignment $a_ass, $a_read_only = false, $a_cancel_cmd = "showOverview", $a_peer_review_cmd = null, $a_peer_rating_html = null)
 {
     global $ilCtrl, $ilUser;
     include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
     $form = new ilPropertyFormGUI();
     $form->setTitle($this->lng->txt("exc_assignment") . " \"" . $a_ass->getTitle() . "\"");
     if (!$a_read_only) {
         $text = new ilTextAreaInputGUI($this->lng->txt("exc_your_text"), "atxt");
         $text->setRequired((bool) $a_ass->getMandatory());
         $text->setRows(40);
         $form->addItem($text);
         // custom rte tags
         $text->setUseRte(true);
         $text->setRTESupport($ilUser->getId(), "exca~", "exc_ass");
         // see ilObjForumGUI
         $text->disableButtons(array('charmap', 'undo', 'redo', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', 'anchor', 'fullscreen', 'cut', 'copy', 'paste', 'pastetext'));
         $form->setFormAction($ilCtrl->getFormAction($this, "updateAssignmentText"));
         $form->addCommandButton("updateAssignmentTextAndReturn", $this->lng->txt("save_return"));
         $form->addCommandButton("updateAssignmentText", $this->lng->txt("save"));
     } else {
         $text = new ilNonEditableValueGUI($this->lng->txt("exc_files_returned_text"), "atxt", true);
         $form->addItem($text);
         if (!$a_peer_review_cmd) {
             $form->setFormAction($ilCtrl->getFormAction($this, "showOverview"));
         } else {
             $rating = new ilCustomInputGUI($this->lng->txt("exc_peer_review_rating"));
             $rating->setHtml($a_peer_rating_html);
             $form->addItem($rating);
             $comm = new ilTextAreaInputGUI($this->lng->txt("exc_peer_review_comment"), "comm");
             $comm->setCols(75);
             $comm->setRows(15);
             $form->addItem($comm);
             $form->setFormAction($ilCtrl->getFormAction($this, $a_peer_review_cmd));
             $form->addCommandButton($a_peer_review_cmd, $this->lng->txt("save"));
         }
     }
     $form->addCommandButton($a_cancel_cmd, $this->lng->txt("cancel"));
     return $form;
 }
예제 #30
0
 public function populateQuestionSpecificFormPart(ilPropertyFormGUI $form)
 {
     // cloze text
     $cloze_text = new ilTextAreaInputGUI($this->lng->txt("cloze_text"), 'cloze_text');
     $cloze_text->setRequired(true);
     $cloze_text->setValue($this->applyIndizesToGapText($this->object->getClozeText()));
     $cloze_text->setInfo($this->lng->txt("close_text_hint"));
     $cloze_text->setRows(10);
     $cloze_text->setCols(80);
     if (!$this->object->getSelfAssessmentEditingMode()) {
         if ($this->object->getAdditionalContentEditingMode() == assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT) {
             $cloze_text->setUseRte(TRUE);
             include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
             $cloze_text->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("assessment"));
             $cloze_text->addPlugin("latex");
             $cloze_text->addButton("latex");
             $cloze_text->addButton("pastelatex");
         }
     } else {
         $cloze_text->setUseRte(TRUE);
         $cloze_text->setRteTags(self::getSelfAssessmentTags());
         $cloze_text->setUseTagsForRteOnly(false);
     }
     $cloze_text->setRTESupport($this->object->getId(), "qpl", "assessment");
     $form->addItem($cloze_text);
     $tpl = new ilTemplate("tpl.il_as_qpl_cloze_gap_button_code.html", TRUE, TRUE, "Modules/TestQuestionPool");
     $tpl->setVariable('INSERT_GAP', $this->lng->txt('insert_gap'));
     $tpl->setVariable('CREATE_GAPS', $this->lng->txt('create_gaps'));
     $tpl->parseCurrentBlock();
     $button = new ilCustomInputGUI('&nbsp;', '');
     $button->setHtml($tpl->get());
     $form->addItem($button);
     // text rating
     if (!$this->object->getSelfAssessmentEditingMode()) {
         $textrating = new ilSelectInputGUI($this->lng->txt("text_rating"), "textgap_rating");
         $text_options = array("ci" => $this->lng->txt("cloze_textgap_case_insensitive"), "cs" => $this->lng->txt("cloze_textgap_case_sensitive"), "l1" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "1"), "l2" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "2"), "l3" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "3"), "l4" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "4"), "l5" => sprintf($this->lng->txt("cloze_textgap_levenshtein_of"), "5"));
         $textrating->setOptions($text_options);
         $textrating->setValue($this->object->getTextgapRating());
         $form->addItem($textrating);
         // text field length
         $fixedTextLength = new ilNumberInputGUI($this->lng->txt("cloze_fixed_textlength"), "fixedTextLength");
         $ftl = $this->object->getFixedTextLength();
         $fixedTextLength->setValue($ftl > 0 ? $ftl : '');
         $fixedTextLength->setMinValue(0);
         $fixedTextLength->setSize(3);
         $fixedTextLength->setMaxLength(6);
         $fixedTextLength->setInfo($this->lng->txt('cloze_fixed_textlength_description'));
         $fixedTextLength->setRequired(false);
         $form->addItem($fixedTextLength);
         // identical scoring
         $identical_scoring = new ilCheckboxInputGUI($this->lng->txt("identical_scoring"), "identical_scoring");
         $identical_scoring->setValue(1);
         $identical_scoring->setChecked($this->object->getIdenticalScoring());
         $identical_scoring->setInfo($this->lng->txt('identical_scoring_desc'));
         $identical_scoring->setRequired(FALSE);
         $form->addItem($identical_scoring);
     }
     return $form;
 }