本文整理汇总了PHP中ilFileInputGUI::setFilename方法的典型用法代码示例。如果您正苦于以下问题:PHP ilFileInputGUI::setFilename方法的具体用法?PHP ilFileInputGUI::setFilename怎么用?PHP ilFileInputGUI::setFilename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ilFileInputGUI
的用法示例。
在下文中一共展示了ilFileInputGUI::setFilename方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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");
//.........这里部分代码省略.........
示例2: initForm
/**
* Init form
*/
protected function initForm()
{
$this->setFormAction($this->ctrl->getFormAction($this->parent_gui));
$this->setTitle($this->pl->txt('edit_type_template'));
$types_available = array();
$types = array(srCertificateTemplateTypeFactory::getById(srCertificateTemplateType::TEMPLATE_TYPE_HTML), srCertificateTemplateTypeFactory::getById(srCertificateTemplateType::TEMPLATE_TYPE_JASPER));
/** @var $type srCertificateTemplateType */
foreach ($types as $type) {
if ($type->isAvailable()) {
$types_available[$type->getId()] = $type->getTitle();
}
}
if (!count($types_available)) {
ilUtil::sendInfo($this->pl->txt('msg_no_template_types'));
}
$item = new ilSelectInputGUI($this->pl->txt('template_type_id'), 'template_type_id');
$item->setOptions($types_available);
$item->setRequired(true);
$item->setValue($this->type->getTemplateTypeId());
$this->addItem($item);
$item = new ilFileInputGUI($this->pl->txt('template_file'), 'template_file');
$template_file = $this->type->getCertificateTemplatesPath(true);
if (is_file($template_file)) {
$item->setValue($template_file);
}
$item->setFilename($template_file);
$item->setInfo($this->pl->txt('template_file_info'));
$item->setRequired(!is_file($template_file));
$this->addItem($item);
$assets = $this->type->getAssets();
if (count($assets)) {
$item = new ilMultiSelectInputGUI($this->pl->txt('assets'), 'remove_assets');
$options = array();
foreach ($assets as $asset) {
$options[$asset] = $asset;
}
$item->setOptions($options);
$item->setInfo($this->pl->txt('assets_info'));
$this->addItem($item);
}
$item = new ilFileWizardInputGUI($this->pl->txt('add_assets'), 'add_assets');
$item->setFilenames(array(0 => ''));
$this->addItem($item);
$this->addCommandButton('downloadDefaultTemplate', $this->pl->txt('download_default_template'));
if (is_file($this->type->getCertificateTemplatesPath(true))) {
$this->addCommandButton('downloadTemplate', $this->pl->txt('download_template'));
}
$this->addCommandButton('updateTemplate', $this->lng->txt('save'));
}