24 require_once(
"./Services/COPage/classes/class.ilPCParagraph.php");
25 require_once(
"./Services/COPage/classes/class.ilPageContentGUI.php");
56 $next_class = $this->ctrl->getNextClass($this);
59 $cmd = $this->ctrl->getCmd();
76 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.sourcecode_edit.html",
"Services/COPage");
79 $this->tpl->setVariable(
"TXT_ACTION", $this->lng->txt(
"cont_edit_src"));
81 if ($this->pg_obj->getParentType() ==
"lm" ||
82 $this->pg_obj->getParentType() ==
"dbk")
84 $this->tpl->setVariable(
"LINK_ILINK",
85 $this->ctrl->getLinkTargetByClass(
"ilInternalLinkGUI",
"showLinkHelp"));
86 $this->tpl->setVariable(
"TXT_ILINK",
"[".$this->lng->txt(
"cont_internal_link").
"]");
92 if (key(
$_POST[
"cmd"]) ==
"update")
94 $s_lang =
$_POST[
"par_language"];
95 $s_char =
$_POST[
"par_characteristic"];
96 $s_subchar =
$_POST[
"par_subcharacteristic"];
97 $s_downloadtitle =
$_POST[
"par_downloadtitle"];
98 $s_showlinenumbers = (
$_POST[
"par_showlinenumbers"]==
"on")?
'y':
'n';
99 $s_autoindent = (
$_POST[
"par_autoindent"]==
"on")?
'y':
'n';
103 $s_lang = $this->content_obj->getLanguage();
104 $s_char = $this->content_obj->getCharacteristic();
105 $s_subchar = $this->content_obj->getSubCharacteristic();
106 $s_downloadtitle = $this->content_obj->getDownloadTitle();
107 $s_showlinenumbers = $this->content_obj->getShowLineNumbers();
108 $s_autoindent = $this->content_obj->getAutoIndent ();
113 if (key(
$_POST[
"cmd"]) ==
"update")
115 $s_text = stripslashes(
$_POST[
"par_content"]);
119 $s_text = $this->content_obj->xml2output($this->content_obj->getText());
122 $this->tpl->setVariable(
"PAR_TA_NAME",
"par_content");
123 $this->tpl->setVariable(
"PAR_TA_CONTENT", $s_text);
127 if (strcmp($s_showlinenumbers,
"y")==0)
129 $this->tpl->setVariable(
"SHOWLINENUMBERS",
"checked=\"checked\"");
132 if (strcmp($s_autoindent,
"y") == 0)
134 $this->tpl->setVariable(
"AUTOINDENT",
"checked=\"checked\"");
138 $this->tpl->setVariable(
"DOWNLOAD_TITLE_VALUE", $s_downloadtitle);
141 $this->tpl->setCurrentBlock(
"commands");
142 $this->tpl->setVariable(
"BTN_NAME",
"update");
143 $this->tpl->setVariable(
"UPLOAD_BTN_NAME",
"upload");
144 $this->tpl->setVariable(
"BTN_TEXT", $this->lng->txt(
"save"));
145 $this->tpl->setVariable(
"BTN_CANCEL",
"cancelUpdate");
146 $this->tpl->setVariable(
"TXT_CANCEL", $this->lng->txt(
"cancel"));
147 $this->tpl->parseCurrentBlock();
152 $this->tpl->setVariable (
"TXT_CREATEFILE", $this->lng->txt(
"create_download_link"));
153 $this->tpl->setVariable (
"TXT_DOWNLOADTITLE", $this->lng->txt(
"cont_download_title"));
154 $this->tpl->setVariable (
"TXT_IMPORTFILE", $this->lng->txt(
"import_file"));
155 $this->tpl->setVariable (
"TXT_UPLOAD_BTN", $this->lng->txt(
"import"));
156 $this->tpl->setVariable (
"TXT_SUBCHARACTERISTIC", $this->lng->txt(
"cont_src"));
157 $this->tpl->setVariable (
"TXT_LANGUAGE", $this->lng->txt(
"language"));
158 $this->tpl->setVariable (
"TXT_SHOWLINENUMBERS", $this->lng->txt(
"cont_show_line_numbers"));
159 $this->tpl->setVariable (
"TXT_AUTOINDENT", $this->lng->txt(
"cont_autoindent"));
162 $this->tpl->setVariable (
"FORMACTION", $this->ctrl->getFormAction($this));
164 require_once(
"Services/MetaData/classes/class.ilMDLanguageItem.php");
167 $this->tpl->setVariable (
"SELECT_LANGUAGE", $select_lang);
171 $select_subchar =
ilUtil::formSelect ($s_proglang,
"par_subcharacteristic",$prog_langs,
false,
true);
172 $this->tpl->setVariable (
"SELECT_SUBCHARACTERISTIC", $select_subchar);
184 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.sourcecode_edit.html",
"Services/COPage");
185 $this->tpl->setVariable(
"TXT_ACTION", $this->lng->txt(
"cont_insert_src"));
187 if ($this->pg_obj->getParentType() ==
"lm" ||
188 $this->pg_obj->getParentType() ==
"dbk")
190 $this->tpl->setVariable(
"LINK_ILINK",
191 $this->ctrl->getLinkTargetByClass(
"ilInternalLinkGUI",
"showLinkHelp"));
192 $this->tpl->setVariable(
"TXT_ILINK",
"[".$this->lng->txt(
"cont_internal_link").
"]");
201 if (key(
$_POST[
"cmd"]) ==
"create_src")
203 $s_lang =
$_POST[
"par_language"];
204 $s_subchar =
$_POST[
"par_subcharacteristic"];
205 $s_downloadtitle =
$_POST[
"par_downloadtitle"];
206 $s_showlinenumbers = strcmp(
$_POST[
"par_showlinenumbers"],
'on')==0?
'checked=\"true\"':
'';
207 $s_autoindent = strcmp(
$_POST[
"par_autoindent"],
'on')==0?
'checked=\"true\"':
'';
208 $s_isexample = strcmp(
$_POST[
"par_isexample"],
"on")==0?
'checked=\"true\"':
'';
214 $s_lang =
$_SESSION[
"il_text_lang_".$_GET[
"ref_id"]];
218 $s_lang = $ilUser->getLanguage();
221 $s_showlinenumbers =
'CHECKED';
222 $s_autoindent =
'CHECKED';
229 $this->tpl->setVariable(
"SHOWLINENUMBERS", $s_showlinenumbers);
230 $this->tpl->setVariable(
"AUTOINDENT", $s_autoindent);
231 $this->tpl->setVariable(
"DOWNLOAD_TITLE_VALUE", $s_downloadtitle);
232 $this->tpl->setVariable(
"ISEXAMPLE", $s_isexample);
239 $this->tpl->setVariable(
"PAR_TA_NAME",
"par_content");
241 if (key(
$_POST[
"cmd"]) ==
"create_src")
243 $this->tpl->setVariable(
"PAR_TA_CONTENT", stripslashes(
$_POST[
"par_content"]));
247 $this->tpl->setVariable(
"PAR_TA_CONTENT",
"");
252 $this->tpl->setCurrentBlock(
"commands");
253 $this->tpl->setVariable(
"BTN_NAME",
"create_src");
254 $this->tpl->setVariable(
"UPLOAD_BTN_NAME",
"create_src");
255 $this->tpl->setVariable(
"BTN_TEXT", $this->lng->txt(
"save"));
256 $this->tpl->setVariable(
"BTN_CANCEL",
"cancelCreate");
257 $this->tpl->setVariable(
"TXT_CANCEL", $this->lng->txt(
"cancel"));
258 $this->tpl->parseCurrentBlock();
270 $ilBench->start(
"Editor",
"Paragraph_update");
273 $this->content_obj->setLanguage(
$_POST[
"par_language"]);
274 $this->content_obj->setCharacteristic(
$_POST[
"par_characteristic"]);
280 $this->content_obj->setLanguage(
$_POST[
"par_language"]);
281 $this->content_obj->setSubCharacteristic(
$_POST[
"par_subcharacteristic"]);
282 $this->content_obj->setDownloadTitle(
$_POST[
"par_downloadtitle"]);
283 $this->content_obj->setShowLineNumbers((
$_POST[
"par_showlinenumbers"]==
"on")?
"y":
"n");
284 $this->content_obj->setAutoIndent((
$_POST[
"par_autoindent"]==
"on")?
"y":
"n");
285 $this->content_obj->setSubCharacteristic(
$_POST[
"par_subcharacteristic"]);
286 $this->content_obj->setCharacteristic(
"Code");
288 $this->updated = $this->content_obj->setText(
289 $this->content_obj->input2xml(
$_POST[
"par_content"], 0,
false));
291 if ($this->updated !==
true)
294 $ilBench->stop(
"Editor",
"Paragraph_update");
299 $this->updated = $this->pg_obj->update();
301 $ilBench->stop(
"Editor",
"Paragraph_update");
303 if ($this->updated ===
true && $this->ctrl->getCmd () !=
"upload" )
305 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
318 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
327 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
328 $this->content_obj->setLanguage(
$_POST[
"par_language"]);
334 $this->content_obj->setCharacteristic (
$_POST[
"par_characteristic"]);
335 $this->content_obj->setSubCharacteristic(
$_POST[
"par_subcharacteristic"]);
336 $this->content_obj->setDownloadTitle (
$_POST[
"par_downloadtitle"]);
337 $this->content_obj->setShowLineNumbers ((
$_POST[
"par_showlinenumbers"]==
'on')?
'y':
'n');
338 $this->content_obj->setCharacteristic (
'Code');
339 $this->content_obj->setAutoIndent ((
$_POST[
"par_indent"]==
'on')?
'y':
'n');
346 $this->updated = $this->content_obj->setText(
347 $this->content_obj->input2xml(
$_POST[
"par_content"], 0,
false));
349 if ($this->updated !==
true)
355 $this->updated = $this->pg_obj->update();
357 if ($this->updated ===
true && !$uploaded)
359 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
372 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
381 if (isset($_FILES[
'userfile'][
'name']))
383 $userfile = $_FILES[
'userfile'][
'tmp_name'];
385 if ($userfile ==
"" || !is_uploaded_file($userfile))
387 $error_str =
"<b>Error(s):</b><br>Upload error: file name must not be empty!";
388 $this->tpl->setVariable(
"MESSAGE", $error_str);
389 $this->content_obj->setText($this->content_obj->input2xml(stripslashes(
$_POST[
"par_content"]), 0,
false));
393 $_POST[
"par_content"] = file_get_contents($userfile);
394 $_POST[
"par_downloadtitle"] = $_FILES[
'userfile'][
'name'];
403 $prog_langs_ini = file (
"Services/COPage/syntax_highlight/php/admin/prog_langs.ini");
404 $prog_langs = array (
"" => $this->lng->txt(
"cont_src_other"));
405 foreach ($prog_langs_ini as $prog_lang) {
406 $prog_lang_prop = split (
":", $prog_lang);
407 if ($prog_lang_prop[2] == 1) {
408 $prog_langs[$prog_lang_prop[0]] = $prog_lang_prop[1];