ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilPCParagraph.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.ilPageContent.php");
5
17{
21 protected $user;
22
23 public $dom;
24 public $par_node; // node of Paragraph element
25
26 protected static $bb_tags = array(
27 "com" => "Comment",
28 "emp" => "Emph",
29 "str" => "Strong",
30 "fn" => "Footnote",
31 "code" => "Code",
32 "acc" => "Accent",
33 "imp" => "Important",
34 "kw" => "Keyw",
35 "sub" => "Sub",
36 "sup" => "Sup",
37 "quot" => "Quotation",
38 );
39
43 public function init()
44 {
45 global $DIC;
46
47 $this->user = $DIC->user();
48 $this->setType("par");
49 }
50
56 protected static function getBBMap()
57 {
58 return self::$bb_tags;
59 }
60
66 protected static function getXMLTagMap()
67 {
68 return array_flip(self::$bb_tags);
69 }
70
71
72
78 public function setNode($a_node)
79 {
80 parent::setNode($a_node); // this is the PageContent node
81
82 $childs = $a_node->child_nodes();
83 for ($i = 0; $i < count($childs); $i++) {
84 if ($childs[$i]->node_name() == "Paragraph") {
85 $this->par_node = $childs[$i]; //... and this the Paragraph node
86 }
87 }
88 }
89
90
96 public function createAtNode(&$node)
97 {
98 $this->node = $this->createPageContentNode();
99 $this->par_node = $this->dom->create_element("Paragraph");
100 $this->par_node = $this->node->append_child($this->par_node);
101 $this->par_node->set_attribute("Language", "");
102 $node->append_child($this->node);
103 }
104
110 public function createBeforeNode(&$node)
111 {
112 $this->node = $this->createPageContentNode();
113 $this->par_node = $this->dom->create_element("Paragraph");
114 $this->par_node = $this->node->append_child($this->par_node);
115 $this->par_node->set_attribute("Language", "");
116 $node->insert_before($this->node, $node);
117 }
118
125 public function createAfter($node)
126 {
127 $this->node = $this->createPageContentNode(false);
128 if ($succ_node = $node->next_sibling()) {
129 $this->node = $succ_node->insert_before($this->node, $succ_node);
130 } else {
131 $parent_node = $node->parent_node();
132 $this->node = $parent_node->append_child($this->node);
133 }
134 $this->par_node = $this->dom->create_element("Paragraph");
135 $this->par_node = $this->node->append_child($this->par_node);
136 $this->par_node->set_attribute("Language", "");
137 }
138
146 public function create(&$a_pg_obj, $a_hier_id, $a_pc_id = "")
147 {
148 //echo "-$a_pc_id-";
149 //echo "<br>-".htmlentities($a_pg_obj->getXMLFromDom())."-<br><br>"; mk();
150 $this->node = $this->dom->create_element("PageContent");
151
152 // this next line kicks out placeholders, if something is inserted
153 $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
154
155 $this->par_node = $this->dom->create_element("Paragraph");
156 $this->par_node = $this->node->append_child($this->par_node);
157 $this->par_node->set_attribute("Language", "");
158 }
159
166 public function setText($a_text, $a_auto_split = false)
167 {
168 if (!is_array($a_text)) {
169 $text = array(array("level" => 0, "text" => $a_text));
170 } else {
171 $text = $a_text;
172 }
173
174 if ($a_auto_split) {
175 $text = $this->autoSplit($a_text);
176 }
177
178 // DOMXML_LOAD_PARSING, DOMXML_LOAD_VALIDATING, DOMXML_LOAD_RECOVERING
179 $check = "";
180 foreach ($text as $t) {
181 $check .= "<Paragraph>" . $t["text"] . "</Paragraph>";
182 }
183 /*$temp_dom = domxml_open_mem('<?xml version="1.0" encoding="UTF-8"?><Paragraph>'.$text[0]["text"].'</Paragraph>',
184 DOMXML_LOAD_PARSING, $error);*/
185 $temp_dom = domxml_open_mem(
186 '<?xml version="1.0" encoding="UTF-8"?><Paragraph>' . $check . '</Paragraph>',
188 $error
189 );
190 //$this->text = $a_text;
191
192 // remove all childs
193 if (empty($error)) {
194 $temp_dom = domxml_open_mem(
195 '<?xml version="1.0" encoding="UTF-8"?><Paragraph>' . $text[0]["text"] . '</Paragraph>',
197 $error
198 );
199
200 // delete children of paragraph node
201 $children = $this->par_node->child_nodes();
202 for ($i = 0; $i < count($children); $i++) {
203 $this->par_node->remove_child($children[$i]);
204 }
205
206 // copy new content children in paragraph node
207 $xpc = xpath_new_context($temp_dom);
208 $path = "//Paragraph";
209 $res = xpath_eval($xpc, $path);
210 if (count($res->nodeset) == 1) {
211 $new_par_node = $res->nodeset[0];
212 $new_childs = $new_par_node->child_nodes();
213
214 for ($i = 0; $i < count($new_childs); $i++) {
215 $cloned_child = $new_childs[$i]->clone_node(true);
216 $this->par_node->append_child($cloned_child);
217 }
218 $orig_characteristic = $this->getCharacteristic();
219
220 // if headlines are entered and current characteristic is a headline
221 // use no characteristic as standard
222 if ((count($text) > 1) && (substr($orig_characteristic, 0, 8) == "Headline")) {
223 $orig_characteristic = "";
224 }
225 if ($text[0]["level"] > 0) {
226 $this->par_node->set_attribute("Characteristic", 'Headline' . $text[0]["level"]);
227 }
228 }
229
230 $ok = true;
231
232 $c_node = $this->node;
233 // add other chunks afterwards
234 for ($i = 1; $i < count($text); $i++) {
235 if ($ok) {
236 $next_par = new ilPCParagraph($this->getPage());
237 $next_par->createAfter($c_node);
238 $next_par->setLanguage($this->getLanguage());
239 if ($text[$i]["level"] > 0) {
240 $next_par->setCharacteristic("Headline" . $text[$i]["level"]);
241 } else {
242 $next_par->setCharacteristic($orig_characteristic);
243 }
244 $ok = $next_par->setText($text[$i]["text"], false);
245 $c_node = $next_par->node;
246 }
247 }
248
249 return true;
250 } else {
251 // We want the correct number of \n here to have the real lines numbers
252 $text = str_replace("<br>", "\n", $check); // replace <br> with \n to get correct line
253 $text = str_replace("<br/>", "\n", $text);
254 $text = str_replace("<br />", "\n", $text);
255 $text = str_replace("</SimpleListItem>", "</SimpleListItem>\n", $text);
256 $text = str_replace("<SimpleBulletList>", "\n<SimpleBulletList>", $text);
257 $text = str_replace("<SimpleNumberedList>", "\n<SimpleNumberedList>", $text);
258 $text = str_replace("<Paragraph>\n", "<Paragraph>", $text);
259 $text = str_replace("</Paragraph>", "</Paragraph>\n", $text);
260 include_once("./Services/Dom/classes/class.ilDomDocument.php");
261 $doc = new ilDOMDocument();
262 $text = '<?xml version="1.0" encoding="UTF-8"?><Paragraph>' . $text . '</Paragraph>';
263 //echo htmlentities($text);
264 $this->success = $doc->loadXML($text);
265 $error = $doc->errors;
266 $estr = "";
267 foreach ($error as $e) {
268 $e = str_replace(" in Entity", "", $e);
269 $estr .= $e . "<br />";
270 }
271 if (DEVMODE) {
272 $estr .= "<br />" . $text;
273 }
274
275 return $estr;
276 }
277 }
278
284 public function getText($a_short_mode = false)
285 {
286 if (is_object($this->par_node)) {
287 $content = "";
288 $childs = $this->par_node->child_nodes();
289 for ($i = 0; $i < count($childs); $i++) {
290 $content .= $this->dom->dump_node($childs[$i]);
291 }
292 return $content;
293 } else {
294 return "";
295 }
296 }
297
301 public function getParagraphSequenceContent($a_pg_obj)
302 {
303 $childs = $this->par_node->parent_node()->parent_node()->child_nodes();
304 $seq = array();
305 $cur_seq = array();
306 $found = false;
307 $pc_id = $this->readPCId();
308 $hier_id = $this->readHierId();
309 for ($i = 0; $i < count($childs); $i++) {
310 $pchilds = $childs[$i]->child_nodes();
311 if ($pchilds[0]->node_name() == "Paragraph" &&
312 $pchilds[0]->get_attribute("Characteristic") != "Code") {
313 $cur_seq[] = $childs[$i];
314
315 // check whether this is the sequence of the current paragraph
316 if ($childs[$i]->get_attribute("PCID") == $pc_id &&
317 $childs[$i]->get_attribute("HierId") == $hier_id) {
318 $found = true;
319 }
320
321 // if this is the current sequenc, get it
322 if ($found) {
323 $seq = $cur_seq;
324 }
325 } else {
326 // non-paragraph element found -> init the current sequence
327 $cur_seq = array();
328 $found = false;
329 }
330 }
331
332 $content = "";
333 $ids = "###";
334 $id_sep = "";
335 foreach ($seq as $p_node) {
336 $ids .= $id_sep . $p_node->get_attribute("HierId") . ":" . $p_node->get_attribute("PCID");
337 $po = $a_pg_obj->getContentObject(
338 $p_node->get_attribute("HierId"),
339 $p_node->get_attribute("PCID")
340 );
341 $s_text = $po->getText();
342 $s_text = $po->xml2output($s_text, true, false);
343 $char = $po->getCharacteristic();
344 if ($char == "") {
345 $char = "Standard";
346 }
347 $s_text = ilPCParagraphGUI::xml2outputJS($s_text, $char, $po->readPCId());
348 $content .= $s_text;
349 $id_sep = ";";
350 }
351 $ids .= "###";
352
353 return $ids . $content;
354 }
355
361 public function setCharacteristic($a_char)
362 {
363 if (!empty($a_char)) {
364 $this->par_node->set_attribute("Characteristic", $a_char);
365 } else {
366 if ($this->par_node->has_attribute("Characteristic")) {
367 $this->par_node->remove_attribute("Characteristic");
368 }
369 }
370 }
371
377 public function getCharacteristic()
378 {
379 if (is_object($this->par_node)) {
380 return $this->par_node->get_attribute("Characteristic");
381 }
382 }
383
384
388 public function setSubCharacteristic($a_char)
389 {
390 if (!empty($a_char)) {
391 $this->par_node->set_attribute("SubCharacteristic", $a_char);
392 } else {
393 if ($this->par_node->has_attribute("SubCharacteristic")) {
394 $this->par_node->remove_attribute("SubCharacteristic");
395 }
396 }
397 }
398
404 public function getAutoIndent()
405 {
406 return $this->par_node->get_attribute("AutoIndent");
407 }
408
409 public function setAutoIndent($a_char)
410 {
411 if (!empty($a_char)) {
412 $this->par_node->set_attribute("AutoIndent", $a_char);
413 } else {
414 if ($this->par_node->has_attribute("AutoIndent")) {
415 $this->par_node->remove_attribute("AutoIndent");
416 }
417 }
418 }
419
423 public function getSubCharacteristic()
424 {
425 return $this->par_node->get_attribute("SubCharacteristic");
426 }
427
432 public function setDownloadTitle($a_char)
433 {
434 if (!empty($a_char)) {
435 $this->par_node->set_attribute("DownloadTitle", $a_char);
436 } else {
437 if ($this->par_node->has_attribute("DownloadTitle")) {
438 $this->par_node->remove_attribute("DownloadTitle");
439 }
440 }
441 }
442
446 public function getDownloadTitle()
447 {
448 return $this->par_node->get_attribute("DownloadTitle");
449 }
450
455 public function setShowLineNumbers($a_char)
456 {
457 $a_char = empty($a_char)?"n":$a_char;
458
459 $this->par_node->set_attribute("ShowLineNumbers", $a_char);
460 }
461
466 public function getShowLineNumbers()
467 {
468 return $this->par_node->get_attribute("ShowLineNumbers");
469 }
470
474 public function setLanguage($a_lang)
475 {
476 $this->par_node->set_attribute("Language", $a_lang);
477 }
478
482 public function getLanguage()
483 {
484 return $this->par_node->get_attribute("Language");
485 }
486
487 public function input2xml($a_text, $a_wysiwyg = 0, $a_handle_lists = true)
488 {
489 return $this->_input2xml($a_text, $this->getLanguage(), $a_wysiwyg, $a_handle_lists);
490 }
491
500 protected static function replaceBBCode($a_text, $a_bb, $a_tag)
501 {
502 $a_text = preg_replace('/\[' . $a_bb . '\]/i', "<" . $a_tag . ">", $a_text);
503 $a_text = preg_replace('/\[\/' . $a_bb . '\]/i', "</" . $a_tag . ">", $a_text);
504 return $a_text;
505 }
506
507
511 public static function _input2xml($a_text, $a_lang, $a_wysiwyg = 0, $a_handle_lists = true)
512 {
513 if (!$a_wysiwyg) {
514 $a_text = ilUtil::stripSlashes($a_text, false);
515 }
516
517 if ($a_wysiwyg) {
518 $a_text = str_replace("<br />", chr(10), $a_text);
519 }
520
521 // note: the order of the processing steps is crucial
522 // and should be the same as in xml2output() in REVERSE order!
523 $a_text = trim($a_text);
524
525 //echo "<br>between:".htmlentities($a_text);
526
527 // mask html
528 if (!$a_wysiwyg) {
529 $a_text = str_replace("&", "&amp;", $a_text);
530 }
531 $a_text = str_replace("<", "&lt;", $a_text);
532 $a_text = str_replace(">", "&gt;", $a_text);
533
534 // Reconvert PageTurn and BibItemIdentifier
535 $a_text = preg_replace('/&lt;([\s\/]*?PageTurn.*?)&gt;/i', "<$1>", $a_text);
536 $a_text = preg_replace('/&lt;([\s\/]*?BibItemIdentifier.*?)&gt;/i', "<$1>", $a_text);
537
538 //echo "<br>second:".htmlentities($a_text);
539
540 // mask curly brackets
541 /*
542 echo htmlentities($a_text);
543 $a_text = str_replace("{", "&#123;", $a_text);
544 $a_text = str_replace("}", "&#125;", $a_text);
545 echo htmlentities($a_text);*/
546 // linefeed to br
547 $a_text = str_replace(chr(13) . chr(10), "<br />", $a_text);
548 $a_text = str_replace(chr(13), "<br />", $a_text);
549 $a_text = str_replace(chr(10), "<br />", $a_text);
550
551 if ($a_handle_lists) {
552 $a_text = ilPCParagraph::input2xmlReplaceLists($a_text);
553 }
554
555 foreach (self::getBBMap() as $bb => $tag) {
556 // remove empty tags
557 $a_text = str_replace("[" . $bb . "][/" . $bb . "]", "", $a_text);
558
559 // replace bb code by tag
560 $a_text = self::replaceBBCode($a_text, $bb, $tag);
561 }
562
563 $a_text = self::intLinks2xml($a_text);
564
565 // external link
566 $ws = "[ \t\r\f\v\n]*";
567 // remove empty external links
568 while (preg_match("~\[(xln$ws(url$ws=$ws\"([^\"])*\")$ws(target$ws=$ws(\"(Glossary|FAQ|Media)\"))?$ws)\]\[\/xln\]~i", $a_text, $found)) {
569 $a_text = str_replace($found[0], "", $a_text);
570 }
571 while (preg_match('~\[(xln$ws(url$ws=$ws(([^]])*)))$ws\]\[\/xln\]~i', $a_text, $found)) {
572 $a_text = str_replace($found[0], "", $a_text);
573 }
574 // external links
575 while (preg_match("~\[(xln$ws(url$ws=$ws\"([^\"])*\")$ws(target$ws=$ws(\"(Glossary|FAQ|Media)\"))?$ws)\]~i", $a_text, $found)) {
576 $attribs = ilUtil::attribsToArray($found[2]);
577 if (isset($attribs["url"])) {
578 $a2 = ilUtil::attribsToArray($found[4]);
579 $tstr = "";
580 if (in_array($a2["target"], array("FAQ", "Glossary", "Media"))) {
581 $tstr = ' TargetFrame="' . $a2["target"] . '"';
582 }
583 $a_text = str_replace("[" . $found[1] . "]", "<ExtLink Href=\"" . $attribs["url"] . "\"$tstr>", $a_text);
584 } else {
585 $a_text = str_replace("[" . $found[1] . "]", "[error: xln" . $found[1] . "]", $a_text);
586 }
587 }
588
589 // ie/tinymce fix for links without "", see bug #8391
590 while (preg_match('~\[(xln$ws(url$ws=$ws(([^]])*)))$ws\]~i', $a_text, $found)) {
591 if ($found[3] != "") {
592 $a_text = str_replace("[" . $found[1] . "]", "<ExtLink Href=\"" . $found[3] . "\">", $a_text);
593 } else {
594 $a_text = str_replace("[" . $found[1] . "]", "[error: xln" . $found[1] . "]", $a_text);
595 }
596 }
597 $a_text = preg_replace('~\[\/xln\]~i', "</ExtLink>", $a_text);
598
599 // anchor
600 $ws = "[ \t\r\f\v\n]*";
601 while (preg_match("~\[(anc$ws(name$ws=$ws\"([^\"])*\")$ws)\]~i", $a_text, $found)) {
602 $attribs = ilUtil::attribsToArray($found[2]);
603 $a_text = str_replace("[" . $found[1] . "]", "<Anchor Name=\"" . $attribs["name"] . "\">", $a_text);
604 }
605 $a_text = preg_replace("~\[\/anc\]~i", "</Anchor>", $a_text);
606
607 // marked text
608 while (preg_match("~\[(marked$ws(class$ws=$ws\"([^\"])*\")$ws)\]~i", $a_text, $found)) {
609 $attribs = ilUtil::attribsToArray($found[2]);
610 if (isset($attribs["class"])) {
611 $a_text = str_replace("[" . $found[1] . "]", "<Marked Class=\"" . $attribs["class"] . "\">", $a_text);
612 } else {
613 $a_text = str_replace("[" . $found[1] . "]", "[error:marked" . $found[1] . "]", $a_text);
614 }
615 }
616 $a_text = preg_replace('~\[\/marked\]~i', "</Marked>", $a_text);
617
618
619 //echo htmlentities($a_text); exit;
620 return $a_text;
621 }
622
629 public static function intLinks2xml($a_text)
630 {
631 global $DIC;
632
633 $objDefinition = $DIC["objDefinition"];
634
635 $rtypes = $objDefinition->getAllRepositoryTypes();
636
637 // internal links
638 //$any = "[^\]]*"; // this doesn't work :-(
639 $ws = "[ \t\r\f\v\n]*";
640 $ltypes = "page|chap|term|media|obj|dfile|sess|wpage|ppage|" . implode($rtypes, "|");
641 // empty internal links
642 while (preg_match('~\[(iln' . $ws . '((inst' . $ws . '=' . $ws . '([\"0-9])*)?' . $ws .
643 "((" . $ltypes . ")$ws=$ws([\"0-9])*)$ws" .
644 "(target$ws=$ws(\"(New|FAQ|Media)\"))?$ws(anchor$ws=$ws(\"([^\"])*\"))?$ws))\]\[\/iln\]~i", $a_text, $found)) {
645 $a_text = str_replace($found[0], "", $a_text);
646 }
647 while (preg_match('~\[(iln' . $ws . '((inst' . $ws . '=' . $ws . '([\"0-9])*)?' . $ws .
648 "((" . $ltypes . ")$ws=$ws([\"0-9])*)$ws" .
649 "(target$ws=$ws(\"(New|FAQ|Media)\"))?$ws(anchor$ws=$ws(\"([^\"])*\"))?$ws))\]~i", $a_text, $found)) {
650 $attribs = ilUtil::attribsToArray($found[2]);
651 $inst_str = $attribs["inst"];
652 // pages
653 if (isset($attribs["page"])) {
654 $tframestr = "";
655 if (!empty($found[10])) {
656 $tframestr = " TargetFrame=\"" . $found[10] . "\" ";
657 }
658 $ancstr = "";
659 if ($attribs["anchor"] != "") {
660 $ancstr = ' Anchor="' . $attribs["anchor"] . '" ';
661 }
662 // see 26066 for addcslashes
663 $a_text = preg_replace(
664 '/\[' . addcslashes($found[1], '/') . '\]/i',
665 "<IntLink Target=\"il_" . $inst_str . "_pg_" . $attribs['page'] . "\" Type=\"PageObject\"" . $tframestr . $ancstr . ">",
666 $a_text
667 );
668 }
669 // chapters
670 elseif (isset($attribs["chap"])) {
671 if (!empty($found[10])) {
672 $tframestr = " TargetFrame=\"" . $found[10] . "\" ";
673 } else {
674 $tframestr = "";
675 }
676 $a_text = preg_replace(
677 '/\[' . $found[1] . '\]/i',
678 "<IntLink Target=\"il_" . $inst_str . "_st_" . $attribs['chap'] . "\" Type=\"StructureObject\"" . $tframestr . ">",
679 $a_text
680 );
681 }
682 // glossary terms
683 elseif (isset($attribs["term"])) {
684 switch ($found[10]) {
685 case "New":
686 $tframestr = " TargetFrame=\"New\" ";
687 break;
688
689 default:
690 $tframestr = " TargetFrame=\"Glossary\" ";
691 break;
692 }
693 $a_text = preg_replace(
694 '/\[' . $found[1] . '\]/i',
695 "<IntLink Target=\"il_" . $inst_str . "_git_" . $attribs['term'] . "\" Type=\"GlossaryItem\" $tframestr>",
696 $a_text
697 );
698 }
699 // wiki pages
700 elseif (isset($attribs["wpage"])) {
701 $tframestr = "";
702 $a_text = preg_replace(
703 '/\[' . $found[1] . '\]/i',
704 "<IntLink Target=\"il_" . $inst_str . "_wpage_" . $attribs['wpage'] . "\" Type=\"WikiPage\" $tframestr>",
705 $a_text
706 );
707 }
708 // portfolio pages
709 elseif (isset($attribs["ppage"])) {
710 $tframestr = "";
711 $a_text = preg_replace(
712 '/\[' . $found[1] . '\]/i',
713 "<IntLink Target=\"il_" . $inst_str . "_ppage_" . $attribs['ppage'] . "\" Type=\"PortfolioPage\" $tframestr>",
714 $a_text
715 );
716 }
717 // media object
718 elseif (isset($attribs["media"])) {
719 if (!empty($found[10])) {
720 $tframestr = " TargetFrame=\"" . $found[10] . "\" ";
721 $a_text = preg_replace(
722 '/\[' . $found[1] . '\]/i',
723 "<IntLink Target=\"il_" . $inst_str . "_mob_" . $attribs['media'] . "\" Type=\"MediaObject\"" . $tframestr . ">",
724 $a_text
725 );
726 } else {
727 $a_text = preg_replace(
728 '/\[' . $found[1] . '\]/i',
729 "<IntLink Target=\"il_" . $inst_str . "_mob_" . $attribs['media'] . "\" Type=\"MediaObject\"/>",
730 $a_text
731 );
732 }
733 }
734 // direct download file (no repository object)
735 elseif (isset($attribs["dfile"])) {
736 $a_text = preg_replace(
737 '/\[' . $found[1] . '\]/i',
738 "<IntLink Target=\"il_" . $inst_str . "_dfile_" . $attribs['dfile'] . "\" Type=\"File\">",
739 $a_text
740 );
741 }
742 // repository items (id is ref_id (will be used internally but will
743 // be replaced by object id for export purposes)
744 else {
745 foreach ($objDefinition->getAllRepositoryTypes() as $t) {
746 if (isset($attribs[$t])) {
747 $obj_id = $attribs[$t];
748 }
749 }
750 if (isset($attribs["obj"])) {
751 $obj_id = $attribs["obj"];
752 }
753
754 if ($obj_id > 0) {
755 if ($inst_str == "") {
756 $a_text = preg_replace(
757 '/\[' . $found[1] . '\]/i',
758 "<IntLink Target=\"il_" . $inst_str . "_obj_" . $obj_id . "\" Type=\"RepositoryItem\">",
759 $a_text
760 );
761 } else {
762 $a_text = preg_replace(
763 '/\[' . $found[1] . '\]/i',
764 "<IntLink Target=\"il_" . $inst_str . "_" . $found[6] . "_" . $obj_id . "\" Type=\"RepositoryItem\">",
765 $a_text
766 );
767 }
768 } else {
769 $a_text = preg_replace('/\[' . $found[1] . '\]/i', "[error: iln" . $found[1] . "]", $a_text);
770 }
771 }
772 }
773
774 while (preg_match("~\[(iln$ws((inst$ws=$ws([\"0-9])*)?" . $ws . "media$ws=$ws([\"0-9])*)$ws)/\]~i", $a_text, $found)) {
775 $attribs = ilUtil::attribsToArray($found[2]);
776 $inst_str = $attribs["inst"];
777 $a_text = preg_replace(
778 '~\[' . $found[1] . '/\]~i',
779 "<IntLink Target=\"il_" . $inst_str . "_mob_" . $attribs['media'] . "\" Type=\"MediaObject\"/>",
780 $a_text
781 );
782 }
783
784 // user
785 while (preg_match("~\[(iln$ws((inst$ws=$ws([\"0-9])*)?" . $ws . "user$ws=$ws(\"([^\"])*)\")$ws)/\]~i", $a_text, $found)) {
786 $attribs = ilUtil::attribsToArray($found[2]);
787 $inst_str = $attribs["inst"];
788 include_once("./Services/User/classes/class.ilObjUser.php");
789 $user_id = ilObjUser::_lookupId($attribs['user']);
790 $a_text = preg_replace(
791 '~\[' . $found[1] . '/\]~i',
792 "<IntLink Target=\"il_" . $inst_str . "_user_" . $user_id . "\" Type=\"User\"/>",
793 $a_text
794 );
795 }
796
797 $a_text = preg_replace('~\[\/iln\]~i', "</IntLink>", $a_text);
798 return $a_text;
799 }
800
801
809 public static function input2xmlReplaceLists($a_text)
810 {
811 $rows = explode("<br />", $a_text . "<br />");
812 //var_dump($a_text);
813
814 $old_level = 0;
815
816 $text = "";
817
818 foreach ($rows as $row) {
819 $level = 0;
820 if (str_replace("#", "*", substr($row, 0, 3)) == "***") {
821 $level = 3;
822 } elseif (str_replace("#", "*", substr($row, 0, 2)) == "**") {
823 $level = 2;
824 } elseif (str_replace("#", "*", substr($row, 0, 1)) == "*") {
825 $level = 1;
826 }
827
828 // end previous line
829 if ($level < $old_level) {
830 for ($i = $old_level; $i > $level; $i--) {
831 $text .= "</SimpleListItem></" . $clist[$i] . ">";
832 }
833 if ($level > 0) {
834 $text .= "</SimpleListItem>";
835 }
836 } elseif ($old_level > 0 && $level > 0 && ($level == $old_level)) {
837 $text .= "</SimpleListItem>";
838 } elseif (($level == $old_level) && $text != "") {
839 $text .= "<br />";
840 }
841
842 // start next line
843 if ($level > $old_level) {
844 for ($i = $old_level + 1; $i <= $level; $i++) {
845 if (substr($row, $i - 1, 1) == "*") {
846 $clist[$i] = "SimpleBulletList";
847 } else {
848 $clist[$i] = "SimpleNumberedList";
849 }
850 $text .= "<" . $clist[$i] . "><SimpleListItem>";
851 }
852 } elseif ($old_level > 0 && $level > 0) {
853 $text .= "<SimpleListItem>";
854 }
855 $text .= substr($row, $level);
856
857 $old_level = $level;
858 }
859
860 // remove "<br />" at the end
861 if (substr($text, strlen($text) - 6) == "<br />") {
862 $text = substr($text, 0, strlen($text) - 6);
863 }
864
865 return $text;
866 }
867
875 public static function xml2outputReplaceLists($a_text)
876 {
877 $segments = ilPCParagraph::segmentString($a_text, array("<SimpleBulletList>", "</SimpleBulletList>",
878 "</SimpleListItem>", "<SimpleListItem>", "<SimpleListItem/>", "<SimpleNumberedList>", "</SimpleNumberedList>"));
879
880 $current_list = array();
881 $text = "";
882 for ($i = 0; $i <= count($segments); $i++) {
883 if ($segments[$i] == "<SimpleBulletList>") {
884 if (count($current_list) == 0) {
885 $list_start = true;
886 }
887 array_push($current_list, "*");
888 $li = false;
889 } elseif ($segments[$i] == "<SimpleNumberedList>") {
890 if (count($current_list) == 0) {
891 $list_start = true;
892 }
893 array_push($current_list, "#");
894 $li = false;
895 } elseif ($segments[$i] == "</SimpleBulletList>") {
896 array_pop($current_list);
897 $li = false;
898 } elseif ($segments[$i] == "</SimpleNumberedList>") {
899 array_pop($current_list);
900 $li = false;
901 } elseif ($segments[$i] == "<SimpleListItem>") {
902 $li = true;
903 } elseif ($segments[$i] == "</SimpleListItem>") {
904 $li = false;
905 } elseif ($segments[$i] == "<SimpleListItem/>") {
906 if ($list_start) {
907 $text .= "<br />";
908 $list_start = false;
909 }
910 foreach ($current_list as $list) {
911 $text .= $list;
912 }
913 $text .= "<br />";
914 $li = false;
915 } else {
916 if ($li) {
917 if ($list_start) {
918 $text .= "<br />";
919 $list_start = false;
920 }
921 foreach ($current_list as $list) {
922 $text .= $list;
923 }
924 }
925 $text .= $segments[$i];
926 if ($li) {
927 $text .= "<br />";
928 }
929 $li = false;
930 }
931 }
932
933 // remove trailing <br />, if text ends with list
934 if ($segments[count($segments) - 1] == "</SimpleBulletList>" ||
935 $segments[count($segments) - 1] == "</SimpleNumberedList>" &&
936 substr($text, strlen($text) - 6) == "<br />") {
937 $text = substr($text, 0, strlen($text) - 6);
938 }
939
940 return $text;
941 }
942
946 public static function segmentString($a_haystack, $a_needles)
947 {
948 $segments = array();
949
950 $nothing_found = false;
951 while (!$nothing_found) {
952 $nothing_found = true;
953 $found = -1;
954 foreach ($a_needles as $needle) {
955 $pos = stripos($a_haystack, $needle);
956 if (is_int($pos) && ($pos < $found || $found == -1)) {
957 $found = $pos;
958 $found_needle = $needle;
959 $nothing_found = false;
960 }
961 }
962 if ($found > 0) {
963 $segments[] = substr($a_haystack, 0, $found);
964 $a_haystack = substr($a_haystack, $found);
965 }
966 if ($found > -1) {
967 $segments[] = substr($a_haystack, 0, strlen($found_needle));
968 $a_haystack = substr($a_haystack, strlen($found_needle));
969 }
970 }
971 if ($a_haystack != "") {
972 $segments[] = $a_haystack;
973 }
974
975 return $segments;
976 }
977
985 public static function xml2output($a_text, $a_wysiwyg = false, $a_replace_lists = true, $unmask = true)
986 {
987 // note: the order of the processing steps is crucial
988 // and should be the same as in input2xml() in REVERSE order!
989
990 // xml to bb code
991 $any = "[^>]*";
992
993 foreach (self::getBBMap() as $bb => $tag) {
994 $a_text = preg_replace('~<' . $tag . '[^>]*>~i', "[" . $bb . "]", $a_text);
995 $a_text = preg_replace('~</' . $tag . '>~i', "[/" . $bb . "]", $a_text);
996 $a_text = preg_replace('~<' . $tag . '/>~i', "[" . $bb . "][/" . $bb . "]", $a_text);
997 }
998
999 // replace lists
1000 if ($a_replace_lists) {
1001 //echo "<br>".htmlentities($a_text);
1002 $a_text = ilPCParagraph::xml2outputReplaceLists($a_text);
1003 //echo "<br>".htmlentities($a_text);
1004 }
1005
1006 // internal links
1007 while (preg_match('~<IntLink(' . $any . ')>~i', $a_text, $found)) {
1008 $found[0];
1009 $attribs = ilUtil::attribsToArray($found[1]);
1010 $target = explode("_", $attribs["Target"]);
1011 $target_id = $target[count($target) - 1];
1012 $inst_str = (!is_int(strpos($attribs["Target"], "__")))
1013 ? $inst_str = "inst=\"" . $target[1] . "\" "
1014 : $inst_str = "";
1015 switch ($attribs["Type"]) {
1016 case "PageObject":
1017 $tframestr = (!empty($attribs["TargetFrame"]))
1018 ? " target=\"" . $attribs["TargetFrame"] . "\""
1019 : "";
1020 $ancstr = (!empty($attribs["Anchor"]))
1021 ? ' anchor="' . $attribs["Anchor"] . '"'
1022 : "";
1023 $a_text = preg_replace('~<IntLink' . $found[1] . '>~i', "[iln " . $inst_str . "page=\"" . $target_id . "\"$tframestr$ancstr]", $a_text);
1024 break;
1025
1026 case "StructureObject":
1027 $tframestr = (!empty($attribs["TargetFrame"]))
1028 ? " target=\"" . $attribs["TargetFrame"] . "\""
1029 : "";
1030 $a_text = preg_replace('~<IntLink' . $found[1] . '>~i', "[iln " . $inst_str . "chap=\"" . $target_id . "\"$tframestr]", $a_text);
1031 break;
1032
1033 case "GlossaryItem":
1034 $tframestr = (empty($attribs["TargetFrame"]) || $attribs["TargetFrame"] == "Glossary")
1035 ? ""
1036 : " target=\"" . $attribs["TargetFrame"] . "\"";
1037 $a_text = preg_replace('~<IntLink' . $found[1] . '>~i', "[iln " . $inst_str . "term=\"" . $target_id . "\"" . $tframestr . "]", $a_text);
1038 break;
1039
1040 case "WikiPage":
1041 $tframestr = "";
1042 $a_text = preg_replace('~<IntLink' . $found[1] . '>~i', "[iln " . $inst_str . "wpage=\"" . $target_id . "\"" . $tframestr . "]", $a_text);
1043 break;
1044
1045 case "PortfolioPage":
1046 $tframestr = "";
1047 $a_text = preg_replace('~<IntLink' . $found[1] . '>~i', "[iln " . $inst_str . "ppage=\"" . $target_id . "\"" . $tframestr . "]", $a_text);
1048 break;
1049
1050 case "MediaObject":
1051 if (empty($attribs["TargetFrame"])) {
1052 $a_text = preg_replace('~<IntLink' . $found[1] . '>~i', "[iln " . $inst_str . "media=\"" . $target_id . "\"/]", $a_text);
1053 } else {
1054 $a_text = preg_replace('~<IntLink' . $found[1] . '>~i', "[iln media=\"" . $target_id . "\"" .
1055 " target=\"" . $attribs["TargetFrame"] . "\"]", $a_text);
1056 }
1057 break;
1058
1059 // Repository Item (using ref id)
1060 case "RepositoryItem":
1061 if ($inst_str == "") {
1063 } else {
1064 $rtype = $target[count($target) - 2];
1065 $target_type = $rtype;
1066 }
1067 $a_text = preg_replace('~<IntLink' . $found[1] . '>~i', "[iln " . $inst_str . "$target_type=\"" . $target_id . "\"" . $tframestr . "]", $a_text);
1068 break;
1069
1070 // Download File (not in repository, Object ID)
1071 case "File":
1072 $a_text = preg_replace('~<IntLink' . $found[1] . '>~i', "[iln " . $inst_str . "dfile=\"" . $target_id . "\"" . $tframestr . "]", $a_text);
1073 break;
1074
1075 // User
1076 case "User":
1077 include_once("./Services/User/classes/class.ilObjUser.php");
1078 $a_text = preg_replace('~<IntLink' . $found[1] . '>~i', "[iln " . $inst_str . "user=\"" . ilObjUser::_lookupLogin($target_id) . "\"/]", $a_text);
1079 break;
1080
1081 default:
1082 $a_text = preg_replace('~<IntLink' . $found[1] . '>~i', "[iln]", $a_text);
1083 break;
1084 }
1085 }
1086 $a_text = str_replace("</IntLink>", "[/iln]", $a_text);
1087
1088 // external links
1089 while (preg_match('~<ExtLink(' . $any . ')>~i', $a_text, $found)) {
1090 $found[0];
1091 $attribs = ilUtil::attribsToArray($found[1]);
1092 //$found[1] = str_replace("?", "\?", $found[1]);
1093 $tstr = "";
1094 if (in_array($attribs["TargetFrame"], array("FAQ", "Glossary", "Media"))) {
1095 $tstr = ' target="' . $attribs["TargetFrame"] . '"';
1096 }
1097 $a_text = str_replace("<ExtLink" . $found[1] . ">", "[xln url=\"" . $attribs["Href"] . "\"$tstr]", $a_text);
1098 }
1099 $a_text = str_replace("</ExtLink>", "[/xln]", $a_text);
1100
1101 // anchor
1102 while (preg_match('~<Anchor(' . $any . '/)>~i', $a_text, $found)) {
1103 $found[0];
1104 $attribs = ilUtil::attribsToArray($found[1]);
1105 $a_text = str_replace("<Anchor" . $found[1] . ">", "[anc name=\"" . $attribs["Name"] . "\"][/anc]", $a_text);
1106 }
1107 while (preg_match('~<Anchor(' . $any . ')>~i', $a_text, $found)) {
1108 $found[0];
1109 $attribs = ilUtil::attribsToArray($found[1]);
1110 $a_text = str_replace("<Anchor" . $found[1] . ">", "[anc name=\"" . $attribs["Name"] . "\"]", $a_text);
1111 }
1112 $a_text = str_replace("</Anchor>", "[/anc]", $a_text);
1113
1114 // marked text
1115 while (preg_match('~<Marked(' . $any . ')>~i', $a_text, $found)) {
1116 $found[0];
1117 $attribs = ilUtil::attribsToArray($found[1]);
1118 $a_text = str_replace("<Marked" . $found[1] . ">", "[marked class=\"" . $attribs["Class"] . "\"]", $a_text);
1119 }
1120 $a_text = str_replace("</Marked>", "[/marked]", $a_text);
1121
1122 // br to linefeed
1123 if (!$a_wysiwyg) {
1124 $a_text = str_replace("<br />", "\n", $a_text);
1125 $a_text = str_replace("<br/>", "\n", $a_text);
1126 }
1127
1128 if (!$a_wysiwyg) {
1129 // prevent curly brackets from being swallowed up by template engine
1130 $a_text = str_replace("{", "&#123;", $a_text);
1131 $a_text = str_replace("}", "&#125;", $a_text);
1132
1133 // unmask html
1134 if ($unmask) {
1135 $a_text = str_replace("&lt;", "<", $a_text);
1136 $a_text = str_replace("&gt;", ">", $a_text);
1137 }
1138
1139 // this is needed to allow html like <tag attribute="value">... in paragraphs
1140 $a_text = str_replace("&quot;", "\"", $a_text);
1141
1142 // make ampersands in (enabled) html attributes work
1143 // e.g. <a href="foo.php?n=4&t=5">hhh</a>
1144 $a_text = str_replace("&amp;", "&", $a_text);
1145
1146 // make &gt; and $lt; work to allow (disabled) html descriptions
1147 if ($unmask) {
1148 $a_text = str_replace("&lt;", "&amp;lt;", $a_text);
1149 $a_text = str_replace("&gt;", "&amp;gt;", $a_text);
1150 }
1151 }
1152 return $a_text;
1153 //return str_replace("<br />", chr(13).chr(10), $a_text);
1154 }
1155
1162 public function autoSplit($a_text)
1163 {
1164 $a_text = str_replace("=<SimpleBulletList>", "=<br /><SimpleBulletList>", $a_text);
1165 $a_text = str_replace("=<SimpleNumberedList>", "=<br /><SimpleNumberedList>", $a_text);
1166 $a_text = str_replace("</SimpleBulletList>=", "</SimpleBulletList><br />=", $a_text);
1167 $a_text = str_replace("</SimpleNumberedList>=", "</SimpleNumberedList><br />=", $a_text);
1168 $a_text = "<br />" . $a_text . "<br />"; // add preceding and trailing br
1169
1170 $chunks = array();
1171 $c_text = $a_text;
1172 //echo "0";
1173 while ($c_text != "") {
1174 //var_dump($c_text); flush();
1175 //echo "1";
1176 $s1 = strpos($c_text, "<br />=");
1177 if (is_int($s1)) {
1178 //echo "2";
1179 $s2 = strpos($c_text, "<br />==");
1180 if (is_int($s2) && $s2 <= $s1) {
1181 //echo "3";
1182 $s3 = strpos($c_text, "<br />===");
1183 if (is_int($s3) && $s3 <= $s2) { // possible level three header
1184 //echo "4";
1185 $n = strpos($c_text, "<br />", $s3 + 1);
1186 if ($n > ($s3 + 9) && substr($c_text, $n - 3, 9) == "===<br />") {
1187 //echo "5";
1188 // found level three header
1189 if ($s3 > 0 || $head != "") {
1190 //echo "6";
1191 $chunks[] = array("level" => 0,
1192 "text" => $this->removeTrailingBr($head . substr($c_text, 0, $s3)));
1193 $head = "";
1194 }
1195 $chunks[] = array("level" => 3,
1196 "text" => trim(substr($c_text, $s3 + 9, $n - $s3 - 12)));
1197 $c_text = $this->handleNextBr(substr($c_text, $n + 6));
1198 } else {
1199 //echo "7";
1200 $head .= substr($c_text, 0, $n);
1201 $c_text = substr($c_text, $n);
1202 }
1203 } else { // possible level two header
1204 //echo "8";
1205 $n = strpos($c_text, "<br />", $s2 + 1);
1206 if ($n > ($s2 + 8) && substr($c_text, $n - 2, 8) == "==<br />") {
1207 //echo "9";
1208 // found level two header
1209 if ($s2 > 0 || $head != "") {
1210 //echo "A";
1211 $chunks[] = array("level" => 0,
1212 "text" => $this->removeTrailingBr($head . substr($c_text, 0, $s2)));
1213 $head = "";
1214 }
1215 $chunks[] = array("level" => 2, "text" => trim(substr($c_text, $s2 + 8, $n - $s2 - 10)));
1216 $c_text = $this->handleNextBr(substr($c_text, $n + 6));
1217 } else {
1218 //echo "B";
1219 $head .= substr($c_text, 0, $n);
1220 $c_text = substr($c_text, $n);
1221 }
1222 }
1223 } else { // possible level one header
1224 //echo "C";
1225 $n = strpos($c_text, "<br />", $s1 + 1);
1226 if ($n > ($s1 + 7) && substr($c_text, $n - 1, 7) == "=<br />") {
1227 //echo "D";
1228 // found level one header
1229 if ($s1 > 0 || $head != "") {
1230 //echo "E";
1231 $chunks[] = array("level" => 0,
1232 "text" => $this->removeTrailingBr($head . substr($c_text, 0, $s1)));
1233 $head = "";
1234 }
1235 $chunks[] = array("level" => 1, "text" => trim(substr($c_text, $s1 + 7, $n - $s1 - 8)));
1236 $c_text = $this->handleNextBr(substr($c_text, $n + 6));
1237 //echo "<br>ctext:".htmlentities($c_text)."<br>";
1238 } else {
1239 $head .= substr($c_text, 0, $n);
1240 $c_text = substr($c_text, $n);
1241 //echo "<br>head:".$head."c_text:".$c_text."<br>";
1242 }
1243 }
1244 } else {
1245 //echo "G";
1246 $chunks[] = array("level" => 0, "text" => $head . $c_text);
1247 $head = "";
1248 $c_text = "";
1249 }
1250 }
1251 if (count($chunks) == 0) {
1252 $chunks[] = array("level" => 0, "text" => "");
1253 }
1254
1255
1256 // remove preceding br
1257 if (substr($chunks[0]["text"], 0, 6) == "<br />") {
1258 $chunks[0]["text"] = substr($chunks[0]["text"], 6);
1259 }
1260
1261 // remove trailing br
1262 if (substr(
1263 $chunks[count($chunks) - 1]["text"],
1264 strlen($chunks[count($chunks) - 1]["text"]) - 6,
1265 6
1266 ) == "<br />") {
1267 $chunks[count($chunks) - 1]["text"] =
1268 substr($chunks[count($chunks) - 1]["text"], 0, strlen($chunks[count($chunks) - 1]["text"]) - 6);
1269 if ($chunks[count($chunks) - 1]["text"] == "") {
1270 unset($chunks[count($chunks) - 1]);
1271 }
1272 }
1273 return $chunks;
1274 }
1275
1279 public function handleNextBr($a_str)
1280 {
1281 // do not remove, if next line starts with a "=", otherwise two
1282 // headlines in a row will not be recognized
1283 if (substr($a_str, 0, 6) == "<br />" && substr($a_str, 6, 1) != "=") {
1284 $a_str = substr($a_str, 6);
1285 } else {
1286 // if next line starts with a "=" we need to reinsert the <br />
1287 // otherwise it will not be recognized
1288 if (substr($a_str, 0, 1) == "=") {
1289 $a_str = "<br />" . $a_str;
1290 }
1291 }
1292 return $a_str;
1293 }
1294
1298 public function removeTrailingBr($a_str)
1299 {
1300 if (substr($a_str, strlen($a_str) - 6) == "<br />") {
1301 $a_str = substr($a_str, 0, strlen($a_str) - 6);
1302 }
1303 return $a_str;
1304 }
1305
1309 public function getType()
1310 {
1311 return ($this->getCharacteristic() == "Code")?"src":parent::getType();
1312 }
1313
1317
1324 public function saveJS($a_pg_obj, $a_content, $a_char, $a_pc_id, $a_insert_at = "")
1325 {
1327
1328 $this->log->debug("step 1: " . substr($a_content, 0, 1000));
1330 $this->log->debug("step 2: " . substr($t["text"], 0, 1000));
1331 if ($t === false) {
1332 return false;
1333 }
1334
1335 $pc_id = explode(":", $a_pc_id);
1336 $insert_at = explode(":", $a_insert_at);
1337 $t_id = explode(":", $t["id"]);
1338
1339 // insert new paragraph
1340 if ($a_insert_at != "") {
1341 $par = new ilPCParagraph($this->getPage());
1342 $par->create($a_pg_obj, $insert_at[0], $insert_at[1]);
1343 } else {
1344 $par = $a_pg_obj->getContentObject($pc_id[0], $pc_id[1]);
1345 }
1346
1347 if ($a_insert_at != "") {
1348 $pc_id = $a_pg_obj->generatePCId();
1349 $par->writePCId($pc_id);
1350 $this->inserted_pc_id = $pc_id;
1351 } else {
1352 $this->inserted_pc_id = $pc_id[1];
1353 }
1354
1355 $par->setLanguage($ilUser->getLanguage());
1356 $par->setCharacteristic($t["class"]);
1357
1358 $t2 = $par->input2xml($t["text"], true, false);
1359 $this->log->debug("step 3: " . substr($t2, 0, 1000));
1360
1362 $this->log->debug("step 4: " . substr($t2, 0, 1000));
1363
1364 $updated = $par->setText($t2, true);
1365
1366 if ($updated !== true) {
1367 echo $updated;
1368 exit;
1369 return false;
1370 }
1371 $updated = $par->updatePage($a_pg_obj);
1372 //$updated = $a_pg_obj->update();
1373 return $updated;
1374 }
1375
1382 public function getLastSavedPCId($a_pg_obj, $a_as_ajax_str = false)
1383 {
1384 if ($a_as_ajax_str) {
1385 $a_pg_obj->stripHierIDs();
1386 $a_pg_obj->addHierIds();
1387 $ids = "###";
1388 //var_dump($this->inserted_pc_ids);
1389 $combined = $a_pg_obj->getHierIdsForPCIds(
1390 array($this->inserted_pc_id)
1391 );
1392 foreach ($combined as $pc_id => $hier_id) {
1393 //echo "1";
1394 $ids .= $sep . $hier_id . ":" . $pc_id;
1395 $sep = ";";
1396 }
1397 $ids .= "###";
1398 return $ids;
1399 }
1400
1401 return $this->inserted_pc_id;
1402 }
1403
1404
1408 public static function handleAjaxContent($a_content)
1409 {
1410 $a_content = "<dummy>" . $a_content . "</dummy>";
1411
1412 $doc = new DOMDocument();
1413
1414 $content = ilUtil::stripSlashes($a_content, false);
1415
1416 // $content = str_replace("&lt;", "<", $content);
1417 // $content = str_replace("&gt;", ">", $content);
1418 //echo "<br><br>".htmlentities($content); mk();
1419 $res = $doc->loadXML($content);
1420
1421 if (!$res) {
1422 return false;
1423 }
1424
1425 // convert tags
1426 $xpath = new DOMXpath($doc);
1427
1429
1430 $elements = $xpath->query("//span");
1431 include_once("./Services/Utilities/classes/class.ilDOM2Util.php");
1432 while (!is_null($elements) && !is_null($element = $elements->item(0))) {
1433 //$element = $elements->item(0);
1434 $class = $element->getAttribute("class");
1435 if (substr($class, 0, 16) == "ilc_text_inline_") {
1436 $class_arr = explode(" ", $class);
1437 $tag = substr($class_arr[0], 16);
1438 if (isset($tags[$tag])) { // known tag like strong
1439 $cnode = ilDOM2Util::changeName($element, "il" . substr($class_arr[0], 16), false);
1440 } else { // unknown tag -> marked text
1441 $cnode = ilDOM2Util::changeName($element, "ilMarked", false);
1442 $cnode->setAttribute("Class", substr($class_arr[0], 16));
1443 }
1444 for ($i = 1; $i < count($class_arr); $i++) {
1445 $tag = substr($class_arr[$i], 16);
1446 if (isset($tags[$tag])) { // known tag like strong
1447 $cnode = ilDOM2Util::addParent($cnode, "il" . substr($class_arr[$i], 16));
1448 } else { // unknown tag -> marked element
1449 $cnode = ilDOM2Util::addParent($cnode, "ilMarked");
1450 $cnode->setAttribute("Class", substr($class_arr[$i], 16));
1451 }
1452 }
1453 } else {
1455 }
1456
1457 $elements = $xpath->query("//span");
1458 }
1459
1460 // convert tags
1461 $xpath = new DOMXpath($doc);
1462 $elements = $xpath->query("/dummy/div");
1463
1464 $ret = array();
1465 if (!is_null($elements)) {
1466 foreach ($elements as $element) {
1467 $id = $element->getAttribute("id");
1468 $class = $element->getAttribute("class");
1469 $class = substr($class, 15);
1470 if (trim($class) == "") {
1471 $class = "Standard";
1472 }
1473
1474 $text = $doc->saveXML($element);
1475 $text = str_replace("<br/>", "\n", $text);
1476
1477 // remove wrapping div
1478 $pos = strpos($text, ">");
1479 $text = substr($text, $pos + 1);
1480 $pos = strrpos($text, "<");
1481 $text = substr($text, 0, $pos);
1482
1483 // todo: remove empty spans <span ...> </span>
1484
1485 // replace tags by bbcode
1486 foreach (ilPageContentGUI::_getCommonBBButtons() as $bb => $cl) {
1487 if (!in_array($bb, array("code", "tex", "fn", "xln"))) {
1488 $text = str_replace(
1489 "<il" . $cl . ">",
1490 "[" . $bb . "]",
1491 $text
1492 );
1493 $text = str_replace(
1494 "</il" . $cl . ">",
1495 "[/" . $bb . "]",
1496 $text
1497 );
1498 $text = str_replace("<il" . $cl . "/>", "", $text);
1499 }
1500 }
1501 $text = str_replace(
1502 array("<code>", "</code>"),
1503 array("[code]", "[/code]"),
1504 $text
1505 );
1506 $text = str_replace(
1507 array('<sup class="ilc_sup_Sup">', "</sup>"),
1508 array("[sup]", "[/sup]"),
1509 $text
1510 );
1511 $text = str_replace(
1512 array('<sub class="ilc_sub_Sub">', "</sub>"),
1513 array("[sub]", "[/sub]"),
1514 $text
1515 );
1516
1517 $text = str_replace("<code/>", "", $text);
1518 $text = str_replace('<ul class="ilc_list_u_BulletedList"/>', "", $text);
1519 $text = str_replace('<ul class="ilc_list_o_NumberedList"/>', "", $text);
1520
1521 // replace marked text
1522 // external links
1523 $any = "[^>]*";
1524 while (preg_match('~<ilMarked(' . $any . ')>~i', $text, $found)) {
1525 $found[0];
1526 $attribs = ilUtil::attribsToArray($found[1]);
1527 $text = str_replace("<ilMarked" . $found[1] . ">", "[marked class=\"" . $attribs["Class"] . "\"]", $text);
1528 }
1529 $text = str_replace("</ilMarked>", "[/marked]", $text);
1530
1531
1532 $ret[] = array("text" => $text, "id" => $id, "class" => $class);
1533 }
1534 }
1535
1536 // we should only have one here!
1537 return $ret[0];
1538 }
1539
1543 public static function handleAjaxContentPost($text)
1544 {
1545 $text = str_replace(
1546 array("&lt;ul&gt;", "&lt;/ul&gt;"),
1547 array("<SimpleBulletList>", "</SimpleBulletList>"),
1548 $text
1549 );
1550 $text = str_replace(
1551 array("&lt;ul class='ilc_list_u_BulletedList'&gt;", "&lt;/ul&gt;"),
1552 array("<SimpleBulletList>", "</SimpleBulletList>"),
1553 $text
1554 );
1555 $text = str_replace(
1556 array("&lt;ul class=\"ilc_list_u_BulletedList\"&gt;", "&lt;/ul&gt;"),
1557 array("<SimpleBulletList>", "</SimpleBulletList>"),
1558 $text
1559 );
1560 $text = str_replace(
1561 array("&lt;ol&gt;", "&lt;/ol&gt;"),
1562 array("<SimpleNumberedList>", "</SimpleNumberedList>"),
1563 $text
1564 );
1565 $text = str_replace(
1566 array("&lt;ol class='ilc_list_o_NumberedList'&gt;", "&lt;/ol&gt;"),
1567 array("<SimpleNumberedList>", "</SimpleNumberedList>"),
1568 $text
1569 );
1570 $text = str_replace(
1571 array("&lt;ol class=\"ilc_list_o_NumberedList\"&gt;", "&lt;/ol&gt;"),
1572 array("<SimpleNumberedList>", "</SimpleNumberedList>"),
1573 $text
1574 );
1575 $text = str_replace(
1576 array("&lt;li&gt;", "&lt;/li&gt;"),
1577 array("<SimpleListItem>", "</SimpleListItem>"),
1578 $text
1579 );
1580 $text = str_replace(
1581 array("&lt;li class='ilc_list_item_StandardListItem'&gt;", "&lt;/li&gt;"),
1582 array("<SimpleListItem>", "</SimpleListItem>"),
1583 $text
1584 );
1585 $text = str_replace(
1586 array("&lt;li class=\"ilc_list_item_StandardListItem\"&gt;", "&lt;/li&gt;"),
1587 array("<SimpleListItem>", "</SimpleListItem>"),
1588 $text
1589 );
1590
1591 $text = str_replace(
1592 array("&lt;li class=\"ilc_list_item_StandardListItem\"/&gt;"),
1593 array("<SimpleListItem></SimpleListItem>"),
1594 $text
1595 );
1596
1597 $text = str_replace("<SimpleBulletList><br />", "<SimpleBulletList>", $text);
1598 $text = str_replace("<SimpleNumberedList><br />", "<SimpleNumberedList>", $text);
1599 $text = str_replace("<br /><SimpleBulletList>", "<SimpleBulletList>", $text);
1600 $text = str_replace("<br /><SimpleNumberedList>", "<SimpleNumberedList>", $text);
1601 $text = str_replace("</SimpleBulletList><br />", "</SimpleBulletList>", $text);
1602 $text = str_replace("</SimpleNumberedList><br />", "</SimpleNumberedList>", $text);
1603 $text = str_replace("</SimpleListItem><br />", "</SimpleListItem>", $text);
1604
1605 return $text;
1606 }
1607
1615 public function updatePage($a_page)
1616 {
1617 $a_page->beforePageContentUpdate($this);
1618
1619 $ret = $a_page->update();
1620 return $ret;
1621 }
1622
1629 public function autoLinkGlossaries($a_glos)
1630 {
1631 if (is_array($a_glos) && count($a_glos) > 0) {
1632 include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
1633
1634 // check which terms occur in the text (we may
1635 // get some false positives due to the strip_tags, but
1636 // we do not want to find strong or list or other stuff
1637 // within the tags
1638 $text = strip_tags($this->getText());
1639 $found_terms = array();
1640 foreach ($a_glos as $glo) {
1641 if (ilObject::_lookupType($glo) == "glo") {
1642 $ref_ids = ilObject::_getAllReferences($glo);
1643 $glo_ref_id = current($ref_ids);
1644 if ($glo_ref_id > 0) {
1645 $terms = ilGlossaryTerm::getTermList($glo_ref_id);
1646 foreach ($terms as $t) {
1647 if (is_int(stripos($text, $t["term"]))) {
1648 $found_terms[$t["id"]] = $t;
1649 }
1650 }
1651 }
1652 }
1653 }
1654
1655 // did we find anything? -> modify content
1656 if (count($found_terms) > 0) {
1657 self::linkTermsInDom($this->dom, $found_terms, $this->par_node);
1658 }
1659 }
1660 }
1661
1668 protected static function linkTermsInDom($a_dom, $a_terms, $a_par_node = null)
1669 {
1670 // sort terms by their length (shortes first)
1671 // to prevent that nested tags are builded
1672 foreach ($a_terms as $k => $t) {
1673 $a_terms[$k]["termlength"] = strlen($t["term"]);
1674 }
1675 $a_terms = ilUtil::sortArray($a_terms, "termlength", "asc", true);
1676
1677
1678 if ($a_dom instanceof php4DOMDocument) {
1679 $a_dom = $a_dom->myDOMDocument;
1680 }
1681 if ($a_par_node instanceof php4DOMElement) {
1682 $a_par_node = $a_par_node->myDOMNode;
1683 }
1684
1685 $xpath = new DOMXPath($a_dom);
1686
1687 if ($a_par_node == null) {
1688 $parnodes = $xpath->query("//Paragraph[@Characteristic != 'Code']");
1689 } else {
1690 $parnodes = $xpath->query(".//Paragraph[@Characteristic != 'Code']", $a_par_node->parentNode);
1691 }
1692
1693 include_once("./Services/Utilities/classes/class.ilStr.php");
1694
1695 foreach ($parnodes as $parnode) {
1696 $textnodes = $xpath->query('.//text()', $parnode);
1697 foreach ($textnodes as $node) {
1698 $p = $node->getNodePath();
1699
1700 // we do not change text nodes inside of links
1701 if (!is_int(strpos($p, "/IntLink")) &&
1702 !is_int(strpos($p, "/ExtLink"))) {
1703 $node_val = $node->nodeValue;
1704
1705 // all terms
1706 foreach ($a_terms as $t) {
1707 $pos = ilStr::strIPos($node_val, $t["term"]);
1708
1709 // if term found
1710 while (is_int($pos)) {
1711 // check if we are in a tex tag, see #22261
1712 $tex_bpos = ilStr::strrPos(ilStr::subStr($node_val, 0, $pos), "[tex]");
1713 $tex_epos = ilStr::strPos($node_val, "[/tex]", $tex_bpos);
1714 if ($tex_bpos > 0 && $tex_epos > 0 && $tex_bpos < $pos && $tex_epos > $pos) {
1715 $pos += ilStr::strLen($t["term"]);
1716 } else {
1717
1718 // check if the string is not included in another word
1719 // note that []
1720 $valid_limiters = array("", " ", "&nbsp;", ".", ",", ":", ";", "!", "?", "\"", "'", "(", ")");
1721 $b = ($pos > 0)
1722 ? ilStr::subStr($node_val, $pos - 1, 1)
1723 : "";
1724 $a = ilStr::subStr($node_val, $pos + ilStr::strLen($t["term"]), 1);
1725 if ((in_array($b, $valid_limiters) || htmlentities($b, null, 'utf-8') == "&nbsp;") && in_array($a, $valid_limiters)) {
1726 $mid = '[iln term="' . $t["id"] . '"]' .
1727 ilStr::subStr($node_val, $pos, ilStr::strLen($t["term"])) .
1728 "[/iln]";
1729
1730 $node_val = ilStr::subStr($node_val, 0, $pos) .
1731 $mid .
1732 ilStr::subStr($node_val, $pos + ilStr::strLen($t["term"]));
1733
1734 $pos += ilStr::strLen($mid);
1735 } else {
1736 $pos += ilStr::strLen($t["term"]);
1737 }
1738 }
1739 $pos = ilStr::strIPos($node_val, $t["term"], $pos);
1740 }
1741
1742 // insert [iln] tags
1743 }
1744
1745 $node->nodeValue = $node_val;
1746 }
1747
1748 // var_dump($p);
1749// var_dump($node->nodeValue);
1750 }
1751
1752
1753 // dump paragraph node
1754 $text = $a_dom->saveXML($parnode);
1755 $text = substr($text, 0, strlen($text) - strlen("</Paragraph>"));
1756 $text = substr($text, strpos($text, ">") + 1);
1757
1758 // replace [iln] by tags with xml representation
1760
1761 // "set text"
1762 $temp_dom = domxml_open_mem(
1763 '<?xml version="1.0" encoding="UTF-8"?><Paragraph>' . $text . '</Paragraph>',
1765 $error
1766 );
1767 $temp_dom = $temp_dom->myDOMDocument;
1768
1769 if (empty($error)) {
1770 // delete children of paragraph node
1771 $children = $parnode->childNodes;
1772 while ($parnode->hasChildNodes()) {
1773 $parnode->removeChild($parnode->firstChild);
1774 }
1775
1776 // copy new content children in paragraph node
1777 $xpath_temp = new DOMXPath($temp_dom);
1778 $temp_pars = $xpath_temp->query("//Paragraph");
1779
1780 foreach ($temp_pars as $new_par_node) {
1781 $new_childs = $new_par_node->childNodes;
1782
1783 foreach ($new_childs as $new_child) {
1784 //$cloned_child = $new_child->cloneNode(true);
1785 $cloned_child = $a_dom->importNode($new_child, true);
1786 $parnode->appendChild($cloned_child);
1787 }
1788 }
1789 }
1790 }
1791 // exit;
1792 }
1793
1794
1801 public static function autoLinkGlossariesPage($a_page, $a_terms)
1802 {
1803 $a_page->buildDom();
1804 $a_dom = $a_page->getDom();
1805 self::linkTermsInDom($a_dom, $a_terms);
1806
1807 $a_page->update();
1808 }
1809
1818 public static function afterPageUpdate($a_page, DOMDocument $a_domdoc, $a_xml, $a_creation)
1819 {
1820 // pc paragraph
1821 self::saveMetaKeywords($a_page, $a_domdoc);
1822 self::saveAnchors($a_page, $a_domdoc);
1823 }
1824
1830 public static function beforePageDelete($a_page)
1831 {
1832 // delete anchors
1833 self::_deleteAnchors($a_page->getParentType(), $a_page->getId(), $a_page->getLanguage());
1834 }
1835
1844 public static function afterPageHistoryEntry($a_page, DOMDocument $a_old_domdoc, $a_old_xml, $a_old_nr)
1845 {
1846 }
1847
1853 public static function saveAnchors($a_page, $a_domdoc)
1854 {
1855 self::_deleteAnchors($a_page->getParentType(), $a_page->getId(), $a_page->getLanguage());
1856
1857 // get all anchors
1858 $xpath = new DOMXPath($a_domdoc);
1859 $nodes = $xpath->query('//Anchor');
1860 $saved = array();
1861 foreach ($nodes as $node) {
1862 $name = $node->getAttribute("Name");
1863 if (trim($name) != "" && !in_array($name, $saved)) {
1864 self::_saveAnchor($a_page->getParentType(), $a_page->getId(), $a_page->getLanguage(), $name);
1865 $saved[] = $name;
1866 }
1867 }
1868 }
1869
1873 public static function _deleteAnchors($a_parent_type, $a_page_id, $a_page_lang)
1874 {
1875 global $DIC;
1876
1877 $ilDB = $DIC->database();
1878
1879 $ilDB->manipulate(
1880 "DELETE FROM page_anchor WHERE " .
1881 " page_parent_type = " . $ilDB->quote($a_parent_type, "text") .
1882 " AND page_id = " . $ilDB->quote($a_page_id, "integer") .
1883 " AND page_lang = " . $ilDB->quote($a_page_lang, "text")
1884 );
1885 }
1886
1890 public static function _saveAnchor($a_parent_type, $a_page_id, $a_page_lang, $a_anchor_name)
1891 {
1892 global $DIC;
1893
1894 $ilDB = $DIC->database();
1895
1896 $ilDB->manipulate("INSERT INTO page_anchor " .
1897 "(page_parent_type, page_id, page_lang, anchor_name) VALUES (" .
1898 $ilDB->quote($a_parent_type, "text") . "," .
1899 $ilDB->quote($a_page_id, "integer") . "," .
1900 $ilDB->quote($a_page_lang, "text") . "," .
1901 $ilDB->quote($a_anchor_name, "text") .
1902 ")");
1903 }
1904
1908 public static function _readAnchors($a_parent_type, $a_page_id, $a_page_lang = "-")
1909 {
1910 global $DIC;
1911
1912 $ilDB = $DIC->database();
1913
1914 $and_lang = ($a_page_lang != "")
1915 ? " AND page_lang = " . $ilDB->quote($a_page_lang, "text")
1916 : "";
1917
1918 $set = $ilDB->query(
1919 "SELECT * FROM page_anchor " .
1920 " WHERE page_parent_type = " . $ilDB->quote($a_parent_type, "text") .
1921 " AND page_id = " . $ilDB->quote($a_page_id, "integer") .
1922 $and_lang
1923 );
1924 $anchors = array();
1925 while ($rec = $ilDB->fetchAssoc($set)) {
1926 $anchors[] = $rec["anchor_name"];
1927 }
1928 return $anchors;
1929 }
1930
1937 public static function saveMetaKeywords($a_page, $a_domdoc)
1938 {
1939 // not nice, should be set by context per method
1940 if ($a_page->getParentType() == "gdf" ||
1941 $a_page->getParentType() == "lm") {
1942 // get existing keywords
1943 $keywords = array();
1944
1945 // find all Keyw tags
1946 $xpath = new DOMXPath($a_domdoc);
1947 $nodes = $xpath->query('//Keyw');
1948 foreach ($nodes as $node) {
1949 $k = trim(strip_tags($node->nodeValue));
1950 if (!in_array($k, $keywords)) {
1951 $keywords[] = $k;
1952 }
1953 }
1954
1955 $meta_type = ($a_page->getParentType() == "gdf")
1956 ? "gdf"
1957 : "pg";
1958 $meta_rep_id = $a_page->getParentId();
1959 $meta_id = $a_page->getId();
1960
1961 include_once("./Services/MetaData/classes/class.ilMD.php");
1962 $md_obj = new ilMD($meta_rep_id, $meta_id, $meta_type);
1963 $mkeywords = array();
1964 $lang = "";
1965 if (is_object($md_section = $md_obj->getGeneral())) {
1966 foreach ($ids = $md_section->getKeywordIds() as $id) {
1967 $md_key = $md_section->getKeyword($id);
1968 $mkeywords[] = strtolower($md_key->getKeyword());
1969 if ($lang == "") {
1970 $lang = $md_key->getKeywordLanguageCode();
1971 }
1972 }
1973 if ($lang == "") {
1974 foreach ($ids = $md_section->getLanguageIds() as $id) {
1975 $md_lang = $md_section->getLanguage($id);
1976 if ($lang == "") {
1977 $lang = $md_lang->getLanguageCode();
1978 }
1979 }
1980 }
1981 foreach ($keywords as $k) {
1982 if (!in_array(strtolower($k), $mkeywords)) {
1983 if (trim($k) != "" && $lang != "") {
1984 $md_key = $md_section->addKeyword();
1985 $md_key->setKeyword(ilUtil::stripSlashes($k));
1986 $md_key->setKeywordLanguage(new ilMDLanguageItem($lang));
1987 $md_key->save();
1988 }
1989 $mkeywords[] = strtolower($k);
1990 }
1991 }
1992 }
1993 }
1994 }
1995
1999 public function getJavascriptFiles($a_mode)
2000 {
2001 $adve_settings = new ilSetting("adve");
2002
2003 if ($a_mode != "edit" && $adve_settings->get("auto_url_linking")) {
2004 include_once("./Services/Link/classes/class.ilLinkifyUtil.php");
2006 }
2007
2008 return array();
2009 }
2010
2017 public function getOnloadCode($a_mode)
2018 {
2019 $adve_settings = new ilSetting("adve");
2020
2021 if ($a_mode != "edit" && $adve_settings->get("auto_url_linking")) {
2022 return array("il.ExtLink.autolink('.ilc_Paragraph, .ilc_page_fn_Footnote','ilc_link_ExtLink');");
2023 }
2024
2025 return array();
2026 }
2027}
user()
Definition: user.php:4
$n
Definition: RandomTest.php:85
$path
Definition: aliased.php:25
exit
Definition: backend.php:16
An exception for terminatinating execution or to throw for unit testing.
const IL_INSERT_AFTER
static addParent($node, $name)
Add parent.
static replaceByChilds($node)
Replace a node by its child.
static changeName($node, $name, $keep_attributes=true)
Change name of a node.
static getTermList( $a_glo_ref_id, $searchterm="", $a_first_letter="", $a_def="", $a_tax_node=0, $a_add_amet_fields=false, array $a_amet_filter=null, $a_include_references=false)
Get all terms for given set of glossary ids.
static getLocalJsPaths()
Get paths of necessary js files.
static _lookupLogin($a_user_id)
lookup login
static _lookupId($a_user_str)
Lookup id by login.
static _getAllReferences($a_id)
get all reference ids of object
static _lookupType($a_id, $a_reference=false)
lookup object type
static xml2outputJS($s_text, $char, $a_pc_id)
Prepare content for js output.
Class ilPCParagraph.
getText($a_short_mode=false)
Get (xml) content of paragraph.
handleNextBr($a_str)
Remove preceding
static getXMLTagMap()
Get tag to bb map.
static intLinks2xml($a_text)
internal links to xml
removeTrailingBr($a_str)
Remove trailing
static _saveAnchor($a_parent_type, $a_page_id, $a_page_lang, $a_anchor_name)
Save an anchor.
getLastSavedPCId($a_pg_obj, $a_as_ajax_str=false)
Get last inserted pc ids.
static _readAnchors($a_parent_type, $a_page_id, $a_page_lang="-")
Read anchors of a page.
getType()
Need to override getType from ilPageContent to distinguish between Pararagraph and Source.
static _input2xml($a_text, $a_lang, $a_wysiwyg=0, $a_handle_lists=true)
converts user input to xml
static autoLinkGlossariesPage($a_page, $a_terms)
Auto link glossary of whole page.
static xml2output($a_text, $a_wysiwyg=false, $a_replace_lists=true, $unmask=true)
Converts xml from DB to output in edit textarea.
static linkTermsInDom($a_dom, $a_terms, $a_par_node=null)
Link terms in a dom page object in bb style.
setNode($a_node)
Set Page Content Node.
getShowLineNumbers()
get attribute showlinenumbers
autoLinkGlossaries($a_glos)
Auto link glossaries.
static saveAnchors($a_page, $a_domdoc)
Save anchors.
static handleAjaxContent($a_content)
Handle ajax content.
init()
Init page content component.
setSubCharacteristic($a_char)
set attribute subcharacteristic
createAtNode(&$node)
Create new page content (incl.
input2xml($a_text, $a_wysiwyg=0, $a_handle_lists=true)
createAfter($node)
Create paragraph node (incl.
static input2xmlReplaceLists($a_text)
Converts xml from DB to output in edit textarea.
static beforePageDelete($a_page)
Before page is being deleted.
setDownloadTitle($a_char)
set attribute download title
create(&$a_pg_obj, $a_hier_id, $a_pc_id="")
Create paragraph node (incl.
static xml2outputReplaceLists($a_text)
Replaces with *.
getAutoIndent()
Get AutoIndent (Code Paragraphs)
getDownloadTitle()
get attribute download title
static afterPageUpdate($a_page, DOMDocument $a_domdoc, $a_xml, $a_creation)
After page has been updated (or created)
setText($a_text, $a_auto_split=false)
Set (xml) content of text paragraph.
static replaceBBCode($a_text, $a_bb, $a_tag)
Replace bb code.
getOnloadCode($a_mode)
Get onload code.
static getBBMap()
Get bb to xml tag map.
setShowLineNumbers($a_char)
set attribute showlinenumbers
setLanguage($a_lang)
set language
static afterPageHistoryEntry($a_page, DOMDocument $a_old_domdoc, $a_old_xml, $a_old_nr)
After page history entry has been created.
setCharacteristic($a_char)
Set Characteristic of paragraph.
static handleAjaxContentPost($text)
Post input2xml handling of ajax content.
static saveMetaKeywords($a_page, $a_domdoc)
save all keywords
static segmentString($a_haystack, $a_needles)
Segments a string into an array at each position of a substring.
saveJS($a_pg_obj, $a_content, $a_char, $a_pc_id, $a_insert_at="")
Save input coming from ajax.
getLanguage()
get language
createBeforeNode(&$node)
Create new page content (incl.
autoSplit($a_text)
This function splits a paragraph text that has been already processed with input2xml at each header p...
getParagraphSequenceContent($a_pg_obj)
Get paragraph sequenc of current paragraph.
updatePage($a_page)
Update page object (it would be better to have this centralized and to change the constructors and pa...
getSubCharacteristic()
get attribute subcharacteristic
static _deleteAnchors($a_parent_type, $a_page_id, $a_page_lang)
Delete anchors of a page.
getCharacteristic()
Get characteristic of paragraph.
getJavascriptFiles($a_mode)
Get Javascript files.
static _getCommonBBButtons()
Get common bb buttons.
Class ilPageContent.
createPageContentNode($a_set_this_node=true)
Create page content node (always use this method first when adding a new element)
readHierId()
Read PC Id.
readPCId()
Read PC Id.
setType($a_type)
Set Type.
ILIAS Setting Class.
static strPos($a_haystack, $a_needle, $a_offset=null)
Definition: class.ilStr.php:30
static strrPos($a_haystack, $a_needle, $a_offset=null)
Definition: class.ilStr.php:39
static strIPos($a_haystack, $a_needle, $a_offset=null)
Definition: class.ilStr.php:48
static subStr($a_str, $a_start, $a_length=null)
Definition: class.ilStr.php:15
static strLen($a_string)
Definition: class.ilStr.php:78
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static attribsToArray($a_str)
converts a string of format var1 = "val1" var2 = "val2" ... into an array
$tags
Definition: croninfo.php:19
$i
Definition: disco.tpl.php:19
if(!array_key_exists('StateId', $_REQUEST)) $id
$target_id
Definition: goto.php:49
$target_type
Definition: goto.php:48
xpath_eval($xpath_context, $eval_str, $contextnode=null)
domxml_open_mem($str, $mode=0, &$error=null)
xpath_new_context($dom_document)
const DOMXML_LOAD_PARSING
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
Definition: langwiz.php:349
$li
Definition: langwiz.php:233
if(function_exists( 'posix_getuid') &&posix_getuid()===0) if(!array_key_exists('t', $options)) $tag
Definition: cron.php:35
$target
Definition: test.php:19
$row
$ret
Definition: parser.php:6
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
global $ilDB
success()
Definition: success.php:2
$ilUser
Definition: imgupload.php:18
$a_content
Definition: workflow.php:93
$text
Definition: errorreport.php:18
$rows
Definition: xhr_table.php:10