4 require_once(
"./Services/COPage/classes/class.ilPageContent.php");
42 "quot" =>
"Quotation",
52 $this->
user = $DIC->user();
53 $this->lng = $DIC->language();
64 return self::$bb_tags;
74 return array_flip(self::$bb_tags);
86 parent::setNode($a_node);
88 $childs = $a_node->child_nodes();
89 for (
$i = 0;
$i < count($childs);
$i++) {
90 if ($childs[
$i]->node_name() ==
"Paragraph") {
91 $this->par_node = $childs[
$i];
105 $this->par_node = $this->dom->create_element(
"Paragraph");
106 $this->par_node = $this->node->append_child($this->par_node);
107 $this->par_node->set_attribute(
"Language",
"");
108 $node->append_child($this->node);
119 $this->par_node = $this->dom->create_element(
"Paragraph");
120 $this->par_node = $this->node->append_child($this->par_node);
121 $this->par_node->set_attribute(
"Language",
"");
134 if ($succ_node =
$node->next_sibling()) {
135 $this->node = $succ_node->insert_before($this->node, $succ_node);
137 $parent_node =
$node->parent_node();
138 $this->node = $parent_node->append_child($this->node);
140 $this->par_node = $this->dom->create_element(
"Paragraph");
141 $this->par_node = $this->node->append_child($this->par_node);
142 $this->par_node->set_attribute(
"Language",
"");
152 public function create(&$a_pg_obj, $a_hier_id, $a_pc_id =
"", $from_placeholder =
false)
156 $this->node = $this->dom->create_element(
"PageContent");
159 $a_pg_obj->insertContent(
167 $this->par_node = $this->dom->create_element(
"Paragraph");
168 $this->par_node = $this->node->append_child($this->par_node);
169 $this->par_node->set_attribute(
"Language",
"");
178 public function setText($a_text, $a_auto_split =
false)
180 if (!is_array($a_text)) {
181 $text = array(array(
"level" => 0,
"text" => $a_text));
201 '<?xml version="1.0" encoding="UTF-8"?><Paragraph>' . $text[0][
"text"] .
'</Paragraph>',
207 $children = $this->par_node->child_nodes();
208 for (
$i = 0;
$i < count($children);
$i++) {
209 $this->par_node->remove_child($children[
$i]);
214 $path =
"//Paragraph";
216 if (count(
$res->nodeset) == 1) {
217 $new_par_node =
$res->nodeset[0];
218 $new_childs = $new_par_node->child_nodes();
220 for (
$i = 0;
$i < count($new_childs);
$i++) {
221 $cloned_child = $new_childs[
$i]->clone_node(
true);
222 $this->par_node->append_child($cloned_child);
228 if ((count($text) > 1) && (substr($orig_characteristic, 0, 8) ==
"Headline")) {
229 $orig_characteristic =
"";
231 if ($text[0][
"level"] > 0) {
232 $this->par_node->set_attribute(
"Characteristic",
'Headline' . $text[0][
"level"]);
240 for (
$i = 1;
$i < count($text);
$i++) {
243 $next_par->createAfter($c_node);
245 if ($text[
$i][
"level"] > 0) {
246 $next_par->setCharacteristic(
"Headline" . $text[
$i][
"level"]);
248 $next_par->setCharacteristic($orig_characteristic);
250 $ok = $next_par->setText($text[
$i][
"text"],
false);
251 $c_node = $next_par->node;
258 $check = array_reduce($text,
function ($t,
$i) {
259 return $t .
$i[
"text"];
261 $text = str_replace(
"<br>",
"\n", $check);
262 $text = str_replace(
"<br/>",
"\n", $text);
263 $text = str_replace(
"<br />",
"\n", $text);
264 $text = str_replace(
"</SimpleListItem>",
"</SimpleListItem>\n", $text);
265 $text = str_replace(
"<SimpleBulletList>",
"\n<SimpleBulletList>", $text);
266 $text = str_replace(
"<SimpleNumberedList>",
"\n<SimpleNumberedList>", $text);
267 $text = str_replace(
"<Paragraph>\n",
"<Paragraph>", $text);
268 $text = str_replace(
"</Paragraph>",
"</Paragraph>\n", $text);
269 include_once(
"./Services/Dom/classes/class.ilDomDocument.php");
270 $doc =
new ilDOMDocument();
271 $text =
'<?xml version="1.0" encoding="UTF-8"?><Paragraph>' . $text .
'</Paragraph>';
273 $this->
success = $doc->loadXML($text);
274 $error = $doc->errors;
276 foreach ($error as
$e) {
277 $e = str_replace(
" in Entity",
"", $e);
278 $estr .= $e .
"<br />";
281 $estr .=
"<br />" . $text;
296 foreach ($text as $t) {
297 $check .=
"<Paragraph>" . $t[
"text"] .
"</Paragraph>";
302 '<?xml version="1.0" encoding="UTF-8"?><Paragraph>' . $check .
'</Paragraph>',
318 $dom =
new DOMDocument();
319 $dom->recover =
true;
321 for (
$i = 0;
$i < count($text);
$i++) {
323 '<?xml version="1.0" encoding="UTF-8"?><Paragraph>' . $text[
$i][
"text"] .
'</Paragraph>',
324 LIBXML_NOWARNING | LIBXML_NOERROR
327 if ($node->nodeName ==
"Paragraph") {
329 foreach ($node->childNodes as $child) {
330 $inner .=
$dom->saveXML($child);
332 $text[
$i][
"text"] = $inner;
344 public function getText($a_short_mode =
false)
346 if (is_object($this->par_node)) {
348 $childs = $this->par_node->child_nodes();
349 for (
$i = 0;
$i < count($childs);
$i++) {
350 $content .= $this->dom->dump_node($childs[
$i]);
363 $childs = $this->par_node->parent_node()->parent_node()->child_nodes();
369 for (
$i = 0;
$i < count($childs);
$i++) {
370 $pchilds = $childs[
$i]->child_nodes();
371 if ($pchilds[0]->node_name() ==
"Paragraph" &&
372 $pchilds[0]->get_attribute(
"Characteristic") !=
"Code") {
373 $cur_seq[] = $childs[
$i];
376 if ($childs[
$i]->get_attribute(
"PCID") == $pc_id &&
377 $childs[
$i]->get_attribute(
"HierId") ==
$hier_id) {
395 foreach ($seq as $p_node) {
396 $ids .= $id_sep . $p_node->get_attribute(
"HierId") .
":" . $p_node->get_attribute(
"PCID");
397 $po = $a_pg_obj->getContentObject(
398 $p_node->get_attribute(
"HierId"),
399 $p_node->get_attribute(
"PCID")
401 $s_text = $po->getText();
402 $s_text = $po->xml2output($s_text,
true,
false);
403 $char = $po->getCharacteristic();
413 return $ids . $content;
423 if (!empty($a_char)) {
424 $this->par_node->set_attribute(
"Characteristic", $a_char);
426 if ($this->par_node->has_attribute(
"Characteristic")) {
427 $this->par_node->remove_attribute(
"Characteristic");
439 if (is_object($this->par_node)) {
440 return $this->par_node->get_attribute(
"Characteristic");
450 if (!empty($a_char)) {
451 $this->par_node->set_attribute(
"SubCharacteristic", $a_char);
453 if ($this->par_node->has_attribute(
"SubCharacteristic")) {
454 $this->par_node->remove_attribute(
"SubCharacteristic");
466 return $this->par_node->get_attribute(
"AutoIndent");
471 if (!empty($a_char)) {
472 $this->par_node->set_attribute(
"AutoIndent", $a_char);
474 if ($this->par_node->has_attribute(
"AutoIndent")) {
475 $this->par_node->remove_attribute(
"AutoIndent");
485 return $this->par_node->get_attribute(
"SubCharacteristic");
494 if (!empty($a_char)) {
495 $this->par_node->set_attribute(
"DownloadTitle", $a_char);
497 if ($this->par_node->has_attribute(
"DownloadTitle")) {
498 $this->par_node->remove_attribute(
"DownloadTitle");
508 return $this->par_node->get_attribute(
"DownloadTitle");
517 $a_char = empty($a_char)?
"n":$a_char;
519 $this->par_node->set_attribute(
"ShowLineNumbers", $a_char);
528 return $this->par_node->get_attribute(
"ShowLineNumbers");
536 $this->par_node->set_attribute(
"Language", $a_lang);
544 return $this->par_node->get_attribute(
"Language");
547 public function input2xml($a_text, $a_wysiwyg = 0, $a_handle_lists =
true)
562 $a_text = preg_replace(
'/\[' . $a_bb .
'\]/i',
"<" . $a_tag .
">", $a_text);
563 $a_text = preg_replace(
'/\[\/' . $a_bb .
'\]/i',
"</" . $a_tag .
">", $a_text);
571 public static function _input2xml($a_text, $a_lang, $a_wysiwyg = 0, $a_handle_lists =
true)
578 $a_text = str_replace(
"<br />", chr(10), $a_text);
583 $a_text = trim($a_text);
589 $a_text = str_replace(
"&",
"&", $a_text);
591 $a_text = str_replace(
"<",
"<", $a_text);
592 $a_text = str_replace(
">",
">", $a_text);
595 $a_text = preg_replace(
'/<([\s\/]*?PageTurn.*?)>/i',
"<$1>", $a_text);
596 $a_text = preg_replace(
'/<([\s\/]*?BibItemIdentifier.*?)>/i',
"<$1>", $a_text);
607 $a_text = str_replace(chr(13) . chr(10),
"<br />", $a_text);
608 $a_text = str_replace(chr(13),
"<br />", $a_text);
609 $a_text = str_replace(chr(10),
"<br />", $a_text);
611 if ($a_handle_lists) {
615 foreach (self::getBBMap() as $bb => $tag) {
617 $a_text = str_replace(
"[" . $bb .
"][/" . $bb .
"]",
"", $a_text);
620 $a_text = self::replaceBBCode($a_text, $bb, $tag);
623 $a_text = self::intLinks2xml($a_text);
626 $ws =
"[ \t\r\f\v\n]*";
628 while (preg_match(
"~\[(xln$ws(url$ws=$ws\"([^\"])*\")$ws(target$ws=$ws(\"(Glossary|FAQ|Media)\"))?$ws)\]\[\/xln\]~i", $a_text, $found)) {
629 $a_text = str_replace($found[0],
"", $a_text);
631 while (preg_match(
'~\[(xln$ws(url$ws=$ws(([^]])*)))$ws\]\[\/xln\]~i', $a_text, $found)) {
632 $a_text = str_replace($found[0],
"", $a_text);
635 while (preg_match(
"~\[(xln$ws(url$ws=$ws\"([^\"])*\")$ws(target$ws=$ws(\"(Glossary|FAQ|Media)\"))?$ws)\]~i", $a_text, $found)) {
638 if (isset($attribs[
"url"])) {
639 $a_text = self::replaceBBTagByMatching(
640 "[" . $found[1] .
"]",
645 "Href" => $attribs[
"url"]
649 if ($old_text === $a_text) {
650 $a_text = str_replace(
"[" . $found[1] .
"]",
"[error: " . $found[1] .
"]", $a_text);
666 $ws =
"[ \t\r\f\v\n]*";
667 while (preg_match(
"~\[(anc$ws(name$ws=$ws\"([^\"])*\")$ws)\]~i", $a_text, $found)) {
669 $a_text = self::replaceBBTagByMatching(
670 "[" . $found[1] .
"]",
675 "Name" => $attribs[
"name"]
681 while (preg_match(
"~\[(marked$ws(class$ws=$ws\"([^\"])*\")$ws)\]~i", $a_text, $found)) {
683 if (isset($attribs[
"class"])) {
684 $a_text = self::replaceBBTagByMatching(
685 "[" . $found[1] .
"]",
690 "Class" => $attribs[
"class"]
694 $a_text = str_replace(
"[" . $found[1] .
"]",
"[error:marked" . $found[1] .
"]", $a_text);
705 libxml_use_internal_errors(
true);
706 $sxe = simplexml_load_string(
"<?xml version='1.0'?><dummy>" . $content .
"</dummy>");
707 libxml_use_internal_errors(
false);
708 return ($sxe !==
false);
719 string $xml_tag_name,
724 foreach ($attribs as $key => $value) {
726 $attrib_str .=
' ' . $key .
'="' . $value .
'"';
732 $pos1 = strpos($text, $start_tag);
735 if ($end_tag !=
"") {
736 $pos2 = strpos($text, $end_tag, $pos1 + strlen($start_tag));
737 if (is_int($pos1) && is_int($pos2)) {
738 $between = substr($text, $pos1 + strlen($start_tag), $pos2 - ($pos1 + strlen($start_tag)));
739 $ok = self::isValidTagContent($between);
746 $short = ($end_tag ==
"")
750 $slash_chars =
'/[]?()$*';
753 $replace_str = addcslashes($start_tag, $slash_chars);
754 $replace_str = str_replace(
"+",
"\\+", $replace_str);
756 $text = preg_replace(
757 '/' . $replace_str .
'/i',
758 "<" . $xml_tag_name . $attrib_str . $short .
">",
764 if ($end_tag !=
"") {
765 $text = preg_replace(
'~' . addcslashes($end_tag, $slash_chars) .
'~i',
"</" . $xml_tag_name .
">", $text, 1);
770 $text = preg_replace(
771 '/' . addcslashes($start_tag, $slash_chars) .
'/i',
779 $text = preg_replace(
780 '~' . addcslashes($end_tag, $slash_chars) .
'~i',
800 $objDefinition = $DIC[
"objDefinition"];
802 $rtypes = $objDefinition->getAllRepositoryTypes();
806 $ws =
"[ \t\r\f\v\n]*";
807 $ltypes =
"page|chap|term|media|obj|dfile|sess|wpage|ppage|" . implode(
"|", $rtypes);
809 while (preg_match(
'~\[(iln' . $ws .
'((inst' . $ws .
'=' . $ws .
'([\"0-9])*)?' . $ws .
810 "((" . $ltypes .
")$ws=$ws([\"0-9])*)$ws" .
811 "(target$ws=$ws(\"(New|FAQ|Media)\"))?$ws(anchor$ws=$ws(\"([^\"])*\"))?$ws))\]\[\/iln\]~i", $a_text, $found)) {
812 $a_text = str_replace($found[0],
"", $a_text);
814 while (preg_match(
'~\[(iln' . $ws .
'((inst' . $ws .
'=' . $ws .
'([\"0-9])*)?' . $ws .
815 "((" . $ltypes .
")$ws=$ws([\"0-9])*)$ws" .
816 "(target$ws=$ws(\"(New|FAQ|Media)\"))?$ws(anchor$ws=$ws(\"([^\"])*\"))?$ws))\]~i", $a_text, $found)) {
818 $inst_str = $attribs[
"inst"];
820 if (isset($attribs[
"page"])) {
821 $a_text = self::replaceBBTagByMatching(
822 "[" . $found[1] .
"]",
827 "Target" =>
"il_" . $inst_str .
"_pg_" . $attribs[
'page'],
828 "Type" =>
"PageObject",
829 "TargetFrame" => $found[10] ??
"",
830 "Anchor" => $attribs[
"anchor"] ??
"" 835 elseif (isset($attribs[
"chap"])) {
836 $a_text = self::replaceBBTagByMatching(
837 "[" . $found[1] .
"]",
842 "Target" =>
"il_" . $inst_str .
"_st_" . $attribs[
'chap'],
843 "Type" =>
"StructureObject",
844 "TargetFrame" => $found[10] ??
"" 849 elseif (isset($attribs[
"term"])) {
850 $a_text = self::replaceBBTagByMatching(
851 "[" . $found[1] .
"]",
856 "Target" =>
"il_" . $inst_str .
"_git_" . $attribs[
'term'],
857 "Type" =>
"GlossaryItem",
858 "TargetFrame" => (($found[10] ??
"") ==
"New")
865 elseif (isset($attribs[
"wpage"])) {
866 $a_text = self::replaceBBTagByMatching(
867 "[" . $found[1] .
"]",
872 "Target" =>
"il_" . $inst_str .
"_wpage_" . $attribs[
'wpage'],
873 "Type" =>
"WikiPage",
874 "Anchor" => $attribs[
"anchor"] ??
"" 879 elseif (isset($attribs[
"ppage"])) {
880 $a_text = self::replaceBBTagByMatching(
881 "[" . $found[1] .
"]",
886 "Target" =>
"il_" . $inst_str .
"_ppage_" . $attribs[
'ppage'],
887 "Type" =>
"PortfolioPage" 892 elseif (isset($attribs[
"media"])) {
893 $a_text = self::replaceBBTagByMatching(
894 "[" . $found[1] .
"]",
899 "Target" =>
"il_" . $inst_str .
"_mob_" . $attribs[
'media'],
900 "Type" =>
"MediaObject",
901 "TargetFrame" => $found[10] ??
"" 906 elseif (isset($attribs[
"dfile"])) {
907 $a_text = self::replaceBBTagByMatching(
908 "[" . $found[1] .
"]",
913 "Target" =>
"il_" . $inst_str .
"_dfile_" . $attribs[
'dfile'],
921 foreach ($objDefinition->getAllRepositoryTypes() as $t) {
922 if (isset($attribs[$t])) {
923 $obj_id = $attribs[$t];
926 if (isset($attribs[
"obj"])) {
927 $obj_id = $attribs[
"obj"];
931 if ($inst_str ==
"") {
932 $a_text = self::replaceBBTagByMatching(
933 "[" . $found[1] .
"]",
938 "Target" =>
"il_" . $inst_str .
"_obj_" . $obj_id,
939 "Type" =>
"RepositoryItem" 943 $a_text = self::replaceBBTagByMatching(
944 "[" . $found[1] .
"]",
949 "Target" =>
"il_" . $inst_str .
"_" . $found[6] .
"_" . $obj_id,
950 "Type" =>
"RepositoryItem" 955 $a_text = preg_replace(
'/\[' . $found[1] .
'\]/i',
"[error: iln" . $found[1] .
"]", $a_text);
960 while (preg_match(
"~\[(iln$ws((inst$ws=$ws([\"0-9])*)?" . $ws .
"media$ws=$ws([\"0-9])*)$ws)/\]~i", $a_text, $found)) {
962 $inst_str = $attribs[
"inst"] ??
"";
963 $a_text = self::replaceBBTagByMatching(
964 "[" . $found[1] .
"/]",
969 "Target" =>
"il_" . $inst_str .
"_mob_" . $attribs[
'media'],
970 "Type" =>
"MediaObject" 976 while (preg_match(
"~\[(iln$ws((inst$ws=$ws([\"0-9])*)?" . $ws .
"user$ws=$ws(\"([^\"])*)\")$ws)/\]~i", $a_text, $found)) {
978 $inst_str = $attribs[
"inst"];
979 include_once(
"./Services/User/classes/class.ilObjUser.php");
981 $a_text = self::replaceBBTagByMatching(
982 "[" . $found[1] .
"/]",
987 "Target" =>
"il_" . $inst_str .
"_user_" . $user_id,
1006 $rows = explode(
"<br />", $a_text .
"<br />");
1013 foreach (
$rows as $row) {
1015 if (str_replace(
"#",
"*", substr($row, 0, 3)) ==
"***") {
1017 } elseif (str_replace(
"#",
"*", substr($row, 0, 2)) ==
"**") {
1019 } elseif (str_replace(
"#",
"*", substr($row, 0, 1)) ==
"*") {
1024 if ($level < $old_level) {
1025 for (
$i = $old_level;
$i > $level;
$i--) {
1026 $text .=
"</SimpleListItem></" . $clist[
$i] .
">";
1029 $text .=
"</SimpleListItem>";
1031 } elseif ($old_level > 0 && $level > 0 && ($level == $old_level)) {
1032 $text .=
"</SimpleListItem>";
1033 } elseif (($level == $old_level) && $text !=
"") {
1038 if ($level > $old_level) {
1039 for (
$i = $old_level + 1;
$i <= $level;
$i++) {
1040 if (substr($row,
$i - 1, 1) ==
"*") {
1041 $clist[
$i] =
"SimpleBulletList";
1043 $clist[
$i] =
"SimpleNumberedList";
1045 $text .=
"<" . $clist[
$i] .
"><SimpleListItem>";
1047 } elseif ($old_level > 0 && $level > 0) {
1048 $text .=
"<SimpleListItem>";
1050 $text .= substr($row, $level);
1052 $old_level = $level;
1056 if (substr($text, strlen($text) - 6) ==
"<br />") {
1057 $text = substr($text, 0, strlen($text) - 6);
1073 "</SimpleListItem>",
"<SimpleListItem>",
"<SimpleListItem/>",
"<SimpleNumberedList>",
"</SimpleNumberedList>"));
1075 $current_list = array();
1077 for (
$i = 0;
$i <= count($segments);
$i++) {
1078 if ($segments[
$i] ==
"<SimpleBulletList>") {
1079 if (count($current_list) == 0) {
1082 array_push($current_list,
"*");
1084 } elseif ($segments[
$i] ==
"<SimpleNumberedList>") {
1085 if (count($current_list) == 0) {
1088 array_push($current_list,
"#");
1090 } elseif ($segments[
$i] ==
"</SimpleBulletList>") {
1091 array_pop($current_list);
1093 } elseif ($segments[
$i] ==
"</SimpleNumberedList>") {
1094 array_pop($current_list);
1096 } elseif ($segments[
$i] ==
"<SimpleListItem>") {
1098 } elseif ($segments[
$i] ==
"</SimpleListItem>") {
1100 } elseif ($segments[
$i] ==
"<SimpleListItem/>") {
1103 $list_start =
false;
1105 foreach ($current_list as $list) {
1114 $list_start =
false;
1116 foreach ($current_list as $list) {
1120 $text .= $segments[
$i];
1129 if ($segments[count($segments) - 1] ==
"</SimpleBulletList>" ||
1130 $segments[count($segments) - 1] ==
"</SimpleNumberedList>" &&
1131 substr($text, strlen($text) - 6) ==
"<br />") {
1132 $text = substr($text, 0, strlen($text) - 6);
1143 $segments = array();
1145 $nothing_found =
false;
1146 while (!$nothing_found) {
1147 $nothing_found =
true;
1149 foreach ($a_needles as $needle) {
1150 $pos = stripos($a_haystack, $needle);
1151 if (is_int($pos) && ($pos < $found || $found == -1)) {
1153 $found_needle = $needle;
1154 $nothing_found =
false;
1158 $segments[] = substr($a_haystack, 0, $found);
1159 $a_haystack = substr($a_haystack, $found);
1162 $segments[] = substr($a_haystack, 0, strlen($found_needle));
1163 $a_haystack = substr($a_haystack, strlen($found_needle));
1166 if ($a_haystack !=
"") {
1167 $segments[] = $a_haystack;
1180 public static function xml2output($a_text, $a_wysiwyg =
false, $a_replace_lists =
true, $unmask =
true)
1188 foreach (self::getBBMap() as $bb => $tag) {
1189 $a_text = preg_replace(
'~<' . $tag .
'[^>]*>~i',
"[" . $bb .
"]", $a_text);
1190 $a_text = preg_replace(
'~</' . $tag .
'>~i',
"[/" . $bb .
"]", $a_text);
1191 $a_text = preg_replace(
'~<' . $tag .
'/>~i',
"[" . $bb .
"][/" . $bb .
"]", $a_text);
1195 if ($a_replace_lists) {
1202 while (preg_match(
'~<IntLink(' . $any .
')>~i', $a_text, $found)) {
1205 $target = explode(
"_", $attribs[
"Target"]);
1207 $inst_str = (!is_int(strpos($attribs[
"Target"],
"__")))
1208 ? $inst_str =
"inst=\"" . $target[1] .
"\" " 1210 switch ($attribs[
"Type"]) {
1212 $tframestr = (!empty($attribs[
"TargetFrame"]))
1213 ?
" target=\"" . $attribs[
"TargetFrame"] .
"\"" 1215 $ancstr = (!empty($attribs[
"Anchor"]))
1216 ?
' anchor="' . $attribs[
"Anchor"] .
'"' 1218 $a_text = preg_replace(
'~<IntLink' . $found[1] .
'>~i',
"[iln " . $inst_str .
"page=\"" .
$target_id .
"\"$tframestr$ancstr]", $a_text);
1221 case "StructureObject":
1222 $tframestr = (!empty($attribs[
"TargetFrame"]))
1223 ?
" target=\"" . $attribs[
"TargetFrame"] .
"\"" 1225 $a_text = preg_replace(
'~<IntLink' . $found[1] .
'>~i',
"[iln " . $inst_str .
"chap=\"" . $target_id .
"\"$tframestr]", $a_text);
1228 case "GlossaryItem":
1229 $tframestr = (empty($attribs[
"TargetFrame"]) || $attribs[
"TargetFrame"] ==
"Glossary")
1231 :
" target=\"" . $attribs[
"TargetFrame"] .
"\"";
1232 $a_text = preg_replace(
'~<IntLink' . $found[1] .
'>~i',
"[iln " . $inst_str .
"term=\"" . $target_id .
"\"" . $tframestr .
"]", $a_text);
1237 $ancstr = (!empty($attribs[
"Anchor"]))
1238 ?
' anchor="' . $attribs[
"Anchor"] .
'"' 1240 $a_text = preg_replace(
'~<IntLink' . $found[1] .
'>~i',
"[iln " . $inst_str .
"wpage=\"" . $target_id .
"\"" . $tframestr . $ancstr .
"]", $a_text);
1243 case "PortfolioPage":
1245 $a_text = preg_replace(
'~<IntLink' . $found[1] .
'>~i',
"[iln " . $inst_str .
"ppage=\"" . $target_id .
"\"" . $tframestr .
"]", $a_text);
1249 if (empty($attribs[
"TargetFrame"])) {
1250 $a_text = preg_replace(
'~<IntLink' . $found[1] .
'>~i',
"[iln " . $inst_str .
"media=\"" . $target_id .
"\"/]", $a_text);
1252 $a_text = preg_replace(
'~<IntLink' . $found[1] .
'>~i',
"[iln media=\"" . $target_id .
"\"" .
1253 " target=\"" . $attribs[
"TargetFrame"] .
"\"]", $a_text);
1258 case "RepositoryItem":
1259 if ($inst_str ==
"") {
1262 $rtype = $target[count($target) - 2];
1265 $a_text = preg_replace(
'~<IntLink' . $found[1] .
'>~i',
"[iln " . $inst_str .
"$target_type=\"" . $target_id .
"\"" . $tframestr .
"]", $a_text);
1270 $a_text = preg_replace(
'~<IntLink' . $found[1] .
'>~i',
"[iln " . $inst_str .
"dfile=\"" . $target_id .
"\"" . $tframestr .
"]", $a_text);
1275 include_once(
"./Services/User/classes/class.ilObjUser.php");
1276 $a_text = preg_replace(
'~<IntLink' . $found[1] .
'>~i',
"[iln " . $inst_str .
"user=\"" .
ilObjUser::_lookupLogin($target_id) .
"\"/]", $a_text);
1280 $a_text = preg_replace(
'~<IntLink' . $found[1] .
'>~i',
"[iln]", $a_text);
1284 $a_text = str_replace(
"</IntLink>",
"[/iln]", $a_text);
1287 while (preg_match(
'~<ExtLink(' . $any .
')>~i', $a_text, $found)) {
1292 if (in_array($attribs[
"TargetFrame"], array(
"FAQ",
"Glossary",
"Media"))) {
1293 $tstr =
' target="' . $attribs[
"TargetFrame"] .
'"';
1295 $a_text = str_replace(
"<ExtLink" . $found[1] .
">",
"[xln url=\"" . $attribs[
"Href"] .
"\"$tstr]", $a_text);
1297 $a_text = str_replace(
"</ExtLink>",
"[/xln]", $a_text);
1300 while (preg_match(
'~<Anchor(' . $any .
'/)>~i', $a_text, $found)) {
1303 $a_text = str_replace(
"<Anchor" . $found[1] .
">",
"[anc name=\"" . $attribs[
"Name"] .
"\"][/anc]", $a_text);
1305 while (preg_match(
'~<Anchor(' . $any .
')>~i', $a_text, $found)) {
1308 $a_text = str_replace(
"<Anchor" . $found[1] .
">",
"[anc name=\"" . $attribs[
"Name"] .
"\"]", $a_text);
1310 $a_text = str_replace(
"</Anchor>",
"[/anc]", $a_text);
1313 while (preg_match(
'~<Marked(' . $any .
')>~i', $a_text, $found)) {
1316 $a_text = str_replace(
"<Marked" . $found[1] .
">",
"[marked class=\"" . $attribs[
"Class"] .
"\"]", $a_text);
1318 $a_text = str_replace(
"</Marked>",
"[/marked]", $a_text);
1322 $a_text = str_replace(
"<br />",
"\n", $a_text);
1323 $a_text = str_replace(
"<br/>",
"\n", $a_text);
1328 $a_text = str_replace(
"{",
"{", $a_text);
1329 $a_text = str_replace(
"}",
"}", $a_text);
1333 $a_text = str_replace(
"<",
"<", $a_text);
1334 $a_text = str_replace(
">",
">", $a_text);
1338 $a_text = str_replace(
""",
"\"", $a_text);
1342 $a_text = str_replace(
"&",
"&", $a_text);
1346 $a_text = str_replace(
"<",
"&lt;", $a_text);
1347 $a_text = str_replace(
">",
"&gt;", $a_text);
1362 $a_text = str_replace(
"=<SimpleBulletList>",
"=<br /><SimpleBulletList>", $a_text);
1363 $a_text = str_replace(
"=<SimpleNumberedList>",
"=<br /><SimpleNumberedList>", $a_text);
1364 $a_text = str_replace(
"</SimpleBulletList>=",
"</SimpleBulletList><br />=", $a_text);
1365 $a_text = str_replace(
"</SimpleNumberedList>=",
"</SimpleNumberedList><br />=", $a_text);
1366 $a_text =
"<br />" . $a_text .
"<br />";
1371 while ($c_text !=
"") {
1374 $s1 = strpos($c_text,
"<br />=");
1377 $s2 = strpos($c_text,
"<br />==");
1378 if (is_int($s2) && $s2 <= $s1) {
1380 $s3 = strpos($c_text,
"<br />===");
1381 if (is_int($s3) && $s3 <= $s2) {
1383 $n = strpos($c_text,
"<br />", $s3 + 1);
1384 if (
$n > ($s3 + 9) && substr($c_text,
$n - 3, 9) ==
"===<br />") {
1387 if ($s3 > 0 || $head !=
"") {
1389 $chunks[] = array(
"level" => 0,
1393 $chunks[] = array(
"level" => 3,
1394 "text" => trim(substr($c_text, $s3 + 9,
$n - $s3 - 12)));
1398 $head .= substr($c_text, 0,
$n);
1399 $c_text = substr($c_text,
$n);
1403 $n = strpos($c_text,
"<br />", $s2 + 1);
1404 if (
$n > ($s2 + 8) && substr($c_text,
$n - 2, 8) ==
"==<br />") {
1407 if ($s2 > 0 || $head !=
"") {
1409 $chunks[] = array(
"level" => 0,
1413 $chunks[] = array(
"level" => 2,
"text" => trim(substr($c_text, $s2 + 8,
$n - $s2 - 10)));
1417 $head .= substr($c_text, 0,
$n);
1418 $c_text = substr($c_text,
$n);
1423 $n = strpos($c_text,
"<br />", $s1 + 1);
1424 if (
$n > ($s1 + 7) && substr($c_text,
$n - 1, 7) ==
"=<br />") {
1427 if ($s1 > 0 || $head !=
"") {
1429 $chunks[] = array(
"level" => 0,
1433 $chunks[] = array(
"level" => 1,
"text" => trim(substr($c_text, $s1 + 7,
$n - $s1 - 8)));
1437 $head .= substr($c_text, 0,
$n);
1438 $c_text = substr($c_text,
$n);
1444 $chunks[] = array(
"level" => 0,
"text" => $head . $c_text);
1449 if (count($chunks) == 0) {
1450 $chunks[] = array(
"level" => 0,
"text" =>
"");
1455 if (substr($chunks[0][
"text"], 0, 6) ==
"<br />") {
1456 $chunks[0][
"text"] = substr($chunks[0][
"text"], 6);
1461 $chunks[count($chunks) - 1][
"text"],
1462 strlen($chunks[count($chunks) - 1][
"text"]) - 6,
1465 $chunks[count($chunks) - 1][
"text"] =
1466 substr($chunks[count($chunks) - 1][
"text"], 0, strlen($chunks[count($chunks) - 1][
"text"]) - 6);
1467 if ($chunks[count($chunks) - 1][
"text"] ==
"") {
1468 unset($chunks[count($chunks) - 1]);
1481 if (substr($a_str, 0, 6) ==
"<br />" && substr($a_str, 6, 1) !=
"=") {
1482 $a_str = substr($a_str, 6);
1486 if (substr($a_str, 0, 1) ==
"=") {
1487 $a_str =
"<br />" . $a_str;
1498 if (substr($a_str, strlen($a_str) - 6) ==
"<br />") {
1499 $a_str = substr($a_str, 0, strlen($a_str) - 6);
1528 $from_placeholder =
false 1532 $a_content = str_replace(
"<br>",
"<br />", $a_content);
1534 $this->log->debug(
"step 1: " . substr($a_content, 0, 1000));
1536 $t = self::handleAjaxContent($a_content);
1538 return $ex->getMessage() .
": " . htmlentities($a_content);
1540 $this->log->debug(
"step 2: " . substr($t[
"text"], 0, 1000));
1544 $pc_id = explode(
":", $a_pc_id);
1545 $insert_at = explode(
":", $a_insert_at);
1546 $t_id = explode(
":", $t[
"id"]);
1549 if ($a_insert_at !=
"") {
1551 $par->create($a_pg_obj, $insert_at[0], $insert_at[1], $from_placeholder);
1552 $par->writePCId($pc_id[1]);
1554 $par = $a_pg_obj->getContentObject($pc_id[0], $pc_id[1]);
1557 return $this->lng->txt(
"copg_page_element_not_found") .
" (saveJS): " . $pc_id[0] .
":" . $pc_id[1] .
".";
1569 $par->setLanguage(
$ilUser->getLanguage());
1570 $par->setCharacteristic($t[
"class"]);
1572 $t2 = $par->input2xml($t[
"text"],
true,
false);
1573 $this->log->debug(
"step 3: " . substr($t2, 0, 1000));
1576 $this->log->debug(
"step 4: " . substr($t2, 0, 1000));
1578 $updated = $par->setText($t2,
true);
1580 if ($updated !==
true) {
1585 $updated = $par->updatePage($a_pg_obj);
1598 if ($a_as_ajax_str) {
1599 $a_pg_obj->stripHierIDs();
1600 $a_pg_obj->addHierIds();
1603 $combined = $a_pg_obj->getHierIdsForPCIds(
1604 array($this->inserted_pc_id)
1606 foreach ($combined as $pc_id =>
$hier_id) {
1608 $ids .= $sep .
$hier_id .
":" . $pc_id;
1615 return $this->inserted_pc_id;
1624 $a_content =
"<dummy>" . $a_content .
"</dummy>";
1626 $doc =
new DOMDocument();
1633 $res = $doc->loadXML($content);
1640 $xpath =
new DOMXpath($doc);
1642 $tags = self::getXMLTagMap();
1644 $elements = $xpath->query(
"//span");
1645 include_once(
"./Services/Utilities/classes/class.ilDOM2Util.php");
1646 while (!is_null($elements) && !is_null($element = $elements->item(0))) {
1648 $class = $element->getAttribute(
"class");
1649 if (substr($class, 0, 16) ==
"ilc_text_inline_") {
1650 $class_arr = explode(
" ", $class);
1651 $tag = substr($class_arr[0], 16);
1652 if (isset($tags[$tag])) {
1656 $cnode->setAttribute(
"Class", substr($class_arr[0], 16));
1658 for (
$i = 1;
$i < count($class_arr);
$i++) {
1659 $tag = substr($class_arr[
$i], 16);
1660 if (isset($tags[$tag])) {
1664 $cnode->setAttribute(
"Class", substr($class_arr[$i], 16));
1671 $elements = $xpath->query(
"//span");
1675 $xpath =
new DOMXpath($doc);
1676 $elements = $xpath->query(
"/dummy/div");
1679 if (!is_null($elements)) {
1680 foreach ($elements as $element) {
1681 $id = $element->getAttribute(
"id");
1682 $class = $element->getAttribute(
"class");
1683 $class = substr($class, 15);
1684 if (trim($class) ==
"") {
1685 $class =
"Standard";
1688 $text = $doc->saveXML($element);
1689 $text = str_replace(
"<br/>",
"\n", $text);
1692 $pos = strpos($text,
">");
1693 $text = substr($text, $pos + 1);
1694 $pos = strrpos($text,
"<");
1695 $text = substr($text, 0, $pos);
1701 if (!in_array($bb, array(
"code",
"tex",
"fn",
"xln"))) {
1702 $text = str_replace(
1707 $text = str_replace(
1712 $text = str_replace(
"<il" . $cl .
"/>",
"", $text);
1715 $text = str_replace(
1716 array(
"<code>",
"</code>"),
1717 array(
"[code]",
"[/code]"),
1720 $text = str_replace(
1721 array(
'<sup class="ilc_sup_Sup">',
'<sup>',
"</sup>"),
1722 array(
"[sup]",
"[sup]",
"[/sup]"),
1725 $text = str_replace(
1726 array(
'<sub class="ilc_sub_Sub">',
'<sub>',
"</sub>"),
1727 array(
"[sub]",
"[sub]",
"[/sub]"),
1731 $text = str_replace(
"<code/>",
"", $text);
1732 $text = str_replace(
'<ul class="ilc_list_u_BulletedList"/>',
"", $text);
1733 $text = str_replace(
'<ul class="ilc_list_o_NumberedList"/>',
"", $text);
1738 while (preg_match(
'~<ilMarked(' . $any .
')>~i', $text, $found)) {
1741 $text = str_replace(
"<ilMarked" . $found[1] .
">",
"[marked class=\"" . $attribs[
"Class"] .
"\"]", $text);
1743 $text = str_replace(
"</ilMarked>",
"[/marked]", $text);
1746 $ret[] = array(
"text" => $text,
"id" => $id,
"class" => $class);
1759 $text = str_replace(
1760 array(
"<ul>",
"</ul>"),
1761 array(
"<SimpleBulletList>",
"</SimpleBulletList>"),
1764 $text = str_replace(
1765 array(
"<ul class='ilc_list_u_BulletedList'>",
"</ul>"),
1766 array(
"<SimpleBulletList>",
"</SimpleBulletList>"),
1769 $text = str_replace(
1770 array(
"<ul class=\"ilc_list_u_BulletedList\">",
"</ul>"),
1771 array(
"<SimpleBulletList>",
"</SimpleBulletList>"),
1774 $text = str_replace(
1775 array(
"<ol>",
"</ol>"),
1776 array(
"<SimpleNumberedList>",
"</SimpleNumberedList>"),
1779 $text = str_replace(
1780 array(
"<ol class='ilc_list_o_NumberedList'>",
"</ol>"),
1781 array(
"<SimpleNumberedList>",
"</SimpleNumberedList>"),
1784 $text = str_replace(
1785 array(
"<ol class=\"ilc_list_o_NumberedList\">",
"</ol>"),
1786 array(
"<SimpleNumberedList>",
"</SimpleNumberedList>"),
1789 $text = str_replace(
1790 array(
"<li>",
"</li>"),
1791 array(
"<SimpleListItem>",
"</SimpleListItem>"),
1794 $text = str_replace(
1795 array(
"<li class='ilc_list_item_StandardListItem'>",
"</li>"),
1796 array(
"<SimpleListItem>",
"</SimpleListItem>"),
1799 $text = str_replace(
1800 array(
"<li class=\"ilc_list_item_StandardListItem\">",
"</li>"),
1801 array(
"<SimpleListItem>",
"</SimpleListItem>"),
1805 $text = str_replace(
1806 array(
"<li class=\"ilc_list_item_StandardListItem\"/>"),
1807 array(
"<SimpleListItem></SimpleListItem>"),
1811 $text = str_replace(
"<SimpleBulletList><br />",
"<SimpleBulletList>", $text);
1812 $text = str_replace(
"<SimpleNumberedList><br />",
"<SimpleNumberedList>", $text);
1813 $text = str_replace(
"<br /><SimpleBulletList>",
"<SimpleBulletList>", $text);
1814 $text = str_replace(
"<br /><SimpleNumberedList>",
"<SimpleNumberedList>", $text);
1815 $text = str_replace(
"</SimpleBulletList><br />",
"</SimpleBulletList>", $text);
1816 $text = str_replace(
"</SimpleNumberedList><br />",
"</SimpleNumberedList>", $text);
1817 $text = str_replace(
"</SimpleListItem><br />",
"</SimpleListItem>", $text);
1831 $a_page->beforePageContentUpdate($this);
1833 $ret = $a_page->update();
1845 if (is_array($a_glos) && count($a_glos) > 0) {
1850 $text = strip_tags($this->
getText());
1851 $found_terms = array();
1852 foreach ($a_glos as $glo) {
1855 $glo_ref_id = current($ref_ids);
1856 if ($glo_ref_id > 0) {
1858 foreach ($terms as $t) {
1859 if (is_int(stripos($text, $t[
"term"]))) {
1860 $found_terms[$t[
"id"]] = $t;
1867 if (count($found_terms) > 0) {
1868 self::linkTermsInDom($this->dom, $found_terms, $this->par_node);
1883 foreach ($a_terms as $k => $t) {
1884 $a_terms[$k][
"termlength"] = strlen($t[
"term"]);
1890 $a_dom = $a_dom->myDOMDocument;
1893 $a_par_node = $a_par_node->myDOMNode;
1896 $xpath =
new DOMXPath($a_dom);
1898 if ($a_par_node == null) {
1899 $parnodes = $xpath->query(
"//Paragraph[@Characteristic != 'Code']");
1901 $parnodes = $xpath->query(
".//Paragraph[@Characteristic != 'Code']", $a_par_node->parentNode);
1904 include_once(
"./Services/Utilities/classes/class.ilStr.php");
1906 foreach ($parnodes as $parnode) {
1907 $textnodes = $xpath->query(
'.//text()', $parnode);
1908 foreach ($textnodes as
$node) {
1909 $p = $node->getNodePath();
1912 if (!is_int(strpos($p,
"/IntLink")) &&
1913 !is_int(strpos($p,
"/ExtLink"))) {
1914 $node_val = $node->nodeValue;
1917 foreach ($a_terms as $t) {
1921 while (is_int($pos)) {
1925 if ($tex_bpos > 0 && $tex_epos > 0 && $tex_bpos < $pos && $tex_epos > $pos) {
1931 $valid_limiters = array(
"",
" ",
" ",
".",
",",
":",
";",
"!",
"?",
"\"",
"'",
"(",
")");
1936 if ((in_array(
$b, $valid_limiters) || htmlentities(
$b, null,
'utf-8') ==
" ") && in_array(
$a, $valid_limiters)) {
1937 $mid =
'[iln term="' . $t[
"id"] .
'"]' .
1956 $node->nodeValue = $node_val;
1965 $text = $a_dom->saveXML($parnode);
1966 $text = substr($text, 0, strlen($text) - strlen(
"</Paragraph>"));
1967 $text = substr($text, strpos($text,
">") + 1);
1970 $text = self::intLinks2xml($text);
1974 '<?xml version="1.0" encoding="UTF-8"?><Paragraph>' . $text .
'</Paragraph>',
1978 $temp_dom = $temp_dom->myDOMDocument;
1980 if (empty($error)) {
1982 $children = $parnode->childNodes;
1983 while ($parnode->hasChildNodes()) {
1984 $parnode->removeChild($parnode->firstChild);
1988 $xpath_temp =
new DOMXPath($temp_dom);
1989 $temp_pars = $xpath_temp->query(
"//Paragraph");
1991 foreach ($temp_pars as $new_par_node) {
1992 $new_childs = $new_par_node->childNodes;
1994 foreach ($new_childs as $new_child) {
1996 $cloned_child = $a_dom->importNode($new_child,
true);
1997 $parnode->appendChild($cloned_child);
2014 $a_page->buildDom();
2015 $a_dom = $a_page->getDom();
2017 self::linkTermsInDom($a_dom, $a_terms);
2030 public static function afterPageUpdate($a_page, DOMDocument $a_domdoc, $a_xml, $a_creation)
2033 self::saveMetaKeywords($a_page, $a_domdoc);
2034 self::saveAnchors($a_page, $a_domdoc);
2045 self::_deleteAnchors($a_page->getParentType(), $a_page->getId(), $a_page->getLanguage());
2067 self::_deleteAnchors($a_page->getParentType(), $a_page->getId(), $a_page->getLanguage());
2070 $xpath =
new DOMXPath($a_domdoc);
2071 $nodes = $xpath->query(
'//Anchor');
2073 foreach ($nodes as
$node) {
2074 $name = $node->getAttribute(
"Name");
2075 if (trim(
$name) !=
"" && !in_array(
$name, $saved)) {
2076 self::_saveAnchor($a_page->getParentType(), $a_page->getId(), $a_page->getLanguage(),
$name);
2089 $ilDB = $DIC->database();
2092 "DELETE FROM page_anchor WHERE " .
2093 " page_parent_type = " .
$ilDB->quote($a_parent_type,
"text") .
2094 " AND page_id = " .
$ilDB->quote($a_page_id,
"integer") .
2095 " AND page_lang = " .
$ilDB->quote($a_page_lang,
"text")
2102 public static function _saveAnchor($a_parent_type, $a_page_id, $a_page_lang, $a_anchor_name)
2106 $ilDB = $DIC->database();
2108 $ilDB->manipulate(
"INSERT INTO page_anchor " .
2109 "(page_parent_type, page_id, page_lang, anchor_name) VALUES (" .
2110 $ilDB->quote($a_parent_type,
"text") .
"," .
2111 $ilDB->quote($a_page_id,
"integer") .
"," .
2112 $ilDB->quote($a_page_lang,
"text") .
"," .
2113 $ilDB->quote($a_anchor_name,
"text") .
2120 public static function _readAnchors($a_parent_type, $a_page_id, $a_page_lang =
"-")
2124 $ilDB = $DIC->database();
2126 $and_lang = ($a_page_lang !=
"")
2127 ?
" AND page_lang = " .
$ilDB->quote($a_page_lang,
"text")
2130 $set =
$ilDB->query(
2131 "SELECT * FROM page_anchor " .
2132 " WHERE page_parent_type = " .
$ilDB->quote($a_parent_type,
"text") .
2133 " AND page_id = " .
$ilDB->quote($a_page_id,
"integer") .
2137 while ($rec =
$ilDB->fetchAssoc($set)) {
2138 $anchors[] = $rec[
"anchor_name"];
2152 if ($a_page->getParentType() ==
"gdf" ||
2153 $a_page->getParentType() ==
"lm") {
2155 $keywords = array();
2158 $xpath =
new DOMXPath($a_domdoc);
2159 $nodes = $xpath->query(
'//Keyw');
2160 foreach ($nodes as
$node) {
2161 $k = trim(strip_tags($node->nodeValue));
2162 if (!in_array($k, $keywords)) {
2167 $meta_type = ($a_page->getParentType() ==
"gdf")
2170 $meta_rep_id = $a_page->getParentId();
2171 $meta_id = $a_page->getId();
2173 include_once(
"./Services/MetaData/classes/class.ilMD.php");
2174 $md_obj =
new ilMD($meta_rep_id, $meta_id, $meta_type);
2175 $mkeywords = array();
2177 if (is_object($md_section = $md_obj->getGeneral())) {
2178 foreach ($ids = $md_section->getKeywordIds() as $id) {
2179 $md_key = $md_section->getKeyword($id);
2180 $mkeywords[] = strtolower($md_key->getKeyword());
2182 $lang = $md_key->getKeywordLanguageCode();
2186 foreach ($ids = $md_section->getLanguageIds() as $id) {
2187 $md_lang = $md_section->getLanguage($id);
2189 $lang = $md_lang->getLanguageCode();
2193 foreach ($keywords as $k) {
2194 if (!in_array(strtolower($k), $mkeywords)) {
2195 if (trim($k) !=
"" &&
$lang !=
"") {
2196 $md_key = $md_section->addKeyword();
2201 $mkeywords[] = strtolower($k);
2215 if ($a_mode !=
"edit" && $adve_settings->get(
"auto_url_linking")) {
2216 include_once(
"./Services/Link/classes/class.ilLinkifyUtil.php");
2233 if ($a_mode !=
"edit" && $adve_settings->get(
"auto_url_linking")) {
2234 return array(
"il.ExtLink.autolink('.ilc_Paragraph, .ilc_page_fn_Footnote','ilc_link_ExtLink');");
2245 $model = new \stdClass();
2247 $s_text = $this->
xml2output($s_text,
true,
false);
2253 $model->characteristic = $char;
2254 $model->text = $s_text;
2265 public function insert(\
ilPageObject $page, $a_content, $a_char, $a_pc_id, $a_insert_at =
"", $a_new_pc_id =
"")
2269 $this->log->debug(
"step 1: " . substr($a_content, 0, 1000));
2272 $t = self::handleAjaxContent($a_content);
2274 return $ex->getMessage() .
": " . htmlentities($a_content);
2277 $this->log->debug(
"step 2: " . substr($t[
"text"], 0, 1000));
2282 $pc_id = explode(
":", $a_pc_id);
2283 $insert_at = explode(
":", $a_insert_at);
2284 $t_id = explode(
":", $t[
"id"]);
2287 if ($a_insert_at !=
"") {
2289 $par->create($page, $insert_at[0], $insert_at[1]);
2291 $par = $a_pg_obj->getContentObject($pc_id[0], $pc_id[1]);
2294 if ($a_insert_at !=
"") {
2295 $pc_id = ($a_new_pc_id !=
"")
2297 : $a_pg_obj->generatePCId();
2298 $par->writePCId($pc_id);
2299 $this->inserted_pc_id = $pc_id;
2301 $this->inserted_pc_id = $pc_id[1];
2304 $par->setLanguage(
$ilUser->getLanguage());
2305 $par->setCharacteristic($t[
"class"]);
2307 $t2 = $par->input2xml($t[
"text"],
true,
false);
2308 $this->log->debug(
"step 3: " . substr($t2, 0, 1000));
2311 $this->log->debug(
"step 4: " . substr($t2, 0, 1000));
2313 $updated = $par->setText($t2,
true);
2315 if ($updated !==
true) {
2320 $updated = $par->updatePage($a_pg_obj);
static _lookupLogin($a_user_id)
lookup login
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
create(&$a_pg_obj, $a_hier_id, $a_pc_id="", $from_placeholder=false)
Create paragraph node (incl.
getLastSavedPCId($a_pg_obj, $a_as_ajax_str=false)
Get last inserted pc ids.
createAfter($node)
Create paragraph node (incl.
static attribsToArray($a_str)
converts a string of format var1 = "val1" var2 = "val2" ...
static getBBMap()
Get bb to xml tag map.
static strPos($a_haystack, $a_needle, $a_offset=null)
static xml2outputReplaceLists($a_text)
Replaces with *.
getSubCharacteristic()
get attribute subcharacteristic
xpath_new_context($dom_document)
static beforePageDelete($a_page)
Before page is being deleted.
getDownloadTitle()
get attribute download title
setShowLineNumbers($a_char)
set attribute showlinenumbers
removeTrailingBr($a_str)
Remove trailing
static xml2outputJS($s_text)
Prepare content for js output.
static segmentString($a_haystack, $a_needles)
Segments a string into an array at each position of a substring.
static handleAjaxContentPost($text)
Post input2xml handling of ajax content.
domxml_open_mem($str, $mode=0, &$error=null)
static getLocalJsPaths()
Get paths of necessary js files.
input2xml($a_text, $a_wysiwyg=0, $a_handle_lists=true)
xpath_eval($xpath_context, $eval_str, $contextnode=null)
setDownloadTitle($a_char)
set attribute download title
setText($a_text, $a_auto_split=false)
Set (xml) content of text paragraph.
static _lookupId($a_user_str)
Lookup id by login.
static replaceByChilds($node)
Replace a node by its child.
setNode($a_node)
Set Page Content Node.
setType($a_type)
Set Type.
static subStr($a_str, $a_start, $a_length=null)
static getXMLTagMap()
Get tag to bb map.
getLanguage()
get language
getParagraphSequenceContent($a_pg_obj)
Get paragraph sequenc of current paragraph.
static xml2output($a_text, $a_wysiwyg=false, $a_replace_lists=true, $unmask=true)
Converts xml from DB to output in edit textarea.
static _getAllReferences($a_id)
get all reference ids of object
setLanguage($a_lang)
set language
static replaceBBTagByMatching(string $start_tag, string $end_tag, string $xml_tag_name, string $text, array $attribs)
Transforms [iln...]...[] to <IntLink...>...</IntLink>, if content is valid, otherwise it removes the ...
getAutoIndent()
Get AutoIndent (Code Paragraphs)
init()
Init page content component.
static strIPos($a_haystack, $a_needle, $a_offset=null)
static autoLinkGlossariesPage($a_page, $a_terms)
Auto link glossary of whole page.
getType()
Need to override getType from ilPageContent to distinguish between Pararagraph and Source...
setSubCharacteristic($a_char)
set attribute subcharacteristic
createBeforeNode(&$node)
Create new page content (incl.
static afterPageHistoryEntry($a_page, DOMDocument $a_old_domdoc, $a_old_xml, $a_old_nr)
After page history entry has been created.
static input2xmlReplaceLists($a_text)
Converts xml from DB to output in edit textarea.
foreach($_POST as $key=> $value) $res
static handleAjaxContent($a_content)
Handle ajax content.
static linkTermsInDom($a_dom, $a_terms, $a_par_node=null)
Link terms in a dom page object in bb style.
insert(\ilPageObject $page, $a_content, $a_char, $a_pc_id, $a_insert_at="", $a_new_pc_id="")
Save input coming from ajax.
updatePage($a_page)
Update page object (it would be better to have this centralized and to change the constructors and pa...
static isValidTagContent(string $content)
createAtNode(&$node)
Create new page content (incl.
setCharacteristic($a_char)
Set Characteristic of paragraph.
static strrPos($a_haystack, $a_needle, $a_offset=null)
getText($a_short_mode=false)
Get (xml) content of paragraph.
autoLinkGlossaries($a_glos)
Auto link glossaries.
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
static changeName($node, $name, $keep_attributes=true)
Change name of a node.
getCharacteristic()
Get characteristic of paragraph.
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 replaceBBCode($a_text, $a_bb, $a_tag)
Replace bb code.
static saveAnchors($a_page, $a_domdoc)
Save anchors.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
checkTextArray($text)
Check text array.
static _lookupType($a_id, $a_reference=false)
lookup object type
static _readAnchors($a_parent_type, $a_page_id, $a_page_lang="-")
Read anchors of a page.
autoSplit($a_text)
This function splits a paragraph text that has been already processed with input2xml at each header p...
static _saveAnchor($a_parent_type, $a_page_id, $a_page_lang, $a_anchor_name)
Save an anchor.
static _deleteAnchors($a_parent_type, $a_page_id, $a_page_lang)
Delete anchors of a page.
static addParent($node, $name)
Add parent.
static _input2xml($a_text, $a_lang, $a_wysiwyg=0, $a_handle_lists=true)
converts user input to xml
createPageContentNode($a_set_this_node=true)
Create page content node (always use this method first when adding a new element) ...
static _getCommonBBButtons()
Get common bb buttons.
const DOMXML_LOAD_PARSING
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
saveJS( $a_pg_obj, $a_content, $a_char, $a_pc_id, $a_insert_at="", $from_placeholder=false)
Save input coming from ajax.
static afterPageUpdate($a_page, DOMDocument $a_domdoc, $a_xml, $a_creation)
After page has been updated (or created)
getOnloadCode($a_mode)
Get onload code.
handleNextBr($a_str)
Remove preceding
static saveMetaKeywords($a_page, $a_domdoc)
save all keywords
getJavascriptFiles($a_mode)
Get Javascript files.
static intLinks2xml($a_text)
internal links to xml
getShowLineNumbers()
get attribute showlinenumbers