4 require_once(
"./Services/COPage/classes/class.ilPageContent.php");
5 require_once(
"./Services/COPage/classes/class.ilWysiwygUtil.php");
39 $childs = $a_node->child_nodes();
40 for ($i=0; $i<count($childs); $i++)
42 if ($childs[$i]->node_name() ==
"Paragraph")
44 $this->par_node = $childs[$i];
58 $this->par_node =& $this->dom->create_element(
"Paragraph");
59 $this->par_node =& $this->node->append_child($this->par_node);
60 $this->par_node->set_attribute(
"Language",
"");
61 $node->append_child ($this->node);
72 $this->par_node =& $this->dom->create_element(
"Paragraph");
73 $this->par_node =& $this->node->append_child($this->par_node);
74 $this->par_node->set_attribute(
"Language",
"");
87 if($succ_node =
$node->next_sibling())
89 $this->node = $succ_node->insert_before($this->node, $succ_node);
93 $parent_node =
$node->parent_node();
94 $this->node = $parent_node->append_child($this->node);
96 $this->par_node = $this->dom->create_element(
"Paragraph");
97 $this->par_node = $this->node->append_child($this->par_node);
98 $this->par_node->set_attribute(
"Language",
"");
108 function create(&$a_pg_obj, $a_hier_id, $a_pc_id =
"")
112 $this->node =& $this->dom->create_element(
"PageContent");
115 $a_pg_obj->insertContent($this, $a_hier_id,
IL_INSERT_AFTER, $a_pc_id);
117 $this->par_node =& $this->dom->create_element(
"Paragraph");
118 $this->par_node =& $this->node->append_child($this->par_node);
119 $this->par_node->set_attribute(
"Language",
"");
128 function setText($a_text, $a_auto_split =
false)
132 if (!is_array($a_text))
134 $text = array(array(
"level" => 0,
"text" => $a_text));
148 foreach ($text as
$t)
150 $check.=
"<Paragraph>".$t[
"text"].
"</Paragraph>";
154 $temp_dom =
domxml_open_mem(
'<?xml version="1.0" encoding="UTF-8"?><Paragraph>'.$check.
'</Paragraph>',
161 $temp_dom =
domxml_open_mem(
'<?xml version="1.0" encoding="UTF-8"?><Paragraph>'.$text[0][
"text"].
'</Paragraph>',
165 $children = $this->par_node->child_nodes();
166 for($i=0; $i<count($children); $i++)
168 $this->par_node->remove_child($children[$i]);
173 $path =
"//Paragraph";
175 if (count(
$res->nodeset) == 1)
177 $new_par_node =&
$res->nodeset[0];
178 $new_childs = $new_par_node->child_nodes();
180 for($i=0; $i<count($new_childs); $i++)
182 $cloned_child =& $new_childs[$i]->clone_node(
true);
183 $this->par_node->append_child($cloned_child);
189 if ((count($text) > 1) && (substr($orig_characteristic, 0, 8) ==
"Headline"))
191 $orig_characteristic =
"";
193 if ($text[0][
"level"] > 0)
195 $this->par_node->set_attribute(
"Characteristic",
'Headline'.$text[0][
"level"]);
203 for ($i=1; $i<count($text); $i++)
208 $next_par->createAfter($c_node);
210 if ($text[$i][
"level"] > 0)
212 $next_par->setCharacteristic(
"Headline".$text[$i][
"level"]);
216 $next_par->setCharacteristic($orig_characteristic);
218 $ok = $next_par->setText($text[$i][
"text"],
false);
219 $c_node = $next_par->node;
228 $text = str_replace(
"<br>",
"\n", $check);
229 $text = str_replace(
"<br/>",
"\n", $text);
230 $text = str_replace(
"<br />",
"\n", $text);
231 $text = str_replace(
"</SimpleListItem>",
"</SimpleListItem>\n", $text);
232 $text = str_replace(
"<SimpleBulletList>",
"\n<SimpleBulletList>", $text);
233 $text = str_replace(
"<SimpleNumberedList>",
"\n<SimpleNumberedList>", $text);
234 $text = str_replace(
"<Paragraph>\n",
"<Paragraph>", $text);
235 $text = str_replace(
"</Paragraph>",
"</Paragraph>\n", $text);
236 include_once(
"./Services/Dom/classes/class.ilDomDocument.php");
237 $doc =
new ilDOMDocument();
238 $text =
'<?xml version="1.0" encoding="UTF-8"?><Paragraph>'.$text.
'</Paragraph>';
240 $this->success = $doc->loadXML($text);
241 $error = $doc->errors;
243 foreach ($error as $e)
245 $e = str_replace(
" in Entity",
"", $e);
259 if (is_object($this->par_node))
262 $childs = $this->par_node->child_nodes();
263 for($i=0; $i<count($childs); $i++)
265 $content .= $this->dom->dump_node($childs[$i]);
280 $childs = $this->par_node->parent_node()->parent_node()->child_nodes();
286 for($i=0; $i<count($childs); $i++)
288 $pchilds = $childs[$i]->child_nodes();
289 if ($pchilds[0]->node_name() ==
"Paragraph" &&
290 $pchilds[0]->get_attribute(
"Characteristic") !=
"Code")
292 $cur_seq[] = $childs[$i];
295 if ($childs[$i]->get_attribute(
"PCID") == $pc_id &&
296 $childs[$i]->get_attribute(
"HierId") ==
$hier_id)
318 foreach ($seq as $p_node)
320 $ids.= $id_sep.$p_node->get_attribute(
"HierId").
":".$p_node->get_attribute(
"PCID");
321 $po = $a_pg_obj->getContentObject($p_node->get_attribute(
"HierId"),
322 $p_node->get_attribute(
"PCID"));
323 $s_text = $po->getText();
324 $s_text = $po->xml2output($s_text,
true,
false);
325 $char = $po->getCharacteristic();
336 return $ids.$content;
348 $this->par_node->set_attribute(
"Characteristic", $a_char);
352 if ($this->par_node->has_attribute(
"Characteristic"))
354 $this->par_node->remove_attribute(
"Characteristic");
366 if (is_object($this->par_node))
368 return $this->par_node->get_attribute(
"Characteristic");
380 $this->par_node->set_attribute(
"SubCharacteristic", $a_char);
384 if ($this->par_node->has_attribute(
"SubCharacteristic"))
386 $this->par_node->remove_attribute(
"SubCharacteristic");
398 return $this->par_node->get_attribute(
"AutoIndent");
405 $this->par_node->set_attribute(
"AutoIndent", $a_char);
409 if ($this->par_node->has_attribute(
"AutoIndent"))
411 $this->par_node->remove_attribute(
"AutoIndent");
421 return $this->par_node->get_attribute(
"SubCharacteristic");
432 $this->par_node->set_attribute(
"DownloadTitle", $a_char);
436 if ($this->par_node->has_attribute(
"DownloadTitle"))
438 $this->par_node->remove_attribute(
"DownloadTitle");
448 return $this->par_node->get_attribute(
"DownloadTitle");
457 $a_char = empty($a_char)?
"n":$a_char;
459 $this->par_node->set_attribute(
"ShowLineNumbers", $a_char);
468 return $this->par_node->get_attribute(
"ShowLineNumbers");
476 $this->par_node->set_attribute(
"Language", $a_lang);
484 return $this->par_node->get_attribute(
"Language");
487 function input2xml($a_text, $a_wysiwyg = 0, $a_handle_lists =
true)
495 static function _input2xml($a_text, $a_lang, $a_wysiwyg = 0, $a_handle_lists =
true)
504 $a_text = str_replace(
"<br />", chr(10), $a_text);
509 $a_text = trim($a_text);
516 $a_text = str_replace(
"&",
"&",$a_text);
518 $a_text = str_replace(
"<",
"<",$a_text);
519 $a_text = str_replace(
">",
">",$a_text);
522 $a_text = preg_replace(
'/<([\s\/]*?PageTurn.*?)>/i',
"<$1>",$a_text);
523 $a_text = preg_replace(
'/<([\s\/]*?BibItemIdentifier.*?)>/i',
"<$1>",$a_text);
534 $a_text = str_replace(chr(13).chr(10),
"<br />",$a_text);
535 $a_text = str_replace(chr(13),
"<br />", $a_text);
536 $a_text = str_replace(chr(10),
"<br />", $a_text);
544 $atags = array(
"com",
"emp",
"str",
"fn",
"quot",
"code",
"acc",
"imp",
"kw");
545 foreach ($atags as $at)
547 $a_text = str_replace(
"[".$at.
"][/".$at.
"]",
"", $a_text);
551 $a_text = eregi_replace(
"\[com\]",
"<Comment Language=\"".$a_lang.
"\">",$a_text);
552 $a_text = eregi_replace(
"\[\/com\]",
"</Comment>",$a_text);
553 $a_text = eregi_replace(
"\[emp\]",
"<Emph>",$a_text);
554 $a_text = eregi_replace(
"\[\/emp\]",
"</Emph>",$a_text);
555 $a_text = eregi_replace(
"\[str\]",
"<Strong>",$a_text);
556 $a_text = eregi_replace(
"\[\/str\]",
"</Strong>",$a_text);
557 $a_text = eregi_replace(
"\[fn\]",
"<Footnote>",$a_text);
558 $a_text = eregi_replace(
"\[\/fn\]",
"</Footnote>",$a_text);
559 $a_text = eregi_replace(
"\[quot\]",
"<Quotation Language=\"".$a_lang.
"\">",$a_text);
560 $a_text = eregi_replace(
"\[\/quot\]",
"</Quotation>",$a_text);
561 $a_text = eregi_replace(
"\[code\]",
"<Code>",$a_text);
562 $a_text = eregi_replace(
"\[\/code\]",
"</Code>",$a_text);
563 $a_text = eregi_replace(
"\[acc\]",
"<Accent>",$a_text);
564 $a_text = eregi_replace(
"\[\/acc\]",
"</Accent>",$a_text);
565 $a_text = eregi_replace(
"\[imp\]",
"<Important>",$a_text);
566 $a_text = eregi_replace(
"\[\/imp\]",
"</Important>",$a_text);
567 $a_text = eregi_replace(
"\[kw\]",
"<Keyw>",$a_text);
568 $a_text = eregi_replace(
"\[\/kw\]",
"</Keyw>",$a_text);
572 $ws=
"[ \t\r\f\v\n]*";
573 $ltypes =
"page|chap|term|media|htlm|lm|dbk|glo|frm|exc|tst|svy|webr|chat|cat|crs|grp|file|fold|mep|wiki|sahs|mcst|obj|dfile";
575 while (eregi(
"\[(iln$ws((inst$ws=$ws([\"0-9])*)?$ws".
576 "((".$ltypes.
")$ws=$ws([\"0-9])*)$ws".
577 "(target$ws=$ws(\"(New|FAQ|Media)\"))?$ws(anchor$ws=$ws(\"([^\"])*\"))?$ws))\]\[\/iln\]", $a_text, $found))
579 $a_text = str_replace($found[0],
"",$a_text);
582 while (eregi(
"\[(iln$ws((inst$ws=$ws([\"0-9])*)?$ws".
583 "((".$ltypes.
")$ws=$ws([\"0-9])*)$ws".
584 "(target$ws=$ws(\"(New|FAQ|Media)\"))?$ws(anchor$ws=$ws(\"([^\"])*\"))?$ws))\]", $a_text, $found))
587 $inst_str = $attribs[
"inst"];
589 if (isset($attribs[
"page"]))
592 if (!empty($found[10]))
594 $tframestr =
" TargetFrame=\"".$found[10].
"\" ";
597 if ($attribs[
"anchor"] !=
"")
599 $ancstr =
' Anchor="'.$attribs[
"anchor"].
'" ';
601 $a_text = eregi_replace(
"\[".$found[1].
"\]",
602 "<IntLink Target=\"il_".$inst_str.
"_pg_".$attribs[page].
"\" Type=\"PageObject\"".$tframestr.$ancstr.
">", $a_text);
605 else if (isset($attribs[
"chap"]))
607 if (!empty($found[10]))
609 $tframestr =
" TargetFrame=\"".$found[10].
"\" ";
615 $a_text = eregi_replace(
"\[".$found[1].
"\]",
616 "<IntLink Target=\"il_".$inst_str.
"_st_".$attribs[chap].
"\" Type=\"StructureObject\"".$tframestr.
">", $a_text);
619 else if (isset($attribs[
"term"]))
624 $tframestr =
" TargetFrame=\"New\" ";
628 $tframestr =
" TargetFrame=\"Glossary\" ";
631 $a_text = eregi_replace(
"\[".$found[1].
"\]",
632 "<IntLink Target=\"il_".$inst_str.
"_git_".$attribs[term].
"\" Type=\"GlossaryItem\" $tframestr>", $a_text);
635 else if (isset($attribs[
"media"]))
637 if (!empty($found[10]))
639 $tframestr =
" TargetFrame=\"".$found[10].
"\" ";
640 $a_text = eregi_replace(
"\[".$found[1].
"\]",
641 "<IntLink Target=\"il_".$inst_str.
"_mob_".$attribs[media].
"\" Type=\"MediaObject\"".$tframestr.
">", $a_text);
645 $a_text = eregi_replace(
"\[".$found[1].
"\]",
646 "<IntLink Target=\"il_".$inst_str.
"_mob_".$attribs[media].
"\" Type=\"MediaObject\"/>", $a_text);
650 else if (isset($attribs[
"dfile"]))
652 $a_text = eregi_replace(
"\[".$found[1].
"\]",
653 "<IntLink Target=\"il_".$inst_str.
"_dfile_".$attribs[dfile].
"\" Type=\"File\">", $a_text);
657 else if (isset($attribs[
"lm"]) || isset($attribs[
"dbk"]) || isset($attribs[
"glo"])
658 || isset($attribs[
"frm"]) || isset($attribs[
"exc"]) || isset($attribs[
"tst"])
659 || isset($attribs[
"svy"]) || isset($attribs[
"obj"]) || isset($attribs[
'webr'])
660 || isset($attribs[
"htlm"]) || isset($attribs[
"chat"]) || isset($attribs[
"grp"])
661 || isset($attribs[
"fold"]) || isset($attribs[
"sahs"]) || isset($attribs[
"mcst"])
662 || isset($attribs[
"mep"]) || isset($attribs[
"wiki"])
663 || isset($attribs[
"cat"]) || isset($attribs[
"crs"]) || isset($attribs[
"file"]))
665 $obj_id = (isset($attribs[
"lm"])) ? $attribs[
"lm"] : $obj_id;
666 $obj_id = (isset($attribs[
"dbk"])) ? $attribs[
"dbk"] : $obj_id;
667 $obj_id = (isset($attribs[
"chat"])) ? $attribs[
"chat"] : $obj_id;
668 $obj_id = (isset($attribs[
"glo"])) ? $attribs[
"glo"] : $obj_id;
669 $obj_id = (isset($attribs[
"frm"])) ? $attribs[
"frm"] : $obj_id;
670 $obj_id = (isset($attribs[
"exc"])) ? $attribs[
"exc"] : $obj_id;
671 $obj_id = (isset($attribs[
"htlm"])) ? $attribs[
"htlm"] : $obj_id;
672 $obj_id = (isset($attribs[
"tst"])) ? $attribs[
"tst"] : $obj_id;
673 $obj_id = (isset($attribs[
"svy"])) ? $attribs[
"svy"] : $obj_id;
674 $obj_id = (isset($attribs[
"obj"])) ? $attribs[
"obj"] : $obj_id;
675 $obj_id = (isset($attribs[
"webr"])) ? $attribs[
"webr"] : $obj_id;
676 $obj_id = (isset($attribs[
"fold"])) ? $attribs[
"fold"] : $obj_id;
677 $obj_id = (isset($attribs[
"cat"])) ? $attribs[
"cat"] : $obj_id;
678 $obj_id = (isset($attribs[
"crs"])) ? $attribs[
"crs"] : $obj_id;
679 $obj_id = (isset($attribs[
"grp"])) ? $attribs[
"grp"] : $obj_id;
680 $obj_id = (isset($attribs[
"file"])) ? $attribs[
"file"] : $obj_id;
681 $obj_id = (isset($attribs[
"sahs"])) ? $attribs[
"sahs"] : $obj_id;
682 $obj_id = (isset($attribs[
"mcst"])) ? $attribs[
"mcst"] : $obj_id;
683 $obj_id = (isset($attribs[
"mep"])) ? $attribs[
"mep"] : $obj_id;
684 $obj_id = (isset($attribs[
"wiki"])) ? $attribs[
"wiki"] : $obj_id;
689 $a_text = eregi_replace(
"\[".$found[1].
"\]",
690 "<IntLink Target=\"il_".$inst_str.
"_obj_".$obj_id.
"\" Type=\"RepositoryItem\">", $a_text);
694 $a_text = eregi_replace(
"\[".$found[1].
"\]",
695 "<IntLink Target=\"il_".$inst_str.
"_".$found[6].
"_".$obj_id.
"\" Type=\"RepositoryItem\">", $a_text);
700 $a_text = eregi_replace(
"\[".$found[1].
"\]",
"[error: iln".$found[1].
"]",$a_text);
703 while (eregi(
"\[(iln$ws((inst$ws=$ws([\"0-9])*)?".$ws.
"media$ws=$ws([\"0-9])*)$ws)/\]", $a_text, $found))
706 $inst_str = $attribs[
"inst"];
707 $a_text = eregi_replace(
"\[".$found[1].
"/\]",
708 "<IntLink Target=\"il_".$inst_str.
"_mob_".$attribs[media].
"\" Type=\"MediaObject\"/>", $a_text);
710 $a_text = eregi_replace(
"\[\/iln\]",
"</IntLink>",$a_text);
713 $ws=
"[ \t\r\f\v\n]*";
715 while (eregi(
"\[(xln$ws(url$ws=$ws\"([^\"])*\")$ws(target$ws=$ws(\"(Glossary|FAQ|Media)\"))?$ws)\]\[\/xln\]", $a_text, $found))
717 $a_text = str_replace($found[0],
"",$a_text);
719 while (eregi(
"\[(xln$ws(url$ws=$ws(([^]])*)))$ws\]\[\/xln\]", $a_text, $found))
721 $a_text = str_replace($found[0],
"",$a_text);
724 while (eregi(
"\[(xln$ws(url$ws=$ws\"([^\"])*\")$ws(target$ws=$ws(\"(Glossary|FAQ|Media)\"))?$ws)\]", $a_text, $found))
727 if (isset($attribs[
"url"]))
731 if (in_array($a2[
"target"], array(
"FAQ",
"Glossary",
"Media")))
733 $tstr =
' TargetFrame="'.$a2[
"target"].
'"';
735 $a_text = str_replace(
"[".$found[1].
"]",
"<ExtLink Href=\"".$attribs[
"url"].
"\"$tstr>", $a_text);
739 $a_text = str_replace(
"[".$found[1].
"]",
"[error: xln".$found[1].
"]",$a_text);
744 while (eregi(
"\[(xln$ws(url$ws=$ws(([^]])*)))$ws\]", $a_text, $found))
748 $a_text = str_replace(
"[".$found[1].
"]",
"<ExtLink Href=\"".$found[3].
"\">", $a_text);
752 $a_text = str_replace(
"[".$found[1].
"]",
"[error: xln".$found[1].
"]",$a_text);
755 $a_text = eregi_replace(
"\[\/xln\]",
"</ExtLink>",$a_text);
758 $ws=
"[ \t\r\f\v\n]*";
759 while (eregi(
"\[(anc$ws(name$ws=$ws\"([^\"])*\")$ws)\]", $a_text, $found))
762 $a_text = str_replace(
"[".$found[1].
"]",
"<Anchor Name=\"".$attribs[
"name"].
"\">", $a_text);
764 $a_text = eregi_replace(
"\[\/anc\]",
"</Anchor>",$a_text);
778 $rows = explode(
"<br />", $a_text.
"<br />");
785 foreach ($rows as
$row)
788 if (str_replace(
"#",
"*", substr($row, 0, 3)) ==
"***")
792 else if (str_replace(
"#",
"*", substr($row, 0, 2)) ==
"**")
796 else if (str_replace(
"#",
"*", substr($row, 0, 1)) ==
"*")
802 if ($level < $old_level)
804 for ($i = $old_level; $i > $level; $i--)
806 $text.=
"</SimpleListItem></".$clist[$i].
">";
810 $text.=
"</SimpleListItem>";
813 else if ($old_level > 0 && $level > 0 && ($level == $old_level))
815 $text.=
"</SimpleListItem>";
817 else if (($level == $old_level) && $text !=
"")
823 if ($level > $old_level)
825 for($i = $old_level + 1; $i <= $level; $i++)
827 if (substr($row, $i - 1, 1) ==
"*")
829 $clist[$i] =
"SimpleBulletList";
833 $clist[$i] =
"SimpleNumberedList";
835 $text.=
"<".$clist[$i].
"><SimpleListItem>";
838 else if ($old_level > 0 && $level > 0)
840 $text.=
"<SimpleListItem>";
842 $text.= substr($row, $level);
848 if (substr($text, strlen($text) - 6) ==
"<br />")
850 $text = substr($text, 0, strlen($text) - 6);
866 "</SimpleListItem>",
"<SimpleListItem>",
"<SimpleListItem/>",
"<SimpleNumberedList>",
"</SimpleNumberedList>"));
868 $current_list = array();
870 for ($i=0; $i<= count($segments); $i++)
872 if ($segments[$i] ==
"<SimpleBulletList>")
874 if (count($current_list) == 0)
878 array_push($current_list,
"*");
881 else if ($segments[$i] ==
"<SimpleNumberedList>")
883 if (count($current_list) == 0)
887 array_push($current_list,
"#");
890 else if ($segments[$i] ==
"</SimpleBulletList>")
892 array_pop($current_list);
895 else if ($segments[$i] ==
"</SimpleNumberedList>")
897 array_pop($current_list);
900 else if ($segments[$i] ==
"<SimpleListItem>")
904 else if ($segments[$i] ==
"</SimpleListItem>")
908 else if ($segments[$i] ==
"<SimpleListItem/>")
915 foreach($current_list as $list)
931 foreach($current_list as $list)
936 $text.= $segments[$i];
946 if ($segments[count($segments) - 1] ==
"</SimpleBulletList>" ||
947 $segments[count($segments) - 1] ==
"</SimpleNumberedList>" &&
948 substr($text, strlen($text) - 6) ==
"<br />")
950 $text = substr($text, 0, strlen($text) - 6);
963 $nothing_found =
false;
964 while (!$nothing_found)
966 $nothing_found =
true;
968 foreach($a_needles as $needle)
970 $pos = stripos($a_haystack, $needle);
971 if (is_int($pos) && ($pos < $found || $found == -1))
974 $found_needle = $needle;
975 $nothing_found =
false;
980 $segments[] = substr($a_haystack, 0, $found);
981 $a_haystack = substr($a_haystack, $found);
985 $segments[] = substr($a_haystack, 0, strlen($found_needle));
986 $a_haystack = substr($a_haystack, strlen($found_needle));
989 if ($a_haystack !=
"")
991 $segments[] = $a_haystack;
1004 static function xml2output($a_text, $a_wysiwyg =
false, $a_replace_lists =
true)
1011 $a_text = eregi_replace(
"<Comment[^>]*>",
"[com]",$a_text);
1012 $a_text = eregi_replace(
"</Comment>",
"[/com]",$a_text);
1013 $a_text = eregi_replace(
"<Comment/>",
"[com][/com]",$a_text);
1014 $a_text = eregi_replace(
"<Emph>",
"[emp]",$a_text);
1015 $a_text = eregi_replace(
"</Emph>",
"[/emp]",$a_text);
1016 $a_text = eregi_replace(
"<Emph/>",
"[emp][/emp]",$a_text);
1017 $a_text = eregi_replace(
"<Strong>",
"[str]",$a_text);
1018 $a_text = eregi_replace(
"</Strong>",
"[/str]",$a_text);
1019 $a_text = eregi_replace(
"<Strong/>",
"[str][/str]",$a_text);
1020 $a_text = eregi_replace(
"<Footnote[^>]*>",
"[fn]",$a_text);
1021 $a_text = eregi_replace(
"</Footnote>",
"[/fn]",$a_text);
1022 $a_text = eregi_replace(
"<Footnote/>",
"[fn][/fn]",$a_text);
1023 $a_text = eregi_replace(
"<Quotation[^>]*>",
"[quot]",$a_text);
1024 $a_text = eregi_replace(
"</Quotation>",
"[/quot]",$a_text);
1025 $a_text = eregi_replace(
"<Quotation/>",
"[quot][/quot]",$a_text);
1026 $a_text = eregi_replace(
"<Code[^>]*>",
"[code]",$a_text);
1027 $a_text = eregi_replace(
"</Code>",
"[/code]",$a_text);
1028 $a_text = eregi_replace(
"<Code/>",
"[code][/code]",$a_text);
1029 $a_text = eregi_replace(
"<Accent>",
"[acc]",$a_text);
1030 $a_text = eregi_replace(
"</Accent>",
"[/acc]",$a_text);
1031 $a_text = eregi_replace(
"<Important>",
"[imp]",$a_text);
1032 $a_text = eregi_replace(
"</Important>",
"[/imp]",$a_text);
1033 $a_text = eregi_replace(
"<Keyw>",
"[kw]",$a_text);
1034 $a_text = eregi_replace(
"</Keyw>",
"[/kw]",$a_text);
1037 if ($a_replace_lists)
1045 while (eregi(
"<IntLink($any)>", $a_text, $found))
1049 $target = explode(
"_", $attribs[
"Target"]);
1051 $inst_str = (!is_int(strpos($attribs[
"Target"],
"__")))
1052 ? $inst_str =
"inst=\"".$target[1].
"\" "
1054 switch($attribs[
"Type"])
1057 $tframestr = (!empty($attribs[
"TargetFrame"]))
1058 ?
" target=\"".$attribs[
"TargetFrame"].
"\""
1060 $ancstr = (!empty($attribs[
"Anchor"]))
1061 ?
' anchor="'.$attribs[
"Anchor"].
'"'
1063 $a_text = eregi_replace(
"<IntLink".$found[1].
">",
"[iln ".$inst_str.
"page=\"".
$target_id.
"\"$tframestr$ancstr]",$a_text);
1066 case "StructureObject":
1067 $tframestr = (!empty($attribs[
"TargetFrame"]))
1068 ?
" target=\"".$attribs[
"TargetFrame"].
"\""
1070 $a_text = eregi_replace(
"<IntLink".$found[1].
">",
"[iln ".$inst_str.
"chap=\"".
$target_id.
"\"$tframestr]",$a_text);
1073 case "GlossaryItem":
1074 $tframestr = (empty($attribs[
"TargetFrame"]) || $attribs[
"TargetFrame"] ==
"Glossary")
1076 :
" target=\"".$attribs[
"TargetFrame"].
"\"";
1077 $a_text = eregi_replace(
"<IntLink".$found[1].
">",
"[iln ".$inst_str.
"term=\"".
$target_id.
"\"".$tframestr.
"]",$a_text);
1081 if (empty($attribs[
"TargetFrame"]))
1083 $a_text = eregi_replace(
"<IntLink".$found[1].
">",
"[iln ".$inst_str.
"media=\"".
$target_id.
"\"/]",$a_text);
1087 $a_text = eregi_replace(
"<IntLink".$found[1].
">",
"[iln media=\"".
$target_id.
"\"".
1088 " target=\"".$attribs[
"TargetFrame"].
"\"]",$a_text);
1093 case "RepositoryItem":
1094 if ($inst_str ==
"")
1100 $rtype = $target[count($target) - 2];
1103 $a_text = eregi_replace(
"<IntLink".$found[1].
">",
"[iln ".$inst_str.
"$target_type=\"".
$target_id.
"\"".$tframestr.
"]",$a_text);
1108 $a_text = eregi_replace(
"<IntLink".$found[1].
">",
"[iln ".$inst_str.
"dfile=\"".
$target_id.
"\"".$tframestr.
"]",$a_text);
1112 $a_text = eregi_replace(
"<IntLink".$found[1].
">",
"[iln]",$a_text);
1116 $a_text = eregi_replace(
"</IntLink>",
"[/iln]",$a_text);
1119 while (eregi(
"<ExtLink($any)>", $a_text, $found))
1125 if (in_array($attribs[
"TargetFrame"], array(
"FAQ",
"Glossary",
"Media")))
1127 $tstr =
' target="'.$attribs[
"TargetFrame"].
'"';
1129 $a_text = str_replace(
"<ExtLink".$found[1].
">",
"[xln url=\"".$attribs[
"Href"].
"\"$tstr]",$a_text);
1131 $a_text = eregi_replace(
"</ExtLink>",
"[/xln]",$a_text);
1134 while (eregi(
"<Anchor($any)>", $a_text, $found))
1138 $a_text = str_replace(
"<Anchor".$found[1].
">",
"[anc name=\"".$attribs[
"Name"].
"\"]",$a_text);
1140 $a_text = eregi_replace(
"</Anchor>",
"[/anc]",$a_text);
1146 $a_text = str_replace(
"<br />",
"\n", $a_text);
1147 $a_text = str_replace(
"<br/>",
"\n", $a_text);
1153 $a_text = str_replace(
"{",
"{", $a_text);
1154 $a_text = str_replace(
"}",
"}", $a_text);
1157 $a_text = str_replace(
"<",
"<", $a_text);
1158 $a_text = str_replace(
">",
">",$a_text);
1161 $a_text = str_replace(
""",
"\"", $a_text);
1165 $a_text = str_replace(
"&",
"&", $a_text);
1168 $a_text = str_replace(
"<",
"&lt;", $a_text);
1169 $a_text = str_replace(
">",
"&gt;", $a_text);
1183 $a_text = str_replace (
"=<SimpleBulletList>",
"=<br /><SimpleBulletList>", $a_text);
1184 $a_text = str_replace (
"=<SimpleNumberedList>",
"=<br /><SimpleNumberedList>", $a_text);
1185 $a_text = str_replace (
"</SimpleBulletList>=",
"</SimpleBulletList><br />=", $a_text);
1186 $a_text = str_replace (
"</SimpleNumberedList>=",
"</SimpleNumberedList><br />=", $a_text);
1187 $a_text =
"<br />".$a_text.
"<br />";
1192 while ($c_text !=
"")
1196 $s1 = strpos($c_text,
"<br />=");
1200 $s2 = strpos($c_text,
"<br />==");
1201 if (is_int($s2) && $s2 <= $s1)
1204 $s3 = strpos($c_text,
"<br />===");
1205 if (is_int($s3) && $s3 <= $s2)
1208 $n = strpos($c_text,
"<br />", $s3 + 1);
1209 if (
$n > ($s3+9) && substr($c_text,
$n-3, 9) ==
"===<br />")
1213 if ($s3 > 0 || $head !=
"")
1216 $chunks[] = array(
"level" => 0,
1220 $chunks[] = array(
"level" => 3,
1221 "text" => trim(substr($c_text, $s3+9,
$n-$s3-12)));
1227 $head.= substr($c_text, 0,
$n);
1228 $c_text = substr($c_text,
$n);
1234 $n = strpos($c_text,
"<br />", $s2 + 1);
1235 if (
$n > ($s2+8) && substr($c_text,
$n-2, 8) ==
"==<br />")
1239 if ($s2 > 0 || $head !=
"")
1242 $chunks[] = array(
"level" => 0,
1246 $chunks[] = array(
"level" => 2,
"text" => trim(substr($c_text, $s2+8,
$n-$s2-10)));
1252 $head.= substr($c_text, 0,
$n);
1253 $c_text = substr($c_text,
$n);
1260 $n = strpos($c_text,
"<br />", $s1 + 1);
1261 if (
$n > ($s1+7) && substr($c_text,
$n-1, 7) ==
"=<br />")
1265 if ($s1 > 0 || $head !=
"")
1268 $chunks[] = array(
"level" => 0,
1272 $chunks[] = array(
"level" => 1,
"text" => trim(substr($c_text, $s1+7,
$n-$s1-8)));
1278 $head.= substr($c_text, 0,
$n);
1279 $c_text = substr($c_text,
$n);
1287 $chunks[] = array(
"level" => 0,
"text" => $head.$c_text);
1292 if (count($chunks) == 0)
1294 $chunks[] = array(
"level" => 0,
"text" =>
"");
1299 if (substr($chunks[0][
"text"], 0, 6) ==
"<br />")
1301 $chunks[0][
"text"] = substr($chunks[0][
"text"], 6);
1305 if (substr($chunks[count($chunks) - 1][
"text"],
1306 strlen($chunks[count($chunks) - 1][
"text"]) - 6, 6) ==
"<br />")
1308 $chunks[count($chunks) - 1][
"text"] =
1309 substr($chunks[count($chunks) - 1][
"text"], 0, strlen($chunks[count($chunks) - 1][
"text"]) - 6);
1310 if ($chunks[count($chunks) - 1][
"text"] ==
"")
1312 unset($chunks[count($chunks) - 1]);
1325 if (substr($a_str, 0, 6) ==
"<br />" && substr($a_str, 6, 1) !=
"=")
1327 $a_str = substr($a_str, 6);
1333 if (substr($a_str, 0, 1) ==
"=")
1335 $a_str =
"<br />".$a_str;
1346 if (substr($a_str, strlen($a_str) - 6) ==
"<br />")
1348 $a_str = substr($a_str, 0, strlen($a_str) - 6);
1371 function saveJS($a_pg_obj, $a_content, $a_char, $a_pc_id, $a_insert_at =
"")
1376 if ($text ===
false)
1381 $pc_id = explode(
":", $a_pc_id);
1382 $insert_at = explode(
":", $a_insert_at);
1383 $t_id = explode(
":",
$t[
"id"]);
1386 if ($a_insert_at !=
"")
1389 $par->create($a_pg_obj, $insert_at[0], $insert_at[1]);
1393 $par = $a_pg_obj->getContentObject($pc_id[0], $pc_id[1]);
1396 if ($a_insert_at !=
"")
1398 $pc_id = $a_pg_obj->generatePCId();
1399 $par->writePCId($pc_id);
1400 $this->inserted_pc_id = $pc_id;
1404 $this->inserted_pc_id = $pc_id[1];
1407 $par->setLanguage($ilUser->getLanguage());
1408 $par->setCharacteristic(
$t[
"class"]);
1410 $t2 = $par->input2xml(
$t[
"text"],
true,
false);
1412 $updated = $par->setText($t2,
true);
1414 if ($updated !==
true)
1416 echo $updated;
exit;
1419 $updated = $a_pg_obj->update();
1433 $a_pg_obj->stripHierIDs();
1434 $a_pg_obj->addHierIds();
1437 $combined = $a_pg_obj->getHierIdsForPCIds(
1438 array($this->inserted_pc_id));
1439 foreach ($combined as $pc_id =>
$hier_id)
1442 $ids.= $sep.$hier_id.
":".$pc_id;
1449 return $this->inserted_pc_id;
1458 $a_content =
"<dummy>".$a_content.
"</dummy>";
1460 $doc =
new DOMDocument();
1467 $res = $doc->loadXML($content);
1475 $xpath =
new DOMXpath($doc);
1477 $elements = $xpath->query(
"//span");
1478 include_once(
"./Services/Utilities/classes/class.ilDOM2Util.php");
1479 while (!is_null($elements) && !is_null($element = $elements->item(0)))
1482 $class = $element->getAttribute(
"class");
1483 if (substr($class, 0, 16) ==
"ilc_text_inline_")
1485 $class_arr = explode(
" ", $class);
1487 for ($i = 1; $i < count($class_arr); $i++)
1497 $elements = $xpath->query(
"//span");
1501 $xpath =
new DOMXpath($doc);
1502 $elements = $xpath->query(
"/dummy/div");
1505 if (!is_null($elements))
1507 foreach ($elements as $element)
1509 $id = $element->getAttribute(
"id");
1510 $class = $element->getAttribute(
"class");
1511 $class = substr($class, 15);
1512 if (trim($class) ==
"")
1514 $class =
"Standard";
1517 $text = $doc->saveXML($element);
1518 $text = str_replace(
"<br/>",
"\n", $text);
1521 $pos = strpos($text,
">");
1522 $text = substr($text, $pos + 1);
1523 $pos = strrpos($text,
"<");
1524 $text = substr($text, 0, $pos);
1531 if (!in_array($bb, array(
"code",
"tex",
"fn",
"xln")))
1533 $text = str_replace(
"<il".$cl.
">",
1534 "[".$bb.
"]", $text);
1535 $text = str_replace(
"</il".$cl.
">",
1536 "[/".$bb.
"]", $text);
1537 $text = str_replace(
"<il".$cl.
"/>",
"", $text);
1540 $text = str_replace(array(
"<code>",
"</code>"),
1541 array(
"[code]",
"[/code]"), $text);
1543 $text = str_replace(
"<code/>",
"", $text);
1544 $text = str_replace(
'<ul class="ilc_list_u_BulletedList"/>',
"", $text);
1545 $text = str_replace(
'<ul class="ilc_list_o_NumberedList"/>',
"", $text);
1547 $ret[] = array(
"text" => $text,
"id" => $id,
"class" => $class);
1560 $text = str_replace(array(
"<ul>",
"</ul>"),
1561 array(
"<SimpleBulletList>",
"</SimpleBulletList>"), $text);
1562 $text = str_replace(array(
"<ul class='ilc_list_u_BulletedList'>",
"</ul>"),
1563 array(
"<SimpleBulletList>",
"</SimpleBulletList>"), $text);
1564 $text = str_replace(array(
"<ul class=\"ilc_list_u_BulletedList\">",
"</ul>"),
1565 array(
"<SimpleBulletList>",
"</SimpleBulletList>"), $text);
1566 $text = str_replace(array(
"<ol>",
"</ol>"),
1567 array(
"<SimpleNumberedList>",
"</SimpleNumberedList>"), $text);
1568 $text = str_replace(array(
"<ol class='ilc_list_o_NumberedList'>",
"</ol>"),
1569 array(
"<SimpleNumberedList>",
"</SimpleNumberedList>"), $text);
1570 $text = str_replace(array(
"<ol class=\"ilc_list_o_NumberedList\">",
"</ol>"),
1571 array(
"<SimpleNumberedList>",
"</SimpleNumberedList>"), $text);
1572 $text = str_replace(array(
"<li>",
"</li>"),
1573 array(
"<SimpleListItem>",
"</SimpleListItem>"), $text);
1574 $text = str_replace(array(
"<li class='ilc_list_item_StandardListItem'>",
"</li>"),
1575 array(
"<SimpleListItem>",
"</SimpleListItem>"), $text);
1576 $text = str_replace(array(
"<li class=\"ilc_list_item_StandardListItem\">",
"</li>"),
1577 array(
"<SimpleListItem>",
"</SimpleListItem>"), $text);
1579 $text = str_replace(array(
"<li class=\"ilc_list_item_StandardListItem\"/>"),
1580 array(
"<SimpleListItem></SimpleListItem>"), $text);
1582 $text = str_replace(
"<SimpleBulletList><br />",
"<SimpleBulletList>", $text);
1583 $text = str_replace(
"<SimpleNumberedList><br />",
"<SimpleNumberedList>", $text);
1584 $text = str_replace(
"<br /><SimpleBulletList>",
"<SimpleBulletList>", $text);
1585 $text = str_replace(
"<br /><SimpleNumberedList>",
"<SimpleNumberedList>", $text);
1586 $text = str_replace(
"</SimpleBulletList><br />",
"</SimpleBulletList>", $text);
1587 $text = str_replace(
"</SimpleNumberedList><br />",
"</SimpleNumberedList>", $text);
1588 $text = str_replace(
"</SimpleListItem><br />",
"</SimpleListItem>", $text);