4require_once(
"./Services/COPage/classes/class.ilPageContent.php");
 
   37            "quot" => 
"Quotation",
 
   47        $this->
user = $DIC->user();
 
   68        return array_flip(self::$bb_tags);
 
   80        parent::setNode($a_node);               
 
   82        $childs = $a_node->child_nodes();
 
   83        for (
$i = 0; 
$i < count($childs); 
$i++) {
 
   84            if ($childs[
$i]->node_name() == 
"Paragraph") {
 
   85                $this->par_node = $childs[
$i];          
 
   99        $this->par_node = $this->dom->create_element(
"Paragraph");
 
  100        $this->par_node = $this->node->append_child($this->par_node);
 
  101        $this->par_node->set_attribute(
"Language", 
"");
 
  102        $node->append_child($this->node);
 
  113        $this->par_node = $this->dom->create_element(
"Paragraph");
 
  114        $this->par_node = $this->node->append_child($this->par_node);
 
  115        $this->par_node->set_attribute(
"Language", 
"");
 
  128        if ($succ_node = 
$node->next_sibling()) {
 
  129            $this->node = $succ_node->insert_before($this->node, $succ_node);
 
  131            $parent_node = 
$node->parent_node();
 
  132            $this->node = $parent_node->append_child($this->node);
 
  134        $this->par_node = $this->dom->create_element(
"Paragraph");
 
  135        $this->par_node = $this->node->append_child($this->par_node);
 
  136        $this->par_node->set_attribute(
"Language", 
"");
 
  146    public function create(&$a_pg_obj, $a_hier_id, $a_pc_id = 
"")
 
  150        $this->node = $this->dom->create_element(
"PageContent");
 
  153        $a_pg_obj->insertContent($this, $a_hier_id, 
IL_INSERT_AFTER, $a_pc_id);
 
  155        $this->par_node = $this->dom->create_element(
"Paragraph");
 
  156        $this->par_node = $this->node->append_child($this->par_node);
 
  157        $this->par_node->set_attribute(
"Language", 
"");
 
  166    public function setText($a_text, $a_auto_split = 
false)
 
  168        if (!is_array($a_text)) {
 
  169            $text = array(array(
"level" => 0, 
"text" => $a_text));
 
  189                '<?xml version="1.0" encoding="UTF-8"?><Paragraph>' . $text[0][
"text"] . 
'</Paragraph>',
 
  195            $children = $this->par_node->child_nodes();
 
  196            for (
$i = 0; 
$i < count($children); 
$i++) {
 
  197                $this->par_node->remove_child($children[
$i]);
 
  202            $path = 
"//Paragraph";
 
  204            if (count(
$res->nodeset) == 1) {
 
  205                $new_par_node = 
$res->nodeset[0];
 
  206                $new_childs = $new_par_node->child_nodes();
 
  208                for (
$i = 0; 
$i < count($new_childs); 
$i++) {
 
  209                    $cloned_child = $new_childs[
$i]->clone_node(
true);
 
  210                    $this->par_node->append_child($cloned_child);
 
  216                if ((count($text) > 1) && (substr($orig_characteristic, 0, 8) == 
"Headline")) {
 
  217                    $orig_characteristic = 
"";
 
  219                if ($text[0][
"level"] > 0) {
 
  220                    $this->par_node->set_attribute(
"Characteristic", 
'Headline' . $text[0][
"level"]);
 
  228            for (
$i = 1; 
$i < count($text); 
$i++) {
 
  231                    $next_par->createAfter($c_node);
 
  233                    if ($text[
$i][
"level"] > 0) {
 
  234                        $next_par->setCharacteristic(
"Headline" . $text[
$i][
"level"]);
 
  236                        $next_par->setCharacteristic($orig_characteristic);
 
  238                    $ok = $next_par->setText($text[
$i][
"text"], 
false);
 
  239                    $c_node = $next_par->node;
 
  246            $check = array_reduce($text, 
function ($t, 
$i) {
 
  247                return $t . 
$i[
"text"];
 
  249            $text = str_replace(
"<br>", 
"\n", $check);          
 
  250            $text = str_replace(
"<br/>", 
"\n", $text);
 
  251            $text = str_replace(
"<br />", 
"\n", $text);
 
  252            $text = str_replace(
"</SimpleListItem>", 
"</SimpleListItem>\n", $text);
 
  253            $text = str_replace(
"<SimpleBulletList>", 
"\n<SimpleBulletList>", $text);
 
  254            $text = str_replace(
"<SimpleNumberedList>", 
"\n<SimpleNumberedList>", $text);
 
  255            $text = str_replace(
"<Paragraph>\n", 
"<Paragraph>", $text);
 
  256            $text = str_replace(
"</Paragraph>", 
"</Paragraph>\n", $text);
 
  257            include_once(
"./Services/Dom/classes/class.ilDomDocument.php");
 
  258            $doc = 
new ilDOMDocument();
 
  259            $text = 
'<?xml version="1.0" encoding="UTF-8"?><Paragraph>' . $text . 
'</Paragraph>';
 
  261            $this->
success = $doc->loadXML($text);
 
  262            $error = $doc->errors;
 
  264            foreach ($error as 
$e) {
 
  265                $e = str_replace(
" in Entity", 
"", 
$e);
 
  266                $estr .= 
$e . 
"<br />";
 
  269                $estr .= 
"<br />" . $text;
 
  284        foreach ($text as $t) {
 
  285            $check .= 
"<Paragraph>" . $t[
"text"] . 
"</Paragraph>";
 
  290                '<?xml version="1.0" encoding="UTF-8"?><Paragraph>' . $check . 
'</Paragraph>',
 
  306        $dom = 
new DOMDocument();
 
  307        $dom->recover = 
true;
 
  309        for (
$i = 0; 
$i < count($text); 
$i++) {
 
  310            $dom->loadXML(
'<?xml version="1.0" encoding="UTF-8"?><Paragraph>' . $text[
$i][
"text"] . 
'</Paragraph>',
 
  311                LIBXML_NOWARNING | LIBXML_NOERROR);
 
  313                if (
$node->nodeName == 
"Paragraph") {
 
  315                    foreach (
$node->childNodes as $child)
 
  317                        $inner .= 
$dom->saveXML($child);
 
  319                    $text[
$i][
"text"] = $inner;
 
  331    public function getText($a_short_mode = 
false)
 
  333        if (is_object($this->par_node)) {
 
  335            $childs = $this->par_node->child_nodes();
 
  336            for (
$i = 0; 
$i < count($childs); 
$i++) {
 
  337                $content .= $this->dom->dump_node($childs[
$i]);
 
  350        $childs = $this->par_node->parent_node()->parent_node()->child_nodes();
 
  356        for (
$i = 0; 
$i < count($childs); 
$i++) {
 
  357            $pchilds = $childs[
$i]->child_nodes();
 
  358            if ($pchilds[0]->node_name() == 
"Paragraph" &&
 
  359                $pchilds[0]->get_attribute(
"Characteristic") != 
"Code") {
 
  360                $cur_seq[] = $childs[
$i];
 
  363                if ($childs[
$i]->get_attribute(
"PCID") == $pc_id &&
 
  364                    $childs[
$i]->get_attribute(
"HierId") == 
$hier_id) {
 
  382        foreach ($seq as $p_node) {
 
  383            $ids .= $id_sep . $p_node->get_attribute(
"HierId") . 
":" . $p_node->get_attribute(
"PCID");
 
  384            $po = $a_pg_obj->getContentObject(
 
  385                $p_node->get_attribute(
"HierId"),
 
  386                $p_node->get_attribute(
"PCID")
 
  388            $s_text = $po->getText();
 
  389            $s_text = $po->xml2output($s_text, 
true, 
false);
 
  390            $char = $po->getCharacteristic();
 
  400        return $ids . $content;
 
  410        if (!empty($a_char)) {
 
  411            $this->par_node->set_attribute(
"Characteristic", $a_char);
 
  413            if ($this->par_node->has_attribute(
"Characteristic")) {
 
  414                $this->par_node->remove_attribute(
"Characteristic");
 
  426        if (is_object($this->par_node)) {
 
  427            return $this->par_node->get_attribute(
"Characteristic");
 
  437        if (!empty($a_char)) {
 
  438            $this->par_node->set_attribute(
"SubCharacteristic", $a_char);
 
  440            if ($this->par_node->has_attribute(
"SubCharacteristic")) {
 
  441                $this->par_node->remove_attribute(
"SubCharacteristic");
 
  453        return $this->par_node->get_attribute(
"AutoIndent");
 
  458        if (!empty($a_char)) {
 
  459            $this->par_node->set_attribute(
"AutoIndent", $a_char);
 
  461            if ($this->par_node->has_attribute(
"AutoIndent")) {
 
  462                $this->par_node->remove_attribute(
"AutoIndent");
 
  472        return $this->par_node->get_attribute(
"SubCharacteristic");
 
  481        if (!empty($a_char)) {
 
  482            $this->par_node->set_attribute(
"DownloadTitle", $a_char);
 
  484            if ($this->par_node->has_attribute(
"DownloadTitle")) {
 
  485                $this->par_node->remove_attribute(
"DownloadTitle");
 
  495        return $this->par_node->get_attribute(
"DownloadTitle");
 
  504        $a_char = empty($a_char)?
"n":$a_char;
 
  506        $this->par_node->set_attribute(
"ShowLineNumbers", $a_char);
 
  515        return $this->par_node->get_attribute(
"ShowLineNumbers");
 
  523        $this->par_node->set_attribute(
"Language", $a_lang);
 
  531        return $this->par_node->get_attribute(
"Language");
 
  534    public function input2xml($a_text, $a_wysiwyg = 0, $a_handle_lists = 
true)
 
  549        $a_text = preg_replace(
'/\[' . $a_bb . 
'\]/i', 
"<" . $a_tag . 
">", $a_text);
 
  550        $a_text = preg_replace(
'/\[\/' . $a_bb . 
'\]/i', 
"</" . $a_tag . 
">", $a_text);
 
  558    public static function _input2xml($a_text, $a_lang, $a_wysiwyg = 0, $a_handle_lists = 
true)
 
  565            $a_text = str_replace(
"<br />", chr(10), $a_text);
 
  570        $a_text = trim($a_text);
 
  576            $a_text = str_replace(
"&", 
"&", $a_text);
 
  578        $a_text = str_replace(
"<", 
"<", $a_text);
 
  579        $a_text = str_replace(
">", 
">", $a_text);
 
  582        $a_text = preg_replace(
'/<([\s\/]*?PageTurn.*?)>/i', 
"<$1>", $a_text);
 
  583        $a_text = preg_replace(
'/<([\s\/]*?BibItemIdentifier.*?)>/i', 
"<$1>", $a_text);
 
  594        $a_text = str_replace(chr(13) . chr(10), 
"<br />", $a_text);
 
  595        $a_text = str_replace(chr(13), 
"<br />", $a_text);
 
  596        $a_text = str_replace(chr(10), 
"<br />", $a_text);
 
  598        if ($a_handle_lists) {
 
  602        foreach (self::getBBMap() as $bb => $tag) {
 
  604            $a_text = str_replace(
"[" . $bb . 
"][/" . $bb . 
"]", 
"", $a_text);
 
  613        $ws = 
"[ \t\r\f\v\n]*";
 
  615        while (preg_match(
"~\[(xln$ws(url$ws=$ws\"([^\"])*\")$ws(target$ws=$ws(\"(Glossary|FAQ|Media)\"))?$ws)\]\[\/xln\]~i", $a_text, $found)) {
 
  616            $a_text = str_replace($found[0], 
"", $a_text);
 
  618        while (preg_match(
'~\[(xln$ws(url$ws=$ws(([^]])*)))$ws\]\[\/xln\]~i', $a_text, $found)) {
 
  619            $a_text = str_replace($found[0], 
"", $a_text);
 
  622        while (preg_match(
"~\[(xln$ws(url$ws=$ws\"([^\"])*\")$ws(target$ws=$ws(\"(Glossary|FAQ|Media)\"))?$ws)\]~i", $a_text, $found)) {
 
  624            if (isset($attribs[
"url"])) {
 
  627                if (in_array($a2[
"target"], array(
"FAQ", 
"Glossary", 
"Media"))) {
 
  628                    $tstr = 
' TargetFrame="' . $a2[
"target"] . 
'"';
 
  630                $a_text = str_replace(
"[" . $found[1] . 
"]", 
"<ExtLink Href=\"" . $attribs[
"url"] . 
"\"$tstr>", $a_text);
 
  632                $a_text = str_replace(
"[" . $found[1] . 
"]", 
"[error: xln" . $found[1] . 
"]", $a_text);
 
  637        while (preg_match(
'~\[(xln$ws(url$ws=$ws(([^]])*)))$ws\]~i', $a_text, $found)) {
 
  638            if ($found[3] != 
"") {
 
  639                $a_text = str_replace(
"[" . $found[1] . 
"]", 
"<ExtLink Href=\"" . $found[3] . 
"\">", $a_text);
 
  641                $a_text = str_replace(
"[" . $found[1] . 
"]", 
"[error: xln" . $found[1] . 
"]", $a_text);
 
  644        $a_text = preg_replace(
'~\[\/xln\]~i', 
"</ExtLink>", $a_text);
 
  647        $ws = 
"[ \t\r\f\v\n]*";
 
  648        while (preg_match(
"~\[(anc$ws(name$ws=$ws\"([^\"])*\")$ws)\]~i", $a_text, $found)) {
 
  650            $a_text = str_replace(
"[" . $found[1] . 
"]", 
"<Anchor Name=\"" . $attribs[
"name"] . 
"\">", $a_text);
 
  652        $a_text = preg_replace(
"~\[\/anc\]~i", 
"</Anchor>", $a_text);
 
  655        while (preg_match(
"~\[(marked$ws(class$ws=$ws\"([^\"])*\")$ws)\]~i", $a_text, $found)) {
 
  657            if (isset($attribs[
"class"])) {
 
  658                $a_text = str_replace(
"[" . $found[1] . 
"]", 
"<Marked Class=\"" . $attribs[
"class"] . 
"\">", $a_text);
 
  660                $a_text = str_replace(
"[" . $found[1] . 
"]", 
"[error:marked" . $found[1] . 
"]", $a_text);
 
  663        $a_text = preg_replace(
'~\[\/marked\]~i', 
"</Marked>", $a_text);
 
  680        $objDefinition = 
$DIC[
"objDefinition"];
 
  682        $rtypes = $objDefinition->getAllRepositoryTypes();
 
  686        $ws = 
"[ \t\r\f\v\n]*";
 
  687        $ltypes = 
"page|chap|term|media|obj|dfile|sess|wpage|ppage|" . implode(
"|", $rtypes);
 
  689        while (preg_match(
'~\[(iln' . $ws . 
'((inst' . $ws . 
'=' . $ws . 
'([\"0-9])*)?' . $ws .
 
  690            "((" . $ltypes . 
")$ws=$ws([\"0-9])*)$ws" .
 
  691            "(target$ws=$ws(\"(New|FAQ|Media)\"))?$ws(anchor$ws=$ws(\"([^\"])*\"))?$ws))\]\[\/iln\]~i", $a_text, $found)) {
 
  692            $a_text = str_replace($found[0], 
"", $a_text);
 
  694        while (preg_match(
'~\[(iln' . $ws . 
'((inst' . $ws . 
'=' . $ws . 
'([\"0-9])*)?' . $ws .
 
  695            "((" . $ltypes . 
")$ws=$ws([\"0-9])*)$ws" .
 
  696            "(target$ws=$ws(\"(New|FAQ|Media)\"))?$ws(anchor$ws=$ws(\"([^\"])*\"))?$ws))\]~i", $a_text, $found)) {
 
  698            $inst_str = $attribs[
"inst"];
 
  700            if (isset($attribs[
"page"])) {
 
  702                if (!empty($found[10])) {
 
  703                    $tframestr = 
" TargetFrame=\"" . $found[10] . 
"\" ";
 
  706                if ($attribs[
"anchor"] != 
"") {
 
  707                    $ancstr = 
' Anchor="' . $attribs[
"anchor"] . 
'" ';
 
  710                $a_text = preg_replace(
 
  711                    '/\[' . addcslashes($found[1], 
'/') . 
'\]/i',
 
  712                    "<IntLink Target=\"il_" . $inst_str . 
"_pg_" . $attribs[
'page'] . 
"\" Type=\"PageObject\"" . $tframestr . $ancstr . 
">",
 
  717            elseif (isset($attribs[
"chap"])) {
 
  718                if (!empty($found[10])) {
 
  719                    $tframestr = 
" TargetFrame=\"" . $found[10] . 
"\" ";
 
  723                $a_text = preg_replace(
 
  724                    '/\[' . $found[1] . 
'\]/i',
 
  725                    "<IntLink Target=\"il_" . $inst_str . 
"_st_" . $attribs[
'chap'] . 
"\" Type=\"StructureObject\"" . $tframestr . 
">",
 
  730            elseif (isset($attribs[
"term"])) {
 
  731                switch ($found[10]) {
 
  733                        $tframestr = 
" TargetFrame=\"New\" ";
 
  737                        $tframestr = 
" TargetFrame=\"Glossary\" ";
 
  740                $a_text = preg_replace(
 
  741                    '/\[' . $found[1] . 
'\]/i',
 
  742                    "<IntLink Target=\"il_" . $inst_str . 
"_git_" . $attribs[
'term'] . 
"\" Type=\"GlossaryItem\" $tframestr>",
 
  747            elseif (isset($attribs[
"wpage"])) {
 
  749                $a_text = preg_replace(
 
  750                    '/\[' . $found[1] . 
'\]/i',
 
  751                    "<IntLink Target=\"il_" . $inst_str . 
"_wpage_" . $attribs[
'wpage'] . 
"\" Type=\"WikiPage\" $tframestr>",
 
  756            elseif (isset($attribs[
"ppage"])) {
 
  758                $a_text = preg_replace(
 
  759                    '/\[' . $found[1] . 
'\]/i',
 
  760                    "<IntLink Target=\"il_" . $inst_str . 
"_ppage_" . $attribs[
'ppage'] . 
"\" Type=\"PortfolioPage\" $tframestr>",
 
  765            elseif (isset($attribs[
"media"])) {
 
  766                if (!empty($found[10])) {
 
  767                    $tframestr = 
" TargetFrame=\"" . $found[10] . 
"\" ";
 
  768                    $a_text = preg_replace(
 
  769                        '/\[' . $found[1] . 
'\]/i',
 
  770                        "<IntLink Target=\"il_" . $inst_str . 
"_mob_" . $attribs[
'media'] . 
"\" Type=\"MediaObject\"" . $tframestr . 
">",
 
  774                    $a_text = preg_replace(
 
  775                        '/\[' . $found[1] . 
'\]/i',
 
  776                        "<IntLink Target=\"il_" . $inst_str . 
"_mob_" . $attribs[
'media'] . 
"\" Type=\"MediaObject\"/>",
 
  782            elseif (isset($attribs[
"dfile"])) {
 
  783                $a_text = preg_replace(
 
  784                    '/\[' . $found[1] . 
'\]/i',
 
  785                    "<IntLink Target=\"il_" . $inst_str . 
"_dfile_" . $attribs[
'dfile'] . 
"\" Type=\"File\">",
 
  792                foreach ($objDefinition->getAllRepositoryTypes() as $t) {
 
  793                    if (isset($attribs[$t])) {
 
  794                        $obj_id = $attribs[$t];
 
  797                if (isset($attribs[
"obj"])) {
 
  798                    $obj_id = $attribs[
"obj"];
 
  802                    if ($inst_str == 
"") {
 
  803                        $a_text = preg_replace(
 
  804                            '/\[' . $found[1] . 
'\]/i',
 
  805                            "<IntLink Target=\"il_" . $inst_str . 
"_obj_" . $obj_id . 
"\" Type=\"RepositoryItem\">",
 
  809                        $a_text = preg_replace(
 
  810                            '/\[' . $found[1] . 
'\]/i',
 
  811                            "<IntLink Target=\"il_" . $inst_str . 
"_" . $found[6] . 
"_" . $obj_id . 
"\" Type=\"RepositoryItem\">",
 
  816                    $a_text = preg_replace(
'/\[' . $found[1] . 
'\]/i', 
"[error: iln" . $found[1] . 
"]", $a_text);
 
  821        while (preg_match(
"~\[(iln$ws((inst$ws=$ws([\"0-9])*)?" . $ws . 
"media$ws=$ws([\"0-9])*)$ws)/\]~i", $a_text, $found)) {
 
  823            $inst_str = $attribs[
"inst"];
 
  824            $a_text = preg_replace(
 
  825                '~\[' . $found[1] . 
'/\]~i',
 
  826                "<IntLink Target=\"il_" . $inst_str . 
"_mob_" . $attribs[
'media'] . 
"\" Type=\"MediaObject\"/>",
 
  832        while (preg_match(
"~\[(iln$ws((inst$ws=$ws([\"0-9])*)?" . $ws . 
"user$ws=$ws(\"([^\"])*)\")$ws)/\]~i", $a_text, $found)) {
 
  834            $inst_str = $attribs[
"inst"];
 
  835            include_once(
"./Services/User/classes/class.ilObjUser.php");
 
  837            $a_text = preg_replace(
 
  838                '~\[' . $found[1] . 
'/\]~i',
 
  839                "<IntLink Target=\"il_" . $inst_str . 
"_user_" . $user_id . 
"\" Type=\"User\"/>",
 
  844        $a_text = preg_replace(
'~\[\/iln\]~i', 
"</IntLink>", $a_text);
 
  858        $rows = explode(
"<br />", $a_text . 
"<br />");
 
  865        foreach (
$rows as $row) {
 
  867            if (str_replace(
"#", 
"*", substr($row, 0, 3)) == 
"***") {
 
  869            } elseif (str_replace(
"#", 
"*", substr($row, 0, 2)) == 
"**") {
 
  871            } elseif (str_replace(
"#", 
"*", substr($row, 0, 1)) == 
"*") {
 
  876            if ($level < $old_level) {
 
  877                for (
$i = $old_level; 
$i > $level; 
$i--) {
 
  878                    $text .= 
"</SimpleListItem></" . $clist[
$i] . 
">";
 
  881                    $text .= 
"</SimpleListItem>";
 
  883            } elseif ($old_level > 0 && $level > 0 && ($level == $old_level)) {
 
  884                $text .= 
"</SimpleListItem>";
 
  885            } elseif (($level == $old_level) && $text != 
"") {
 
  890            if ($level > $old_level) {
 
  891                for (
$i = $old_level + 1; 
$i <= $level; 
$i++) {
 
  892                    if (substr($row, 
$i - 1, 1) == 
"*") {
 
  893                        $clist[
$i] = 
"SimpleBulletList";
 
  895                        $clist[
$i] = 
"SimpleNumberedList";
 
  897                    $text .= 
"<" . $clist[
$i] . 
"><SimpleListItem>";
 
  899            } elseif ($old_level > 0 && $level > 0) {
 
  900                $text .= 
"<SimpleListItem>";
 
  902            $text .= substr($row, $level);
 
  908        if (substr($text, strlen($text) - 6) == 
"<br />") {
 
  909            $text = substr($text, 0, strlen($text) - 6);
 
  925            "</SimpleListItem>", 
"<SimpleListItem>", 
"<SimpleListItem/>", 
"<SimpleNumberedList>", 
"</SimpleNumberedList>"));
 
  927        $current_list = array();
 
  929        for (
$i = 0; 
$i <= count($segments); 
$i++) {
 
  930            if ($segments[
$i] == 
"<SimpleBulletList>") {
 
  931                if (count($current_list) == 0) {
 
  934                array_push($current_list, 
"*");
 
  936            } elseif ($segments[
$i] == 
"<SimpleNumberedList>") {
 
  937                if (count($current_list) == 0) {
 
  940                array_push($current_list, 
"#");
 
  942            } elseif ($segments[
$i] == 
"</SimpleBulletList>") {
 
  943                array_pop($current_list);
 
  945            } elseif ($segments[
$i] == 
"</SimpleNumberedList>") {
 
  946                array_pop($current_list);
 
  948            } elseif ($segments[
$i] == 
"<SimpleListItem>") {
 
  950            } elseif ($segments[
$i] == 
"</SimpleListItem>") {
 
  952            } elseif ($segments[
$i] == 
"<SimpleListItem/>") {
 
  957                foreach ($current_list as $list) {
 
  968                    foreach ($current_list as $list) {
 
  972                $text .= $segments[
$i];
 
  981        if ($segments[count($segments) - 1] == 
"</SimpleBulletList>" ||
 
  982            $segments[count($segments) - 1] == 
"</SimpleNumberedList>" &&
 
  983            substr($text, strlen($text) - 6) == 
"<br />") {
 
  984            $text = substr($text, 0, strlen($text) - 6);
 
  997        $nothing_found = 
false;
 
  998        while (!$nothing_found) {
 
  999            $nothing_found = 
true;
 
 1001            foreach ($a_needles as $needle) {
 
 1002                $pos = stripos($a_haystack, $needle);
 
 1003                if (is_int($pos) && ($pos < $found || $found == -1)) {
 
 1005                    $found_needle = $needle;
 
 1006                    $nothing_found = 
false;
 
 1010                $segments[] = substr($a_haystack, 0, $found);
 
 1011                $a_haystack = substr($a_haystack, $found);
 
 1014                $segments[] = substr($a_haystack, 0, strlen($found_needle));
 
 1015                $a_haystack = substr($a_haystack, strlen($found_needle));
 
 1018        if ($a_haystack != 
"") {
 
 1019            $segments[] = $a_haystack;
 
 1032    public static function xml2output($a_text, $a_wysiwyg = 
false, $a_replace_lists = 
true, $unmask = 
true)
 
 1040        foreach (self::getBBMap() as $bb => $tag) {
 
 1041            $a_text = preg_replace(
'~<' . $tag . 
'[^>]*>~i', 
"[" . $bb . 
"]", $a_text);
 
 1042            $a_text = preg_replace(
'~</' . $tag . 
'>~i', 
"[/" . $bb . 
"]", $a_text);
 
 1043            $a_text = preg_replace(
'~<' . $tag . 
'/>~i', 
"[" . $bb . 
"][/" . $bb . 
"]", $a_text);
 
 1047        if ($a_replace_lists) {
 
 1054        while (preg_match(
'~<IntLink(' . $any . 
')>~i', $a_text, $found)) {
 
 1057            $target = explode(
"_", $attribs[
"Target"]);
 
 1059            $inst_str = (!is_int(strpos($attribs[
"Target"], 
"__")))
 
 1060                ? $inst_str = 
"inst=\"" . $target[1] . 
"\" " 
 1062            switch ($attribs[
"Type"]) {
 
 1064                    $tframestr = (!empty($attribs[
"TargetFrame"]))
 
 1065                        ? 
" target=\"" . $attribs[
"TargetFrame"] . 
"\"" 
 1067                    $ancstr = (!empty($attribs[
"Anchor"]))
 
 1068                        ? 
' anchor="' . $attribs[
"Anchor"] . 
'"' 
 1070                    $a_text = preg_replace(
'~<IntLink' . $found[1] . 
'>~i', 
"[iln " . $inst_str . 
"page=\"" . 
$target_id . 
"\"$tframestr$ancstr]", $a_text);
 
 1073                case "StructureObject":
 
 1074                    $tframestr = (!empty($attribs[
"TargetFrame"]))
 
 1075                        ? 
" target=\"" . $attribs[
"TargetFrame"] . 
"\"" 
 1077                    $a_text = preg_replace(
'~<IntLink' . $found[1] . 
'>~i', 
"[iln " . $inst_str . 
"chap=\"" . 
$target_id . 
"\"$tframestr]", $a_text);
 
 1080                case "GlossaryItem":
 
 1081                    $tframestr = (empty($attribs[
"TargetFrame"]) || $attribs[
"TargetFrame"] == 
"Glossary")
 
 1083                        : 
" target=\"" . $attribs[
"TargetFrame"] . 
"\"";
 
 1084                    $a_text = preg_replace(
'~<IntLink' . $found[1] . 
'>~i', 
"[iln " . $inst_str . 
"term=\"" . 
$target_id . 
"\"" . $tframestr . 
"]", $a_text);
 
 1089                    $a_text = preg_replace(
'~<IntLink' . $found[1] . 
'>~i', 
"[iln " . $inst_str . 
"wpage=\"" . 
$target_id . 
"\"" . $tframestr . 
"]", $a_text);
 
 1092                case "PortfolioPage":
 
 1094                    $a_text = preg_replace(
'~<IntLink' . $found[1] . 
'>~i', 
"[iln " . $inst_str . 
"ppage=\"" . 
$target_id . 
"\"" . $tframestr . 
"]", $a_text);
 
 1098                    if (empty($attribs[
"TargetFrame"])) {
 
 1099                        $a_text = preg_replace(
'~<IntLink' . $found[1] . 
'>~i', 
"[iln " . $inst_str . 
"media=\"" . 
$target_id . 
"\"/]", $a_text);
 
 1101                        $a_text = preg_replace(
'~<IntLink' . $found[1] . 
'>~i', 
"[iln media=\"" . 
$target_id . 
"\"" .
 
 1102                            " target=\"" . $attribs[
"TargetFrame"] . 
"\"]", $a_text);
 
 1107                case "RepositoryItem":
 
 1108                    if ($inst_str == 
"") {
 
 1111                        $rtype = $target[count($target) - 2];
 
 1114                    $a_text = preg_replace(
'~<IntLink' . $found[1] . 
'>~i', 
"[iln " . $inst_str . 
"$target_type=\"" . 
$target_id . 
"\"" . $tframestr . 
"]", $a_text);
 
 1119                    $a_text = preg_replace(
'~<IntLink' . $found[1] . 
'>~i', 
"[iln " . $inst_str . 
"dfile=\"" . 
$target_id . 
"\"" . $tframestr . 
"]", $a_text);
 
 1124                    include_once(
"./Services/User/classes/class.ilObjUser.php");
 
 1129                    $a_text = preg_replace(
'~<IntLink' . $found[1] . 
'>~i', 
"[iln]", $a_text);
 
 1133        $a_text = str_replace(
"</IntLink>", 
"[/iln]", $a_text);
 
 1136        while (preg_match(
'~<ExtLink(' . $any . 
')>~i', $a_text, $found)) {
 
 1141            if (in_array($attribs[
"TargetFrame"], array(
"FAQ", 
"Glossary", 
"Media"))) {
 
 1142                $tstr = 
' target="' . $attribs[
"TargetFrame"] . 
'"';
 
 1144            $a_text = str_replace(
"<ExtLink" . $found[1] . 
">", 
"[xln url=\"" . $attribs[
"Href"] . 
"\"$tstr]", $a_text);
 
 1146        $a_text = str_replace(
"</ExtLink>", 
"[/xln]", $a_text);
 
 1149        while (preg_match(
'~<Anchor(' . $any . 
'/)>~i', $a_text, $found)) {
 
 1152            $a_text = str_replace(
"<Anchor" . $found[1] . 
">", 
"[anc name=\"" . $attribs[
"Name"] . 
"\"][/anc]", $a_text);
 
 1154        while (preg_match(
'~<Anchor(' . $any . 
')>~i', $a_text, $found)) {
 
 1157            $a_text = str_replace(
"<Anchor" . $found[1] . 
">", 
"[anc name=\"" . $attribs[
"Name"] . 
"\"]", $a_text);
 
 1159        $a_text = str_replace(
"</Anchor>", 
"[/anc]", $a_text);
 
 1162        while (preg_match(
'~<Marked(' . $any . 
')>~i', $a_text, $found)) {
 
 1165            $a_text = str_replace(
"<Marked" . $found[1] . 
">", 
"[marked class=\"" . $attribs[
"Class"] . 
"\"]", $a_text);
 
 1167        $a_text = str_replace(
"</Marked>", 
"[/marked]", $a_text);
 
 1171            $a_text = str_replace(
"<br />", 
"\n", $a_text);
 
 1172            $a_text = str_replace(
"<br/>", 
"\n", $a_text);
 
 1177            $a_text = str_replace(
"{", 
"{", $a_text);
 
 1178            $a_text = str_replace(
"}", 
"}", $a_text);
 
 1182                $a_text = str_replace(
"<", 
"<", $a_text);
 
 1183                $a_text = str_replace(
">", 
">", $a_text);
 
 1187            $a_text = str_replace(
""", 
"\"", $a_text);
 
 1191            $a_text = str_replace(
"&", 
"&", $a_text);
 
 1195                $a_text = str_replace(
"<", 
"&lt;", $a_text);
 
 1196                $a_text = str_replace(
">", 
"&gt;", $a_text);
 
 1211        $a_text = str_replace(
"=<SimpleBulletList>", 
"=<br /><SimpleBulletList>", $a_text);
 
 1212        $a_text = str_replace(
"=<SimpleNumberedList>", 
"=<br /><SimpleNumberedList>", $a_text);
 
 1213        $a_text = str_replace(
"</SimpleBulletList>=", 
"</SimpleBulletList><br />=", $a_text);
 
 1214        $a_text = str_replace(
"</SimpleNumberedList>=", 
"</SimpleNumberedList><br />=", $a_text);
 
 1215        $a_text = 
"<br />" . $a_text . 
"<br />";                
 
 1220        while ($c_text != 
"") {
 
 1223            $s1 = strpos($c_text, 
"<br />=");
 
 1226                $s2 = strpos($c_text, 
"<br />==");
 
 1227                if (is_int($s2) && $s2 <= $s1) {
 
 1229                    $s3 = strpos($c_text, 
"<br />===");
 
 1230                    if (is_int($s3) && $s3 <= $s2) {            
 
 1232                        $n = strpos($c_text, 
"<br />", $s3 + 1);
 
 1233                        if (
$n > ($s3 + 9) && substr($c_text, 
$n - 3, 9) == 
"===<br />") {
 
 1236                            if ($s3 > 0 || $head != 
"") {
 
 1238                                $chunks[] = array(
"level" => 0,
 
 1242                            $chunks[] = array(
"level" => 3,
 
 1243                                "text" => trim(substr($c_text, $s3 + 9, 
$n - $s3 - 12)));
 
 1247                            $head .= substr($c_text, 0, 
$n);
 
 1248                            $c_text = substr($c_text, 
$n);
 
 1252                        $n = strpos($c_text, 
"<br />", $s2 + 1);
 
 1253                        if (
$n > ($s2 + 8) && substr($c_text, 
$n - 2, 8) == 
"==<br />") {
 
 1256                            if ($s2 > 0 || $head != 
"") {
 
 1258                                $chunks[] = array(
"level" => 0,
 
 1262                            $chunks[] = array(
"level" => 2, 
"text" => trim(substr($c_text, $s2 + 8, 
$n - $s2 - 10)));
 
 1266                            $head .= substr($c_text, 0, 
$n);
 
 1267                            $c_text = substr($c_text, 
$n);
 
 1272                    $n = strpos($c_text, 
"<br />", $s1 + 1);
 
 1273                    if (
$n > ($s1 + 7) && substr($c_text, 
$n - 1, 7) == 
"=<br />") {
 
 1276                        if ($s1 > 0 || $head != 
"") {
 
 1278                            $chunks[] = array(
"level" => 0,
 
 1282                        $chunks[] = array(
"level" => 1, 
"text" => trim(substr($c_text, $s1 + 7, 
$n - $s1 - 8)));
 
 1286                        $head .= substr($c_text, 0, 
$n);
 
 1287                        $c_text = substr($c_text, 
$n);
 
 1293                $chunks[] = array(
"level" => 0, 
"text" => $head . $c_text);
 
 1298        if (count($chunks) == 0) {
 
 1299            $chunks[] = array(
"level" => 0, 
"text" => 
"");
 
 1304        if (substr($chunks[0][
"text"], 0, 6) == 
"<br />") {
 
 1305            $chunks[0][
"text"] = substr($chunks[0][
"text"], 6);
 
 1310            $chunks[count($chunks) - 1][
"text"],
 
 1311            strlen($chunks[count($chunks) - 1][
"text"]) - 6,
 
 1314            $chunks[count($chunks) - 1][
"text"] =
 
 1315                substr($chunks[count($chunks) - 1][
"text"], 0, strlen($chunks[count($chunks) - 1][
"text"]) - 6);
 
 1316            if ($chunks[count($chunks) - 1][
"text"] == 
"") {
 
 1317                unset($chunks[count($chunks) - 1]);
 
 1330        if (substr($a_str, 0, 6) == 
"<br />" && substr($a_str, 6, 1) != 
"=") {
 
 1331            $a_str = substr($a_str, 6);
 
 1335            if (substr($a_str, 0, 1) == 
"=") {
 
 1336                $a_str = 
"<br />" . $a_str;
 
 1347        if (substr($a_str, strlen($a_str) - 6) == 
"<br />") {
 
 1348            $a_str = substr($a_str, 0, strlen($a_str) - 6);
 
 1375        $this->log->debug(
"step 1: " . substr(
$a_content, 0, 1000));
 
 1377        $this->log->debug(
"step 2: " . substr($t[
"text"], 0, 1000));
 
 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 != 
"") {
 
 1388            $par->create($a_pg_obj, $insert_at[0], $insert_at[1]);
 
 1390            $par = $a_pg_obj->getContentObject($pc_id[0], $pc_id[1]);
 
 1393        if ($a_insert_at != 
"") {
 
 1394            $pc_id = $a_pg_obj->generatePCId();
 
 1395            $par->writePCId($pc_id);
 
 1396            $this->inserted_pc_id = $pc_id;
 
 1398            $this->inserted_pc_id = $pc_id[1];
 
 1401        $par->setLanguage(
$ilUser->getLanguage());
 
 1402        $par->setCharacteristic($t[
"class"]);
 
 1404        $t2 = $par->input2xml($t[
"text"], 
true, 
false);
 
 1405        $this->log->debug(
"step 3: " . substr($t2, 0, 1000));
 
 1408        $this->log->debug(
"step 4: " . substr($t2, 0, 1000));
 
 1410        $updated = $par->setText($t2, 
true);
 
 1412        if ($updated !== 
true) {
 
 1417        $updated = $par->updatePage($a_pg_obj);
 
 1430        if ($a_as_ajax_str) {
 
 1431            $a_pg_obj->stripHierIDs();
 
 1432            $a_pg_obj->addHierIds();
 
 1435            $combined = $a_pg_obj->getHierIdsForPCIds(
 
 1436                array($this->inserted_pc_id)
 
 1438            foreach ($combined as $pc_id => 
$hier_id) {
 
 1440                $ids .= $sep . 
$hier_id . 
":" . $pc_id;
 
 1447        return $this->inserted_pc_id;
 
 1458        $doc = 
new DOMDocument();
 
 1465        $res = $doc->loadXML($content);
 
 1472        $xpath = 
new DOMXpath($doc);
 
 1476        $elements = $xpath->query(
"//span");
 
 1477        include_once(
"./Services/Utilities/classes/class.ilDOM2Util.php");
 
 1478        while (!is_null($elements) && !is_null($element = $elements->item(0))) {
 
 1480            $class = $element->getAttribute(
"class");
 
 1481            if (substr($class, 0, 16) == 
"ilc_text_inline_") {
 
 1482                $class_arr = explode(
" ", $class);
 
 1483                $tag = substr($class_arr[0], 16);
 
 1484                if (isset($tags[$tag])) {               
 
 1488                    $cnode->setAttribute(
"Class", substr($class_arr[0], 16));
 
 1490                for (
$i = 1; 
$i < count($class_arr); 
$i++) {
 
 1491                    $tag = substr($class_arr[
$i], 16);
 
 1492                    if (isset($tags[$tag])) {           
 
 1496                        $cnode->setAttribute(
"Class", substr($class_arr[
$i], 16));
 
 1503            $elements = $xpath->query(
"//span");
 
 1507        $xpath = 
new DOMXpath($doc);
 
 1508        $elements = $xpath->query(
"/dummy/div");
 
 1511        if (!is_null($elements)) {
 
 1512            foreach ($elements as $element) {
 
 1513                $id = $element->getAttribute(
"id");
 
 1514                $class = $element->getAttribute(
"class");
 
 1515                $class = substr($class, 15);
 
 1516                if (trim($class) == 
"") {
 
 1517                    $class = 
"Standard";
 
 1520                $text = $doc->saveXML($element);
 
 1521                $text = str_replace(
"<br/>", 
"\n", $text);
 
 1524                $pos = strpos($text, 
">");
 
 1525                $text = substr($text, $pos + 1);
 
 1526                $pos = strrpos($text, 
"<");
 
 1527                $text = substr($text, 0, $pos);
 
 1533                    if (!in_array($bb, array(
"code", 
"tex", 
"fn", 
"xln"))) {
 
 1534                        $text = str_replace(
 
 1539                        $text = str_replace(
 
 1544                        $text = str_replace(
"<il" . $cl . 
"/>", 
"", $text);
 
 1547                $text = str_replace(
 
 1548                    array(
"<code>", 
"</code>"),
 
 1549                    array(
"[code]", 
"[/code]"),
 
 1552                $text = str_replace(
 
 1553                    array(
'<sup class="ilc_sup_Sup">', 
"</sup>"),
 
 1554                    array(
"[sup]", 
"[/sup]"),
 
 1557                $text = str_replace(
 
 1558                    array(
'<sub class="ilc_sub_Sub">', 
"</sub>"),
 
 1559                    array(
"[sub]", 
"[/sub]"),
 
 1563                $text = str_replace(
"<code/>", 
"", $text);
 
 1564                $text = str_replace(
'<ul class="ilc_list_u_BulletedList"/>', 
"", $text);
 
 1565                $text = str_replace(
'<ul class="ilc_list_o_NumberedList"/>', 
"", $text);
 
 1570                while (preg_match(
'~<ilMarked(' . $any . 
')>~i', $text, $found)) {
 
 1573                    $text = str_replace(
"<ilMarked" . $found[1] . 
">", 
"[marked class=\"" . $attribs[
"Class"] . 
"\"]", $text);
 
 1575                $text = str_replace(
"</ilMarked>", 
"[/marked]", $text);
 
 1578                $ret[] = array(
"text" => $text, 
"id" => $id, 
"class" => $class);
 
 1591        $text = str_replace(
 
 1592            array(
"<ul>", 
"</ul>"),
 
 1593            array(
"<SimpleBulletList>", 
"</SimpleBulletList>"),
 
 1596        $text = str_replace(
 
 1597            array(
"<ul class='ilc_list_u_BulletedList'>", 
"</ul>"),
 
 1598            array(
"<SimpleBulletList>", 
"</SimpleBulletList>"),
 
 1601        $text = str_replace(
 
 1602            array(
"<ul class=\"ilc_list_u_BulletedList\">", 
"</ul>"),
 
 1603            array(
"<SimpleBulletList>", 
"</SimpleBulletList>"),
 
 1606        $text = str_replace(
 
 1607            array(
"<ol>", 
"</ol>"),
 
 1608            array(
"<SimpleNumberedList>", 
"</SimpleNumberedList>"),
 
 1611        $text = str_replace(
 
 1612            array(
"<ol class='ilc_list_o_NumberedList'>", 
"</ol>"),
 
 1613            array(
"<SimpleNumberedList>", 
"</SimpleNumberedList>"),
 
 1616        $text = str_replace(
 
 1617            array(
"<ol class=\"ilc_list_o_NumberedList\">", 
"</ol>"),
 
 1618            array(
"<SimpleNumberedList>", 
"</SimpleNumberedList>"),
 
 1621        $text = str_replace(
 
 1622            array(
"<li>", 
"</li>"),
 
 1623            array(
"<SimpleListItem>", 
"</SimpleListItem>"),
 
 1626        $text = str_replace(
 
 1627            array(
"<li class='ilc_list_item_StandardListItem'>", 
"</li>"),
 
 1628            array(
"<SimpleListItem>", 
"</SimpleListItem>"),
 
 1631        $text = str_replace(
 
 1632            array(
"<li class=\"ilc_list_item_StandardListItem\">", 
"</li>"),
 
 1633            array(
"<SimpleListItem>", 
"</SimpleListItem>"),
 
 1637        $text = str_replace(
 
 1638            array(
"<li class=\"ilc_list_item_StandardListItem\"/>"),
 
 1639            array(
"<SimpleListItem></SimpleListItem>"),
 
 1643        $text = str_replace(
"<SimpleBulletList><br />", 
"<SimpleBulletList>", $text);
 
 1644        $text = str_replace(
"<SimpleNumberedList><br />", 
"<SimpleNumberedList>", $text);
 
 1645        $text = str_replace(
"<br /><SimpleBulletList>", 
"<SimpleBulletList>", $text);
 
 1646        $text = str_replace(
"<br /><SimpleNumberedList>", 
"<SimpleNumberedList>", $text);
 
 1647        $text = str_replace(
"</SimpleBulletList><br />", 
"</SimpleBulletList>", $text);
 
 1648        $text = str_replace(
"</SimpleNumberedList><br />", 
"</SimpleNumberedList>", $text);
 
 1649        $text = str_replace(
"</SimpleListItem><br />", 
"</SimpleListItem>", $text);
 
 1663        $a_page->beforePageContentUpdate($this);
 
 1665        $ret = $a_page->update();
 
 1677        if (is_array($a_glos) && count($a_glos) > 0) {
 
 1682            $text = strip_tags($this->
getText());
 
 1683            $found_terms = array();
 
 1684            foreach ($a_glos as $glo) {
 
 1687                    $glo_ref_id = current($ref_ids);
 
 1688                    if ($glo_ref_id > 0) {
 
 1690                        foreach ($terms as $t) {
 
 1691                            if (is_int(stripos($text, $t[
"term"]))) {
 
 1692                                $found_terms[$t[
"id"]] = $t;
 
 1699            if (count($found_terms) > 0) {
 
 1715        foreach ($a_terms as $k => $t) {
 
 1716            $a_terms[$k][
"termlength"] = strlen($t[
"term"]);
 
 1722            $a_dom = $a_dom->myDOMDocument;
 
 1725            $a_par_node = $a_par_node->myDOMNode;
 
 1728        $xpath = 
new DOMXPath($a_dom);
 
 1730        if ($a_par_node == 
null) {
 
 1731            $parnodes = $xpath->query(
"//Paragraph[@Characteristic != 'Code']");
 
 1733            $parnodes = $xpath->query(
".//Paragraph[@Characteristic != 'Code']", $a_par_node->parentNode);
 
 1736        include_once(
"./Services/Utilities/classes/class.ilStr.php");
 
 1738        foreach ($parnodes as $parnode) {
 
 1739            $textnodes = $xpath->query(
'.//text()', $parnode);
 
 1740            foreach ($textnodes as 
$node) {
 
 1741                $p = 
$node->getNodePath();
 
 1744                if (!is_int(strpos($p, 
"/IntLink")) &&
 
 1745                    !is_int(strpos($p, 
"/ExtLink"))) {
 
 1746                    $node_val = 
$node->nodeValue;
 
 1749                    foreach ($a_terms as $t) {
 
 1753                        while (is_int($pos)) {
 
 1757                            if ($tex_bpos > 0 && $tex_epos > 0 && $tex_bpos < $pos && $tex_epos > $pos) {
 
 1763                                $valid_limiters = array(
"", 
" ", 
" ", 
".", 
",", 
":", 
";", 
"!", 
"?", 
"\"", 
"'", 
"(", 
")");
 
 1768                                if ((in_array(
$b, $valid_limiters) || htmlentities(
$b, 
null, 
'utf-8') == 
" ") && in_array(
$a, $valid_limiters)) {
 
 1769                                    $mid = 
'[iln term="' . $t[
"id"] . 
'"]' .
 
 1788                    $node->nodeValue = $node_val;
 
 1797            $text = $a_dom->saveXML($parnode);
 
 1798            $text = substr($text, 0, strlen($text) - strlen(
"</Paragraph>"));
 
 1799            $text = substr($text, strpos($text, 
">") + 1);
 
 1806                '<?xml version="1.0" encoding="UTF-8"?><Paragraph>' . $text . 
'</Paragraph>',
 
 1810            $temp_dom = $temp_dom->myDOMDocument;
 
 1812            if (empty($error)) {
 
 1814                $children = $parnode->childNodes;
 
 1815                while ($parnode->hasChildNodes()) {
 
 1816                    $parnode->removeChild($parnode->firstChild);
 
 1820                $xpath_temp = 
new DOMXPath($temp_dom);
 
 1821                $temp_pars = $xpath_temp->query(
"//Paragraph");
 
 1823                foreach ($temp_pars as $new_par_node) {
 
 1824                    $new_childs = $new_par_node->childNodes;
 
 1826                    foreach ($new_childs as $new_child) {
 
 1828                        $cloned_child = $a_dom->importNode($new_child, 
true);
 
 1829                        $parnode->appendChild($cloned_child);
 
 1846        $a_page->buildDom();
 
 1847        $a_dom = $a_page->getDom();
 
 1862    public static function afterPageUpdate($a_page, DOMDocument $a_domdoc, $a_xml, $a_creation)
 
 1902        $xpath = 
new DOMXPath($a_domdoc);
 
 1903        $nodes = $xpath->query(
'//Anchor');
 
 1905        foreach ($nodes as 
$node) {
 
 1907            if (trim(
$name) != 
"" && !in_array(
$name, $saved)) {
 
 1924            "DELETE FROM page_anchor WHERE " .
 
 1925            " page_parent_type = " . 
$ilDB->quote($a_parent_type, 
"text") .
 
 1926            " AND page_id = " . 
$ilDB->quote($a_page_id, 
"integer") .
 
 1927            " AND page_lang = " . 
$ilDB->quote($a_page_lang, 
"text")
 
 1934    public static function _saveAnchor($a_parent_type, $a_page_id, $a_page_lang, $a_anchor_name)
 
 1940        $ilDB->manipulate(
"INSERT INTO page_anchor " .
 
 1941            "(page_parent_type, page_id, page_lang, anchor_name) VALUES (" .
 
 1942            $ilDB->quote($a_parent_type, 
"text") . 
"," .
 
 1943            $ilDB->quote($a_page_id, 
"integer") . 
"," .
 
 1944            $ilDB->quote($a_page_lang, 
"text") . 
"," .
 
 1945            $ilDB->quote($a_anchor_name, 
"text") .
 
 1952    public static function _readAnchors($a_parent_type, $a_page_id, $a_page_lang = 
"-")
 
 1958        $and_lang = ($a_page_lang != 
"")
 
 1959            ? 
" AND page_lang = " . 
$ilDB->quote($a_page_lang, 
"text")
 
 1962        $set = 
$ilDB->query(
 
 1963            "SELECT * FROM page_anchor " .
 
 1964            " WHERE page_parent_type = " . 
$ilDB->quote($a_parent_type, 
"text") .
 
 1965            " AND page_id = " . 
$ilDB->quote($a_page_id, 
"integer") .
 
 1969        while ($rec = 
$ilDB->fetchAssoc($set)) {
 
 1970            $anchors[] = $rec[
"anchor_name"];
 
 1984        if ($a_page->getParentType() == 
"gdf" ||
 
 1985            $a_page->getParentType() == 
"lm") {
 
 1987            $keywords = array();
 
 1990            $xpath = 
new DOMXPath($a_domdoc);
 
 1991            $nodes = $xpath->query(
'//Keyw');
 
 1992            foreach ($nodes as 
$node) {
 
 1993                $k = trim(strip_tags(
$node->nodeValue));
 
 1994                if (!in_array($k, $keywords)) {
 
 1999            $meta_type = ($a_page->getParentType() == 
"gdf")
 
 2002            $meta_rep_id = $a_page->getParentId();
 
 2003            $meta_id = $a_page->getId();
 
 2005            include_once(
"./Services/MetaData/classes/class.ilMD.php");
 
 2006            $md_obj = 
new ilMD($meta_rep_id, $meta_id, $meta_type);
 
 2007            $mkeywords = array();
 
 2009            if (is_object($md_section = $md_obj->getGeneral())) {
 
 2010                foreach ($ids = $md_section->getKeywordIds() as $id) {
 
 2011                    $md_key = $md_section->getKeyword($id);
 
 2012                    $mkeywords[] = strtolower($md_key->getKeyword());
 
 2014                        $lang = $md_key->getKeywordLanguageCode();
 
 2018                    foreach ($ids = $md_section->getLanguageIds() as $id) {
 
 2019                        $md_lang = $md_section->getLanguage($id);
 
 2021                            $lang = $md_lang->getLanguageCode();
 
 2025                foreach ($keywords as $k) {
 
 2026                    if (!in_array(strtolower($k), $mkeywords)) {
 
 2027                        if (trim($k) != 
"" && 
$lang != 
"") {
 
 2028                            $md_key = $md_section->addKeyword();
 
 2033                        $mkeywords[] = strtolower($k);
 
 2047        if ($a_mode != 
"edit" && $adve_settings->get(
"auto_url_linking")) {
 
 2048            include_once(
"./Services/Link/classes/class.ilLinkifyUtil.php");
 
 2065        if ($a_mode != 
"edit" && $adve_settings->get(
"auto_url_linking")) {
 
 2066            return array(
"il.ExtLink.autolink('.ilc_Paragraph, .ilc_page_fn_Footnote','ilc_link_ExtLink');");
 
An exception for terminatinating execution or to throw for unit testing.
static addParent($node, $name)
Add parent.
static replaceByChilds($node)
Replace a node by its child.
static changeName($node, $name, $keep_attributes=true)
Change name of a node.
static getTermList( $a_glo_ref_id, $searchterm="", $a_first_letter="", $a_def="", $a_tax_node=0, $a_add_amet_fields=false, array $a_amet_filter=null, $a_include_references=false)
Get all terms for given set of glossary ids.
static getLocalJsPaths()
Get paths of necessary js files.
static _lookupLogin($a_user_id)
lookup login
static _lookupId($a_user_str)
Lookup id by login.
static _getAllReferences($a_id)
get all reference ids of object
static _lookupType($a_id, $a_reference=false)
lookup object type
static xml2outputJS($s_text, $char, $a_pc_id)
Prepare content for js output.
getText($a_short_mode=false)
Get (xml) content of paragraph.
handleNextBr($a_str)
Remove preceding
static getXMLTagMap()
Get tag to bb map.
static intLinks2xml($a_text)
internal links to xml
removeTrailingBr($a_str)
Remove trailing
static _saveAnchor($a_parent_type, $a_page_id, $a_page_lang, $a_anchor_name)
Save an anchor.
getLastSavedPCId($a_pg_obj, $a_as_ajax_str=false)
Get last inserted pc ids.
static _readAnchors($a_parent_type, $a_page_id, $a_page_lang="-")
Read anchors of a page.
getType()
Need to override getType from ilPageContent to distinguish between Pararagraph and Source.
static _input2xml($a_text, $a_lang, $a_wysiwyg=0, $a_handle_lists=true)
converts user input to xml
static autoLinkGlossariesPage($a_page, $a_terms)
Auto link glossary of whole page.
static xml2output($a_text, $a_wysiwyg=false, $a_replace_lists=true, $unmask=true)
Converts xml from DB to output in edit textarea.
static linkTermsInDom($a_dom, $a_terms, $a_par_node=null)
Link terms in a dom page object in bb style.
setNode($a_node)
Set Page Content Node.
getShowLineNumbers()
get attribute showlinenumbers
autoLinkGlossaries($a_glos)
Auto link glossaries.
static saveAnchors($a_page, $a_domdoc)
Save anchors.
static handleAjaxContent($a_content)
Handle ajax content.
init()
Init page content component.
setSubCharacteristic($a_char)
set attribute subcharacteristic
createAtNode(&$node)
Create new page content (incl.
input2xml($a_text, $a_wysiwyg=0, $a_handle_lists=true)
createAfter($node)
Create paragraph node (incl.
static input2xmlReplaceLists($a_text)
Converts xml from DB to output in edit textarea.
static beforePageDelete($a_page)
Before page is being deleted.
setDownloadTitle($a_char)
set attribute download title
create(&$a_pg_obj, $a_hier_id, $a_pc_id="")
Create paragraph node (incl.
checkTextArray($text)
Check text array.
static xml2outputReplaceLists($a_text)
Replaces with *.
getAutoIndent()
Get AutoIndent (Code Paragraphs)
getDownloadTitle()
get attribute download title
static afterPageUpdate($a_page, DOMDocument $a_domdoc, $a_xml, $a_creation)
After page has been updated (or created)
setText($a_text, $a_auto_split=false)
Set (xml) content of text paragraph.
static replaceBBCode($a_text, $a_bb, $a_tag)
Replace bb code.
getOnloadCode($a_mode)
Get onload code.
static getBBMap()
Get bb to xml tag map.
setShowLineNumbers($a_char)
set attribute showlinenumbers
setLanguage($a_lang)
set language
static afterPageHistoryEntry($a_page, DOMDocument $a_old_domdoc, $a_old_xml, $a_old_nr)
After page history entry has been created.
setCharacteristic($a_char)
Set Characteristic of paragraph.
static handleAjaxContentPost($text)
Post input2xml handling of ajax content.
static saveMetaKeywords($a_page, $a_domdoc)
save all keywords
static segmentString($a_haystack, $a_needles)
Segments a string into an array at each position of a substring.
saveJS($a_pg_obj, $a_content, $a_char, $a_pc_id, $a_insert_at="")
Save input coming from ajax.
getLanguage()
get language
createBeforeNode(&$node)
Create new page content (incl.
autoSplit($a_text)
This function splits a paragraph text that has been already processed with input2xml at each header p...
getParagraphSequenceContent($a_pg_obj)
Get paragraph sequenc of current paragraph.
updatePage($a_page)
Update page object (it would be better to have this centralized and to change the constructors and pa...
getSubCharacteristic()
get attribute subcharacteristic
static _deleteAnchors($a_parent_type, $a_page_id, $a_page_lang)
Delete anchors of a page.
getCharacteristic()
Get characteristic of paragraph.
getJavascriptFiles($a_mode)
Get Javascript files.
static _getCommonBBButtons()
Get common bb buttons.
createPageContentNode($a_set_this_node=true)
Create page content node (always use this method first when adding a new element)
setType($a_type)
Set Type.
static strPos($a_haystack, $a_needle, $a_offset=null)
static strrPos($a_haystack, $a_needle, $a_offset=null)
static strIPos($a_haystack, $a_needle, $a_offset=null)
static subStr($a_str, $a_start, $a_length=null)
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static attribsToArray($a_str)
converts a string of format var1 = "val1" var2 = "val2" ... into an array
xpath_eval($xpath_context, $eval_str, $contextnode=null)
domxml_open_mem($str, $mode=0, &$error=null)
xpath_new_context($dom_document)
const DOMXML_LOAD_PARSING
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
foreach($_POST as $key=> $value) $res