ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilPCParagraphGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once("./Services/COPage/classes/class.ilPCParagraph.php");
5require_once("./Services/COPage/classes/class.ilPageContentGUI.php");
6
18{
22 protected $user;
23
28 public function __construct($a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id = "")
29 {
30 global $DIC;
31
32 $this->user = $DIC->user();
33 $this->ctrl = $DIC->ctrl();
34 $this->lng = $DIC->language();
35 parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
36
37 // characteristics (should be flexible in the future)
39 }
40
44 public static function _getStandardCharacteristics()
45 {
46 global $DIC;
47
48 $lng = $DIC->language();
49
50 return array("Standard" => $lng->txt("cont_standard"),
51 "Headline1" => $lng->txt("cont_Headline1"),
52 "Headline2" => $lng->txt("cont_Headline2"),
53 "Headline3" => $lng->txt("cont_Headline3"),
54 "Citation" => $lng->txt("cont_Citation"),
55 "Mnemonic" => $lng->txt("cont_Mnemonic"),
56 "Example" => $lng->txt("cont_Example"),
57 "Additional" => $lng->txt("cont_Additional"),
58 "Remark" => $lng->txt("cont_Remark"),
59 "List" => $lng->txt("cont_List"),
60 "TableContent" => $lng->txt("cont_TableContent")
61 );
62 }
63
67 public static function _getCharacteristics($a_style_id)
68 {
71
72 if ($a_style_id > 0 &&
73 ilObject::_lookupType($a_style_id) == "sty") {
74 include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
75 $style = new ilObjStyleSheet($a_style_id);
76 $types = array("text_block", "heading1", "heading2", "heading3");
77 $chars = array();
78 foreach ($types as $t) {
79 $chars = array_merge($chars, $style->getCharacteristics($t));
80 }
81 $new_chars = array();
82 foreach ($chars as $char) {
83 if ($st_chars[$char] != "") { // keep lang vars for standard chars
84 $new_chars[$char] = $st_chars[$char];
85 } else {
86 $new_chars[$char] = $char;
87 }
88 asort($new_chars);
89 }
90 $chars = $new_chars;
91 }
92
93 return $chars;
94 }
95
103 public static function _getTextCharacteristics($a_style_id, $a_include_core = false)
104 {
105 $chars = array();
106
107 if ($a_style_id > 0 &&
108 ilObject::_lookupType($a_style_id) == "sty") {
109 include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
110 $style = new ilObjStyleSheet($a_style_id);
111 $types = array("text_inline");
112 foreach ($types as $t) {
113 $chars = array_merge($chars, $style->getCharacteristics($t, false, $a_include_core));
114 }
115 }
116
117 return $chars;
118 }
119
120
124 public function executeCommand()
125 {
126 // get next class that processes or forwards current command
127 $next_class = $this->ctrl->getNextClass($this);
128
130 array("text_block", "heading1", "heading2", "heading3")
131 ); // scorm-2004
132
133 // get current command
134 $cmd = $this->ctrl->getCmd();
135
136 $this->log->debug("ilPCParagraphGUI: executeCommand " . $cmd);
137
138 switch ($next_class) {
139 default:
140 $ret = $this->$cmd();
141 break;
142 }
143
144 return $ret;
145 }
146
150 public function edit($a_insert = false)
151 {
153
154 // add paragraph edit template
155 $tpl = new ilTemplate("tpl.paragraph_edit.html", true, true, "Services/COPage");
156
157 // help text
158 $this->insertHelp($tpl);
159
160 // operations
161 if ($a_insert) {
162 $tpl->setCurrentBlock("commands");
163 $tpl->setVariable("BTN_NAME", "create_par");
164 $tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
165 $tpl->setVariable("BTN_CANCEL", "cancelCreate");
166 $tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
167 $tpl->parseCurrentBlock();
168 /*$tpl->setCurrentBlock("commands2");
169 $tpl->setVariable("BTN_NAME", "create_par");
170 $tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
171 $tpl->setVariable("BTN_CANCEL", "cancelCreate");
172 $tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
173 $tpl->parseCurrentBlock();*/
174 $tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_insert_par"));
175 } else {
176 $tpl->setCurrentBlock("commands");
177 $tpl->setVariable("BTN_NAME", "update");
178 $tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
179 $tpl->setVariable("BTN_CANCEL", "cancelUpdate");
180 $tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
181 $tpl->parseCurrentBlock();
182 /*$tpl->setCurrentBlock("commands2");
183 $tpl->setVariable("BTN_NAME", "update");
184 $tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
185 $tpl->setVariable("BTN_CANCEL", "cancelUpdate");
186 $tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
187 $tpl->parseCurrentBlock();*/
188 $tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_edit_par"));
189 }
190
191 // language and characteristic selection
192 $s_char = $this->determineCharacteristic($a_insert);
193 if (!$a_insert) {
194 if (key($_POST["cmd"]) == "update") {
195 $s_lang = $_POST["par_language"];
196 } else {
197 $s_lang = $this->content_obj->getLanguage();
198 }
199 } else {
200 if (key($_POST["cmd"]) == "create_par") {
201 $s_lang = $_POST["par_language"];
202 } else {
203 if ($_SESSION["il_text_lang_" . $_GET["ref_id"]] != "") {
204 $s_lang = $_SESSION["il_text_lang_" . $_GET["ref_id"]];
205 } else {
206 $s_lang = $ilUser->getLanguage();
207 }
208 }
209 }
210
211 $this->insertStyleSelectionList($tpl, $s_char);
212 // $this->insertCharacteristicTable($tpl, $s_char);
213
214
215 $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
216
217 $tpl->setVariable("PAR_TA_NAME", "par_content");
218 $tpl->setVariable("BB_MENU", $this->getBBMenu());
219 $this->tpl->addJavascript("./Services/COPage/phpBB/3_0_5/editor.js");
220 $this->tpl->addJavascript("./Services/COPage/js/paragraph_editing.js");
221 $this->setStyle();
222
223 $this->displayValidationError();
224
225 $tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
226 $tpl->setVariable("TXT_ANCHOR", $this->lng->txt("cont_anchor"));
227
228 require_once("Services/MetaData/classes/class.ilMDLanguageItem.php");
230 $select_lang = ilUtil::formSelect($s_lang, "par_language", $lang, false, true);
231 $tpl->setVariable("SELECT_LANGUAGE", $select_lang);
232
233 $tpl->setVariable("TXT_CHARACTERISTIC", $this->lng->txt("cont_characteristic"));
234 // $select_char = ilUtil::formSelect ($s_char,
235 // "par_characteristic",$this->chars,false,true);
236 // $tpl->setVariable("SELECT_CHARACTERISTIC", $select_char);
237
238 if (key($_POST["cmd"]) == "update" || key($_POST["cmd"]) == "create_par") {
239 $s_text = ilUtil::stripSlashes($_POST["par_content"], false);
240 // prevent curly brackets from being swallowed up by template engine
241 $s_text = str_replace("{", "&#123;", $s_text);
242 $s_text = str_replace("}", "&#125;", $s_text);
243 } elseif (!$a_insert) {
244 $s_text = $this->content_obj->xml2output($this->content_obj->getText());
245 }
246
247 $tpl->setVariable("PAR_TA_CONTENT", $s_text);
248
249 $tpl->parseCurrentBlock();
250
251 $this->tpl->setContent($tpl->get());
252 return $tpl->get();
253 }
254
261 public function determineCharacteristic($a_insert = false)
262 {
263 // language and characteristic selection
264 if (!$a_insert) {
265 if (key($_POST["cmd"]) == "update") {
266 $s_char = $_POST["par_characteristic"];
267 } else {
268 $s_char = $this->content_obj->getCharacteristic();
269 if ($s_char == "") {
270 $s_char = "Standard";
271 }
272 }
273 } else {
274 if (key($_POST["cmd"]) == "create_par") {
275 $s_char = $_POST["par_characteristic"];
276 } else {
277 $s_char = "Standard";
278
279 // set characteristic of new paragraphs in list items to "List"
280 $cont_obj = $this->pg_obj->getContentObject($this->getHierId());
281 if (is_object($cont_obj)) {
282 if ($cont_obj->getType() == "li" ||
283 ($cont_obj->getType() == "par" && $cont_obj->getCharacteristic() == "List")) {
284 $s_char = "List";
285 }
286
287 if ($cont_obj->getType() == "td" ||
288 ($cont_obj->getType() == "par" && $cont_obj->getCharacteristic() == "TableContent")) {
289 $s_char = "TableContent";
290 }
291 }
292 }
293 }
294 return $s_char;
295 }
296
300 public function editJS()
301 {
302 $s_text = $this->content_obj->getText();
303 $this->log->debug("step 1: " . substr($s_text, 0, 1000));
304
305 //echo "\n<br><br>".htmlentities($s_text);
306 $s_text = $this->content_obj->xml2output($s_text, true, false);
307 $this->log->debug("step 2: " . substr($s_text, 0, 1000));
308
309 //echo "\n<br><br>".htmlentities($s_text);
310 $char = $this->determineCharacteristic(false);
311 $s_text = ilPCParagraphGUI::xml2outputJS($s_text, $char, $this->content_obj->readPCId());
312 $this->log->debug("step 3: " . substr($s_text, 0, 1000));
313
314 //echo "\n<br><br>".htmlentities($s_text);
315 $ids = "###" . $this->content_obj->readHierId() . ":" . $this->content_obj->readPCId() . "###" .
316 $char . "###";
317 echo $ids . $s_text;
318 $this->log->debug("step 4: " . substr($ids . $s_text, 0, 1000));
319 exit;
320 }
321
325 public function editMultipleJS()
326 {
327 echo $this->content_obj->getParagraphSequenceContent($this->pg_obj);
328 exit;
329 }
330
334 public static function xml2outputJS($s_text, $char, $a_pc_id)
335 {
336 // $s_text = "<div class='ilc_text_block_".$char."' id='$a_pc_id'>".$s_text."</div>";
337 $s_text = $s_text;
338 // lists
339 $s_text = str_replace(
340 array("<SimpleBulletList>", "</SimpleBulletList>"),
341 array("<ul class='ilc_list_u_BulletedList'>", "</ul>"),
342 $s_text
343 );
344 $s_text = str_replace(
345 array("<SimpleNumberedList>", "</SimpleNumberedList>"),
346 array("<ol class='ilc_list_o_NumberedList'>", "</ol>"),
347 $s_text
348 );
349 $s_text = str_replace(
350 array("<SimpleListItem>", "</SimpleListItem>"),
351 array("<li class='ilc_list_item_StandardListItem'>", "</li>"),
352 $s_text
353 );
354 $s_text = str_replace(
355 array("<SimpleListItem/>"),
356 array("<li class='ilc_list_item_StandardListItem'></li>"),
357 $s_text
358 );
359 //$s_text = str_replace("<SimpleBulletList><br />", "<SimpleBulletList>", $s_text);
360 //$s_text = str_replace("<SimpleNumberedList><br />", "<SimpleNumberedList>", $s_text);
361 //$s_text = str_replace("</SimpleListItem><br />", "</SimpleListItem>", $s_text);
362
363
364 // spans
365 include_once("./Services/COPage/classes/class.ilPageContentGUI.php");
366 foreach (ilPageContentGUI::_getCommonBBButtons() as $bb => $cl) {
367 if (!in_array($bb, array("code", "tex", "fn", "xln", "sub", "sup"))) {
368 $s_text = str_replace(
369 "[" . $bb . "]",
370 '<span class="ilc_text_inline_' . $cl . '">',
371 $s_text
372 );
373 $s_text = str_replace(
374 "[/" . $bb . "]",
375 '</span>',
376 $s_text
377 );
378 }
379 }
380
381 // marked text spans
382 $ws= "[ \t\r\f\v\n]*";
383 while (preg_match("~\[(marked$ws(class$ws=$ws\"([^\"])*\")$ws)\]~i", $s_text, $found)) {
384 $attribs = ilUtil::attribsToArray($found[2]);
385 if (isset($attribs["class"])) {
386 $s_text = str_replace("[" . $found[1] . "]", "<span class=\"ilc_text_inline_" . $attribs["class"] . "\">", $s_text);
387 } else {
388 $s_text = str_replace("[" . $found[1] . "]", "[error:marked" . $found[1] . "]", $s_text);
389 }
390 }
391 $s_text = preg_replace('~\[\/marked\]~i', "</span>", $s_text);
392
393
394 // code
395 $s_text = str_replace(
396 array("[code]", "[/code]"),
397 array("<code>", "</code>"),
398 $s_text
399 );
400
401 // sup
402 $s_text = str_replace(
403 array("[sup]", "[/sup]"),
404 array('<sup class="ilc_sup_Sup">', "</sup>"),
405 $s_text
406 );
407
408 // sub
409 $s_text = str_replace(
410 array("[sub]", "[/sub]"),
411 array('<sub class="ilc_sub_Sub">', "</sub>"),
412 $s_text
413 );
414
415 return $s_text;
416 }
417
418
425 public function saveJS()
426 {
428
429 $this->log->debug("start");
430
431 $this->updated = $this->content_obj->saveJS(
432 $this->pg_obj,
433 $_POST["ajaxform_content"],
434 ilUtil::stripSlashes($_POST["ajaxform_char"]),
435 ilUtil::stripSlashes($_POST["pc_id_str"])
436 );
437
438 $this->log->debug("ilPCParagraphGUI, saveJS: got updated value " . $this->updated);
439
440 if ($_POST["quick_save"]) {
441 if ($this->updated === true) {
442 $a_pc_id_str = $this->content_obj->getLastSavedPcId($this->pg_obj, true);
443 $this->log->debug("ilPCParagraphGUI, saveJS: echoing pc_id_str " . $a_pc_id_str . " (and exit)");
444 echo $a_pc_id_str;
445 exit;
446 }
447 }
448
449 if ($this->updated !== true && is_array($this->updated)) {
450 $this->outputError($this->updated);
451 }
452
453 $a_pc_id_str = $this->content_obj->getLastSavedPcId($this->pg_obj, true);
454
455 $ilCtrl->setParameterByClass(
456 $ilCtrl->getReturnClass($this),
457 "updated_pc_id_str",
458 urlencode($a_pc_id_str)
459 );
460 $this->log->debug("ilPCParagraphGUI, saveJS: redirecting to edit command of " . $ilCtrl->getReturnClass($this) . ".");
461 $ilCtrl->redirectByClass($ilCtrl->getReturnClass($this), "edit", "", true);
462 }
463
469 public function outputError($a_err)
470 {
471 $err_str = "";
472 foreach ($a_err as $err) {
473 $err_str.= $err[1] . "<br />";
474 }
475 echo $err_str;
476 $this->log->debug("ilPCParagraphGUI, outputError() and exit: " . substr($err_str, 0, 100));
477 exit;
478 }
479
480
484 public function cancel()
485 {
486 $this->log->debug("ilPCParagraphGUI, cancel(): return to parent: jump" . $this->hier_id);
487 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
488 }
489
493 public function insertCharacteristicTable($a_tpl, $a_seleted_value)
494 {
495 $i = 0;
496
497 $chars = $this->getCharacteristics();
498
499 if ($chars[$a_seleted_value] == "" && ($a_seleted_value != "")) {
500 $chars = array_merge(
501 array($a_seleted_value => $a_seleted_value),
502 $chars
503 );
504 }
505
506 foreach ($chars as $char => $char_lang) {
507 $a_tpl->setCurrentBlock("characteristic_cell");
508 $a_tpl->setVariable(
509 "CHAR_HTML",
510 '<div class="ilc_text_block_' . $char . '" style="margin-top:2px; margin-bottom:2px; position:static;">' . $char_lang . "</div>"
511 );
512 $a_tpl->setVariable("CHAR_VALUE", $char);
513 if ($char == $a_seleted_value) {
514 $a_tpl->setVariable(
515 "SELECTED",
516 ' checked="checked" '
517 );
518 }
519 $a_tpl->parseCurrentBlock();
520 if ((($i+1) % 3) == 0) { //
521 $a_tpl->touchBlock("characteristic_row");
522 }
523 $i++;
524 }
525 $a_tpl->touchBlock("characteristic_table");
526 }
527
534 public function insertStyleSelectionList($a_tpl, $a_selected)
535 {
536 $a_tpl->setVariable("ADV_SEL_STYLE", self::getStyleSelector(
537 $a_selected,
538 $this->getCharacteristics()
539 ));
540 }
541
545 public static function getStyleSelector($a_selected, $a_chars, $a_use_callback = false)
546 {
547 include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
548 $selection = new ilAdvancedSelectionListGUI();
549 $selection->setPullRight(false);
550 $selection->setFormSelectMode(
551 "par_characteristic",
552 "",
553 false,
554 "",
555 "",
556 "",
557 "",
558 "",
559 "",
560 ""
561 );
562 $selection->setId("style_selection");
563 $selection->setSelectionHeaderClass("ilEditSubmit ilTinyMenuDropDown");
564 $selection->setHeaderIcon(ilAdvancedSelectionListGUI::DOWN_ARROW_DARK);
565 $selection->setSelectedValue($a_selected);
566 $selection->setUseImages(false);
568 if ($a_use_callback) {
569 $selection->setSelectCallback("ilCOPage.setParagraphClass");
570 }
571
572 $chars = $a_chars;
573 $title_char = ($chars[$a_selected] != "")
574 ? $chars[$a_selected]
575 : $a_selected;
576 $selection->setListTitle($title_char);
577
578 if ($chars[$a_seleted] == "" && ($a_seleted != "")) {
579 $chars = array_merge(
580 array($a_seleted => $a_seleted),
581 $chars
582 );
583 }
584
585 foreach ($chars as $char => $char_lang) {
586 $t = "text_block";
587 $tag = "div";
588 switch ($char) {
589 case "Headline1": $t = "heading1"; $tag = "h1"; break;
590 case "Headline2": $t = "heading2"; $tag = "h2"; break;
591 case "Headline3": $t = "heading3"; $tag = "h3"; break;
592 }
593 $html = '<div class="ilCOPgEditStyleSelectionItem"><' . $tag . ' class="ilc_' . $t . '_' . $char . '" style="' . self::$style_selector_reset . '">' . $char_lang . "</" . $tag . "></div>";
594 $selection->addItem(
595 $char_lang,
596 $char,
597 "",
598 "",
599 $char,
600 "",
601 $html
602 );
603 }
604 return $selection->getHTML();
605 }
606
610 public static function getCharStyleSelector($a_par_type, $a_use_callback = true, $a_style_id = 0)
611 {
612 global $DIC;
613
614 $lng = $DIC->language();
615
616 include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
617 $selection = new ilAdvancedSelectionListGUI();
618 $selection->setPullRight(false);
619 $selection->setFormSelectMode(
620 "char_characteristic",
621 "",
622 false,
623 "",
624 "",
625 "",
626 "",
627 "",
628 "",
629 ""
630 );
631 $selection->setId("char_style_selection");
632 $selection->setSelectionHeaderClass("ilEditSubmit");
633 $selection->setHeaderIcon(ilAdvancedSelectionListGUI::DOWN_ARROW_DARK);
634 //$selection->setSelectedValue($a_selected);
635 $selection->setUseImages(false);
636 $selection->setOnClickMode(ilAdvancedSelectionListGUI::ON_ITEM_CLICK_NOP);
637 if (is_string($a_use_callback)) {
638 $selection->setSelectCallback($a_use_callback);
639 } elseif ($a_use_callback === true) {
640 $selection->setSelectCallback("ilCOPage.setCharacterClass");
641 }
642
643 //$chars = $a_chars;
644 //$title_char = ($chars[$a_selected] != "")
645 // ? $chars[$a_selected]
646 // : $a_selected;
647 $selection->setListTitle("&nbsp;<i>A</i>");
648
649 /*if ($chars[$a_seleted] == "" && ($a_seleted != ""))
650 {
651 $chars = array_merge(array($a_seleted => $a_seleted),
652 $chars);
653 }*/
654
655 $chars = array(
656 "Comment" => array("code" => "com", "txt" => $lng->txt("cont_char_style_com")),
657 "Quotation" => array("code" => "quot", "txt" =>$lng->txt("cont_char_style_quot")),
658 "Accent" => array("code" => "acc", "txt" => $lng->txt("cont_char_style_acc")),
659 "Code" => array("code" => "code", "txt" => $lng->txt("cont_char_style_code"))
660 );
661
662 if ($a_style_id > 0) {
663 foreach (ilPCParagraphGUI::_getTextCharacteristics($a_style_id) as $c) {
664 if (!isset($chars[$c])) {
665 $chars[$c] = array("code" => "", "txt" => $c);
666 }
667 }
668 }
669
670 foreach ($chars as $key => $char) {
672 $a_par_type,
673 "active_" . $char["code"],
674 true
675 )) {
676 $t = "text_inline";
677 $tag = "span";
678 switch ($key) {
679 case "Code": $tag = "code"; break;
680 }
681 $html = '<' . $tag . ' class="ilc_' . $t . '_' . $key . '" style="font-size:90%; margin-top:2px; margin-bottom:2px; position:static;">' . $char["txt"] . "</" . $tag . ">";
682
683 // this next line is very important for IE. The real onclick event is on the surrounding <tr> of the
684 // advanced selection list. But it is impossible to prevent the tr-event from removing the focus
685 // on tiny withouth the following line, that receives the click event before and stops the faulty default
686 // bevaviour of IE, see bug report #8723
687 $html = '<a class="nostyle" style="display:block;" href="#" onclick="return false;">' . $html . "</a>";
688 $selection->addItem(
689 $char["txt"],
690 $key,
691 "",
692 "",
693 $key,
694 "",
695 $html
696 );
697 }
698 }
699 return $selection->getHTML();
700 }
701
705 private function setStyle()
706 {
707 include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
708
709 if ($this->pg_obj->getParentType() == "gdf" ||
710 $this->pg_obj->getParentType() == "lm") {
711 if ($this->pg_obj->getParentType() != "gdf") {
712 $this->tpl->setContentStylesheet(ilObjStyleSheet::getContentStylePath(
713 ilObjContentObject::_lookupStyleSheetId($this->pg_obj->getParentId())
714 ));
715 } else {
716 $this->tpl->setContentStylesheet(ilObjStyleSheet::getContentStylePath(0));
717 }
718 } else {
719 if ($this->pg_obj->getParentType() != "sahs") {
720 // $this->tpl->setContentStylesheet(ilObjStyleSheet::getContentStylePath(0));
721 }
722 }
723 }
724
728 public function insert()
729 {
730 $this->log->debug("ilPCParagraphGUI, saveJS: got updated value " . $this->updated);
731 return $this->edit(true);
732 }
733
737 public function update()
738 {
739 $this->log->debug("ilPCParagraphGUI, update(): start");
740
741 // set language and characteristic
742 $this->content_obj->setLanguage($_POST["par_language"]);
743 $this->content_obj->setCharacteristic($_POST["par_characteristic"]);
744
745 $this->updated = $this->content_obj->setText(
746 $this->content_obj->input2xml(
747 $_POST["par_content"],
748 $_POST["usedwsiwygeditor"]
749 ),
750 true
751 );
752 if ($this->updated !== true) {
753 $this->edit();
754 return;
755 }
756
757 $this->updated = $this->content_obj->updatePage($this->pg_obj);
758
759
760 if ($this->updated === true) {
761 $this->log->debug("ilPCParagraphGUI, update(): return to parent: jump" . $this->hier_id);
762 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
763 } else {
764 $this->log->debug("ilPCParagraphGUI, update(): call edit.");
765 $this->edit();
766 }
767 }
768
769
773 public function create()
774 {
775 $this->log->debug("ilPCParagraphGUI, create(): start.");
776
777 if ($_POST["ajaxform_hier_id"] != "") {
778 return $this->createJS();
779 }
780
781 $this->content_obj = new ilPCParagraph($this->getPage());
782 //echo "+".$this->pc_id."+";
783 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
784
785 $this->content_obj->setLanguage($_POST["par_language"]);
786 $_SESSION["il_text_lang_" . $_GET["ref_id"]] = $_POST["par_language"];
787 $this->content_obj->setCharacteristic($_POST["par_characteristic"]);
788
789 $this->updated = $this->content_obj->setText(
790 $this->content_obj->input2xml(
791 $_POST["par_content"],
792 $_POST["usedwsiwygeditor"]
793 ),
794 true
795 );
796
797 if ($this->updated !== true) {
798 $this->insert();
799 return;
800 }
801 $this->updated = $this->content_obj->updatePage($this->pg_obj);
802
803 if ($this->updated === true) {
804 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
805 } else {
806 $this->insert();
807 }
808 }
809
813 public function createJS()
814 {
817
818 $this->log->debug("ilPCParagraphGUI, createJS(): start");
819
820 $this->content_obj = new ilPCParagraph($this->getPage());
821 $this->updated = $this->content_obj->saveJS(
822 $this->pg_obj,
823 $_POST["ajaxform_content"],
824 ilUtil::stripSlashes($_POST["ajaxform_char"]),
825 ilUtil::stripSlashes($_POST["pc_id_str"]),
826 $_POST["insert_at_id"]
827 );
828 if ($_POST["quick_save"]) {
829 if ($this->updated) {
830 $a_pc_id_str = $this->content_obj->getLastSavedPcId($this->pg_obj, true);
831 echo $a_pc_id_str;
832 $this->log->debug("ilPCParagraphGUI, createJS(): echo pc id and exit: " . $a_pc_id_str);
833 exit;
834 }
835 }
836
837 if ($this->updated !== true && is_array($this->updated)) {
838 $this->outputError($this->updated);
839 }
840
841 // e.g. e.g. ###3:110dad8bad6df8620071a0a693a2d328###
842 $a_pc_id_str = $this->content_obj->getLastSavedPcId($this->pg_obj, true);
843 $ilCtrl->setParameterByClass(
844 $ilCtrl->getReturnClass($this),
845 "updated_pc_id_str",
846 urlencode($a_pc_id_str)
847 );
848 $this->log->debug("ilPCParagraphGUI, createJS(): return to edit cmd of " . $ilCtrl->getReturnClass($this));
849
850 $ilCtrl->redirectByClass($ilCtrl->getReturnClass($this), "edit", "", true);
851 }
852
856 public function insertHelp($a_tpl)
857 {
859
860 $a_tpl->setCurrentBlock("help_item");
861 $a_tpl->setVariable("TXT_HELP", "<b>" . $lng->txt("cont_syntax_help") . "</b>");
862 $a_tpl->parseCurrentBlock();
863 $a_tpl->setCurrentBlock("help_item");
864 $a_tpl->setVariable("TXT_HELP", "* " . $lng->txt("cont_bullet_list"));
865 $a_tpl->parseCurrentBlock();
866 $a_tpl->setCurrentBlock("help_item");
867 $a_tpl->setVariable("TXT_HELP", "# " . $lng->txt("cont_numbered_list"));
868 $a_tpl->parseCurrentBlock();
869 $a_tpl->setCurrentBlock("help_item");
870 $a_tpl->setVariable("TXT_HELP", "=" . $lng->txt("cont_Headline1") . "=<br />" .
871 "==" . $lng->txt("cont_Headline2") . "==<br />" .
872 "===" . $lng->txt("cont_Headline3") . "===");
873 $a_tpl->parseCurrentBlock();
874
875 if ($this->getPageConfig()->getEnableWikiLinks()) {
876 $a_tpl->setCurrentBlock("help_item");
877 $a_tpl->setVariable("TXT_HELP", "[[" . $lng->txt("cont_wiki_page_link") . "]]");
878 $a_tpl->parseCurrentBlock();
879 }
880
881 $a_tpl->setCurrentBlock("help");
882 $a_tpl->parseCurrentBlock();
883 }
884}
user()
Definition: user.php:4
$_GET["client_id"]
$_POST["username"]
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
User interface class for advanced drop-down selection lists.
static _lookupStyleSheetId($a_cont_obj_id)
lookup style sheet ID
Class ilObjStyleSheet.
static getContentStylePath($a_style_id, $add_random=true)
get content style path
static _lookupType($a_id, $a_reference=false)
lookup object type
Class ilPCParagraphGUI.
saveJS()
Save paragraph by JS call.
insert()
insert paragraph form
insertCharacteristicTable($a_tpl, $a_seleted_value)
Insert characteristic table.
determineCharacteristic($a_insert=false)
Determine current characteristic.
outputError($a_err)
Output error.
static xml2outputJS($s_text, $char, $a_pc_id)
Prepare content for js output.
__construct($a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id="")
Constructor @access public.
createJS()
Create paragraph per JS.
editJS()
Edit paragraph (Ajax mode, sends the content of the paragraph)
create()
create new paragraph in dom and update page in db
executeCommand()
execute command
static _getCharacteristics($a_style_id)
Get characteristics.
static _getTextCharacteristics($a_style_id, $a_include_core=false)
Get text characteristics.
static getStyleSelector($a_selected, $a_chars, $a_use_callback=false)
Get style selector.
edit($a_insert=false)
edit paragraph form
insertHelp($a_tpl)
Insert Help.
insertStyleSelectionList($a_tpl, $a_selected)
Insert style selection list.
static getCharStyleSelector($a_par_type, $a_use_callback=true, $a_style_id=0)
Get character style selector.
static _getStandardCharacteristics()
Get standard characteristics.
update()
update paragraph in dom and update page in db
editMultipleJS()
Edit multiple paragraphs (Ajax mode, sends the content of the paragraphs)
Class ilPCParagraph.
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
getHierId()
get hierarchical id in dom object
getCharacteristicsOfCurrentStyle($a_type)
Get characteristics of current style.
getPageConfig()
Get Page Config.
displayValidationError()
display validation errors
static _getCommonBBButtons()
Get common bb buttons.
getCharacteristics()
Get characteristics.
getBBMenu($a_ta_name="par_content")
Get the bb menu incl.
setCharacteristics($a_chars)
Set Characteristics.
static lookupSettingByParentType($a_par_type, $a_name, $a_default=false)
Lookup setting by parent type.
special template class to simplify handling of ITX/PEAR
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static formSelect( $selected, $varname, $options, $multiple=false, $direct_text=false, $size="0", $style_class="", $attribs="", $disabled=false)
Builds a select form field with options and shows the selected option first.
static attribsToArray($a_str)
converts a string of format var1 = "val1" var2 = "val2" ... into an array
$lang
Definition: consent.php:3
$key
Definition: croninfo.php:18
$i
Definition: disco.tpl.php:19
$html
Definition: example_001.php:87
$style
Definition: example_012.php:70
global $ilCtrl
Definition: ilias.php:18
if(function_exists( 'posix_getuid') &&posix_getuid()===0) if(!array_key_exists('t', $options)) $tag
Definition: cron.php:35
$ret
Definition: parser.php:6
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18