50 $this->
user = $DIC->user();
52 $this->
tabs = $DIC->tabs();
58 $next_class = $this->
ctrl->getNextClass($this);
61 $cmd = $this->
ctrl->getCmd();
63 switch ($next_class) {
65 case strtolower(ilRepoStandardUploadHandlerGUI::class):
67 $gui = $form->getRepoStandardUploadHandlerGUI(
"input_file");
77 public function edit(): void
79 $form = $this->
initPropertyForm($this->
lng->txt(
"cont_edit_src"),
"update",
"cancelCreate");
84 $this->
tabs->setBackTarget(
"",
"");
86 $cmd = $this->
ctrl->getCmd();
87 if ($cmd ==
"update") {
88 $form->setValuesByPost();
100 $par_content = $this->content_obj->xml2output($this->content_obj->getText());
102 $par_content = str_replace(
"{",
"[curlybegin ", $par_content);
103 $par_content = str_replace(
"}",
" curlyend]", $par_content);
105 $form->getItemByPostVar(
"par_content")->setValue($par_content);
110 ->factory()->input()->field()
112 $this->
lng->txt(
"cont_pc_code")
114 $t = $this->gui->ui()->renderer()->render(
$f);
115 $t = str_replace(
"<textarea",
"<textarea name='code' rows='20' form='copg-src-form' ", $t);
116 $t = str_replace(
"[curlybegin ",
"{", $t);
117 $t = str_replace(
" curlyend]",
"}", $t);
125 $form = $this->
initPropertyForm($this->
lng->txt(
"cont_insert_src"),
"create_src",
"cancelCreate");
127 if ($this->pg_obj->getParentType() ==
"lm") {
128 $this->tpl->setVariable(
130 $this->
ctrl->getLinkTargetByClass(
"ilInternalLinkGUI",
"showLinkHelp")
132 $this->tpl->setVariable(
"TXT_ILINK",
"[" . $this->
lng->txt(
"cont_internal_link") .
"]");
137 $cmd = $this->
ctrl->getCmd();
138 if ($cmd ==
"create_src") {
139 $form->setValuesByPost();
144 $form->getItemByPostVar(
"par_language")->setValue($ilUser->getLanguage());
147 $form->getItemByPostVar(
"par_showlinenumbers")->setChecked(
true);
149 $form->getItemByPostVar(
"par_subcharacteristic")->setValue(
"");
150 $form->getItemByPostVar(
"par_content")->setValue(
"");
153 $this->tpl->setContent($form->getHTML());
158 $this->requested_par_content = $this->request->getRaw(
"par_content");
159 $this->requested_par_downloadtitle = str_replace(
'"',
'', $this->request->getString(
"par_downloadtitle"));
185 $this->updated = $this->content_obj->setText(
186 $this->content_obj->input2xml($this->requested_par_content, 0,
false)
189 if ($this->updated !==
true) {
195 $this->updated = $this->pg_obj->update();
197 if ($this->updated ===
true && $this->
ctrl->getCmd() !=
"upload") {
198 $this->
ctrl->returnToParent($this,
"jump" . $this->hier_id);
206 $this->
ctrl->returnToParent($this,
"jump" . $this->hier_id);
212 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
213 $this->content_obj->setLanguage($this->request->getString(
"par_language"));
217 $this->requested_par_content = $this->request->getRaw(
"par_content");
218 $this->requested_par_downloadtitle = str_replace(
'"',
'', $this->request->getString(
"par_downloadtitle"));
222 $this->content_obj->setCharacteristic(
223 $this->request->getString(
"par_characteristic")
225 $this->content_obj->setSubCharacteristic(
226 $this->request->getString(
"par_subcharacteristic")
228 $this->content_obj->setDownloadTitle(str_replace(
'"',
'', $this->requested_par_downloadtitle));
229 $this->content_obj->setShowLineNumbers(
230 $this->request->getString(
"par_showlinenumbers") ?
'y' :
'n' 232 $this->content_obj->setCharacteristic(
'Code');
239 $this->updated = $this->content_obj->setText(
240 $this->content_obj->input2xml($this->requested_par_content, 0,
false)
243 if ($this->updated !==
true) {
248 $this->updated = $this->pg_obj->update();
250 if ($this->updated ===
true) {
251 $this->
ctrl->returnToParent($this,
"jump" . $this->hier_id);
259 $this->
ctrl->returnToParent($this,
"jump" . $this->hier_id);
264 if (isset($_FILES[
'userfile'][
'name'])) {
265 $userfile = $_FILES[
'userfile'][
'tmp_name'];
267 if ($userfile ==
"" || !is_uploaded_file($userfile)) {
268 $error_str =
"<strong>Error(s):</strong><br>Upload error: file name must not be empty!";
269 $this->tpl->setVariable(
"MESSAGE", $error_str);
270 $this->content_obj->setText(
271 $this->content_obj->input2xml(
272 $this->request->getRaw(
"par_content"),
280 $this->requested_par_content = file_get_contents($userfile);
281 $this->requested_par_downloadtitle = $_FILES[
'userfile'][
'name'];
298 $prog_langs[$k] = $v;
309 $form->setTitle($a_title);
310 $form->setFormAction($this->
ctrl->getFormAction($this, $a_cmd));
311 $form->addCommandButton($a_cmd, $this->
lng->txt(
"save"));
312 $form->addCommandButton($a_cmd_cancel, $this->
lng->txt(
"cancel"));
329 $form->addItem($code);
344 $this->
ctrl->setParameter($this,
"cname",
"SourceCode");
345 $form = $this->gui->form([self::class],
"#")
347 ->hidden(
"mode",
"import")
350 $this->
lng->txt(
"import_file"),
351 \Closure::fromCallable([$this,
'handleUploadResult']),
361 $this->
lng->txt(
"cont_download_title")
365 $this->
lng->txt(
"cont_src"),
370 $this->
lng->txt(
"cont_show_line_numbers")
376 ?
string $download_title = null,
377 ?
string $subchar = null,
378 ?
bool $line_numbers = null
379 ): \
ILIAS\Repository\Form\FormAdapterGUI {
380 $this->
ctrl->setParameter($this,
"cname",
"SourceCode");
381 $form = $this->gui->form([self::class],
"#")
383 ->hidden(
"mode",
"manual")
386 $this->
lng->txt(
"cont_download_title"),
392 $this->
lng->txt(
"cont_src"),
399 $this->
lng->txt(
"cont_show_line_numbers"),
409 $this->content_obj->getDownloadTitle(),
410 $this->content_obj->getSubCharacteristic(),
411 ($this->content_obj->getShowLineNumbers() ==
"y")
420 $uuid = $fac->uuid4AsString();
421 $name = $uuid .
".txt";
432 HandlerResult::STATUS_OK,
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(ilPageObject $a_pg_obj, ?ilPageContent $a_content_obj, string $a_hier_id, string $a_pc_id="")
string $requested_par_downloadtitle
Class ChatMainBarProvider .
string $requested_par_content
Content object of ilPageObject (see ILIAS DTD).
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
handleUploadResult(FileUpload $upload, UploadResult $result)
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
moveOneFileTo(UploadResult $uploadResult, string $destination, int $location=Location::STORAGE, string $file_name='', bool $override_existing=false)
Moves a single File (the attributes, metadata and upload-status of which are contained in UploadResul...
Class BasicHandlerResult.
setCurrentTextLang(string $lang_key)
getEditorScriptTag(string $form_pc_id="", string $form_cname="")
static getSupportedLanguagesV51()
Get supported languages (keys are ILIAS <= 5.1 internal values, values are for representation) ...
This class represents a text area property in a property form.
getProgLangOptions()
Get selectable programming languages.
getManualFormAdapter(?string $download_title=null, ?string $subchar=null, ?bool $line_numbers=null)
initPropertyForm(string $a_title, string $a_cmd, string $a_cmd_cancel)
ILIAS COPage InternalGUIService $gui