5require_once(
"./Services/COPage/classes/class.ilPCSourceCode.php");
6require_once(
"./Services/COPage/classes/class.ilPageContentGUI.php");
25 function __construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id =
"")
27 parent::__construct($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")
61 $this->tpl->setVariable(
"LINK_ILINK",
62 $this->ctrl->getLinkTargetByClass(
"ilInternalLinkGUI",
"showLinkHelp"));
63 $this->tpl->setVariable(
"TXT_ILINK",
"[".$this->lng->txt(
"cont_internal_link").
"]");
68 if (key(
$_POST[
"cmd"]) ==
"update")
70 $form->setValuesByPost();
74 $form->getItemByPostVar(
"par_language")->setValue($this->content_obj->getLanguage());
75 $form->getItemByPostVar(
"par_subcharacteristic")->setValue($this->content_obj->getSubCharacteristic());
76 $form->getItemByPostVar(
"par_downloadtitle")->setValue( $this->content_obj->getDownloadTitle());
77 $form->getItemByPostVar(
"par_showlinenumbers")->setChecked(
78 $this->content_obj->getShowLineNumbers()==
"y"?
true:
false);
82 $par_content = $this->content_obj->xml2output($this->content_obj->getText());
85 $par_content = str_replace(
"{",
"{", $par_content);
86 $par_content = str_replace(
"}",
"}", $par_content);
88 $form->getItemByPostVar(
"par_content")->setValue($par_content);
92 $this->tpl->setContent($form->getHTML());
102 $form = $this->
initPropertyForm($this->lng->txt(
"cont_insert_src"),
"create_src",
"cancelCreate");
104 if ($this->pg_obj->getParentType() ==
"lm")
106 $this->tpl->setVariable(
"LINK_ILINK",
107 $this->ctrl->getLinkTargetByClass(
"ilInternalLinkGUI",
"showLinkHelp"));
108 $this->tpl->setVariable(
"TXT_ILINK",
"[".$this->lng->txt(
"cont_internal_link").
"]");
113 if (key(
$_POST[
"cmd"]) ==
"create_src")
115 $form->setValuesByPost();
121 $form->getItemByPostVar(
"par_language")->setValue(
$_SESSION[
"il_text_lang_".
$_GET[
"ref_id"]]);
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());
147 $ilBench->start(
"Editor",
"Paragraph_update");
150 $this->content_obj->setLanguage(
$_POST[
"par_language"]);
151 $this->content_obj->setCharacteristic(
$_POST[
"par_characteristic"]);
157 $this->content_obj->setLanguage(
$_POST[
"par_language"]);
158 $this->content_obj->setSubCharacteristic(
$_POST[
"par_subcharacteristic"]);
160 $this->content_obj->setShowLineNumbers(
$_POST[
"par_showlinenumbers"]?
"y":
"n");
162 $this->content_obj->setSubCharacteristic(
$_POST[
"par_subcharacteristic"]);
163 $this->content_obj->setCharacteristic(
"Code");
165 $this->updated = $this->content_obj->setText(
166 $this->content_obj->input2xml(
$_POST[
"par_content"], 0,
false));
168 if ($this->updated !==
true)
171 $ilBench->stop(
"Editor",
"Paragraph_update");
176 $this->updated = $this->pg_obj->update();
178 $ilBench->stop(
"Editor",
"Paragraph_update");
180 if ($this->updated ===
true && $this->ctrl->getCmd () !=
"upload" )
182 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
195 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
204 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
205 $this->content_obj->setLanguage(
$_POST[
"par_language"]);
211 $this->content_obj->setCharacteristic (
$_POST[
"par_characteristic"]);
212 $this->content_obj->setSubCharacteristic(
$_POST[
"par_subcharacteristic"]);
214 $this->content_obj->setShowLineNumbers (
$_POST[
"par_showlinenumbers"]?
'y':
'n');
215 $this->content_obj->setCharacteristic (
'Code');
223 $this->updated = $this->content_obj->setText(
224 $this->content_obj->input2xml(
$_POST[
"par_content"], 0,
false));
226 if ($this->updated !==
true)
232 $this->updated = $this->pg_obj->update();
234 if ($this->updated ===
true && !$uploaded)
236 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
249 $this->ctrl->returnToParent($this,
"jump".$this->hier_id);
253 if (isset($_FILES[
'userfile'][
'name']))
255 $userfile = $_FILES[
'userfile'][
'tmp_name'];
257 if ($userfile ==
"" || !is_uploaded_file($userfile))
259 $error_str =
"<b>Error(s):</b><br>Upload error: file name must not be empty!";
260 $this->tpl->setVariable(
"MESSAGE", $error_str);
261 $this->content_obj->setText($this->content_obj->input2xml(stripslashes(
$_POST[
"par_content"]), 0,
false));
265 $_POST[
"par_content"] = file_get_contents($userfile);
266 $_POST[
"par_downloadtitle"] = $_FILES[
'userfile'][
'name'];
283 include_once(
"./Services/UIComponent/SyntaxHighlighter/classes/class.ilSyntaxHighlighter.php");
286 $prog_langs[$k] = $v;
302 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
304 $form->setTitle($a_title);
305 $form->setFormAction($this->ctrl->getFormAction($this, $a_cmd));
306 $form->addCommandButton($a_cmd,$this->lng->txt(
"save"));
307 $form->addCommandButton($a_cmd_cancel,$this->lng->txt(
"cancel"));
310 require_once(
"Services/MetaData/classes/class.ilMDLanguageItem.php");
312 include_once(
"./Services/Form/classes/class.ilSelectInputGUI.php");
314 $lang->setOptions($lang_var);
315 $form->addItem(
$lang);
318 $code_style =
new ilSelectInputGUI( $this->lng->txt(
"cont_src"),
"par_subcharacteristic");
319 $code_style->setOptions($prog_langs);
320 $form->addItem($code_style);
321 include_once(
"./Services/Form/classes/class.ilSelectInputGUI.php");
322 $line_number =
new ilCheckboxInputGUI($this->lng->txt(
"cont_show_line_numbers"),
"par_showlinenumbers");
323 $form->addItem($line_number);
328 include_once(
"./Services/Form/classes/class.ilSelectInputGUI.php");
331 $form->addItem(
$code);
333 include_once(
"./Services/Form/classes/class.ilTextInputGUI.php");
334 $downlaod_title =
new ilTextInputGUI($this->lng->txt(
"cont_download_title"),
"par_downloadtitle");
335 $downlaod_title->setSize(40);
336 $form->addItem($downlaod_title);
338 include_once(
"./Services/Form/classes/class.ilFileInputGUI.php");
340 $form->addItem(
$file);
An exception for terminatinating execution or to throw for unit testing.
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
getProgLangOptions()
Get selectable programming languages.
update()
update paragraph in dom and update page in db
edit()
edit paragraph form
__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id="")
Constructor @access public.
cancelUpdate()
cancel update
cancelCreate()
cancel creating paragraph
executeCommand()
execute command
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
displayValidationError()
display validation errors
static getSupportedLanguagesV51()
Get supported languages (keys are ILIAS <= 5.1 internal values, values are for representation)
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
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file