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 $a_text = eregi_replace(
"\[com\]",
"<Comment Language=\"".$a_lang.
"\">",$a_text);
545 $a_text = eregi_replace(
"\[\/com\]",
"</Comment>",$a_text);
546 $a_text = eregi_replace(
"\[emp\]",
"<Emph>",$a_text);
547 $a_text = eregi_replace(
"\[\/emp\]",
"</Emph>",$a_text);
548 $a_text = eregi_replace(
"\[str\]",
"<Strong>",$a_text);
549 $a_text = eregi_replace(
"\[\/str\]",
"</Strong>",$a_text);
550 $a_text = eregi_replace(
"\[fn\]",
"<Footnote>",$a_text);
551 $a_text = eregi_replace(
"\[\/fn\]",
"</Footnote>",$a_text);
552 $a_text = eregi_replace(
"\[quot\]",
"<Quotation Language=\"".$a_lang.
"\">",$a_text);
553 $a_text = eregi_replace(
"\[\/quot\]",
"</Quotation>",$a_text);
554 $a_text = eregi_replace(
"\[code\]",
"<Code>",$a_text);
555 $a_text = eregi_replace(
"\[\/code\]",
"</Code>",$a_text);
556 $a_text = eregi_replace(
"\[acc\]",
"<Accent>",$a_text);
557 $a_text = eregi_replace(
"\[\/acc\]",
"</Accent>",$a_text);
558 $a_text = eregi_replace(
"\[imp\]",
"<Important>",$a_text);
559 $a_text = eregi_replace(
"\[\/imp\]",
"</Important>",$a_text);
560 $a_text = eregi_replace(
"\[kw\]",
"<Keyw>",$a_text);
561 $a_text = eregi_replace(
"\[\/kw\]",
"</Keyw>",$a_text);
565 $ws=
"[ \t\r\f\v\n]*";
567 while (eregi(
"\[(iln$ws((inst$ws=$ws([\"0-9])*)?$ws".
568 "((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)$ws=$ws([\"0-9])*)$ws".
569 "(target$ws=$ws(\"(New|FAQ|Media)\"))?$ws(anchor$ws=$ws(\"([^\"])*\"))?$ws))\]", $a_text, $found))
572 $inst_str = $attribs[
"inst"];
574 if (isset($attribs[
"page"]))
577 if (!empty($found[10]))
579 $tframestr =
" TargetFrame=\"".$found[10].
"\" ";
582 if ($attribs[
"anchor"] !=
"")
584 $ancstr =
' Anchor="'.$attribs[
"anchor"].
'" ';
586 $a_text = eregi_replace(
"\[".$found[1].
"\]",
587 "<IntLink Target=\"il_".$inst_str.
"_pg_".$attribs[page].
"\" Type=\"PageObject\"".$tframestr.$ancstr.
">", $a_text);
590 else if (isset($attribs[
"chap"]))
592 if (!empty($found[10]))
594 $tframestr =
" TargetFrame=\"".$found[10].
"\" ";
600 $a_text = eregi_replace(
"\[".$found[1].
"\]",
601 "<IntLink Target=\"il_".$inst_str.
"_st_".$attribs[chap].
"\" Type=\"StructureObject\"".$tframestr.
">", $a_text);
604 else if (isset($attribs[
"term"]))
609 $tframestr =
" TargetFrame=\"New\" ";
613 $tframestr =
" TargetFrame=\"Glossary\" ";
616 $a_text = eregi_replace(
"\[".$found[1].
"\]",
617 "<IntLink Target=\"il_".$inst_str.
"_git_".$attribs[term].
"\" Type=\"GlossaryItem\" $tframestr>", $a_text);
620 else if (isset($attribs[
"media"]))
622 if (!empty($found[10]))
624 $tframestr =
" TargetFrame=\"".$found[10].
"\" ";
625 $a_text = eregi_replace(
"\[".$found[1].
"\]",
626 "<IntLink Target=\"il_".$inst_str.
"_mob_".$attribs[media].
"\" Type=\"MediaObject\"".$tframestr.
">", $a_text);
630 $a_text = eregi_replace(
"\[".$found[1].
"\]",
631 "<IntLink Target=\"il_".$inst_str.
"_mob_".$attribs[media].
"\" Type=\"MediaObject\"/>", $a_text);
635 else if (isset($attribs[
"dfile"]))
637 $a_text = eregi_replace(
"\[".$found[1].
"\]",
638 "<IntLink Target=\"il_".$inst_str.
"_dfile_".$attribs[dfile].
"\" Type=\"File\">", $a_text);
642 else if (isset($attribs[
"lm"]) || isset($attribs[
"dbk"]) || isset($attribs[
"glo"])
643 || isset($attribs[
"frm"]) || isset($attribs[
"exc"]) || isset($attribs[
"tst"])
644 || isset($attribs[
"svy"]) || isset($attribs[
"obj"]) || isset($attribs[
'webr'])
645 || isset($attribs[
"htlm"]) || isset($attribs[
"chat"]) || isset($attribs[
"grp"])
646 || isset($attribs[
"fold"]) || isset($attribs[
"sahs"]) || isset($attribs[
"mcst"])
647 || isset($attribs[
"mep"]) || isset($attribs[
"wiki"])
648 || isset($attribs[
"cat"]) || isset($attribs[
"crs"]) || isset($attribs[
"file"]))
650 $obj_id = (isset($attribs[
"lm"])) ? $attribs[
"lm"] : $obj_id;
651 $obj_id = (isset($attribs[
"dbk"])) ? $attribs[
"dbk"] : $obj_id;
652 $obj_id = (isset($attribs[
"chat"])) ? $attribs[
"chat"] : $obj_id;
653 $obj_id = (isset($attribs[
"glo"])) ? $attribs[
"glo"] : $obj_id;
654 $obj_id = (isset($attribs[
"frm"])) ? $attribs[
"frm"] : $obj_id;
655 $obj_id = (isset($attribs[
"exc"])) ? $attribs[
"exc"] : $obj_id;
656 $obj_id = (isset($attribs[
"htlm"])) ? $attribs[
"htlm"] : $obj_id;
657 $obj_id = (isset($attribs[
"tst"])) ? $attribs[
"tst"] : $obj_id;
658 $obj_id = (isset($attribs[
"svy"])) ? $attribs[
"svy"] : $obj_id;
659 $obj_id = (isset($attribs[
"obj"])) ? $attribs[
"obj"] : $obj_id;
660 $obj_id = (isset($attribs[
"webr"])) ? $attribs[
"webr"] : $obj_id;
661 $obj_id = (isset($attribs[
"fold"])) ? $attribs[
"fold"] : $obj_id;
662 $obj_id = (isset($attribs[
"cat"])) ? $attribs[
"cat"] : $obj_id;
663 $obj_id = (isset($attribs[
"crs"])) ? $attribs[
"crs"] : $obj_id;
664 $obj_id = (isset($attribs[
"grp"])) ? $attribs[
"grp"] : $obj_id;
665 $obj_id = (isset($attribs[
"file"])) ? $attribs[
"file"] : $obj_id;
666 $obj_id = (isset($attribs[
"sahs"])) ? $attribs[
"sahs"] : $obj_id;
667 $obj_id = (isset($attribs[
"mcst"])) ? $attribs[
"mcst"] : $obj_id;
668 $obj_id = (isset($attribs[
"mep"])) ? $attribs[
"mep"] : $obj_id;
669 $obj_id = (isset($attribs[
"wiki"])) ? $attribs[
"wiki"] : $obj_id;
674 $a_text = eregi_replace(
"\[".$found[1].
"\]",
675 "<IntLink Target=\"il_".$inst_str.
"_obj_".$obj_id.
"\" Type=\"RepositoryItem\">", $a_text);
679 $a_text = eregi_replace(
"\[".$found[1].
"\]",
680 "<IntLink Target=\"il_".$inst_str.
"_".$found[6].
"_".$obj_id.
"\" Type=\"RepositoryItem\">", $a_text);
685 $a_text = eregi_replace(
"\[".$found[1].
"\]",
"[error: iln".$found[1].
"]",$a_text);
688 while (eregi(
"\[(iln$ws((inst$ws=$ws([\"0-9])*)?".$ws.
"media$ws=$ws([\"0-9])*)$ws)/\]", $a_text, $found))
691 $inst_str = $attribs[
"inst"];
692 $a_text = eregi_replace(
"\[".$found[1].
"/\]",
693 "<IntLink Target=\"il_".$inst_str.
"_mob_".$attribs[media].
"\" Type=\"MediaObject\"/>", $a_text);
695 $a_text = eregi_replace(
"\[\/iln\]",
"</IntLink>",$a_text);
698 $ws=
"[ \t\r\f\v\n]*";
699 while (eregi(
"\[(xln$ws(url$ws=$ws\"([^\"])*\")$ws(target$ws=$ws(\"(Glossary|FAQ|Media)\"))?$ws)\]", $a_text, $found))
702 if (isset($attribs[
"url"]))
706 if (in_array($a2[
"target"], array(
"FAQ",
"Glossary",
"Media")))
708 $tstr =
' TargetFrame="'.$a2[
"target"].
'"';
710 $a_text = str_replace(
"[".$found[1].
"]",
"<ExtLink Href=\"".$attribs[
"url"].
"\"$tstr>", $a_text);
714 $a_text = str_replace(
"[".$found[1].
"]",
"[error: xln".$found[1].
"]",$a_text);
719 while (eregi(
"\[(xln$ws(url$ws=$ws(([^]])*)))$ws\]", $a_text, $found))
723 $a_text = str_replace(
"[".$found[1].
"]",
"<ExtLink Href=\"".$found[3].
"\">", $a_text);
727 $a_text = str_replace(
"[".$found[1].
"]",
"[error: xln".$found[1].
"]",$a_text);
730 $a_text = eregi_replace(
"\[\/xln\]",
"</ExtLink>",$a_text);
733 $ws=
"[ \t\r\f\v\n]*";
734 while (eregi(
"\[(anc$ws(name$ws=$ws\"([^\"])*\")$ws)\]", $a_text, $found))
737 $a_text = str_replace(
"[".$found[1].
"]",
"<Anchor Name=\"".$attribs[
"name"].
"\">", $a_text);
739 $a_text = eregi_replace(
"\[\/anc\]",
"</Anchor>",$a_text);
753 $rows = explode(
"<br />", $a_text.
"<br />");
760 foreach ($rows as
$row)
763 if (str_replace(
"#",
"*", substr($row, 0, 3)) ==
"***")
767 else if (str_replace(
"#",
"*", substr($row, 0, 2)) ==
"**")
771 else if (str_replace(
"#",
"*", substr($row, 0, 1)) ==
"*")
777 if ($level < $old_level)
779 for ($i = $old_level; $i > $level; $i--)
781 $text.=
"</SimpleListItem></".$clist[$i].
">";
785 $text.=
"</SimpleListItem>";
788 else if ($old_level > 0 && $level > 0 && ($level == $old_level))
790 $text.=
"</SimpleListItem>";
792 else if (($level == $old_level) && $text !=
"")
798 if ($level > $old_level)
800 for($i = $old_level + 1; $i <= $level; $i++)
802 if (substr($row, $i - 1, 1) ==
"*")
804 $clist[$i] =
"SimpleBulletList";
808 $clist[$i] =
"SimpleNumberedList";
810 $text.=
"<".$clist[$i].
"><SimpleListItem>";
813 else if ($old_level > 0 && $level > 0)
815 $text.=
"<SimpleListItem>";
817 $text.= substr($row, $level);
823 if (substr($text, strlen($text) - 6) ==
"<br />")
825 $text = substr($text, 0, strlen($text) - 6);
841 "</SimpleListItem>",
"<SimpleListItem>",
"<SimpleListItem/>",
"<SimpleNumberedList>",
"</SimpleNumberedList>"));
843 $current_list = array();
845 for ($i=0; $i<= count($segments); $i++)
847 if ($segments[$i] ==
"<SimpleBulletList>")
849 if (count($current_list) == 0)
853 array_push($current_list,
"*");
856 else if ($segments[$i] ==
"<SimpleNumberedList>")
858 if (count($current_list) == 0)
862 array_push($current_list,
"#");
865 else if ($segments[$i] ==
"</SimpleBulletList>")
867 array_pop($current_list);
870 else if ($segments[$i] ==
"</SimpleNumberedList>")
872 array_pop($current_list);
875 else if ($segments[$i] ==
"<SimpleListItem>")
879 else if ($segments[$i] ==
"</SimpleListItem>")
883 else if ($segments[$i] ==
"<SimpleListItem/>")
890 foreach($current_list as $list)
906 foreach($current_list as $list)
911 $text.= $segments[$i];
921 if ($segments[count($segments) - 1] ==
"</SimpleBulletList>" ||
922 $segments[count($segments) - 1] ==
"</SimpleNumberedList>" &&
923 substr($text, strlen($text) - 6) ==
"<br />")
925 $text = substr($text, 0, strlen($text) - 6);
938 $nothing_found =
false;
939 while (!$nothing_found)
941 $nothing_found =
true;
943 foreach($a_needles as $needle)
945 $pos = stripos($a_haystack, $needle);
946 if (is_int($pos) && ($pos < $found || $found == -1))
949 $found_needle = $needle;
950 $nothing_found =
false;
955 $segments[] = substr($a_haystack, 0, $found);
956 $a_haystack = substr($a_haystack, $found);
960 $segments[] = substr($a_haystack, 0, strlen($found_needle));
961 $a_haystack = substr($a_haystack, strlen($found_needle));
964 if ($a_haystack !=
"")
966 $segments[] = $a_haystack;
979 static function xml2output($a_text, $a_wysiwyg =
false, $a_replace_lists =
true)
986 $a_text = eregi_replace(
"<Comment[^>]*>",
"[com]",$a_text);
987 $a_text = eregi_replace(
"</Comment>",
"[/com]",$a_text);
988 $a_text = eregi_replace(
"<Comment/>",
"[com][/com]",$a_text);
989 $a_text = eregi_replace(
"<Emph>",
"[emp]",$a_text);
990 $a_text = eregi_replace(
"</Emph>",
"[/emp]",$a_text);
991 $a_text = eregi_replace(
"<Emph/>",
"[emp][/emp]",$a_text);
992 $a_text = eregi_replace(
"<Strong>",
"[str]",$a_text);
993 $a_text = eregi_replace(
"</Strong>",
"[/str]",$a_text);
994 $a_text = eregi_replace(
"<Strong/>",
"[str][/str]",$a_text);
995 $a_text = eregi_replace(
"<Footnote[^>]*>",
"[fn]",$a_text);
996 $a_text = eregi_replace(
"</Footnote>",
"[/fn]",$a_text);
997 $a_text = eregi_replace(
"<Footnote/>",
"[fn][/fn]",$a_text);
998 $a_text = eregi_replace(
"<Quotation[^>]*>",
"[quot]",$a_text);
999 $a_text = eregi_replace(
"</Quotation>",
"[/quot]",$a_text);
1000 $a_text = eregi_replace(
"<Quotation/>",
"[quot][/quot]",$a_text);
1001 $a_text = eregi_replace(
"<Code[^>]*>",
"[code]",$a_text);
1002 $a_text = eregi_replace(
"</Code>",
"[/code]",$a_text);
1003 $a_text = eregi_replace(
"<Code/>",
"[code][/code]",$a_text);
1004 $a_text = eregi_replace(
"<Accent>",
"[acc]",$a_text);
1005 $a_text = eregi_replace(
"</Accent>",
"[/acc]",$a_text);
1006 $a_text = eregi_replace(
"<Important>",
"[imp]",$a_text);
1007 $a_text = eregi_replace(
"</Important>",
"[/imp]",$a_text);
1008 $a_text = eregi_replace(
"<Keyw>",
"[kw]",$a_text);
1009 $a_text = eregi_replace(
"</Keyw>",
"[/kw]",$a_text);
1012 if ($a_replace_lists)
1020 while (eregi(
"<IntLink($any)>", $a_text, $found))
1024 $target = explode(
"_", $attribs[
"Target"]);
1026 $inst_str = (!is_int(strpos($attribs[
"Target"],
"__")))
1027 ? $inst_str =
"inst=\"".$target[1].
"\" "
1029 switch($attribs[
"Type"])
1032 $tframestr = (!empty($attribs[
"TargetFrame"]))
1033 ?
" target=\"".$attribs[
"TargetFrame"].
"\""
1035 $ancstr = (!empty($attribs[
"Anchor"]))
1036 ?
' anchor="'.$attribs[
"Anchor"].
'"'
1038 $a_text = eregi_replace(
"<IntLink".$found[1].
">",
"[iln ".$inst_str.
"page=\"".
$target_id.
"\"$tframestr$ancstr]",$a_text);
1041 case "StructureObject":
1042 $tframestr = (!empty($attribs[
"TargetFrame"]))
1043 ?
" target=\"".$attribs[
"TargetFrame"].
"\""
1045 $a_text = eregi_replace(
"<IntLink".$found[1].
">",
"[iln ".$inst_str.
"chap=\"".
$target_id.
"\"$tframestr]",$a_text);
1048 case "GlossaryItem":
1049 $tframestr = (empty($attribs[
"TargetFrame"]) || $attribs[
"TargetFrame"] ==
"Glossary")
1051 :
" target=\"".$attribs[
"TargetFrame"].
"\"";
1052 $a_text = eregi_replace(
"<IntLink".$found[1].
">",
"[iln ".$inst_str.
"term=\"".
$target_id.
"\"".$tframestr.
"]",$a_text);
1056 if (empty($attribs[
"TargetFrame"]))
1058 $a_text = eregi_replace(
"<IntLink".$found[1].
">",
"[iln ".$inst_str.
"media=\"".
$target_id.
"\"/]",$a_text);
1062 $a_text = eregi_replace(
"<IntLink".$found[1].
">",
"[iln media=\"".
$target_id.
"\"".
1063 " target=\"".$attribs[
"TargetFrame"].
"\"]",$a_text);
1068 case "RepositoryItem":
1069 if ($inst_str ==
"")
1075 $rtype = $target[count($target) - 2];
1078 $a_text = eregi_replace(
"<IntLink".$found[1].
">",
"[iln ".$inst_str.
"$target_type=\"".
$target_id.
"\"".$tframestr.
"]",$a_text);
1083 $a_text = eregi_replace(
"<IntLink".$found[1].
">",
"[iln ".$inst_str.
"dfile=\"".
$target_id.
"\"".$tframestr.
"]",$a_text);
1087 $a_text = eregi_replace(
"<IntLink".$found[1].
">",
"[iln]",$a_text);
1091 $a_text = eregi_replace(
"</IntLink>",
"[/iln]",$a_text);
1094 while (eregi(
"<ExtLink($any)>", $a_text, $found))
1100 if (in_array($attribs[
"TargetFrame"], array(
"FAQ",
"Glossary",
"Media")))
1102 $tstr =
' target="'.$attribs[
"TargetFrame"].
'"';
1104 $a_text = str_replace(
"<ExtLink".$found[1].
">",
"[xln url=\"".$attribs[
"Href"].
"\"$tstr]",$a_text);
1106 $a_text = eregi_replace(
"</ExtLink>",
"[/xln]",$a_text);
1109 while (eregi(
"<Anchor($any)>", $a_text, $found))
1113 $a_text = str_replace(
"<Anchor".$found[1].
">",
"[anc name=\"".$attribs[
"Name"].
"\"]",$a_text);
1115 $a_text = eregi_replace(
"</Anchor>",
"[/anc]",$a_text);
1121 $a_text = str_replace(
"<br />",
"\n", $a_text);
1122 $a_text = str_replace(
"<br/>",
"\n", $a_text);
1128 $a_text = str_replace(
"{",
"{", $a_text);
1129 $a_text = str_replace(
"}",
"}", $a_text);
1132 $a_text = str_replace(
"<",
"<", $a_text);
1133 $a_text = str_replace(
">",
">",$a_text);
1136 $a_text = str_replace(
""",
"\"", $a_text);
1140 $a_text = str_replace(
"&",
"&", $a_text);
1143 $a_text = str_replace(
"<",
"&lt;", $a_text);
1144 $a_text = str_replace(
">",
"&gt;", $a_text);
1158 $a_text = str_replace (
"=<SimpleBulletList>",
"=<br /><SimpleBulletList>", $a_text);
1159 $a_text = str_replace (
"=<SimpleNumberedList>",
"=<br /><SimpleNumberedList>", $a_text);
1160 $a_text = str_replace (
"</SimpleBulletList>=",
"</SimpleBulletList><br />=", $a_text);
1161 $a_text = str_replace (
"</SimpleNumberedList>=",
"</SimpleNumberedList><br />=", $a_text);
1162 $a_text =
"<br />".$a_text.
"<br />";
1167 while ($c_text !=
"")
1171 $s1 = strpos($c_text,
"<br />=");
1175 $s2 = strpos($c_text,
"<br />==");
1176 if (is_int($s2) && $s2 <= $s1)
1179 $s3 = strpos($c_text,
"<br />===");
1180 if (is_int($s3) && $s3 <= $s2)
1183 $n = strpos($c_text,
"<br />", $s3 + 1);
1184 if (
$n > ($s3+9) && substr($c_text,
$n-3, 9) ==
"===<br />")
1188 if ($s3 > 0 || $head !=
"")
1191 $chunks[] = array(
"level" => 0,
1195 $chunks[] = array(
"level" => 3,
1196 "text" => trim(substr($c_text, $s3+9,
$n-$s3-12)));
1202 $head.= substr($c_text, 0,
$n);
1203 $c_text = substr($c_text,
$n);
1209 $n = strpos($c_text,
"<br />", $s2 + 1);
1210 if (
$n > ($s2+8) && substr($c_text,
$n-2, 8) ==
"==<br />")
1214 if ($s2 > 0 || $head !=
"")
1217 $chunks[] = array(
"level" => 0,
1221 $chunks[] = array(
"level" => 2,
"text" => trim(substr($c_text, $s2+8,
$n-$s2-10)));
1227 $head.= substr($c_text, 0,
$n);
1228 $c_text = substr($c_text,
$n);
1235 $n = strpos($c_text,
"<br />", $s1 + 1);
1236 if (
$n > ($s1+7) && substr($c_text,
$n-1, 7) ==
"=<br />")
1240 if ($s1 > 0 || $head !=
"")
1243 $chunks[] = array(
"level" => 0,
1247 $chunks[] = array(
"level" => 1,
"text" => trim(substr($c_text, $s1+7,
$n-$s1-8)));
1253 $head.= substr($c_text, 0,
$n);
1254 $c_text = substr($c_text,
$n);
1262 $chunks[] = array(
"level" => 0,
"text" => $head.$c_text);
1267 if (count($chunks) == 0)
1269 $chunks[] = array(
"level" => 0,
"text" =>
"");
1274 if (substr($chunks[0][
"text"], 0, 6) ==
"<br />")
1276 $chunks[0][
"text"] = substr($chunks[0][
"text"], 6);
1280 if (substr($chunks[count($chunks) - 1][
"text"],
1281 strlen($chunks[count($chunks) - 1][
"text"]) - 6, 6) ==
"<br />")
1283 $chunks[count($chunks) - 1][
"text"] =
1284 substr($chunks[count($chunks) - 1][
"text"], 0, strlen($chunks[count($chunks) - 1][
"text"]) - 6);
1285 if ($chunks[count($chunks) - 1][
"text"] ==
"")
1287 unset($chunks[count($chunks) - 1]);
1300 if (substr($a_str, 0, 6) ==
"<br />" && substr($a_str, 6, 1) !=
"=")
1302 $a_str = substr($a_str, 6);
1308 if (substr($a_str, 0, 1) ==
"=")
1310 $a_str =
"<br />".$a_str;
1321 if (substr($a_str, strlen($a_str) - 6) ==
"<br />")
1323 $a_str = substr($a_str, 0, strlen($a_str) - 6);
1346 function saveJS($a_pg_obj, $a_content, $a_char, $a_pc_id, $a_insert_at =
"")
1351 if ($text ===
false)
1356 $pc_id = explode(
":", $a_pc_id);
1357 $insert_at = explode(
":", $a_insert_at);
1358 $t_id = explode(
":",
$t[
"id"]);
1361 if ($a_insert_at !=
"")
1364 $par->create($a_pg_obj, $insert_at[0], $insert_at[1]);
1368 $par = $a_pg_obj->getContentObject($pc_id[0], $pc_id[1]);
1371 if ($a_insert_at !=
"")
1373 $pc_id = $a_pg_obj->generatePCId();
1374 $par->writePCId($pc_id);
1375 $this->inserted_pc_id = $pc_id;
1379 $this->inserted_pc_id = $pc_id[1];
1382 $par->setLanguage($ilUser->getLanguage());
1383 $par->setCharacteristic(
$t[
"class"]);
1385 $t2 = $par->input2xml(
$t[
"text"],
true,
false);
1387 $updated = $par->setText($t2,
true);
1389 if ($updated !==
true)
1391 echo $updated;
exit;
1394 $updated = $a_pg_obj->update();
1408 $a_pg_obj->stripHierIDs();
1409 $a_pg_obj->addHierIds();
1412 $combined = $a_pg_obj->getHierIdsForPCIds(
1413 array($this->inserted_pc_id));
1414 foreach ($combined as $pc_id =>
$hier_id)
1417 $ids.= $sep.$hier_id.
":".$pc_id;
1424 return $this->inserted_pc_id;
1433 $a_content =
"<dummy>".$a_content.
"</dummy>";
1435 $doc =
new DOMDocument();
1442 $res = $doc->loadXML($content);
1450 $xpath =
new DOMXpath($doc);
1452 $elements = $xpath->query(
"//span");
1453 include_once(
"./Services/Utilities/classes/class.ilDOM2Util.php");
1454 while (!is_null($elements) && !is_null($element = $elements->item(0)))
1457 $class = $element->getAttribute(
"class");
1458 if (substr($class, 0, 16) ==
"ilc_text_inline_")
1460 $class_arr = explode(
" ", $class);
1462 for ($i = 1; $i < count($class_arr); $i++)
1472 $elements = $xpath->query(
"//span");
1476 $xpath =
new DOMXpath($doc);
1477 $elements = $xpath->query(
"/dummy/div");
1480 if (!is_null($elements))
1482 foreach ($elements as $element)
1484 $id = $element->getAttribute(
"id");
1485 $class = $element->getAttribute(
"class");
1486 $class = substr($class, 15);
1487 if (trim($class) ==
"")
1489 $class =
"Standard";
1492 $text = $doc->saveXML($element);
1493 $text = str_replace(
"<br/>",
"\n", $text);
1496 $pos = strpos($text,
">");
1497 $text = substr($text, $pos + 1);
1498 $pos = strrpos($text,
"<");
1499 $text = substr($text, 0, $pos);
1506 if (!in_array($bb, array(
"code",
"tex",
"fn",
"xln")))
1508 $text = str_replace(
"<il".$cl.
">",
1509 "[".$bb.
"]", $text);
1510 $text = str_replace(
"</il".$cl.
">",
1511 "[/".$bb.
"]", $text);
1512 $text = str_replace(
"<il".$cl.
"/>",
"", $text);
1515 $text = str_replace(array(
"<code>",
"</code>"),
1516 array(
"[code]",
"[/code]"), $text);
1518 $text = str_replace(
"<code/>",
"", $text);
1519 $text = str_replace(
'<ul class="ilc_list_u_BulletedList"/>',
"", $text);
1520 $text = str_replace(
'<ul class="ilc_list_o_NumberedList"/>',
"", $text);
1522 $ret[] = array(
"text" => $text,
"id" => $id,
"class" => $class);
1535 $text = str_replace(array(
"<ul>",
"</ul>"),
1536 array(
"<SimpleBulletList>",
"</SimpleBulletList>"), $text);
1537 $text = str_replace(array(
"<ul class='ilc_list_u_BulletedList'>",
"</ul>"),
1538 array(
"<SimpleBulletList>",
"</SimpleBulletList>"), $text);
1539 $text = str_replace(array(
"<ul class=\"ilc_list_u_BulletedList\">",
"</ul>"),
1540 array(
"<SimpleBulletList>",
"</SimpleBulletList>"), $text);
1541 $text = str_replace(array(
"<ol>",
"</ol>"),
1542 array(
"<SimpleNumberedList>",
"</SimpleNumberedList>"), $text);
1543 $text = str_replace(array(
"<ol class='ilc_list_o_NumberedList'>",
"</ol>"),
1544 array(
"<SimpleNumberedList>",
"</SimpleNumberedList>"), $text);
1545 $text = str_replace(array(
"<ol class=\"ilc_list_o_NumberedList\">",
"</ol>"),
1546 array(
"<SimpleNumberedList>",
"</SimpleNumberedList>"), $text);
1547 $text = str_replace(array(
"<li>",
"</li>"),
1548 array(
"<SimpleListItem>",
"</SimpleListItem>"), $text);
1549 $text = str_replace(array(
"<li class='ilc_list_item_StandardListItem'>",
"</li>"),
1550 array(
"<SimpleListItem>",
"</SimpleListItem>"), $text);
1551 $text = str_replace(array(
"<li class=\"ilc_list_item_StandardListItem\">",
"</li>"),
1552 array(
"<SimpleListItem>",
"</SimpleListItem>"), $text);
1554 $text = str_replace(array(
"<li class=\"ilc_list_item_StandardListItem\"/>"),
1555 array(
"<SimpleListItem></SimpleListItem>"), $text);
1557 $text = str_replace(
"<SimpleBulletList><br />",
"<SimpleBulletList>", $text);
1558 $text = str_replace(
"<SimpleNumberedList><br />",
"<SimpleNumberedList>", $text);
1559 $text = str_replace(
"<br /><SimpleBulletList>",
"<SimpleBulletList>", $text);
1560 $text = str_replace(
"<br /><SimpleNumberedList>",
"<SimpleNumberedList>", $text);
1561 $text = str_replace(
"</SimpleBulletList><br />",
"</SimpleBulletList>", $text);
1562 $text = str_replace(
"</SimpleNumberedList><br />",
"</SimpleNumberedList>", $text);
1563 $text = str_replace(
"</SimpleListItem><br />",
"</SimpleListItem>", $text);