43 $this->
user = $DIC->user();
50 $next_class = $this->
ctrl->getNextClass($this);
53 $cmd = $this->
ctrl->getCmd();
55 switch ($next_class) {
62 public function edit(): void
64 $form = $this->
initPropertyForm($this->
lng->txt(
"cont_edit_src"),
"update",
"cancelCreate");
66 if ($this->pg_obj->getParentType() ==
"lm") {
67 $this->tpl->setVariable(
69 $this->
ctrl->getLinkTargetByClass(
"ilInternalLinkGUI",
"showLinkHelp")
71 $this->tpl->setVariable(
"TXT_ILINK",
"[" . $this->
lng->txt(
"cont_internal_link") .
"]");
76 $cmd = $this->
ctrl->getCmd();
77 if ($cmd ==
"update") {
78 $form->setValuesByPost();
80 $form->getItemByPostVar(
"par_language")->setValue($this->content_obj->getLanguage());
81 $form->getItemByPostVar(
"par_subcharacteristic")->setValue($this->content_obj->getSubCharacteristic());
82 $form->getItemByPostVar(
"par_downloadtitle")->setValue($this->content_obj->getDownloadTitle());
83 $form->getItemByPostVar(
"par_showlinenumbers")->setChecked(
84 $this->content_obj->getShowLineNumbers() ==
"y" 89 $par_content = $this->content_obj->xml2output($this->content_obj->getText());
92 $par_content = str_replace(
"{",
"{", $par_content);
93 $par_content = str_replace(
"}",
"}", $par_content);
95 $form->getItemByPostVar(
"par_content")->setValue($par_content);
99 $this->tpl->setContent($form->getHTML());
106 $form = $this->
initPropertyForm($this->
lng->txt(
"cont_insert_src"),
"create_src",
"cancelCreate");
108 if ($this->pg_obj->getParentType() ==
"lm") {
109 $this->tpl->setVariable(
111 $this->
ctrl->getLinkTargetByClass(
"ilInternalLinkGUI",
"showLinkHelp")
113 $this->tpl->setVariable(
"TXT_ILINK",
"[" . $this->
lng->txt(
"cont_internal_link") .
"]");
118 $cmd = $this->
ctrl->getCmd();
119 if ($cmd ==
"create_src") {
120 $form->setValuesByPost();
125 $form->getItemByPostVar(
"par_language")->setValue(
$ilUser->getLanguage());
128 $form->getItemByPostVar(
"par_showlinenumbers")->setChecked(
true);
130 $form->getItemByPostVar(
"par_subcharacteristic")->setValue(
"");
131 $form->getItemByPostVar(
"par_content")->setValue(
"");
134 $this->tpl->setContent($form->getHTML());
139 $this->requested_par_content = $this->request->getRaw(
"par_content");
140 $this->requested_par_downloadtitle = str_replace(
'"',
'', $this->request->getString(
"par_downloadtitle"));
146 $this->content_obj->setLanguage(
147 $this->request->getString(
"par_language")
149 $this->content_obj->setCharacteristic($this->request->getString(
"par_characteristic"));
152 $this->content_obj->setLanguage($this->request->getString(
"par_language"));
153 $this->content_obj->setSubCharacteristic($this->request->getString(
"par_subcharacteristic"));
154 $this->content_obj->setDownloadTitle(
155 str_replace(
'"',
'', $this->requested_par_downloadtitle)
157 $this->content_obj->setShowLineNumbers(
158 $this->request->getString(
"par_showlinenumbers") ?
"y" :
"n" 160 $this->content_obj->setSubCharacteristic($this->request->getString(
"par_subcharacteristic"));
161 $this->content_obj->setCharacteristic(
"Code");
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 =
"<b>Error(s):</b><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;
287 $form->setTitle($a_title);
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 $lang->setOptions($lang_var);
295 $form->addItem(
$lang);
299 $code_style->setOptions($prog_langs);
300 $form->addItem($code_style);
301 $line_number =
new ilCheckboxInputGUI($this->
lng->txt(
"cont_show_line_numbers"),
"par_showlinenumbers");
302 $form->addItem($line_number);
306 $form->addItem($code);
308 $downlaod_title =
new ilTextInputGUI($this->
lng->txt(
"cont_download_title"),
"par_downloadtitle");
309 $downlaod_title->setSize(40);
310 $form->addItem($downlaod_title);
313 $form->addItem($file);
__construct(ilPageObject $a_pg_obj, ?ilPageContent $a_content_obj, string $a_hier_id, string $a_pc_id="")
string $requested_par_downloadtitle
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
string $requested_par_content
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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...
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
setCurrentTextLang(string $lang_key)
static getSupportedLanguagesV51()
Get supported languages (keys are ILIAS <= 5.1 internal values, values are for representation) ...
__construct(Container $dic, ilPlugin $plugin)
This class represents a text area property in a property form.
getProgLangOptions()
Get selectable programming languages.
initPropertyForm(string $a_title, string $a_cmd, string $a_cmd_cancel)