本文整理汇总了PHP中ilFileInputGUI::checkInput方法的典型用法代码示例。如果您正苦于以下问题:PHP ilFileInputGUI::checkInput方法的具体用法?PHP ilFileInputGUI::checkInput怎么用?PHP ilFileInputGUI::checkInput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ilFileInputGUI
的用法示例。
在下文中一共展示了ilFileInputGUI::checkInput方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: certificateEditor
/**
* 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");
//.........这里部分代码省略.........
示例2: suggestedsolution
/**
* 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");
//.........这里部分代码省略.........
示例3: checkInput
/**
* Check input, strip slashes etc. set alert, if input is not ok.
*
* @return boolean Input ok, true/false
*/
function checkInput()
{
global $lng;
// if no information is received, something went wrong
// this is e.g. the case, if the post_max_size has been exceeded
if (!is_array($_FILES[$this->getPostVar()])) {
$this->setAlert($lng->txt("form_msg_file_size_exceeds"));
return false;
}
// empty file, could be a folder
if ($_FILES[$this->getPostVar()]["size"] < 1) {
$this->setAlert($lng->txt("error_upload_was_zero_bytes"));
return false;
}
// call base
$inputValid = parent::checkInput();
// set additionally sent input on post array
if ($inputValid) {
$_POST[$this->getPostVar()]["extract"] = isset($_POST["extract"]) ? (bool) $_POST["extract"] : false;
$_POST[$this->getPostVar()]["title"] = isset($_POST["title"]) ? $_POST["title"] : "";
$_POST[$this->getPostVar()]["description"] = isset($_POST["description"]) ? $_POST["description"] : "";
$_POST[$this->getPostVar()]["keep_structure"] = isset($_POST["keep_structure"]) ? (bool) $_POST["keep_structure"] : true;
}
return $inputValid;
}