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");
85 $this->
tabs->setBackTarget(
"",
"");
87 $cmd = $this->
ctrl->getCmd();
88 if ($cmd ==
"update") {
89 $form->setValuesByPost();
101 $par_content = $this->content_obj->xml2output($this->content_obj->getText());
103 $par_content = str_replace(
"{",
"[curlybegin ", $par_content);
104 $par_content = str_replace(
"}",
" curlyend]", $par_content);
106 $form->getItemByPostVar(
"par_content")->setValue($par_content);
111 ->factory()->input()->field()
113 $this->
lng->txt(
"cont_pc_code")
114 )->withValue($par_content);
115 $t = $this->gui->ui()->renderer()->render(
$f);
116 $t = str_replace(
"<textarea",
"<textarea name='code' rows='20' form='copg-src-form' ", $t);
117 $t = str_replace(
"[curlybegin ",
"{", $t);
118 $t = str_replace(
" curlyend]",
"}", $t);
119 $t =
"<div class='c-form copg-src-form'>$t</div>";
127 $form = $this->
initPropertyForm($this->
lng->txt(
"cont_insert_src"),
"create",
"cancelCreate");
129 if ($this->pg_obj->getParentType() ==
"lm") {
130 $this->tpl->setVariable(
132 $this->
ctrl->getLinkTargetByClass(
"ilInternalLinkGUI",
"showLinkHelp")
134 $this->tpl->setVariable(
"TXT_ILINK",
"[" . $this->
lng->txt(
"cont_internal_link") .
"]");
139 $cmd = $this->
ctrl->getCmd();
140 if ($cmd ==
"create_src") {
141 $form->setValuesByPost();
146 $form->getItemByPostVar(
"par_language")->setValue($ilUser->getLanguage());
149 $form->getItemByPostVar(
"par_showlinenumbers")->setChecked(
true);
151 $form->getItemByPostVar(
"par_subcharacteristic")->setValue(
"");
152 $form->getItemByPostVar(
"par_content")->setValue(
"");
155 $this->tpl->setContent($form->getHTML());
160 $this->requested_par_content = $this->request->getRaw(
"par_content");
161 $this->requested_par_downloadtitle = str_replace(
'"',
'', $this->request->getString(
"par_downloadtitle"));
163 $this->updated = $this->content_obj->setText(
164 $this->content_obj->input2xml($this->requested_par_content, 0,
false)
167 if ($this->updated !==
true) {
173 $this->updated = $this->pg_obj->update();
175 if ($this->updated ===
true && $this->
ctrl->getCmd() !=
"upload") {
176 $this->
ctrl->returnToParent($this,
"jump" . $this->hier_id);
184 $this->
ctrl->returnToParent($this,
"jump" . $this->hier_id);
190 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
191 $this->content_obj->setLanguage($this->request->getString(
"par_language"));
195 $this->requested_par_content = $this->request->getRaw(
"par_content");
196 $this->requested_par_downloadtitle = str_replace(
'"',
'', $this->request->getString(
"par_downloadtitle"));
200 $this->content_obj->setCharacteristic(
201 $this->request->getString(
"par_characteristic")
203 $this->content_obj->setSubCharacteristic(
204 $this->request->getString(
"par_subcharacteristic")
206 $this->content_obj->setDownloadTitle(str_replace(
'"',
'', $this->requested_par_downloadtitle));
207 $this->content_obj->setShowLineNumbers(
208 $this->request->getString(
"par_showlinenumbers") ?
'y' :
'n'
210 $this->content_obj->setCharacteristic(
'Code');
217 $this->updated = $this->content_obj->setText(
218 $this->content_obj->input2xml($this->requested_par_content, 0,
false)
221 if ($this->updated !==
true) {
226 $this->updated = $this->pg_obj->update();
228 if ($this->updated ===
true) {
229 $this->
ctrl->returnToParent($this,
"jump" . $this->hier_id);
237 $this->
ctrl->returnToParent($this,
"jump" . $this->hier_id);
242 if (isset($_FILES[
'userfile'][
'name'])) {
243 $userfile = $_FILES[
'userfile'][
'tmp_name'];
245 if ($userfile ==
"" || !is_uploaded_file($userfile)) {
246 $error_str =
"<strong>Error(s):</strong><br>Upload error: file name must not be empty!";
247 $this->tpl->setVariable(
"MESSAGE", $error_str);
248 $this->content_obj->setText(
249 $this->content_obj->input2xml(
250 $this->request->getRaw(
"par_content"),
258 $this->requested_par_content = file_get_contents($userfile);
259 $this->requested_par_downloadtitle = $_FILES[
'userfile'][
'name'];
276 $prog_langs[$k] = $v;
288 $form->setFormAction($this->
ctrl->getFormAction($this, $a_cmd));
289 $form->addCommandButton($a_cmd, $this->
lng->txt(
"save"));
290 $form->addCommandButton($a_cmd_cancel, $this->
lng->txt(
"cancel"));
294 $form->addItem($code);
301 $this->
ctrl->setParameter($this,
"cname",
"SourceCode");
302 $form = $this->gui->form([self::class],
"#")
304 ->hidden(
"mode",
"import")
307 $this->
lng->txt(
"import_file"),
308 \Closure::fromCallable([$this,
'handleUploadResult']),
318 $this->
lng->txt(
"cont_download_title")
322 $this->
lng->txt(
"cont_src"),
323 $this->getProgLangOptions()
327 $this->
lng->txt(
"cont_show_line_numbers")
333 ?
string $download_title =
null,
334 ?
string $subchar =
null,
335 ?
bool $line_numbers =
null
336 ): \
ILIAS\Repository\Form\FormAdapterGUI {
337 $this->
ctrl->setParameter($this,
"cname",
"SourceCode");
338 $form = $this->gui->form([self::class],
"#")
340 ->hidden(
"mode",
"manual")
343 $this->
lng->txt(
"cont_download_title"),
349 $this->
lng->txt(
"cont_src"),
350 $this->getProgLangOptions(),
356 $this->
lng->txt(
"cont_show_line_numbers"),
365 return $this->getManualFormAdapter(
366 $this->content_obj->getDownloadTitle(),
367 $this->content_obj->getSubCharacteristic(),
368 ($this->content_obj->getShowLineNumbers() ==
"y")
376 $fac = new
ILIAS\Data\UUID\Factory();
377 $uuid = $fac->uuid4AsString();
378 $name = $uuid .
".txt";
389 HandlerResult::STATUS_OK,
Class BasicHandlerResult.
static getBaseContentStylePath()
handleUploadResult(FileUpload $upload, UploadResult $result)
__construct(ilPageObject $a_pg_obj, ?ilPageContent $a_content_obj, string $a_hier_id, string $a_pc_id="")
initPropertyForm(string $a_title, string $a_cmd, string $a_cmd_cancel)
getProgLangOptions()
Get selectable programming languages.
string $requested_par_downloadtitle
cancelUpdate()
cancel update
getManualFormAdapter(?string $download_title=null, ?string $subchar=null, ?bool $line_numbers=null)
string $requested_par_content
cancelCreate()
cancel creating page content
static getSupportedLanguages()
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
ILIAS COPage InternalGUIService $gui
setCurrentTextLang(string $lang_key)
getEditorScriptTag(string $form_pc_id="", string $form_cname="")
Content object of ilPageObject (see ILIAS DTD).
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a text area property in a property form.
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...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.