5require_once(
"./Services/COPage/classes/class.ilPCSourceCode.php");
6require_once(
"./Services/COPage/classes/class.ilPageContentGUI.php");
27 parent::ilPageContentGUI($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
37 $next_class = $this->ctrl->getNextClass($this);
40 $cmd = $this->ctrl->getCmd();
57 $form = $this->
initPropertyForm($this->lng->txt(
"cont_edit_src"),
"update",
"cancelCreate");
59 if ($this->pg_obj->getParentType() ==
"lm" ||
60 $this->pg_obj->getParentType() ==
"dbk")
62 $this->tpl->setVariable(
"LINK_ILINK",
63 $this->ctrl->getLinkTargetByClass(
"ilInternalLinkGUI",
"showLinkHelp"));
64 $this->tpl->setVariable(
"TXT_ILINK",
"[".$this->lng->txt(
"cont_internal_link").
"]");
69 if (key(
$_POST[
"cmd"]) ==
"update")
71 $form->setValuesByPost();
75 $form->getItemByPostVar(
"par_language")->setValue($this->content_obj->getLanguage());
76 $form->getItemByPostVar(
"par_subcharacteristic")->setValue($this->content_obj->getSubCharacteristic());
77 $form->getItemByPostVar(
"par_downloadtitle")->setValue( $this->content_obj->getDownloadTitle());
78 $form->getItemByPostVar(
"par_showlinenumbers")->setChecked(
79 $this->content_obj->getShowLineNumbers()==
"y"?
true:
false);
80 $form->getItemByPostVar(
"par_autoindent")->setChecked(
81 $this->content_obj->getAutoIndent()==
"y"?
true:
false);
83 $par_content = $this->content_obj->xml2output($this->content_obj->getText());
86 $par_content = str_replace(
"{",
"{", $par_content);
87 $par_content = str_replace(
"}",
"}", $par_content);
89 $form->getItemByPostVar(
"par_content")->setValue($par_content);
93 $this->tpl->setContent($form->getHTML());
103 $form = $this->
initPropertyForm($this->lng->txt(
"cont_insert_src"),
"create_src",
"cancelCreate");
105 if ($this->pg_obj->getParentType() ==
"lm" ||
106 $this->pg_obj->getParentType() ==
"dbk")
108 $this->tpl->setVariable(
"LINK_ILINK",
109 $this->ctrl->getLinkTargetByClass(
"ilInternalLinkGUI",
"showLinkHelp"));
110 $this->tpl->setVariable(
"TXT_ILINK",
"[".$this->lng->txt(
"cont_internal_link").
"]");
115 if (key(
$_POST[
"cmd"]) ==
"create_src")
117 $form->setValuesByPost();
123 $form->getItemByPostVar(
"par_language")->setValue(
$_SESSION[
"il_text_lang_".
$_GET[
"ref_id"]]);
127 $form->getItemByPostVar(
"par_language")->setValue(
$ilUser->getLanguage());
130 $form->getItemByPostVar(
"par_showlinenumbers")->setChecked(
true);
131 $form->getItemByPostVar(
"par_autoindent")->setChecked(
true);
132 $form->getItemByPostVar(
"par_subcharacteristic")->setValue(
"");
133 $form->getItemByPostVar(
"par_content")->setValue(
"");
136 $this->tpl->setContent($form->getHTML());
149 $ilBench->start(
"Editor",
"Paragraph_update");
152 $this->content_obj->setLanguage(
$_POST[
"par_language"]);
153 $this->content_obj->setCharacteristic(
$_POST[
"par_characteristic"]);
159 $this->content_obj->setLanguage(
$_POST[
"par_language"]);
160 $this->content_obj->setSubCharacteristic(
$_POST[
"par_subcharacteristic"]);
162 $this->content_obj->setShowLineNumbers(
$_POST[
"par_showlinenumbers"]?
"y":
"n");
163 $this->content_obj->setAutoIndent(
$_POST[
"par_autoindent"]?
"y":
"n");
164 $this->content_obj->setSubCharacteristic(
$_POST[
"par_subcharacteristic"]);
165 $this->content_obj->setCharacteristic(
"Code");
167 $this->updated = $this->content_obj->setText(
168 $this->content_obj->input2xml(
$_POST[
"par_content"], 0,
false));
170 if ($this->updated !==
true)
173 $ilBench->stop(
"Editor",
"Paragraph_update");
178 $this->updated = $this->pg_obj->update();
180 $ilBench->stop(
"Editor",
"Paragraph_update");
182 if ($this->updated ===
true && $this->ctrl->getCmd () !=
"upload" )
184 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
197 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
206 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
207 $this->content_obj->setLanguage(
$_POST[
"par_language"]);
213 $this->content_obj->setCharacteristic (
$_POST[
"par_characteristic"]);
214 $this->content_obj->setSubCharacteristic(
$_POST[
"par_subcharacteristic"]);
216 $this->content_obj->setShowLineNumbers (
$_POST[
"par_showlinenumbers"]?
'y':
'n');
217 $this->content_obj->setCharacteristic (
'Code');
218 $this->content_obj->setAutoIndent (
$_POST[
"par_autoindent"]?
'y':
'n');
225 $this->updated = $this->content_obj->setText(
226 $this->content_obj->input2xml(
$_POST[
"par_content"], 0,
false));
228 if ($this->updated !==
true)
234 $this->updated = $this->pg_obj->update();
236 if ($this->updated ===
true && !$uploaded)
238 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
251 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
255 if (isset($_FILES[
'userfile'][
'name']))
257 $userfile = $_FILES[
'userfile'][
'tmp_name'];
259 if ($userfile ==
"" || !is_uploaded_file($userfile))
261 $error_str =
"<b>Error(s):</b><br>Upload error: file name must not be empty!";
262 $this->tpl->setVariable(
"MESSAGE", $error_str);
263 $this->content_obj->setText($this->content_obj->input2xml(stripslashes(
$_POST[
"par_content"]), 0,
false));
267 $_POST[
"par_content"] = file_get_contents($userfile);
268 $_POST[
"par_downloadtitle"] = $_FILES[
'userfile'][
'name'];
277 $prog_langs_ini = file (
"Services/COPage/syntax_highlight/php/admin/prog_langs.ini");
278 $prog_langs = array (
"" => $this->lng->txt(
"cont_src_other"));
279 foreach ($prog_langs_ini as $prog_lang) {
280 $prog_lang_prop = split (
":", $prog_lang);
281 if ($prog_lang_prop[2] == 1) {
282 $prog_langs[$prog_lang_prop[0]] = $prog_lang_prop[1];
300 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
302 $form->setTitle($a_title);
303 $form->setFormAction($this->ctrl->getFormAction($this, $a_cmd));
304 $form->addCommandButton($a_cmd_cancel,$this->lng->txt(
"cancel"));
305 $form->addCommandButton($a_cmd,$this->lng->txt(
"save"));
307 require_once(
"Services/MetaData/classes/class.ilMDLanguageItem.php");
309 include_once(
"./Services/Form/classes/class.ilSelectInputGUI.php");
311 $lang->setOptions($lang_var);
312 $form->addItem(
$lang);
315 $code_style =
new ilSelectInputGUI( $this->lng->txt(
"cont_src"),
"par_subcharacteristic");
316 $code_style->setOptions($prog_langs);
317 $form->addItem($code_style);
318 include_once(
"./Services/Form/classes/class.ilSelectInputGUI.php");
319 $line_number =
new ilCheckboxInputGUI($this->lng->txt(
"cont_show_line_numbers"),
"par_showlinenumbers");
320 $form->addItem($line_number);
321 $indent =
new ilCheckboxInputGUI($this->lng->txt(
"cont_autoindent"),
"par_autoindent");
322 $form->addItem($indent);
325 include_once(
"./Services/Form/classes/class.ilSelectInputGUI.php");
328 $form->addItem(
$code);
330 include_once(
"./Services/Form/classes/class.ilTextInputGUI.php");
331 $downlaod_title =
new ilTextInputGUI($this->lng->txt(
"cont_download_title"),
"par_downloadtitle");
332 $downlaod_title->setSize(40);
333 $form->addItem($downlaod_title);
335 include_once(
"./Services/Form/classes/class.ilFileInputGUI.php");
337 $form->addItem(
$file);
initPropertyForm($a_title, $a_cmd, $a_cmd_cancel)
initiates property form GUI class
insert()
insert paragraph form
create()
create new paragraph in dom and update page in db
update()
update paragraph in dom and update page in db
edit()
edit paragraph form
cancelUpdate()
cancel update
& executeCommand()
execute command
ilPCSourceCodeGUI($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id="")
Constructor @access public.
cancelCreate()
cancel creating paragraph
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
displayValidationError()
display validation errors
This class represents a text area property in a property form.
This class represents a text property in a property form.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled