ILIAS  release_7 Revision v7.30-3-g800a261c036
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 "Book" => $lng->txt("cont_Book"),
55 "Numbers" => $lng->txt("cont_Numbers"),
56 "Verse" => $lng->txt("cont_Verse"),
57 "List" => $lng->txt("cont_List"),
58 "TableContent" => $lng->txt("cont_TableContent")
59 );
60 }
61
65 public static function _getStandardTextCharacteristics()
66 {
67 global $DIC;
68
69 $lng = $DIC->language();
70 return ["Mnemonic", "Attention"];
71 return array("Mnemonic" => $lng->txt("cont_Mnemonic"),
72 "Attention" => $lng->txt("cont_Attention")
73 );
74 }
75
79 public static function _getCharacteristics($a_style_id)
80 {
83
84
85 if ($a_style_id > 0 &&
86 ilObject::_lookupType($a_style_id) == "sty") {
87 include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
88 $style = new ilObjStyleSheet($a_style_id);
89 $types = array("heading1", "heading2", "heading3", "text_block");
90 $chars = array();
91 foreach ($types as $t) {
92 $chars = array_merge($chars, $style->getCharacteristics($t));
93 }
94 $new_chars = array();
95 foreach ($chars as $char) {
96 if ($st_chars[$char] != "") { // keep lang vars for standard chars
97 $new_chars[$char] = $st_chars[$char];
98 } else {
99 $new_chars[$char] = $char;
100 }
101// asort($new_chars);
102 }
103 $chars = $new_chars;
104 }
105
106 return $chars;
107 }
108
116 public static function _getTextCharacteristics($a_style_id, $a_include_core = false)
117 {
118 $chars = array();
119
120 if ($a_style_id > 0 &&
121 ilObject::_lookupType($a_style_id) == "sty") {
122 $style = new ilObjStyleSheet($a_style_id);
123 $types = array("text_inline");
124 foreach ($types as $t) {
125 $chars = array_merge($chars, $style->getCharacteristics($t, false, $a_include_core));
126 }
127 } else {
129 }
130
131 return $chars;
132 }
133
134
138 public function executeCommand()
139 {
140 // get next class that processes or forwards current command
141 $next_class = $this->ctrl->getNextClass($this);
142
144 array("text_block", "heading1", "heading2", "heading3")
145 ); // scorm-2004
146
147 // get current command
148 $cmd = $this->ctrl->getCmd();
149
150 $this->log->debug("ilPCParagraphGUI: executeCommand " . $cmd);
151
152 switch ($next_class) {
153 default:
154 $ret = $this->$cmd();
155 break;
156 }
157
158 return $ret;
159 }
160
164 public function edit($a_insert = false)
165 {
167
168 // add paragraph edit template
169 $tpl = new ilTemplate("tpl.paragraph_edit.html", true, true, "Services/COPage");
170
171 // help text
172 $this->insertHelp($tpl);
173
174 // operations
175 if ($a_insert) {
176 $tpl->setCurrentBlock("commands");
177 $tpl->setVariable("BTN_NAME", "create_par");
178 $tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
179 $tpl->setVariable("BTN_CANCEL", "cancelCreate");
180 $tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
181 $tpl->parseCurrentBlock();
182 /*$tpl->setCurrentBlock("commands2");
183 $tpl->setVariable("BTN_NAME", "create_par");
184 $tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
185 $tpl->setVariable("BTN_CANCEL", "cancelCreate");
186 $tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
187 $tpl->parseCurrentBlock();*/
188 $tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_insert_par"));
189 } else {
190 $tpl->setCurrentBlock("commands");
191 $tpl->setVariable("BTN_NAME", "update");
192 $tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
193 $tpl->setVariable("BTN_CANCEL", "cancelUpdate");
194 $tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
195 $tpl->parseCurrentBlock();
196 /*$tpl->setCurrentBlock("commands2");
197 $tpl->setVariable("BTN_NAME", "update");
198 $tpl->setVariable("BTN_TEXT", $this->lng->txt("save"));
199 $tpl->setVariable("BTN_CANCEL", "cancelUpdate");
200 $tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
201 $tpl->parseCurrentBlock();*/
202 $tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_edit_par"));
203 }
204
205 // language and characteristic selection
206 $s_char = $this->determineCharacteristic($a_insert);
207 if (!$a_insert) {
208 if (key($_POST["cmd"]) == "update") {
209 $s_lang = $_POST["par_language"];
210 } else {
211 $s_lang = $this->content_obj->getLanguage();
212 }
213 } else {
214 if (key($_POST["cmd"]) == "create_par") {
215 $s_lang = $_POST["par_language"];
216 } else {
217 if ($_SESSION["il_text_lang_" . $_GET["ref_id"]] != "") {
218 $s_lang = $_SESSION["il_text_lang_" . $_GET["ref_id"]];
219 } else {
220 $s_lang = $ilUser->getLanguage();
221 }
222 }
223 }
224
225 $this->insertStyleSelectionList($tpl, $s_char);
226 // $this->insertCharacteristicTable($tpl, $s_char);
227
228
229 $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
230
231 $tpl->setVariable("PAR_TA_NAME", "par_content");
232 $tpl->setVariable("BB_MENU", $this->getBBMenu());
233 $this->tpl->addJavascript("./Services/COPage/phpBB/3_0_5/editor.js");
234 $this->tpl->addJavascript("./Services/COPage/js/paragraph_editing.js");
235 $this->setStyle();
236
237 $this->displayValidationError();
238
239 $tpl->setVariable("TXT_LANGUAGE", $this->lng->txt("language"));
240 $tpl->setVariable("TXT_ANCHOR", $this->lng->txt("cont_anchor"));
241
242 require_once("Services/MetaData/classes/class.ilMDLanguageItem.php");
244 $select_lang = ilUtil::formSelect($s_lang, "par_language", $lang, false, true);
245 $tpl->setVariable("SELECT_LANGUAGE", $select_lang);
246
247 $tpl->setVariable("TXT_CHARACTERISTIC", $this->lng->txt("cont_characteristic"));
248 // $select_char = ilUtil::formSelect ($s_char,
249 // "par_characteristic",$this->chars,false,true);
250 // $tpl->setVariable("SELECT_CHARACTERISTIC", $select_char);
251
252 if (key($_POST["cmd"]) == "update" || key($_POST["cmd"]) == "create_par") {
253 $s_text = ilUtil::stripSlashes($_POST["par_content"], false);
254 // prevent curly brackets from being swallowed up by template engine
255 $s_text = str_replace("{", "&#123;", $s_text);
256 $s_text = str_replace("}", "&#125;", $s_text);
257 } elseif (!$a_insert) {
258 $s_text = $this->content_obj->xml2output($this->content_obj->getText());
259 }
260
261 $tpl->setVariable("PAR_TA_CONTENT", $s_text);
262
263 $tpl->parseCurrentBlock();
264
265 $this->tpl->setContent($tpl->get());
266 return $tpl->get();
267 }
268
275 public function determineCharacteristic($a_insert = false)
276 {
277 // language and characteristic selection
278 if (!$a_insert) {
279 if (key($_POST["cmd"]) == "update") {
280 $s_char = $_POST["par_characteristic"];
281 } else {
282 $s_char = $this->content_obj->getCharacteristic();
283 if ($s_char == "") {
284 $s_char = "Standard";
285 }
286 }
287 } else {
288 if (key($_POST["cmd"]) == "create_par") {
289 $s_char = $_POST["par_characteristic"];
290 } else {
291 $s_char = "Standard";
292
293 // set characteristic of new paragraphs in list items to "List"
294 $cont_obj = $this->pg_obj->getContentObject($this->getHierId());
295 if (is_object($cont_obj)) {
296 if ($cont_obj->getType() == "li" ||
297 ($cont_obj->getType() == "par" && $cont_obj->getCharacteristic() == "List")) {
298 $s_char = "List";
299 }
300
301 if ($cont_obj->getType() == "td" ||
302 ($cont_obj->getType() == "par" && $cont_obj->getCharacteristic() == "TableContent")) {
303 $s_char = "TableContent";
304 }
305 }
306 }
307 }
308 return $s_char;
309 }
310
314 public function editJS()
315 {
316 $s_text = $this->content_obj->getText();
317 $this->log->debug("step 1: " . substr($s_text, 0, 1000));
318
319 //echo "\n<br><br>".htmlentities($s_text);
320 $s_text = $this->content_obj->xml2output($s_text, true, false);
321 $this->log->debug("step 2: " . substr($s_text, 0, 1000));
322
323 //echo "\n<br><br>".htmlentities($s_text);
324 $char = $this->determineCharacteristic(false);
325 $s_text = ilPCParagraphGUI::xml2outputJS($s_text, $char, $this->content_obj->readPCId());
326 $this->log->debug("step 3: " . substr($s_text, 0, 1000));
327
328 //echo "\n<br><br>".htmlentities($s_text);
329 $ids = "###" . $this->content_obj->readHierId() . ":" . $this->content_obj->readPCId() . "###" .
330 $char . "###";
331 echo $ids . $s_text;
332 $this->log->debug("step 4: " . substr($ids . $s_text, 0, 1000));
333 exit;
334 }
335
339 public function editMultipleJS()
340 {
341 echo $this->content_obj->getParagraphSequenceContent($this->pg_obj);
342 exit;
343 }
344
348 public static function xml2outputJS($s_text)
349 {
350 // lists
351 $s_text = str_replace(
352 array("<SimpleBulletList>", "</SimpleBulletList>"),
353 array("<ul class='ilc_list_u_BulletedList'>", "</ul>"),
354 $s_text
355 );
356 $s_text = str_replace(
357 array("<SimpleNumberedList>", "</SimpleNumberedList>"),
358 array("<ol class='ilc_list_o_NumberedList'>", "</ol>"),
359 $s_text
360 );
361 $s_text = str_replace(
362 array("<SimpleListItem>", "</SimpleListItem>"),
363 array("<li class='ilc_list_item_StandardListItem'>", "</li>"),
364 $s_text
365 );
366 $s_text = str_replace(
367 array("<SimpleListItem/>"),
368 array("<li class='ilc_list_item_StandardListItem'></li>"),
369 $s_text
370 );
371 //$s_text = str_replace("<SimpleBulletList><br />", "<SimpleBulletList>", $s_text);
372 //$s_text = str_replace("<SimpleNumberedList><br />", "<SimpleNumberedList>", $s_text);
373 //$s_text = str_replace("</SimpleListItem><br />", "</SimpleListItem>", $s_text);
374
375
376 // spans
377 include_once("./Services/COPage/classes/class.ilPageContentGUI.php");
378 foreach (ilPageContentGUI::_getCommonBBButtons() as $bb => $cl) {
379 if (!in_array($bb, array("code", "tex", "fn", "xln", "sub", "sup"))) {
380 $s_text = str_replace(
381 "[" . $bb . "]",
382 '<span class="ilc_text_inline_' . $cl . '">',
383 $s_text
384 );
385 $s_text = str_replace(
386 "[/" . $bb . "]",
387 '</span>',
388 $s_text
389 );
390 }
391 }
392
393 // marked text spans
394 $ws = "[ \t\r\f\v\n]*";
395 while (preg_match("~\[(marked$ws(class$ws=$ws\"([^\"])*\")$ws)\]~i", $s_text, $found)) {
396 $attribs = ilUtil::attribsToArray($found[2]);
397 if (isset($attribs["class"])) {
398 $s_text = str_replace("[" . $found[1] . "]", "<span class=\"ilc_text_inline_" . $attribs["class"] . "\">", $s_text);
399 } else {
400 $s_text = str_replace("[" . $found[1] . "]", "[error:marked" . $found[1] . "]", $s_text);
401 }
402 }
403 $s_text = preg_replace('~\[\/marked\]~i', "</span>", $s_text);
404
405
406 // code
407 $s_text = str_replace(
408 array("[code]", "[/code]"),
409 array("<code>", "</code>"),
410 $s_text
411 );
412
413 // sup
414 $s_text = str_replace(
415 array("[sup]", "[/sup]"),
416 array('<sup class="ilc_sup_Sup">', "</sup>"),
417 $s_text
418 );
419
420 // sub
421 $s_text = str_replace(
422 array("[sub]", "[/sub]"),
423 array('<sub class="ilc_sub_Sub">', "</sub>"),
424 $s_text
425 );
426
427 return $s_text;
428 }
429
430
437 public function saveJS()
438 {
439 $ilCtrl = $this->ctrl;
440
441 $this->log->debug("start");
442
443 $this->updated = $this->content_obj->saveJS(
444 $this->pg_obj,
445 $_POST["ajaxform_content"],
446 ilUtil::stripSlashes($_POST["ajaxform_char"]),
447 ilUtil::stripSlashes($_POST["pc_id_str"])
448 );
449
450 $this->log->debug("ilPCParagraphGUI, saveJS: got updated value " . $this->updated);
451
452 if ($_POST["quick_save"]) {
453 if ($this->updated === true) {
454 $a_pc_id_str = $this->content_obj->getLastSavedPcId($this->pg_obj, true);
455 $this->log->debug("ilPCParagraphGUI, saveJS: echoing pc_id_str " . $a_pc_id_str . " (and exit)");
456 echo $a_pc_id_str;
457 exit;
458 }
459 }
460
461 if ($this->updated !== true && is_array($this->updated)) {
462 $this->outputError($this->updated);
463 }
464
465 $a_pc_id_str = $this->content_obj->getLastSavedPcId($this->pg_obj, true);
466
467 $ilCtrl->setParameterByClass(
468 $ilCtrl->getReturnClass($this),
469 "updated_pc_id_str",
470 urlencode($a_pc_id_str)
471 );
472 $this->log->debug("ilPCParagraphGUI, saveJS: redirecting to edit command of " . $ilCtrl->getReturnClass($this) . ".");
473 $ilCtrl->redirectByClass($ilCtrl->getReturnClass($this), "edit", "", true);
474 }
475
481 public function outputError($a_err)
482 {
483 $err_str = "";
484 foreach ($a_err as $err) {
485 $err_str .= $err[1] . "<br />";
486 }
487 echo $err_str;
488 $this->log->debug("ilPCParagraphGUI, outputError() and exit: " . substr($err_str, 0, 100));
489 exit;
490 }
491
492
496 public function cancel()
497 {
498 $this->log->debug("ilPCParagraphGUI, cancel(): return to parent: jump" . $this->hier_id);
499 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
500 }
501
505 public function insertCharacteristicTable($a_tpl, $a_seleted_value)
506 {
507 $i = 0;
508
509 $chars = $this->getCharacteristics();
510
511 if ($chars[$a_seleted_value] == "" && ($a_seleted_value != "")) {
512 $chars = array_merge(
513 array($a_seleted_value => $a_seleted_value),
514 $chars
515 );
516 }
517
518 foreach ($chars as $char => $char_lang) {
519 $a_tpl->setCurrentBlock("characteristic_cell");
520 $a_tpl->setVariable(
521 "CHAR_HTML",
522 '<div class="ilc_text_block_' . $char . '" style="margin-top:2px; margin-bottom:2px; position:static;">' . $char_lang . "</div>"
523 );
524 $a_tpl->setVariable("CHAR_VALUE", $char);
525 if ($char == $a_seleted_value) {
526 $a_tpl->setVariable(
527 "SELECTED",
528 ' checked="checked" '
529 );
530 }
531 $a_tpl->parseCurrentBlock();
532 if ((($i + 1) % 3) == 0) { //
533 $a_tpl->touchBlock("characteristic_row");
534 }
535 $i++;
536 }
537 $a_tpl->touchBlock("characteristic_table");
538 }
539
546 public function insertStyleSelectionList($a_tpl, $a_selected)
547 {
548 $a_tpl->setVariable("ADV_SEL_STYLE", self::getStyleSelector(
549 $a_selected,
550 $this->getCharacteristics()
551 ));
552 }
553
557 public static function getStyleSelector($a_selected, $a_chars, $a_use_callback = false)
558 {
559 include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
560 $selection = new ilAdvancedSelectionListGUI();
561 $selection->setPullRight(false);
562 $selection->setFormSelectMode(
563 "par_characteristic",
564 "",
565 false,
566 "",
567 "",
568 "",
569 "",
570 "",
571 "",
572 ""
573 );
574 $selection->setId("style_selection");
575 $selection->setSelectionHeaderClass("ilEditSubmit ilTinyMenuDropDown");
576 $selection->setHeaderIcon(ilAdvancedSelectionListGUI::DOWN_ARROW_DARK);
577 $selection->setSelectedValue($a_selected);
578 $selection->setUseImages(false);
580 if ($a_use_callback) {
581 $selection->setSelectCallback("ilCOPage.setParagraphClass");
582 }
583
584 $chars = $a_chars;
585 $title_char = ($chars[$a_selected] != "")
586 ? $chars[$a_selected]
587 : $a_selected;
588 $selection->setListTitle($title_char);
589
590 if ($chars[$a_seleted] == "" && ($a_seleted != "")) {
591 $chars = array_merge(
592 array($a_seleted => $a_seleted),
593 $chars
594 );
595 }
596
597 foreach ($chars as $char => $char_lang) {
598 $t = "text_block";
599 $tag = "div";
600 switch ($char) {
601 case "Headline1": $t = "heading1"; $tag = "h1"; break;
602 case "Headline2": $t = "heading2"; $tag = "h2"; break;
603 case "Headline3": $t = "heading3"; $tag = "h3"; break;
604 }
605 $html = '<div class="ilCOPgEditStyleSelectionItem"><' . $tag . ' class="ilc_' . $t . '_' . $char . '" style="' . self::$style_selector_reset . '">' . $char_lang . "</" . $tag . "></div>";
606 $selection->addItem(
607 $char_lang,
608 $char,
609 "",
610 "",
611 $char,
612 "",
613 $html
614 );
615 }
616 return $selection->getHTML();
617 }
618
622 public static function getCharStyleSelector($a_par_type, $a_use_callback = true, $a_style_id = 0)
623 {
624 global $DIC;
625
626 $lng = $DIC->language();
627
628 include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
629 $selection = new ilAdvancedSelectionListGUI();
630 $selection->setPullRight(false);
631 $selection->setFormSelectMode(
632 "char_characteristic",
633 "",
634 false,
635 "",
636 "",
637 "",
638 "",
639 "",
640 "",
641 ""
642 );
643 $selection->setId("char_style_selection");
644 $selection->setSelectionHeaderClass("ilEditSubmit");
645 $selection->setHeaderIcon(ilAdvancedSelectionListGUI::DOWN_ARROW_DARK);
646 //$selection->setSelectedValue($a_selected);
647 $selection->setUseImages(false);
648 $selection->setOnClickMode(ilAdvancedSelectionListGUI::ON_ITEM_CLICK_NOP);
649 if (is_string($a_use_callback)) {
650 $selection->setSelectCallback($a_use_callback);
651 } elseif ($a_use_callback === true) {
652 $selection->setSelectCallback("ilCOPage.setCharacterClass");
653 }
654
655 //$chars = $a_chars;
656 //$title_char = ($chars[$a_selected] != "")
657 // ? $chars[$a_selected]
658 // : $a_selected;
659 $selection->setListTitle("&nbsp;<i>A</i>");
660
661 /*if ($chars[$a_seleted] == "" && ($a_seleted != ""))
662 {
663 $chars = array_merge(array($a_seleted => $a_seleted),
664 $chars);
665 }*/
666
667 $chars = array(
668 "Comment" => array("code" => "com", "txt" => $lng->txt("cont_char_style_com")),
669 "Quotation" => array("code" => "quot", "txt" => $lng->txt("cont_char_style_quot")),
670 "Accent" => array("code" => "acc", "txt" => $lng->txt("cont_char_style_acc")),
671 "Code" => array("code" => "code", "txt" => $lng->txt("cont_char_style_code"))
672 );
673
674 foreach (ilPCParagraphGUI::_getTextCharacteristics($a_style_id) as $c) {
675 if (!isset($chars[$c])) {
676 $chars[$c] = array("code" => "", "txt" => $c);
677 }
678 }
679
680 foreach ($chars as $key => $char) {
682 $a_par_type,
683 "active_" . $char["code"],
684 true
685 )) {
686 $t = "text_inline";
687 $tag = "span";
688 switch ($key) {
689 case "Code": $tag = "code"; break;
690 }
691 $html = '<' . $tag . ' class="ilc_' . $t . '_' . $key . '" style="font-size:90%; margin-top:2px; margin-bottom:2px; position:static;">' . $char["txt"] . "</" . $tag . ">";
692
693 // this next line is very important for IE. The real onclick event is on the surrounding <tr> of the
694 // advanced selection list. But it is impossible to prevent the tr-event from removing the focus
695 // on tiny withouth the following line, that receives the click event before and stops the faulty default
696 // bevaviour of IE, see bug report #8723
697 $html = '<a class="nostyle" style="display:block;" href="#" onclick="return false;">' . $html . "</a>";
698 $selection->addItem(
699 $char["txt"],
700 $key,
701 "",
702 "",
703 $key,
704 "",
705 $html
706 );
707 }
708 }
709 return $selection->getHTML();
710 }
711
715 private function setStyle()
716 {
717 include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
718
719 if ($this->pg_obj->getParentType() == "gdf" ||
720 $this->pg_obj->getParentType() == "lm") {
721 if ($this->pg_obj->getParentType() != "gdf") {
722 $this->tpl->addCss(ilObjStyleSheet::getContentStylePath(
723 ilObjContentObject::_lookupStyleSheetId($this->pg_obj->getParentId())
724 ));
725 } else {
726 $this->tpl->addCss(ilObjStyleSheet::getContentStylePath(0));
727 }
728 } else {
729 if ($this->pg_obj->getParentType() != "sahs") {
730 // $this->tpl->setContentStylesheet(ilObjStyleSheet::getContentStylePath(0));
731 }
732 }
733 }
734
738 public function insert()
739 {
740 $this->log->debug("ilPCParagraphGUI, saveJS: got updated value " . $this->updated);
741 return $this->edit(true);
742 }
743
747 public function update()
748 {
749 $this->log->debug("ilPCParagraphGUI, update(): start");
750
751 // set language and characteristic
752 $this->content_obj->setLanguage($_POST["par_language"]);
753 $this->content_obj->setCharacteristic($_POST["par_characteristic"]);
754
755 $this->updated = $this->content_obj->setText(
756 $this->content_obj->input2xml(
757 $_POST["par_content"],
758 $_POST["usedwsiwygeditor"]
759 ),
760 true
761 );
762 if ($this->updated !== true) {
763 $this->edit();
764 return;
765 }
766
767 $this->updated = $this->content_obj->updatePage($this->pg_obj);
768
769
770 if ($this->updated === true) {
771 $this->log->debug("ilPCParagraphGUI, update(): return to parent: jump" . $this->hier_id);
772 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
773 } else {
774 $this->log->debug("ilPCParagraphGUI, update(): call edit.");
775 $this->edit();
776 }
777 }
778
779
783 public function create()
784 {
785 $this->log->debug("ilPCParagraphGUI, create(): start.");
786
787 if ($_POST["ajaxform_hier_id"] != "") {
788 return $this->createJS();
789 }
790
791 $this->content_obj = new ilPCParagraph($this->getPage());
792 //echo "+".$this->pc_id."+";
793 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
794
795 $this->content_obj->setLanguage($_POST["par_language"]);
796 $_SESSION["il_text_lang_" . $_GET["ref_id"]] = $_POST["par_language"];
797 $this->content_obj->setCharacteristic($_POST["par_characteristic"]);
798
799 $this->updated = $this->content_obj->setText(
800 $this->content_obj->input2xml(
801 $_POST["par_content"],
802 $_POST["usedwsiwygeditor"]
803 ),
804 true
805 );
806
807 if ($this->updated !== true) {
808 $this->insert();
809 return;
810 }
811 $this->updated = $this->content_obj->updatePage($this->pg_obj);
812
813 if ($this->updated === true) {
814 $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
815 } else {
816 $this->insert();
817 }
818 }
819
823 public function createJS()
824 {
826 $ilCtrl = $this->ctrl;
827
828 $this->log->debug("ilPCParagraphGUI, createJS(): start");
829
830 $this->content_obj = new ilPCParagraph($this->getPage());
831 $this->updated = $this->content_obj->saveJS(
832 $this->pg_obj,
833 $_POST["ajaxform_content"],
834 ilUtil::stripSlashes($_POST["ajaxform_char"]),
835 ilUtil::stripSlashes($_POST["pc_id_str"]),
836 $_POST["insert_at_id"]
837 );
838 if ($_POST["quick_save"]) {
839 if ($this->updated) {
840 $a_pc_id_str = $this->content_obj->getLastSavedPcId($this->pg_obj, true);
841 echo $a_pc_id_str;
842 $this->log->debug("ilPCParagraphGUI, createJS(): echo pc id and exit: " . $a_pc_id_str);
843 exit;
844 }
845 }
846
847 if ($this->updated !== true && is_array($this->updated)) {
848 $this->outputError($this->updated);
849 }
850
851 // e.g. e.g. ###3:110dad8bad6df8620071a0a693a2d328###
852 $a_pc_id_str = $this->content_obj->getLastSavedPcId($this->pg_obj, true);
853 $ilCtrl->setParameterByClass(
854 $ilCtrl->getReturnClass($this),
855 "updated_pc_id_str",
856 urlencode($a_pc_id_str)
857 );
858 $this->log->debug("ilPCParagraphGUI, createJS(): return to edit cmd of " . $ilCtrl->getReturnClass($this));
859
860 $ilCtrl->redirectByClass($ilCtrl->getReturnClass($this), "edit", "", true);
861 }
862
866 public function insertHelp($a_tpl)
867 {
869
870 $a_tpl->setCurrentBlock("help_item");
871 $a_tpl->setVariable("TXT_HELP", "<b>" . $lng->txt("cont_syntax_help") . "</b>");
872 $a_tpl->parseCurrentBlock();
873 $a_tpl->setCurrentBlock("help_item");
874 $a_tpl->setVariable("TXT_HELP", "* " . $lng->txt("cont_bullet_list"));
875 $a_tpl->parseCurrentBlock();
876 $a_tpl->setCurrentBlock("help_item");
877 $a_tpl->setVariable("TXT_HELP", "# " . $lng->txt("cont_numbered_list"));
878 $a_tpl->parseCurrentBlock();
879 $a_tpl->setCurrentBlock("help_item");
880 $a_tpl->setVariable("TXT_HELP", "=" . $lng->txt("cont_Headline1") . "=<br />" .
881 "==" . $lng->txt("cont_Headline2") . "==<br />" .
882 "===" . $lng->txt("cont_Headline3") . "===");
883 $a_tpl->parseCurrentBlock();
884
885 if ($this->getPageConfig()->getEnableWikiLinks()) {
886 $a_tpl->setCurrentBlock("help_item");
887 $a_tpl->setVariable("TXT_HELP", "[[" . $lng->txt("cont_wiki_page_link") . "]]");
888 $a_tpl->parseCurrentBlock();
889 }
890
891 $a_tpl->setCurrentBlock("help");
892 $a_tpl->parseCurrentBlock();
893 }
894}
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, $add_token=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.
createJS()
Create paragraph per JS.
__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id="")
Constructor @access public.
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.
static _getStandardTextCharacteristics()
Get standard characteristics.
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)
static xml2outputJS($s_text)
Prepare content for js output.
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
$c
Definition: cli.php:37
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
exit
Definition: login.php:29
$i
Definition: metadata.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$ret
Definition: parser.php:6
$lang
Definition: xapiexit.php:8