5 require_once(
"./Services/COPage/classes/class.ilPCSourceCode.php");
6 require_once(
"./Services/COPage/classes/class.ilPageContentGUI.php");
37 $next_class = $this->ctrl->getNextClass($this);
40 $cmd = $this->ctrl->getCmd();
57 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.sourcecode_edit.html",
"Services/COPage");
60 $this->tpl->setVariable(
"TXT_ACTION", $this->lng->txt(
"cont_edit_src"));
62 if ($this->pg_obj->getParentType() ==
"lm" ||
63 $this->pg_obj->getParentType() ==
"dbk")
65 $this->tpl->setVariable(
"LINK_ILINK",
66 $this->ctrl->getLinkTargetByClass(
"ilInternalLinkGUI",
"showLinkHelp"));
67 $this->tpl->setVariable(
"TXT_ILINK",
"[".$this->lng->txt(
"cont_internal_link").
"]");
73 if (key(
$_POST[
"cmd"]) ==
"update")
75 $s_lang =
$_POST[
"par_language"];
76 $s_char =
$_POST[
"par_characteristic"];
77 $s_subchar =
$_POST[
"par_subcharacteristic"];
79 $s_showlinenumbers = (
$_POST[
"par_showlinenumbers"]==
"on")?
'y':
'n';
80 $s_autoindent = (
$_POST[
"par_autoindent"]==
"on")?
'y':
'n';
84 $s_lang = $this->content_obj->getLanguage();
85 $s_char = $this->content_obj->getCharacteristic();
86 $s_subchar = $this->content_obj->getSubCharacteristic();
87 $s_downloadtitle = $this->content_obj->getDownloadTitle();
88 $s_showlinenumbers = $this->content_obj->getShowLineNumbers();
89 $s_autoindent = $this->content_obj->getAutoIndent ();
94 if (key(
$_POST[
"cmd"]) ==
"update")
96 $s_text = stripslashes(
$_POST[
"par_content"]);
100 $s_text = $this->content_obj->xml2output($this->content_obj->getText());
103 $this->tpl->setVariable(
"PAR_TA_NAME",
"par_content");
108 if (strcmp($s_showlinenumbers,
"y")==0)
110 $this->tpl->setVariable(
"SHOWLINENUMBERS",
"checked=\"checked\"");
113 if (strcmp($s_autoindent,
"y") == 0)
115 $this->tpl->setVariable(
"AUTOINDENT",
"checked=\"checked\"");
119 $this->tpl->setVariable(
"DOWNLOAD_TITLE_VALUE", $s_downloadtitle);
122 $this->tpl->setCurrentBlock(
"commands");
123 $this->tpl->setVariable(
"BTN_NAME",
"update");
124 $this->tpl->setVariable(
"UPLOAD_BTN_NAME",
"upload");
125 $this->tpl->setVariable(
"BTN_TEXT", $this->lng->txt(
"save"));
126 $this->tpl->setVariable(
"BTN_CANCEL",
"cancelUpdate");
127 $this->tpl->setVariable(
"TXT_CANCEL", $this->lng->txt(
"cancel"));
128 $this->tpl->parseCurrentBlock();
133 $this->tpl->setVariable (
"TXT_CREATEFILE", $this->lng->txt(
"create_download_link"));
134 $this->tpl->setVariable (
"TXT_DOWNLOADTITLE", $this->lng->txt(
"cont_download_title"));
135 $this->tpl->setVariable (
"TXT_IMPORTFILE", $this->lng->txt(
"import_file"));
136 $this->tpl->setVariable (
"TXT_UPLOAD_BTN", $this->lng->txt(
"import"));
137 $this->tpl->setVariable (
"TXT_SUBCHARACTERISTIC", $this->lng->txt(
"cont_src"));
138 $this->tpl->setVariable (
"TXT_LANGUAGE", $this->lng->txt(
"language"));
139 $this->tpl->setVariable (
"TXT_SHOWLINENUMBERS", $this->lng->txt(
"cont_show_line_numbers"));
140 $this->tpl->setVariable (
"TXT_AUTOINDENT", $this->lng->txt(
"cont_autoindent"));
143 $this->tpl->setVariable (
"FORMACTION", $this->ctrl->getFormAction($this));
145 require_once(
"Services/MetaData/classes/class.ilMDLanguageItem.php");
148 $this->tpl->setVariable (
"SELECT_LANGUAGE", $select_lang);
152 $select_subchar =
ilUtil::formSelect ($s_proglang,
"par_subcharacteristic",$prog_langs,
false,
true);
153 $this->tpl->setVariable (
"SELECT_SUBCHARACTERISTIC", $select_subchar);
165 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.sourcecode_edit.html",
"Services/COPage");
166 $this->tpl->setVariable(
"TXT_ACTION", $this->lng->txt(
"cont_insert_src"));
168 if ($this->pg_obj->getParentType() ==
"lm" ||
169 $this->pg_obj->getParentType() ==
"dbk")
171 $this->tpl->setVariable(
"LINK_ILINK",
172 $this->ctrl->getLinkTargetByClass(
"ilInternalLinkGUI",
"showLinkHelp"));
173 $this->tpl->setVariable(
"TXT_ILINK",
"[".$this->lng->txt(
"cont_internal_link").
"]");
182 if (key(
$_POST[
"cmd"]) ==
"create_src")
184 $s_lang =
$_POST[
"par_language"];
185 $s_subchar =
$_POST[
"par_subcharacteristic"];
187 $s_showlinenumbers = strcmp(
$_POST[
"par_showlinenumbers"],
'on')==0?
'checked=\"true\"':
'';
188 $s_autoindent = strcmp(
$_POST[
"par_autoindent"],
'on')==0?
'checked=\"true\"':
'';
189 $s_isexample = strcmp(
$_POST[
"par_isexample"],
"on")==0?
'checked=\"true\"':
'';
195 $s_lang =
$_SESSION[
"il_text_lang_".$_GET[
"ref_id"]];
199 $s_lang = $ilUser->getLanguage();
202 $s_showlinenumbers =
'CHECKED';
203 $s_autoindent =
'CHECKED';
210 $this->tpl->setVariable(
"SHOWLINENUMBERS", $s_showlinenumbers);
211 $this->tpl->setVariable(
"AUTOINDENT", $s_autoindent);
212 $this->tpl->setVariable(
"DOWNLOAD_TITLE_VALUE", $s_downloadtitle);
213 $this->tpl->setVariable(
"ISEXAMPLE", $s_isexample);
220 $this->tpl->setVariable(
"PAR_TA_NAME",
"par_content");
222 if (key(
$_POST[
"cmd"]) ==
"create_src")
228 $this->tpl->setVariable(
"PAR_TA_CONTENT",
"");
233 $this->tpl->setCurrentBlock(
"commands");
234 $this->tpl->setVariable(
"BTN_NAME",
"create_src");
235 $this->tpl->setVariable(
"UPLOAD_BTN_NAME",
"create_src");
236 $this->tpl->setVariable(
"BTN_TEXT", $this->lng->txt(
"save"));
237 $this->tpl->setVariable(
"BTN_CANCEL",
"cancelCreate");
238 $this->tpl->setVariable(
"TXT_CANCEL", $this->lng->txt(
"cancel"));
239 $this->tpl->parseCurrentBlock();
251 $ilBench->start(
"Editor",
"Paragraph_update");
254 $this->content_obj->setLanguage(
$_POST[
"par_language"]);
255 $this->content_obj->setCharacteristic(
$_POST[
"par_characteristic"]);
261 $this->content_obj->setLanguage(
$_POST[
"par_language"]);
262 $this->content_obj->setSubCharacteristic(
$_POST[
"par_subcharacteristic"]);
264 $this->content_obj->setShowLineNumbers((
$_POST[
"par_showlinenumbers"]==
"on")?
"y":
"n");
265 $this->content_obj->setAutoIndent((
$_POST[
"par_autoindent"]==
"on")?
"y":
"n");
266 $this->content_obj->setSubCharacteristic(
$_POST[
"par_subcharacteristic"]);
267 $this->content_obj->setCharacteristic(
"Code");
269 $this->updated = $this->content_obj->setText(
270 $this->content_obj->input2xml(
$_POST[
"par_content"], 0,
false));
272 if ($this->updated !==
true)
275 $ilBench->stop(
"Editor",
"Paragraph_update");
280 $this->updated = $this->pg_obj->update();
282 $ilBench->stop(
"Editor",
"Paragraph_update");
284 if ($this->updated ===
true && $this->ctrl->getCmd () !=
"upload" )
286 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
299 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
308 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
309 $this->content_obj->setLanguage(
$_POST[
"par_language"]);
315 $this->content_obj->setCharacteristic (
$_POST[
"par_characteristic"]);
316 $this->content_obj->setSubCharacteristic(
$_POST[
"par_subcharacteristic"]);
318 $this->content_obj->setShowLineNumbers ((
$_POST[
"par_showlinenumbers"]==
'on')?
'y':
'n');
319 $this->content_obj->setCharacteristic (
'Code');
320 $this->content_obj->setAutoIndent ((
$_POST[
"par_indent"]==
'on')?
'y':
'n');
327 $this->updated = $this->content_obj->setText(
328 $this->content_obj->input2xml(
$_POST[
"par_content"], 0,
false));
330 if ($this->updated !==
true)
336 $this->updated = $this->pg_obj->update();
338 if ($this->updated ===
true && !$uploaded)
340 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
353 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
362 if (isset($_FILES[
'userfile'][
'name']))
364 $userfile = $_FILES[
'userfile'][
'tmp_name'];
366 if ($userfile ==
"" || !is_uploaded_file($userfile))
368 $error_str =
"<b>Error(s):</b><br>Upload error: file name must not be empty!";
369 $this->tpl->setVariable(
"MESSAGE", $error_str);
370 $this->content_obj->setText($this->content_obj->input2xml(stripslashes(
$_POST[
"par_content"]), 0,
false));
374 $_POST[
"par_content"] = file_get_contents($userfile);
375 $_POST[
"par_downloadtitle"] = $_FILES[
'userfile'][
'name'];
384 $prog_langs_ini = file (
"Services/COPage/syntax_highlight/php/admin/prog_langs.ini");
385 $prog_langs = array (
"" => $this->lng->txt(
"cont_src_other"));
386 foreach ($prog_langs_ini as $prog_lang) {
387 $prog_lang_prop = split (
":", $prog_lang);
388 if ($prog_lang_prop[2] == 1) {
389 $prog_langs[$prog_lang_prop[0]] = $prog_lang_prop[1];