45 "quot" =>
"Quotation",
60 while (is_int(strpos($a_str,
"="))) {
61 $eq_pos = strpos($a_str,
"=");
62 $qu1_pos = strpos($a_str,
"\"");
63 $qu2_pos = strpos(substr($a_str, $qu1_pos + 1),
"\"") + $qu1_pos + 1;
64 if (is_int($eq_pos) && is_int($qu1_pos) && is_int($qu2_pos)) {
65 $var = trim(substr($a_str, 0, $eq_pos));
66 $val = trim(substr($a_str, $qu1_pos + 1, ($qu2_pos - $qu1_pos) - 1));
67 $attribs[$var] = $val;
68 $a_str = substr($a_str, $qu2_pos + 1);
76 public function init(): void
80 $this->
user = $DIC->user();
81 $this->
lng = $DIC->language();
90 return self::$bb_tags;
98 return array_flip(self::$bb_tags);
103 parent::setNode($a_node);
106 for (
$i = 0, $iMax = count($childs);
$i < $iMax;
$i++) {
107 if ($childs[
$i]->node_name() ==
"Paragraph") {
108 $this->par_node = $childs[
$i];
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",
"");
131 $this->par_node = $this->dom->create_element(
"Paragraph");
132 $this->par_node = $this->node->append_child($this->par_node);
133 $this->par_node->set_attribute(
"Language",
"");
145 $this->node = $succ_node->insert_before($this->node, $succ_node);
148 $this->node = $parent_node->append_child($this->node);
150 $this->par_node = $this->dom->create_element(
"Paragraph");
151 $this->par_node = $this->node->append_child($this->par_node);
152 $this->par_node->set_attribute(
"Language",
"");
162 string $a_pc_id =
"",
163 bool $from_placeholder =
false 167 $this->node = $this->dom->create_element(
"PageContent");
178 $this->par_node = $this->dom->create_element(
"Paragraph");
179 $this->par_node = $this->node->append_child($this->par_node);
180 $this->par_node->set_attribute(
"Language",
"");
191 bool $a_auto_split =
false 197 $text = [[
"level" => 0,
"text" => $text]];
201 $orig_characteristic =
"";
205 $t = $text[0][
"text"] ??
"";
207 '<?xml version="1.0" encoding="UTF-8"?><Paragraph>' . $t .
'</Paragraph>',
213 $children = $this->par_node->child_nodes();
214 for (
$i = 0, $iMax = count($children);
$i < $iMax;
$i++) {
215 $this->par_node->remove_child($children[
$i]);
220 $path =
"//Paragraph";
222 if (count(
$res->nodeset) == 1) {
223 $new_par_node =
$res->nodeset[0];
224 $new_childs = $new_par_node->child_nodes();
226 for (
$i = 0, $iMax = count($new_childs);
$i < $iMax;
$i++) {
227 $cloned_child = $new_childs[
$i]->clone_node(
true);
228 $this->par_node->append_child($cloned_child);
234 if ((count($text) > 1) && (substr($orig_characteristic, 0, 8) ==
"Headline")) {
235 $orig_characteristic =
"";
237 if (isset($text[0][
"level"]) && $text[0][
"level"] > 0) {
238 $this->par_node->set_attribute(
"Characteristic",
'Headline' . $text[0][
"level"]);
246 for (
$i = 1, $iMax = count($text);
$i < $iMax;
$i++) {
249 $next_par->createAfter($c_node);
251 if ($text[
$i][
"level"] > 0) {
252 $next_par->setCharacteristic(
"Headline" . $text[
$i][
"level"]);
254 $next_par->setCharacteristic($orig_characteristic);
256 $ok = $next_par->setText($text[
$i][
"text"],
false);
257 $c_node = $next_par->node;
264 $check = array_reduce($text,
function ($t,
$i) {
265 return $t .
$i[
"text"];
267 $text = str_replace(
"<br>",
"\n",
$check);
268 $text = str_replace(
"<br/>",
"\n", $text);
269 $text = str_replace(
"<br />",
"\n", $text);
270 $text = str_replace(
"</SimpleListItem>",
"</SimpleListItem>\n", $text);
271 $text = str_replace(
"<SimpleBulletList>",
"\n<SimpleBulletList>", $text);
272 $text = str_replace(
"<SimpleNumberedList>",
"\n<SimpleNumberedList>", $text);
273 $text = str_replace(
"<Paragraph>\n",
"<Paragraph>", $text);
274 $text = str_replace(
"</Paragraph>",
"</Paragraph>\n", $text);
276 $text =
'<?xml version="1.0" encoding="UTF-8"?><Paragraph>' . $text .
'</Paragraph>';
278 $doc->loadXML($text);
279 $error = $doc->getErrors();
281 foreach ($error as
$e) {
282 $e = str_replace(
" in Entity",
"", $e);
283 $estr .= $e .
"<br />";
286 $estr .=
"<br />" . $text;
299 foreach ($text as $t) {
300 $check .=
"<Paragraph>" . $t[
"text"] .
"</Paragraph>";
305 '<?xml version="1.0" encoding="UTF-8"?><Paragraph>' .
$check .
'</Paragraph>',
312 if (is_string($error) && $error !=
"") {
321 $dom->recover =
true;
323 for (
$i = 0, $iMax = count($text);
$i < $iMax;
$i++) {
325 '<?xml version="1.0" encoding="UTF-8"?><Paragraph>' . $text[
$i][
"text"] .
'</Paragraph>',
326 LIBXML_NOWARNING | LIBXML_NOERROR
329 if ($node->nodeName ==
"Paragraph") {
331 foreach ($node->childNodes as $child) {
332 $inner .=
$dom->saveXML($child);
334 $text[
$i][
"text"] = $inner;
344 public function getText(
bool $a_short_mode =
false): string
346 if (is_object($this->par_node)) {
348 $childs = $this->par_node->child_nodes();
349 for (
$i = 0, $iMax = count($childs);
$i < $iMax;
$i++) {
350 $content .= $this->dom->dump_node($childs[
$i]);
364 $childs = $this->par_node->parent_node()->parent_node()->child_nodes();
370 for (
$i = 0, $iMax = count($childs);
$i < $iMax;
$i++) {
371 $pchilds = $childs[
$i]->child_nodes();
372 if ($pchilds[0]->node_name() ==
"Paragraph" &&
373 $pchilds[0]->get_attribute(
"Characteristic") !=
"Code") {
374 $cur_seq[] = $childs[
$i];
377 if ($childs[
$i]->get_attribute(
"PCID") == $pc_id &&
378 $childs[
$i]->get_attribute(
"HierId") ==
$hier_id) {
396 foreach ($seq as $p_node) {
397 $ids .= $id_sep . $p_node->get_attribute(
"HierId") .
":" . $p_node->get_attribute(
"PCID");
399 $p_node->get_attribute(
"HierId"),
400 $p_node->get_attribute(
"PCID")
402 $s_text = $po->getText();
403 $s_text = $po->xml2output($s_text,
true,
false);
404 $char = $po->getCharacteristic();
414 return $ids . $content;
422 if (!empty($a_char)) {
423 $this->par_node->set_attribute(
"Characteristic", $a_char);
425 if ($this->par_node->has_attribute(
"Characteristic")) {
426 $this->par_node->remove_attribute(
"Characteristic");
433 if (is_object($this->par_node)) {
434 return $this->par_node->get_attribute(
"Characteristic");
441 if (!empty($a_char)) {
442 $this->par_node->set_attribute(
"SubCharacteristic", $a_char);
444 if ($this->par_node->has_attribute(
"SubCharacteristic")) {
445 $this->par_node->remove_attribute(
"SubCharacteristic");
452 return (
string) $this->par_node->get_attribute(
"AutoIndent");
457 if (!empty($a_char)) {
458 $this->par_node->set_attribute(
"AutoIndent", $a_char);
460 if ($this->par_node->has_attribute(
"AutoIndent")) {
461 $this->par_node->remove_attribute(
"AutoIndent");
468 return $this->par_node->get_attribute(
"SubCharacteristic");
473 if (!empty($a_char)) {
474 $this->par_node->set_attribute(
"DownloadTitle", $a_char);
476 if ($this->par_node->has_attribute(
"DownloadTitle")) {
477 $this->par_node->remove_attribute(
"DownloadTitle");
484 return $this->par_node->get_attribute(
"DownloadTitle");
489 $a_char = empty($a_char)
493 $this->par_node->set_attribute(
"ShowLineNumbers", $a_char);
498 return $this->par_node->get_attribute(
"ShowLineNumbers");
503 $this->par_node->set_attribute(
"Language", $a_lang);
508 return $this->par_node->get_attribute(
"Language");
513 bool $a_wysiwyg =
false,
514 bool $a_handle_lists =
true 524 $a_text = preg_replace(
'/\[' . $a_bb .
'\]/i',
"<" . $a_tag .
">", $a_text);
525 $a_text = preg_replace(
'/\[\/' . $a_bb .
'\]/i',
"</" . $a_tag .
">", $a_text);
537 bool $a_wysiwyg =
false,
538 bool $a_handle_lists =
true 541 if (!defined(
'COPAGE_TEST')) {
545 $log->
debug(
"...text: " . substr($a_text, 0, 1000));
547 $log->
debug(
"...wysiwyg: " . $a_wysiwyg);
548 $log->
debug(
"...handle_lists: " . $a_handle_lists);
556 $a_text = str_replace(
"<br />", chr(10), $a_text);
561 $a_text = trim($a_text);
567 $a_text = str_replace(
"&",
"&", $a_text);
569 $a_text = str_replace(
"<",
"<", $a_text);
570 $a_text = str_replace(
">",
">", $a_text);
580 $a_text = str_replace(chr(13) . chr(10),
"<br />", $a_text);
581 $a_text = str_replace(chr(13),
"<br />", $a_text);
582 $a_text = str_replace(chr(10),
"<br />", $a_text);
584 if ($a_handle_lists) {
588 foreach (self::getBBMap() as $bb => $tag) {
590 $a_text = str_replace(
"[" . $bb .
"][/" . $bb .
"]",
"", $a_text);
593 $a_text = self::replaceBBCode($a_text, $bb, $tag);
596 $a_text = self::intLinks2xml($a_text);
599 $ws =
"[ \t\r\f\v\n]*";
601 while (preg_match(
"~\[(xln$ws(url$ws=$ws\"([^\"])*\")$ws(target$ws=$ws(\"(Glossary|FAQ|Media)\"))?$ws)\]\[\/xln\]~i", $a_text, $found)) {
602 $a_text = str_replace($found[0],
"", $a_text);
604 while (preg_match(
'~\[(xln$ws(url$ws=$ws(([^]])*)))$ws\]\[\/xln\]~i', $a_text, $found)) {
605 $a_text = str_replace($found[0],
"", $a_text);
608 while (preg_match(
"~\[(xln$ws(url$ws=$ws\"([^\"])*\")$ws(target$ws=$ws(\"(Glossary|FAQ|Media)\"))?$ws)\]~i", $a_text, $found)) {
610 $attribs = self::attribsToArray($found[2]);
611 if (isset($attribs[
"url"])) {
612 $a_text = self::replaceBBTagByMatching(
613 "[" . $found[1] .
"]",
618 "Href" => $attribs[
"url"]
622 if ($old_text === $a_text) {
623 $a_text = str_replace(
"[" . $found[1] .
"]",
"[error: " . $found[1] .
"]", $a_text);
639 $ws =
"[ \t\r\f\v\n]*";
640 while (preg_match(
"~\[(anc$ws(name$ws=$ws\"([^\"])*\")$ws)\]~i", $a_text, $found)) {
641 $attribs = self::attribsToArray($found[2]);
642 $a_text = self::replaceBBTagByMatching(
643 "[" . $found[1] .
"]",
648 "Name" => $attribs[
"name"]
654 while (preg_match(
"~\[(marked$ws(class$ws=$ws\"([^\"])*\")$ws)\]~i", $a_text, $found)) {
655 $attribs = self::attribsToArray($found[2]);
656 if (isset($attribs[
"class"])) {
657 $a_text = self::replaceBBTagByMatching(
658 "[" . $found[1] .
"]",
663 "Class" => $attribs[
"class"]
667 $a_text = str_replace(
"[" . $found[1] .
"]",
"[error:marked" . $found[1] .
"]", $a_text);
671 if (!is_null(
$log)) {
672 $log->
debug(
"...finish: " . substr($a_text, 0, 1000));
680 $use_internal_errors = libxml_use_internal_errors(
true);
681 $sxe = simplexml_load_string(
"<?xml version='1.0'?><dummy>" . $content .
"</dummy>");
682 libxml_use_internal_errors($use_internal_errors);
683 return ($sxe !==
false);
694 string $xml_tag_name,
699 foreach ($attribs as
$key => $value) {
701 $attrib_str .=
' ' .
$key .
'="' . $value .
'"';
707 $pos1 = strpos($text, $start_tag);
710 if ($end_tag !=
"") {
711 $pos2 = strpos($text, $end_tag, $pos1 + strlen($start_tag));
712 if (is_int($pos1) && is_int($pos2)) {
713 $between = substr($text, $pos1 + strlen($start_tag), $pos2 - ($pos1 + strlen($start_tag)));
714 $ok = self::isValidTagContent($between);
721 $short = ($end_tag ==
"")
725 $slash_chars =
'/[]?()$*';
728 $replace_str = addcslashes($start_tag, $slash_chars);
729 $replace_str = str_replace(
"+",
"\\+", $replace_str);
731 $text = preg_replace(
732 '/' . $replace_str .
'/i',
733 "<" . $xml_tag_name . $attrib_str . $short .
">",
739 if ($end_tag !=
"") {
740 $text = preg_replace(
'~' . addcslashes($end_tag, $slash_chars) .
'~i',
"</" . $xml_tag_name .
">", $text, 1);
745 $text = preg_replace(
746 '/' . addcslashes($start_tag, $slash_chars) .
'/i',
754 $text = preg_replace(
755 '~' . addcslashes($end_tag, $slash_chars) .
'~i',
773 $objDefinition = $DIC[
"objDefinition"];
775 $rtypes = $objDefinition->getAllRepositoryTypes();
779 $ws =
"[ \t\r\f\v\n]*";
780 $ltypes =
"page|chap|term|media|obj|dfile|sess|wpage|ppage|" . implode(
"|", $rtypes);
782 while (preg_match(
'~\[(iln' . $ws .
'((inst' . $ws .
'=' . $ws .
'([\"0-9])*)?' . $ws .
783 "((" . $ltypes .
")$ws=$ws([\"0-9])*)$ws" .
784 "(target$ws=$ws(\"(New|FAQ|Media)\"))?$ws(anchor$ws=$ws(\"([^\"])*\"))?$ws))\]\[\/iln\]~i", $a_text, $found)) {
785 $a_text = str_replace($found[0],
"", $a_text);
787 while (preg_match(
'~\[(iln' . $ws .
'((inst' . $ws .
'=' . $ws .
'([\"0-9])*)?' . $ws .
788 "((" . $ltypes .
")$ws=$ws([\"0-9])*)$ws" .
789 "(target$ws=$ws(\"(New|FAQ|Media)\"))?$ws(anchor$ws=$ws(\"([^\"])*\"))?$ws))\]~i", $a_text, $found)) {
790 $attribs = self::attribsToArray($found[2]);
791 $inst_str = $attribs[
"inst"] ??
"";
793 if (isset($attribs[
"page"])) {
794 $a_text = self::replaceBBTagByMatching(
795 "[" . $found[1] .
"]",
800 "Target" =>
"il_" . $inst_str .
"_pg_" . $attribs[
'page'],
801 "Type" =>
"PageObject",
802 "TargetFrame" => $found[10] ??
"",
803 "Anchor" => $attribs[
"anchor"] ??
"" 808 elseif (isset($attribs[
"chap"])) {
809 $a_text = self::replaceBBTagByMatching(
810 "[" . $found[1] .
"]",
815 "Target" =>
"il_" . $inst_str .
"_st_" . $attribs[
'chap'],
816 "Type" =>
"StructureObject",
817 "TargetFrame" => $found[10] ??
"" 822 elseif (isset($attribs[
"term"])) {
823 $a_text = self::replaceBBTagByMatching(
824 "[" . $found[1] .
"]",
829 "Target" =>
"il_" . $inst_str .
"_git_" . $attribs[
'term'],
830 "Type" =>
"GlossaryItem",
831 "TargetFrame" => (($found[10] ??
"") ==
"New")
838 elseif (isset($attribs[
"wpage"])) {
839 $a_text = self::replaceBBTagByMatching(
840 "[" . $found[1] .
"]",
845 "Target" =>
"il_" . $inst_str .
"_wpage_" . $attribs[
'wpage'],
846 "Type" =>
"WikiPage",
847 "Anchor" => $attribs[
"anchor"] ??
"" 852 elseif (isset($attribs[
"ppage"])) {
853 $a_text = self::replaceBBTagByMatching(
854 "[" . $found[1] .
"]",
859 "Target" =>
"il_" . $inst_str .
"_ppage_" . $attribs[
'ppage'],
860 "Type" =>
"PortfolioPage" 865 elseif (isset($attribs[
"media"])) {
866 $a_text = self::replaceBBTagByMatching(
867 "[" . $found[1] .
"]",
872 "Target" =>
"il_" . $inst_str .
"_mob_" . $attribs[
'media'],
873 "Type" =>
"MediaObject",
874 "TargetFrame" => $found[10] ??
"" 879 elseif (isset($attribs[
"dfile"])) {
880 $a_text = self::replaceBBTagByMatching(
881 "[" . $found[1] .
"]",
886 "Target" =>
"il_" . $inst_str .
"_dfile_" . $attribs[
'dfile'],
894 foreach ($objDefinition->getAllRepositoryTypes() as $t) {
895 if (isset($attribs[$t])) {
896 $obj_id = $attribs[$t];
899 if (isset($attribs[
"obj"])) {
900 $obj_id = $attribs[
"obj"];
904 if ($inst_str ==
"") {
905 $a_text = self::replaceBBTagByMatching(
906 "[" . $found[1] .
"]",
911 "Target" =>
"il_" . $inst_str .
"_obj_" . $obj_id,
912 "Type" =>
"RepositoryItem" 916 $a_text = self::replaceBBTagByMatching(
917 "[" . $found[1] .
"]",
922 "Target" =>
"il_" . $inst_str .
"_" . $found[6] .
"_" . $obj_id,
923 "Type" =>
"RepositoryItem" 928 $a_text = preg_replace(
'/\[' . $found[1] .
'\]/i',
"[error: iln" . $found[1] .
"]", $a_text);
933 while (preg_match(
"~\[(iln$ws((inst$ws=$ws([\"0-9])*)?" . $ws .
"media$ws=$ws([\"0-9])*)$ws)/\]~i", $a_text, $found)) {
934 $attribs = self::attribsToArray($found[2]);
935 $inst_str = $attribs[
"inst"] ??
"";
936 $a_text = self::replaceBBTagByMatching(
937 "[" . $found[1] .
"/]",
942 "Target" =>
"il_" . $inst_str .
"_mob_" . $attribs[
'media'],
943 "Type" =>
"MediaObject" 949 while (preg_match(
"~\[(iln$ws((inst$ws=$ws([\"0-9])*)?" . $ws .
"user$ws=$ws(\"([^\"])*)\")$ws)/\]~i", $a_text, $found)) {
950 $attribs = self::attribsToArray($found[2]);
951 $inst_str = $attribs[
"inst"] ??
"";
953 $a_text = self::replaceBBTagByMatching(
954 "[" . $found[1] .
"/]",
959 "Target" =>
"il_" . $inst_str .
"_user_" . $user_id,
977 $rows = explode(
"<br />", $a_text .
"<br />");
985 foreach (
$rows as $row) {
987 if (str_replace(
"#",
"*", substr($row, 0, 3)) ==
"***") {
989 } elseif (str_replace(
"#",
"*", substr($row, 0, 2)) ==
"**") {
991 } elseif (str_replace(
"#",
"*", substr($row, 0, 1)) ==
"*") {
996 if ($level < $old_level) {
997 for (
$i = $old_level;
$i > $level;
$i--) {
998 $text .=
"</SimpleListItem></" . $clist[
$i] .
">";
1001 $text .=
"</SimpleListItem>";
1003 } elseif ($old_level > 0 && $level > 0 && ($level == $old_level)) {
1004 $text .=
"</SimpleListItem>";
1005 } elseif (($level == $old_level) && $text !=
"") {
1010 if ($level > $old_level) {
1011 for (
$i = $old_level + 1;
$i <= $level;
$i++) {
1012 if (substr($row,
$i - 1, 1) ==
"*") {
1013 $clist[
$i] =
"SimpleBulletList";
1015 $clist[
$i] =
"SimpleNumberedList";
1017 $text .=
"<" . $clist[
$i] .
"><SimpleListItem>";
1019 } elseif ($old_level > 0 && $level > 0) {
1020 $text .=
"<SimpleListItem>";
1022 $text .= substr($row, $level);
1024 $old_level = $level;
1028 if (substr($text, strlen($text) - 6) ==
"<br />") {
1029 $text = substr($text, 0, strlen($text) - 6);
1043 $list_start =
false;
1047 "</SimpleListItem>",
"<SimpleListItem>",
"<SimpleListItem/>",
"<SimpleNumberedList>",
"</SimpleNumberedList>"));
1049 $current_list = array();
1051 for (
$i = 0, $iMax = count($segments);
$i < $iMax;
$i++) {
1052 if ($segments[
$i] ==
"<SimpleBulletList>") {
1053 if (count($current_list) == 0) {
1056 $current_list[] =
"*";
1058 } elseif ($segments[
$i] ==
"<SimpleNumberedList>") {
1059 if (count($current_list) == 0) {
1062 $current_list[] =
"#";
1064 } elseif ($segments[
$i] ==
"</SimpleBulletList>") {
1065 array_pop($current_list);
1067 } elseif ($segments[
$i] ==
"</SimpleNumberedList>") {
1068 array_pop($current_list);
1070 } elseif ($segments[
$i] ==
"<SimpleListItem>") {
1072 } elseif ($segments[
$i] ==
"</SimpleListItem>") {
1074 } elseif ($segments[
$i] ==
"<SimpleListItem/>") {
1077 $list_start =
false;
1079 foreach ($current_list as $list) {
1088 $list_start =
false;
1090 foreach ($current_list as $list) {
1094 $text .= $segments[
$i];
1103 if ((($segments[count($segments) - 1] ??
"") ===
"</SimpleBulletList>" ||
1104 ($segments[count($segments) - 1] ??
"") ===
"</SimpleNumberedList>") &&
1105 substr($text, strlen($text) - 6) ===
"<br />") {
1106 $text = substr($text, 0, -6);
1119 $segments = array();
1122 $nothing_found =
false;
1123 while (!$nothing_found) {
1124 $nothing_found =
true;
1126 foreach ($a_needles as $needle) {
1127 $pos = stripos($a_haystack, $needle);
1128 if (is_int($pos) && ($pos < $found || $found == -1)) {
1130 $found_needle = $needle;
1131 $nothing_found =
false;
1135 $segments[] = substr($a_haystack, 0, $found);
1136 $a_haystack = substr($a_haystack, $found);
1139 $segments[] = substr($a_haystack, 0, strlen($found_needle));
1140 $a_haystack = substr($a_haystack, strlen($found_needle));
1143 if ($a_haystack !=
"") {
1144 $segments[] = $a_haystack;
1157 bool $a_wysiwyg =
false,
1158 bool $a_replace_lists =
true,
1168 foreach (self::getBBMap() as $bb => $tag) {
1169 $a_text = preg_replace(
'~<' . $tag .
'[^>]*>~i',
"[" . $bb .
"]", $a_text);
1170 $a_text = preg_replace(
'~</' . $tag .
'>~i',
"[/" . $bb .
"]", $a_text);
1171 $a_text = preg_replace(
'~<' . $tag .
'/>~i',
"[" . $bb .
"][/" . $bb .
"]", $a_text);
1175 if ($a_replace_lists) {
1182 while (preg_match(
'~<IntLink(' . $any .
')>~i', $a_text, $found)) {
1183 $attribs = self::attribsToArray($found[1]);
1184 $target = explode(
"_", $attribs[
"Target"]);
1186 $inst_str = (!is_int(strpos($attribs[
"Target"],
"__")))
1187 ? $inst_str =
"inst=\"" . ($target[1] ??
'') .
"\" " 1189 switch ($attribs[
"Type"]) {
1191 $tframestr = (!empty($attribs[
"TargetFrame"]))
1192 ?
" target=\"" . $attribs[
"TargetFrame"] .
"\"" 1194 $ancstr = (!empty($attribs[
"Anchor"]))
1195 ?
' anchor="' . $attribs[
"Anchor"] .
'"' 1197 $a_text = preg_replace(
'~<IntLink' . $found[1] .
'>~i',
"[iln " . $inst_str .
"page=\"" .
$target_id .
"\"$tframestr$ancstr]", $a_text);
1200 case "StructureObject":
1201 $tframestr = (!empty($attribs[
"TargetFrame"]))
1202 ?
" target=\"" . $attribs[
"TargetFrame"] .
"\"" 1204 $a_text = preg_replace(
'~<IntLink' . $found[1] .
'>~i',
"[iln " . $inst_str .
"chap=\"" . $target_id .
"\"$tframestr]", $a_text);
1207 case "GlossaryItem":
1208 $tframestr = (empty($attribs[
"TargetFrame"]) || $attribs[
"TargetFrame"] ==
"Glossary")
1210 :
" target=\"" . $attribs[
"TargetFrame"] .
"\"";
1211 $a_text = preg_replace(
'~<IntLink' . $found[1] .
'>~i',
"[iln " . $inst_str .
"term=\"" . $target_id .
"\"" . $tframestr .
"]", $a_text);
1216 $ancstr = (!empty($attribs[
"Anchor"]))
1217 ?
' anchor="' . $attribs[
"Anchor"] .
'"' 1219 $a_text = preg_replace(
'~<IntLink' . $found[1] .
'>~i',
"[iln " . $inst_str .
"wpage=\"" . $target_id .
"\"" . $tframestr . $ancstr .
"]", $a_text);
1222 case "PortfolioPage":
1224 $a_text = preg_replace(
'~<IntLink' . $found[1] .
'>~i',
"[iln " . $inst_str .
"ppage=\"" . $target_id .
"\"" . $tframestr .
"]", $a_text);
1228 if (empty($attribs[
"TargetFrame"])) {
1229 $a_text = preg_replace(
'~<IntLink' . $found[1] .
'>~i',
"[iln " . $inst_str .
"media=\"" . $target_id .
"\"/]", $a_text);
1231 $a_text = preg_replace(
'~<IntLink' . $found[1] .
'>~i',
"[iln media=\"" . $target_id .
"\"" .
1232 " target=\"" . ($attribs[
"TargetFrame"] ??
"") .
"\"]", $a_text);
1237 case "RepositoryItem":
1238 if ($inst_str ==
"") {
1241 $rtype = ($target[count($target) - 2] ??
"");
1244 $a_text = preg_replace(
'~<IntLink' . $found[1] .
'>~i',
"[iln " . $inst_str .
"$target_type=\"" . $target_id .
"\"" . $tframestr .
"]", $a_text);
1249 $a_text = preg_replace(
'~<IntLink' . $found[1] .
'>~i',
"[iln " . $inst_str .
"dfile=\"" . $target_id .
"\"" . $tframestr .
"]", $a_text);
1254 $a_text = preg_replace(
'~<IntLink' . $found[1] .
'>~i',
"[iln " . $inst_str .
"user=\"" .
ilObjUser::_lookupLogin((
int) $target_id) .
"\"/]", $a_text);
1258 $a_text = preg_replace(
'~<IntLink' . $found[1] .
'>~i',
"[iln]", $a_text);
1262 $a_text = str_replace(
"</IntLink>",
"[/iln]", $a_text);
1265 while (preg_match(
'~<ExtLink(' . $any .
')>~i', $a_text, $found)) {
1266 $attribs = self::attribsToArray($found[1]);
1269 if (in_array(($attribs[
"TargetFrame"] ??
""), array(
"FAQ",
"Glossary",
"Media"))) {
1270 $tstr =
' target="' . ($attribs[
"TargetFrame"] ??
"") .
'"';
1272 $a_text = str_replace(
"<ExtLink" . $found[1] .
">",
"[xln url=\"" . ($attribs[
"Href"] ??
"") .
"\"$tstr]", $a_text);
1274 $a_text = str_replace(
"</ExtLink>",
"[/xln]", $a_text);
1277 while (preg_match(
'~<Anchor(' . $any .
'/)>~i', $a_text, $found)) {
1278 $attribs = self::attribsToArray($found[1]);
1279 $a_text = str_replace(
"<Anchor" . $found[1] .
">",
"[anc name=\"" . ($attribs[
"Name"] ??
"") .
"\"][/anc]", $a_text);
1281 while (preg_match(
'~<Anchor(' . $any .
')>~i', $a_text, $found)) {
1282 $attribs = self::attribsToArray($found[1]);
1283 $a_text = str_replace(
"<Anchor" . $found[1] .
">",
"[anc name=\"" . ($attribs[
"Name"] ??
"") .
"\"]", $a_text);
1285 $a_text = str_replace(
"</Anchor>",
"[/anc]", $a_text);
1288 while (preg_match(
'~<Marked(' . $any .
')>~i', $a_text, $found)) {
1289 $attribs = self::attribsToArray($found[1]);
1290 $a_text = str_replace(
"<Marked" . $found[1] .
">",
"[marked class=\"" . ($attribs[
"Class"] ??
"") .
"\"]", $a_text);
1292 $a_text = str_replace(
"</Marked>",
"[/marked]", $a_text);
1296 $a_text = str_replace(
"<br />",
"\n", $a_text);
1297 $a_text = str_replace(
"<br/>",
"\n", $a_text);
1302 $a_text = str_replace(
"{",
"{", $a_text);
1303 $a_text = str_replace(
"}",
"}", $a_text);
1307 $a_text = str_replace(
"<",
"<", $a_text);
1308 $a_text = str_replace(
">",
">", $a_text);
1312 $a_text = str_replace(
""",
"\"", $a_text);
1316 $a_text = str_replace(
"&",
"&", $a_text);
1320 $a_text = str_replace(
"<",
"&lt;", $a_text);
1321 $a_text = str_replace(
">",
"&gt;", $a_text);
1335 $a_text = str_replace(
"=<SimpleBulletList>",
"=<br /><SimpleBulletList>", $a_text);
1336 $a_text = str_replace(
"=<SimpleNumberedList>",
"=<br /><SimpleNumberedList>", $a_text);
1337 $a_text = str_replace(
"</SimpleBulletList>=",
"</SimpleBulletList><br />=", $a_text);
1338 $a_text = str_replace(
"</SimpleNumberedList>=",
"</SimpleNumberedList><br />=", $a_text);
1339 $a_text =
"<br />" . $a_text .
"<br />";
1344 while ($c_text !=
"") {
1347 $s1 = strpos($c_text,
"<br />=");
1350 $s2 = strpos($c_text,
"<br />==");
1351 if (is_int($s2) && $s2 <= $s1) {
1353 $s3 = strpos($c_text,
"<br />===");
1354 if (is_int($s3) && $s3 <= $s2) {
1356 $n = strpos($c_text,
"<br />", $s3 + 1);
1357 if ($n > ($s3 + 9) && substr($c_text, $n - 3, 9) ==
"===<br />") {
1360 if ($s3 > 0 || $head !=
"") {
1362 $chunks[] = array(
"level" => 0,
1366 $chunks[] = array(
"level" => 3,
1367 "text" => trim(substr($c_text, $s3 + 9, $n - $s3 - 12)));
1368 $c_text = $this->
handleNextBr(substr($c_text, $n + 6));
1371 $head .= substr($c_text, 0, $n);
1372 $c_text = substr($c_text, $n);
1376 $n = strpos($c_text,
"<br />", $s2 + 1);
1377 if ($n > ($s2 + 8) && substr($c_text, $n - 2, 8) ==
"==<br />") {
1380 if ($s2 > 0 || $head !=
"") {
1382 $chunks[] = array(
"level" => 0,
1386 $chunks[] = array(
"level" => 2,
"text" => trim(substr($c_text, $s2 + 8, $n - $s2 - 10)));
1387 $c_text = $this->
handleNextBr(substr($c_text, $n + 6));
1390 $head .= substr($c_text, 0, $n);
1391 $c_text = substr($c_text, $n);
1395 $n = strpos($c_text,
"<br />", $s1 + 1);
1396 if ($n > ($s1 + 7) && substr($c_text, $n - 1, 7) ==
"=<br />") {
1398 if ($s1 > 0 || $head !=
"") {
1399 $chunks[] = array(
"level" => 0,
1403 $chunks[] = array(
"level" => 1,
"text" => trim(substr($c_text, $s1 + 7, $n - $s1 - 8)));
1404 $c_text = $this->
handleNextBr(substr($c_text, $n + 6));
1407 $head .= substr($c_text, 0, $n);
1408 $c_text = substr($c_text, $n);
1414 $chunks[] = array(
"level" => 0,
"text" => $head . $c_text);
1419 if (count($chunks) == 0) {
1420 $chunks[] = array(
"level" => 0,
"text" =>
"");
1425 if (substr($chunks[0][
"text"], 0, 6) ==
"<br />") {
1426 $chunks[0][
"text"] = substr($chunks[0][
"text"], 6);
1431 $chunks[count($chunks) - 1][
"text"],
1432 strlen($chunks[count($chunks) - 1][
"text"]) - 6,
1435 $chunks[count($chunks) - 1][
"text"] =
1436 substr($chunks[count($chunks) - 1][
"text"], 0, strlen($chunks[count($chunks) - 1][
"text"]) - 6);
1437 if ($chunks[count($chunks) - 1][
"text"] ==
"") {
1438 unset($chunks[count($chunks) - 1]);
1451 if (substr($a_str, 0, 6) ==
"<br />" && substr($a_str, 6, 1) !=
"=") {
1452 $a_str = substr($a_str, 6);
1456 if (substr($a_str, 0, 1) ==
"=") {
1457 $a_str =
"<br />" . $a_str;
1468 if (substr($a_str, strlen($a_str) - 6) ==
"<br />") {
1469 $a_str = substr($a_str, 0, strlen($a_str) - 6);
1481 : parent::getType();
1499 string $a_insert_at =
"",
1500 bool $from_placeholder =
false 1504 $a_content = str_replace(
"<br>",
"<br />", $a_content);
1506 $this->log->debug(
"step 1: " . substr($a_content, 0, 1000));
1508 $t = self::handleAjaxContent($a_content);
1510 return $ex->getMessage() .
": " . htmlentities($a_content);
1512 $this->log->debug(
"step 2: " . substr($t[
"text"], 0, 1000));
1516 $pc_id = explode(
":", $a_pc_id);
1517 $insert_at = explode(
":", $a_insert_at);
1518 $t_id = explode(
":", $t[
"id"]);
1521 if ($a_insert_at !=
"") {
1523 $par->create($a_pg_obj, $insert_at[0], $insert_at[1], $from_placeholder);
1524 $par->writePCId($pc_id[1]);
1529 return $this->
lng->txt(
"copg_page_element_not_found") .
" (saveJS): " . $pc_id[0] .
":" . $pc_id[1] .
".";
1541 $par->setLanguage(
$ilUser->getLanguage());
1542 $par->setCharacteristic($t[
"class"]);
1544 $t2 = $par->input2xml($t[
"text"],
true,
false);
1545 $this->log->debug(
"step 3: " . substr($t2, 0, 1000));
1548 $this->log->debug(
"step 4: " . substr($t2, 0, 1000));
1550 $updated = $par->setText($t2,
true);
1556 $updated = $par->updatePage($a_pg_obj);
1565 bool $a_as_ajax_str =
false 1569 if ($a_as_ajax_str) {
1574 array($this->inserted_pc_id)
1576 foreach ($combined as $pc_id =>
$hier_id) {
1578 $ids .= $sep .
$hier_id .
":" . $pc_id;
1595 $a_content =
"<dummy>" . $a_content .
"</dummy>";
1604 $res = $doc->loadXML($content);
1611 $xpath =
new DOMXpath($doc);
1613 $tags = self::getXMLTagMap();
1615 $elements = $xpath->query(
"//span");
1616 while (!is_null($elements) && !is_null($element = $elements->item(0))) {
1618 $class = $element->getAttribute(
"class");
1619 if (substr($class, 0, 16) ==
"ilc_text_inline_") {
1620 $class_arr = explode(
" ", $class);
1621 $tag = substr($class_arr[0], 16);
1622 if (isset($tags[$tag])) {
1626 $cnode->setAttribute(
"Class", substr($class_arr[0], 16));
1628 for (
$i = 1, $iMax = count($class_arr);
$i < $iMax;
$i++) {
1629 $tag = substr($class_arr[
$i], 16);
1630 if (isset($tags[$tag])) {
1634 $cnode->setAttribute(
"Class", substr($class_arr[$i], 16));
1641 $elements = $xpath->query(
"//span");
1645 $xpath =
new DOMXpath($doc);
1646 $elements = $xpath->query(
"/dummy/div");
1649 if (!is_null($elements)) {
1650 foreach ($elements as $element) {
1651 $id = $element->getAttribute(
"id");
1652 $class = $element->getAttribute(
"class");
1653 $class = substr($class, 15);
1654 if (trim($class) ==
"") {
1655 $class =
"Standard";
1658 $text = $doc->saveXML($element);
1659 $text = str_replace(
"<br/>",
"\n", $text);
1662 $pos = strpos($text,
">");
1663 $text = substr($text, $pos + 1);
1664 $pos = strrpos($text,
"<");
1665 $text = substr($text, 0, $pos);
1671 if (!in_array($bb, array(
"code",
"tex",
"fn",
"xln"))) {
1672 $text = str_replace(
1677 $text = str_replace(
1682 $text = str_replace(
"<il" . $cl .
"/>",
"", $text);
1685 $text = str_replace(
1686 array(
"<code>",
"</code>"),
1687 array(
"[code]",
"[/code]"),
1690 $text = str_replace(
1691 array(
'<sup class="ilc_sup_Sup">',
'<sup>',
"</sup>"),
1692 array(
"[sup]",
"[sup]",
"[/sup]"),
1695 $text = str_replace(
1696 array(
'<sub class="ilc_sub_Sub">',
'<sub>',
"</sub>"),
1697 array(
"[sub]",
"[sub]",
"[/sub]"),
1701 $text = str_replace(
"<code/>",
"", $text);
1702 $text = str_replace(
'<ul class="ilc_list_u_BulletedList"/>',
"", $text);
1703 $text = str_replace(
'<ul class="ilc_list_o_NumberedList"/>',
"", $text);
1708 while (preg_match(
'~<ilMarked(' . $any .
')>~i', $text, $found)) {
1709 $attribs = self::attribsToArray($found[1]);
1710 $text = str_replace(
"<ilMarked" . $found[1] .
">",
"[marked class=\"" . $attribs[
"Class"] .
"\"]", $text);
1712 $text = str_replace(
"</ilMarked>",
"[/marked]", $text);
1715 $ret[] = array(
"text" => $text,
"id" =>
$id,
"class" => $class);
1728 $text = str_replace(
1729 array(
"<ul>",
"</ul>"),
1730 array(
"<SimpleBulletList>",
"</SimpleBulletList>"),
1733 $text = str_replace(
1734 array(
"<ul class='ilc_list_u_BulletedList'>",
"</ul>"),
1735 array(
"<SimpleBulletList>",
"</SimpleBulletList>"),
1738 $text = str_replace(
1739 array(
"<ul class=\"ilc_list_u_BulletedList\">",
"</ul>"),
1740 array(
"<SimpleBulletList>",
"</SimpleBulletList>"),
1743 $text = str_replace(
1744 array(
"<ol>",
"</ol>"),
1745 array(
"<SimpleNumberedList>",
"</SimpleNumberedList>"),
1748 $text = str_replace(
1749 array(
"<ol class='ilc_list_o_NumberedList'>",
"</ol>"),
1750 array(
"<SimpleNumberedList>",
"</SimpleNumberedList>"),
1753 $text = str_replace(
1754 array(
"<ol class=\"ilc_list_o_NumberedList\">",
"</ol>"),
1755 array(
"<SimpleNumberedList>",
"</SimpleNumberedList>"),
1758 $text = str_replace(
1759 array(
"<li>",
"</li>"),
1760 array(
"<SimpleListItem>",
"</SimpleListItem>"),
1763 $text = str_replace(
1764 array(
"<li class='ilc_list_item_StandardListItem'>",
"</li>"),
1765 array(
"<SimpleListItem>",
"</SimpleListItem>"),
1768 $text = str_replace(
1769 array(
"<li class=\"ilc_list_item_StandardListItem\">",
"</li>"),
1770 array(
"<SimpleListItem>",
"</SimpleListItem>"),
1774 $text = str_replace(
1775 array(
"<li class=\"ilc_list_item_StandardListItem\"/>"),
1776 array(
"<SimpleListItem></SimpleListItem>"),
1780 $text = str_replace(
"<SimpleBulletList><br />",
"<SimpleBulletList>", $text);
1781 $text = str_replace(
"<SimpleNumberedList><br />",
"<SimpleNumberedList>", $text);
1782 $text = str_replace(
"<br /><SimpleBulletList>",
"<SimpleBulletList>", $text);
1783 $text = str_replace(
"<br /><SimpleNumberedList>",
"<SimpleNumberedList>", $text);
1784 $text = str_replace(
"</SimpleBulletList><br />",
"</SimpleBulletList>", $text);
1785 $text = str_replace(
"</SimpleNumberedList><br />",
"</SimpleNumberedList>", $text);
1786 $text = str_replace(
"</SimpleListItem><br />",
"</SimpleListItem>", $text);
1801 return $a_page->
update();
1807 if (is_array($a_glos) && count($a_glos) > 0) {
1812 $text = strip_tags($this->
getText());
1813 $found_terms = array();
1814 foreach ($a_glos as $glo) {
1817 $glo_ref_id = current($ref_ids);
1818 if ($glo_ref_id > 0) {
1820 foreach ($terms as $t) {
1821 if (is_int(stripos($text, $t[
"term"]))) {
1822 $found_terms[$t[
"id"]] = $t;
1829 if (count($found_terms) > 0) {
1830 self::linkTermsInDom($this->dom, $found_terms, $this->par_node);
1846 foreach ($a_terms as $k => $t) {
1847 $a_terms[$k][
"termlength"] = strlen($t[
"term"]);
1853 $a_dom = $a_dom->myDOMDocument;
1856 $par_node = $a_par_node->myDOMNode;
1861 if ($par_node == null) {
1862 $parnodes = $xpath->query(
"//Paragraph[@Characteristic != 'Code']");
1864 $parnodes = $xpath->query(
".//Paragraph[@Characteristic != 'Code']", $par_node->parentNode);
1867 $strrPos =
function (
string $a_haystack,
string $a_needle, ?
int $a_offset = null):
int {
1868 if (function_exists(
"mb_strpos")) {
1869 return mb_strrpos($a_haystack, $a_needle, $a_offset,
"UTF-8");
1871 return strrpos($a_haystack, $a_needle, $a_offset);
1875 foreach ($parnodes as $parnode) {
1876 $textnodes = $xpath->query(
'.//text()', $parnode);
1877 foreach ($textnodes as
$node) {
1878 $p = $node->getNodePath();
1881 if (!is_int(strpos($p,
"/IntLink")) &&
1882 !is_int(strpos($p,
"/ExtLink"))) {
1883 $node_val = $node->nodeValue;
1886 foreach ($a_terms as $t) {
1890 while (is_int($pos)) {
1892 $tex_bpos = $strrPos(
ilStr::subStr($node_val, 0, $pos),
"[tex]");
1894 if ($tex_bpos > 0 && $tex_epos > 0 && $tex_bpos < $pos && $tex_epos > $pos) {
1900 $valid_limiters = array(
"",
" ",
" ",
".",
",",
":",
";",
"!",
"?",
"\"",
"'",
"(",
")");
1905 if ((in_array(
$b, $valid_limiters) || htmlentities(
$b, null,
'utf-8') ==
" ") && in_array(
$a, $valid_limiters)) {
1906 $mid =
'[iln term="' . $t[
"id"] .
'"]' .
1925 $node->nodeValue = $node_val;
1934 $text = $a_dom->saveXML($parnode);
1935 $text = substr($text, 0, strlen($text) - strlen(
"</Paragraph>"));
1936 $text = substr($text, strpos($text,
">") + 1);
1939 $text = self::intLinks2xml($text);
1943 '<?xml version="1.0" encoding="UTF-8"?><Paragraph>' . $text .
'</Paragraph>',
1947 $temp_dom = $temp_dom->myDOMDocument;
1949 if (empty($error)) {
1951 $children = $parnode->childNodes;
1952 while ($parnode->hasChildNodes()) {
1953 $parnode->removeChild($parnode->firstChild);
1957 $xpath_temp =
new DOMXPath($temp_dom);
1958 $temp_pars = $xpath_temp->query(
"//Paragraph");
1960 foreach ($temp_pars as $new_par_node) {
1961 $new_childs = $new_par_node->childNodes;
1963 foreach ($new_childs as $new_child) {
1965 $cloned_child = $a_dom->importNode($new_child,
true);
1966 $parnode->appendChild($cloned_child);
1984 $a_dom = $a_page->
getDom();
1986 self::linkTermsInDom($a_dom, $a_terms);
2001 self::saveMetaKeywords($a_page, $a_domdoc);
2002 self::saveAnchors($a_page, $a_domdoc);
2037 $nodes = $xpath->query(
'//Anchor');
2039 foreach ($nodes as
$node) {
2040 $name = $node->getAttribute(
"Name");
2041 if (trim(
$name) !=
"" && !in_array(
$name, $saved)) {
2052 string $a_parent_type,
2058 $ilDB = $DIC->database();
2061 "DELETE FROM page_anchor WHERE " .
2062 " page_parent_type = " .
$ilDB->quote($a_parent_type,
"text") .
2063 " AND page_id = " .
$ilDB->quote($a_page_id,
"integer") .
2064 " AND page_lang = " .
$ilDB->quote($a_page_lang,
"text")
2072 string $a_parent_type,
2074 string $a_page_lang,
2075 string $a_anchor_name
2079 $ilDB = $DIC->database();
2081 $ilDB->manipulate(
"INSERT INTO page_anchor " .
2082 "(page_parent_type, page_id, page_lang, anchor_name) VALUES (" .
2083 $ilDB->quote($a_parent_type,
"text") .
"," .
2084 $ilDB->quote($a_page_id,
"integer") .
"," .
2085 $ilDB->quote($a_page_lang,
"text") .
"," .
2086 $ilDB->quote($a_anchor_name,
"text") .
2094 string $a_parent_type,
2096 string $a_page_lang =
"-" 2100 $ilDB = $DIC->database();
2102 $and_lang = ($a_page_lang !=
"")
2103 ?
" AND page_lang = " .
$ilDB->quote($a_page_lang,
"text")
2106 $set =
$ilDB->query(
2107 "SELECT * FROM page_anchor " .
2108 " WHERE page_parent_type = " .
$ilDB->quote($a_parent_type,
"text") .
2109 " AND page_id = " .
$ilDB->quote($a_page_id,
"integer") .
2113 while ($rec =
$ilDB->fetchAssoc($set)) {
2114 $anchors[] = $rec[
"anchor_name"];
2130 $keywords = array();
2134 $nodes = $xpath->query(
'//Keyw');
2135 foreach ($nodes as
$node) {
2136 $k = trim(strip_tags($node->nodeValue));
2137 if (!in_array($k, $keywords)) {
2146 $meta_id = $a_page->
getId();
2148 $md_obj =
new ilMD($meta_rep_id, $meta_id, $meta_type);
2149 $mkeywords = array();
2151 if (is_object($md_section = $md_obj->getGeneral())) {
2152 foreach ($ids = $md_section->getKeywordIds() as
$id) {
2153 $md_key = $md_section->getKeyword(
$id);
2154 $mkeywords[] = strtolower($md_key->getKeyword());
2156 $lang = $md_key->getKeywordLanguageCode();
2160 foreach ($ids = $md_section->getLanguageIds() as
$id) {
2161 $md_lang = $md_section->getLanguage(
$id);
2163 $lang = $md_lang->getLanguageCode();
2167 foreach ($keywords as $k) {
2168 if (!in_array(strtolower($k), $mkeywords)) {
2169 if (trim($k) !=
"" &&
$lang !=
"") {
2170 $md_key = $md_section->addKeyword();
2175 $mkeywords[] = strtolower($k);
2186 if ($a_mode !=
"edit" && $adve_settings->get(
"auto_url_linking")) {
2197 if ($a_mode !=
"edit" && $adve_settings->get(
"auto_url_linking")) {
2198 return array(
"il.ExtLink.autolink('.ilc_Paragraph, .ilc_page_fn_Footnote','ilc_link_ExtLink');");
2206 $model = new \stdClass();
2208 $s_text = $this->
xml2output($s_text,
true,
false);
2214 $model->characteristic = $char;
2215 $model->text = $s_text;
2232 string $a_insert_at =
"",
2233 string $a_new_pc_id =
"" 2237 $this->log->debug(
"step 1: " . substr($a_content, 0, 1000));
2240 $t = self::handleAjaxContent($a_content);
2242 return $ex->getMessage() .
": " . htmlentities($a_content);
2245 $this->log->debug(
"step 2: " . substr($t[
"text"], 0, 1000));
2250 $pc_id = explode(
":", $a_pc_id);
2251 $insert_at = explode(
":", $a_insert_at);
2252 $t_id = explode(
":", $t[
"id"]);
2255 if ($a_insert_at !=
"") {
2257 $par->create($page, $insert_at[0], $insert_at[1]);
2262 if ($a_insert_at !=
"") {
2263 $pc_id = ($a_new_pc_id !=
"")
2266 $par->writePCId($pc_id);
2267 $this->inserted_pc_id = $pc_id;
2269 $this->inserted_pc_id = $pc_id[1];
2272 $par->setLanguage(
$ilUser->getLanguage());
2273 $par->setCharacteristic($t[
"class"]);
2275 $t2 = $par->input2xml($t[
"text"],
true,
false);
2276 $this->log->debug(
"step 3: " . substr($t2, 0, 1000));
2279 $this->log->debug(
"step 4: " . substr($t2, 0, 1000));
2281 $updated = $par->setText($t2,
true);
2287 $updated = $par->updatePage($page);
xpath_eval(php4DOMXPath $xpath_context, string $eval_str, $contextnode=null)
static saveMetaKeywords(ilPageObject $a_page, DOMDocument $a_domdoc)
save all keywords
stripHierIDs()
strip all hierarchical id attributes out of the dom tree
setType(string $a_type)
Set Type.
removeTrailingBr(string $a_str)
Remove trailing
static xml2outputJS(string $s_text)
Prepare content for js output.
static handleAjaxContent(string $a_content)
Handle ajax content.
setAutoIndent(string $a_char)
buildDom(bool $a_force=false)
static getLogger(string $a_component_id)
Get component logger.
static getBBMap()
Get bb to xml tag map.
getJavascriptFiles(string $a_mode)
static _readAnchors(string $a_parent_type, int $a_page_id, string $a_page_lang="-")
Read anchors of a page.
static xml2outputReplaceLists(string $a_text)
Replaces with *.
static replaceByChilds(DOMNode $node)
static autoLinkGlossariesPage(ilPageObject $a_page, array $a_terms)
Auto link glossary of whole page.
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
update(bool $a_validate=true, bool $a_no_history=false)
update complete page content in db (dom xml content is used)
static _getAllReferences(int $id)
get all reference ids for object ID
static getLocalJsPaths()
Get paths of necessary js files.
debug(string $a_message, array $a_context=array())
updatePage(ilPageObject $a_page)
Update page object (it would be better to have this centralized and to change the constructors and pa...
static strPos(string $a_haystack, string $a_needle, ?int $a_offset=null)
saveJS(ilPageObject $a_pg_obj, string $a_content, string $a_char, string $a_pc_id, string $a_insert_at="", bool $from_placeholder=false)
Save input coming from ajax.
getOnloadCode(string $a_mode)
static changeName(DOMNode $node, string $name, bool $keep_attributes=true)
static xml2output(string $a_text, bool $a_wysiwyg=false, bool $a_replace_lists=true, bool $unmask=true)
Converts xml from DB to output in edit textarea.
insert(\ilPageObject $page, string $a_content, string $a_char, string $a_pc_id, string $a_insert_at="", string $a_new_pc_id="")
Save input coming from ajax.
static _lookupId($a_user_str)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static subStr(string $a_str, int $a_start, ?int $a_length=null)
beforePageContentUpdate(ilPageContent $a_page_content)
Before page content update Note: This one is "work in progress", currently only text paragraphs call ...
static getTermList(array $a_glo_ref_id, string $searchterm="", string $a_first_letter="", string $a_def="", int $a_tax_node=0, bool $a_add_amet_fields=false, array $a_amet_filter=null, bool $a_include_references=false)
Get all terms for given set of glossary ids.
checkTextArray(array $text)
Check text array.
static _saveAnchor(string $a_parent_type, int $a_page_id, string $a_page_lang, string $a_anchor_name)
Save an anchor.
getLastSavedPCId(ilPageObject $a_pg_obj, bool $a_as_ajax_str=false)
Get last inserted pc ids.
static linkTermsInDom(php4DOMDocument $a_dom, array $a_terms, php4DOMElement $a_par_node=null)
Link terms in a dom page object in bb style.
static getXMLTagMap()
Get tag to bb map.
static input2xmlReplaceLists(string $a_text)
Converts xml from DB to output in edit textarea.
createAfter(php4DOMElement $node)
Create paragraph node (incl.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
create(ilPageObject $a_pg_obj, string $a_hier_id, string $a_pc_id="", bool $from_placeholder=false)
Create paragraph node (incl.
static saveAnchors(ilPageObject $a_page, DOMDocument $a_domdoc)
Save anchors.
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 ...
setCharacteristic(string $a_char)
Set Characteristic of paragraph.
static addParent(DOMNode $node, string $name)
setLanguage(string $a_lang)
static strLen(string $a_string)
xpath_new_context($dom_document)
static handleAjaxContentPost(string $text)
Post input2xml handling of ajax content.
static afterPageHistoryEntry(ilPageObject $a_page, DOMDocument $a_old_domdoc, string $a_old_xml, int $a_old_nr)
After page history entry has been created.
getHierIdsForPCIds(array $a_pc_ids)
Get hier ids for a set of pc ids.
getType()
Need to override getType from ilPageContent to distinguish between Pararagraph and Source...
static beforePageDelete(ilPageObject $a_page)
Before page is being deleted.
handleNextBr(string $a_str)
Remove preceding
domxml_open_mem($str, $mode=0, &$error=null)
static isValidTagContent(string $content)
setText(string $a_text, bool $a_auto_split=false)
Set (xml) content of text paragraph.
insertContent(ilPageContent $a_cont_obj, string $a_pos, int $a_mode=IL_INSERT_AFTER, string $a_pcid="", bool $remove_placeholder=true)
insert a content node before/after a sibling or as first child of a parent
static _input2xml(string $a_text, string $a_lang, bool $a_wysiwyg=false, bool $a_handle_lists=true)
Converts user input to xml User input comes as bb code information, e.g.
input2xml(string $a_text, bool $a_wysiwyg=false, bool $a_handle_lists=true)
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
static replaceBBCode(string $a_text, string $a_bb, string $a_tag)
setShowLineNumbers(string $a_char)
insert_before($newnode, $refnode)
static intLinks2xml(string $a_text)
internal links to xml
autoSplit(string $a_text)
This function splits a paragraph text that has been already processed with input2xml at each header p...
static _deleteAnchors(string $a_parent_type, int $a_page_id, string $a_page_lang)
Delete anchors of a page.
setDownloadTitle(string $a_char)
createPageContentNode(bool $a_set_this_node=true)
Create page content node (always use this method first when adding a new element) ...
createBeforeNode(php4DOMElement $node)
Create new page content (incl.
getText(bool $a_short_mode=false)
Get (xml) content of paragraph.
getContentObject(string $a_hier_id, string $a_pc_id="")
Get a content object of the page.
createAtNode(php4DOMElement $node)
Create new page content (incl.
addHierIDs()
Add hierarchical ID (e.g.
setNode(php4DOMElement $a_node)
static afterPageUpdate(ilPageObject $a_page, DOMDocument $a_domdoc, string $a_xml, bool $a_creation)
After page has been updated (or created)
autoLinkGlossaries(array $a_glos)
static _getCommonBBButtons()
fixTextArray(array $text)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
static segmentString(string $a_haystack, array $a_needles)
Segments a string into an array at each position of a substring.
static strIPos(string $a_haystack, string $a_needle, ?int $a_offset=null)
static _lookupType(int $id, bool $reference=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setSubCharacteristic(string $a_char)
getParagraphSequenceContent(ilPageObject $a_pg_obj)
Get paragraph sequenc of current paragraph.
const DOMXML_LOAD_PARSING
static attribsToArray(string $a_str)
converts a string of format var1 = "val1" var2 = "val2" ...
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
static _lookupLogin(int $a_user_id)