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