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