ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilPCParagraph.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once("./Services/COPage/classes/class.ilPageContent.php");
5 
17 {
21  protected $user;
22 
23  public $dom;
24  public $par_node; // node of Paragraph element
25 
26  protected static $bb_tags = array(
27  "com" => "Comment",
28  "emp" => "Emph",
29  "str" => "Strong",
30  "fn" => "Footnote",
31  "code" => "Code",
32  "acc" => "Accent",
33  "imp" => "Important",
34  "kw" => "Keyw",
35  "sub" => "Sub",
36  "sup" => "Sup",
37  "quot" => "Quotation",
38  );
39 
43  public function init()
44  {
45  global $DIC;
46 
47  $this->user = $DIC->user();
48  $this->setType("par");
49  }
50 
56  protected static function getBBMap()
57  {
58  return self::$bb_tags;
59  }
60 
66  protected static function getXMLTagMap()
67  {
68  return array_flip(self::$bb_tags);
69  }
70 
71 
72 
78  public function setNode($a_node)
79  {
80  parent::setNode($a_node); // this is the PageContent node
81 
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]; //... and this the Paragraph node
86  }
87  }
88  }
89 
90 
96  public function createAtNode(&$node)
97  {
98  $this->node = $this->createPageContentNode();
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);
103  }
104 
110  public function createBeforeNode(&$node)
111  {
112  $this->node = $this->createPageContentNode();
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", "");
116  $node->insert_before($this->node, $node);
117  }
118 
125  public function createAfter($node)
126  {
127  $this->node = $this->createPageContentNode(false);
128  if ($succ_node = $node->next_sibling()) {
129  $this->node = $succ_node->insert_before($this->node, $succ_node);
130  } else {
131  $parent_node = $node->parent_node();
132  $this->node = $parent_node->append_child($this->node);
133  }
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", "");
137  }
138 
146  public function create(&$a_pg_obj, $a_hier_id, $a_pc_id = "")
147  {
148  //echo "-$a_pc_id-";
149  //echo "<br>-".htmlentities($a_pg_obj->getXMLFromDom())."-<br><br>"; mk();
150  $this->node = $this->dom->create_element("PageContent");
151 
152  // this next line kicks out placeholders, if something is inserted
153  $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
154 
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", "");
158  }
159 
166  public function setText($a_text, $a_auto_split = false)
167  {
168  if (!is_array($a_text)) {
169  $text = array(array("level" => 0, "text" => $a_text));
170  } else {
171  $text = $a_text;
172  }
173 
174  if ($a_auto_split) {
175  $text = $this->autoSplit($a_text);
176  }
177 
178  // DOMXML_LOAD_PARSING, DOMXML_LOAD_VALIDATING, DOMXML_LOAD_RECOVERING
179  $check = "";
180  foreach ($text as $t) {
181  $check.= "<Paragraph>" . $t["text"] . "</Paragraph>";
182  }
183  /*$temp_dom = domxml_open_mem('<?xml version="1.0" encoding="UTF-8"?><Paragraph>'.$text[0]["text"].'</Paragraph>',
184  DOMXML_LOAD_PARSING, $error);*/
185  $temp_dom = domxml_open_mem(
186  '<?xml version="1.0" encoding="UTF-8"?><Paragraph>' . $check . '</Paragraph>',
188  $error
189  );
190  //$this->text = $a_text;
191 
192  // remove all childs
193  if (empty($error)) {
194  $temp_dom = domxml_open_mem(
195  '<?xml version="1.0" encoding="UTF-8"?><Paragraph>' . $text[0]["text"] . '</Paragraph>',
197  $error
198  );
199 
200  // delete children of paragraph node
201  $children = $this->par_node->child_nodes();
202  for ($i=0; $i<count($children); $i++) {
203  $this->par_node->remove_child($children[$i]);
204  }
205 
206  // copy new content children in paragraph node
207  $xpc = xpath_new_context($temp_dom);
208  $path = "//Paragraph";
209  $res = xpath_eval($xpc, $path);
210  if (count($res->nodeset) == 1) {
211  $new_par_node = $res->nodeset[0];
212  $new_childs = $new_par_node->child_nodes();
213 
214  for ($i=0; $i<count($new_childs); $i++) {
215  $cloned_child = $new_childs[$i]->clone_node(true);
216  $this->par_node->append_child($cloned_child);
217  }
218  $orig_characteristic = $this->getCharacteristic();
219 
220  // if headlines are entered and current characteristic is a headline
221  // use no characteristic as standard
222  if ((count($text) > 1) && (substr($orig_characteristic, 0, 8) == "Headline")) {
223  $orig_characteristic = "";
224  }
225  if ($text[0]["level"] > 0) {
226  $this->par_node->set_attribute("Characteristic", 'Headline' . $text[0]["level"]);
227  }
228  }
229 
230  $ok = true;
231 
232  $c_node = $this->node;
233  // add other chunks afterwards
234  for ($i=1; $i<count($text); $i++) {
235  if ($ok) {
236  $next_par = new ilPCParagraph($this->getPage());
237  $next_par->createAfter($c_node);
238  $next_par->setLanguage($this->getLanguage());
239  if ($text[$i]["level"] > 0) {
240  $next_par->setCharacteristic("Headline" . $text[$i]["level"]);
241  } else {
242  $next_par->setCharacteristic($orig_characteristic);
243  }
244  $ok = $next_par->setText($text[$i]["text"], false);
245  $c_node = $next_par->node;
246  }
247  }
248 
249  return true;
250  } else {
251  // We want the correct number of \n here to have the real lines numbers
252  $text = str_replace("<br>", "\n", $check); // replace <br> with \n to get correct line
253  $text = str_replace("<br/>", "\n", $text);
254  $text = str_replace("<br />", "\n", $text);
255  $text = str_replace("</SimpleListItem>", "</SimpleListItem>\n", $text);
256  $text = str_replace("<SimpleBulletList>", "\n<SimpleBulletList>", $text);
257  $text = str_replace("<SimpleNumberedList>", "\n<SimpleNumberedList>", $text);
258  $text = str_replace("<Paragraph>\n", "<Paragraph>", $text);
259  $text = str_replace("</Paragraph>", "</Paragraph>\n", $text);
260  include_once("./Services/Dom/classes/class.ilDomDocument.php");
261  $doc = new ilDOMDocument();
262  $text = '<?xml version="1.0" encoding="UTF-8"?><Paragraph>' . $text . '</Paragraph>';
263  //echo htmlentities($text);
264  $this->success = $doc->loadXML($text);
265  $error = $doc->errors;
266  $estr = "";
267  foreach ($error as $e) {
268  $e = str_replace(" in Entity", "", $e);
269  $estr.= $e . "<br />";
270  }
271  if (DEVMODE) {
272  $estr.= "<br />" . $text;
273  }
274 
275  return $estr;
276  }
277  }
278 
284  public function getText($a_short_mode = false)
285  {
286  if (is_object($this->par_node)) {
287  $content = "";
288  $childs = $this->par_node->child_nodes();
289  for ($i=0; $i<count($childs); $i++) {
290  $content .= $this->dom->dump_node($childs[$i]);
291  }
292  return $content;
293  } else {
294  return "";
295  }
296  }
297 
301  public function getParagraphSequenceContent($a_pg_obj)
302  {
303  $childs = $this->par_node->parent_node()->parent_node()->child_nodes();
304  $seq = array();
305  $cur_seq = array();
306  $found = false;
307  $pc_id = $this->readPCId();
308  $hier_id = $this->readHierId();
309  for ($i=0; $i<count($childs); $i++) {
310  $pchilds = $childs[$i]->child_nodes();
311  if ($pchilds[0]->node_name() == "Paragraph" &&
312  $pchilds[0]->get_attribute("Characteristic") != "Code") {
313  $cur_seq[] = $childs[$i];
314 
315  // check whether this is the sequence of the current paragraph
316  if ($childs[$i]->get_attribute("PCID") == $pc_id &&
317  $childs[$i]->get_attribute("HierId") == $hier_id) {
318  $found = true;
319  }
320 
321  // if this is the current sequenc, get it
322  if ($found) {
323  $seq = $cur_seq;
324  }
325  } else {
326  // non-paragraph element found -> init the current sequence
327  $cur_seq = array();
328  $found = false;
329  }
330  }
331 
332  $content = "";
333  $ids = "###";
334  $id_sep = "";
335  foreach ($seq as $p_node) {
336  $ids.= $id_sep . $p_node->get_attribute("HierId") . ":" . $p_node->get_attribute("PCID");
337  $po = $a_pg_obj->getContentObject(
338  $p_node->get_attribute("HierId"),
339  $p_node->get_attribute("PCID")
340  );
341  $s_text = $po->getText();
342  $s_text = $po->xml2output($s_text, true, false);
343  $char = $po->getCharacteristic();
344  if ($char == "") {
345  $char = "Standard";
346  }
347  $s_text = ilPCParagraphGUI::xml2outputJS($s_text, $char, $po->readPCId());
348  $content.= $s_text;
349  $id_sep = ";";
350  }
351  $ids.= "###";
352 
353  return $ids . $content;
354  }
355 
361  public function setCharacteristic($a_char)
362  {
363  if (!empty($a_char)) {
364  $this->par_node->set_attribute("Characteristic", $a_char);
365  } else {
366  if ($this->par_node->has_attribute("Characteristic")) {
367  $this->par_node->remove_attribute("Characteristic");
368  }
369  }
370  }
371 
377  public function getCharacteristic()
378  {
379  if (is_object($this->par_node)) {
380  return $this->par_node->get_attribute("Characteristic");
381  }
382  }
383 
384 
388  public function setSubCharacteristic($a_char)
389  {
390  if (!empty($a_char)) {
391  $this->par_node->set_attribute("SubCharacteristic", $a_char);
392  } else {
393  if ($this->par_node->has_attribute("SubCharacteristic")) {
394  $this->par_node->remove_attribute("SubCharacteristic");
395  }
396  }
397  }
398 
404  public function getAutoIndent()
405  {
406  return $this->par_node->get_attribute("AutoIndent");
407  }
408 
409  public function setAutoIndent($a_char)
410  {
411  if (!empty($a_char)) {
412  $this->par_node->set_attribute("AutoIndent", $a_char);
413  } else {
414  if ($this->par_node->has_attribute("AutoIndent")) {
415  $this->par_node->remove_attribute("AutoIndent");
416  }
417  }
418  }
419 
423  public function getSubCharacteristic()
424  {
425  return $this->par_node->get_attribute("SubCharacteristic");
426  }
427 
432  public function setDownloadTitle($a_char)
433  {
434  if (!empty($a_char)) {
435  $this->par_node->set_attribute("DownloadTitle", $a_char);
436  } else {
437  if ($this->par_node->has_attribute("DownloadTitle")) {
438  $this->par_node->remove_attribute("DownloadTitle");
439  }
440  }
441  }
442 
446  public function getDownloadTitle()
447  {
448  return $this->par_node->get_attribute("DownloadTitle");
449  }
450 
455  public function setShowLineNumbers($a_char)
456  {
457  $a_char = empty($a_char)?"n":$a_char;
458 
459  $this->par_node->set_attribute("ShowLineNumbers", $a_char);
460  }
461 
466  public function getShowLineNumbers()
467  {
468  return $this->par_node->get_attribute("ShowLineNumbers");
469  }
470 
474  public function setLanguage($a_lang)
475  {
476  $this->par_node->set_attribute("Language", $a_lang);
477  }
478 
482  public function getLanguage()
483  {
484  return $this->par_node->get_attribute("Language");
485  }
486 
487  public function input2xml($a_text, $a_wysiwyg = 0, $a_handle_lists = true)
488  {
489  return $this->_input2xml($a_text, $this->getLanguage(), $a_wysiwyg, $a_handle_lists);
490  }
491 
500  protected static function replaceBBCode($a_text, $a_bb, $a_tag)
501  {
502  $a_text = preg_replace('/\[' . $a_bb . '\]/i', "<" . $a_tag . ">", $a_text);
503  $a_text = preg_replace('/\[\/' . $a_bb . '\]/i', "</" . $a_tag . ">", $a_text);
504  return $a_text;
505  }
506 
507 
511  public static function _input2xml($a_text, $a_lang, $a_wysiwyg = 0, $a_handle_lists = true)
512  {
513  if (!$a_wysiwyg) {
514  $a_text = ilUtil::stripSlashes($a_text, false);
515  }
516 
517  if ($a_wysiwyg) {
518  $a_text = str_replace("<br />", chr(10), $a_text);
519  }
520 
521  // note: the order of the processing steps is crucial
522  // and should be the same as in xml2output() in REVERSE order!
523  $a_text = trim($a_text);
524 
525  //echo "<br>between:".htmlentities($a_text);
526 
527  // mask html
528  if (!$a_wysiwyg) {
529  $a_text = str_replace("&", "&amp;", $a_text);
530  }
531  $a_text = str_replace("<", "&lt;", $a_text);
532  $a_text = str_replace(">", "&gt;", $a_text);
533 
534  // Reconvert PageTurn and BibItemIdentifier
535  $a_text = preg_replace('/&lt;([\s\/]*?PageTurn.*?)&gt;/i', "<$1>", $a_text);
536  $a_text = preg_replace('/&lt;([\s\/]*?BibItemIdentifier.*?)&gt;/i', "<$1>", $a_text);
537 
538  //echo "<br>second:".htmlentities($a_text);
539 
540  // mask curly brackets
541  /*
542  echo htmlentities($a_text);
543  $a_text = str_replace("{", "&#123;", $a_text);
544  $a_text = str_replace("}", "&#125;", $a_text);
545  echo htmlentities($a_text);*/
546  // linefeed to br
547  $a_text = str_replace(chr(13) . chr(10), "<br />", $a_text);
548  $a_text = str_replace(chr(13), "<br />", $a_text);
549  $a_text = str_replace(chr(10), "<br />", $a_text);
550 
551  if ($a_handle_lists) {
552  $a_text = ilPCParagraph::input2xmlReplaceLists($a_text);
553  }
554 
555  foreach (self::getBBMap() as $bb => $tag) {
556  // remove empty tags
557  $a_text = str_replace("[" . $bb . "][/" . $bb . "]", "", $a_text);
558 
559  // replace bb code by tag
560  $a_text = self::replaceBBCode($a_text, $bb, $tag);
561  }
562 
563  $a_text = self::intLinks2xml($a_text);
564 
565  // external link
566  $ws= "[ \t\r\f\v\n]*";
567  // remove empty external links
568  while (preg_match("~\[(xln$ws(url$ws=$ws\"([^\"])*\")$ws(target$ws=$ws(\"(Glossary|FAQ|Media)\"))?$ws)\]\[\/xln\]~i", $a_text, $found)) {
569  $a_text = str_replace($found[0], "", $a_text);
570  }
571  while (preg_match('~\[(xln$ws(url$ws=$ws(([^]])*)))$ws\]\[\/xln\]~i', $a_text, $found)) {
572  $a_text = str_replace($found[0], "", $a_text);
573  }
574  // external links
575  while (preg_match("~\[(xln$ws(url$ws=$ws\"([^\"])*\")$ws(target$ws=$ws(\"(Glossary|FAQ|Media)\"))?$ws)\]~i", $a_text, $found)) {
576  $attribs = ilUtil::attribsToArray($found[2]);
577  if (isset($attribs["url"])) {
578  $a2 = ilUtil::attribsToArray($found[4]);
579  $tstr = "";
580  if (in_array($a2["target"], array("FAQ", "Glossary", "Media"))) {
581  $tstr = ' TargetFrame="' . $a2["target"] . '"';
582  }
583  $a_text = str_replace("[" . $found[1] . "]", "<ExtLink Href=\"" . $attribs["url"] . "\"$tstr>", $a_text);
584  } else {
585  $a_text = str_replace("[" . $found[1] . "]", "[error: xln" . $found[1] . "]", $a_text);
586  }
587  }
588 
589  // ie/tinymce fix for links without "", see bug #8391
590  while (preg_match('~\[(xln$ws(url$ws=$ws(([^]])*)))$ws\]~i', $a_text, $found)) {
591  if ($found[3] != "") {
592  $a_text = str_replace("[" . $found[1] . "]", "<ExtLink Href=\"" . $found[3] . "\">", $a_text);
593  } else {
594  $a_text = str_replace("[" . $found[1] . "]", "[error: xln" . $found[1] . "]", $a_text);
595  }
596  }
597  $a_text = preg_replace('~\[\/xln\]~i', "</ExtLink>", $a_text);
598 
599  // anchor
600  $ws= "[ \t\r\f\v\n]*";
601  while (preg_match("~\[(anc$ws(name$ws=$ws\"([^\"])*\")$ws)\]~i", $a_text, $found)) {
602  $attribs = ilUtil::attribsToArray($found[2]);
603  $a_text = str_replace("[" . $found[1] . "]", "<Anchor Name=\"" . $attribs["name"] . "\">", $a_text);
604  }
605  $a_text = preg_replace("~\[\/anc\]~i", "</Anchor>", $a_text);
606 
607  // marked text
608  while (preg_match("~\[(marked$ws(class$ws=$ws\"([^\"])*\")$ws)\]~i", $a_text, $found)) {
609  $attribs = ilUtil::attribsToArray($found[2]);
610  if (isset($attribs["class"])) {
611  $a_text = str_replace("[" . $found[1] . "]", "<Marked Class=\"" . $attribs["class"] . "\">", $a_text);
612  } else {
613  $a_text = str_replace("[" . $found[1] . "]", "[error:marked" . $found[1] . "]", $a_text);
614  }
615  }
616  $a_text = preg_replace('~\[\/marked\]~i', "</Marked>", $a_text);
617 
618 
619  //echo htmlentities($a_text); exit;
620  return $a_text;
621  }
622 
629  public static function intLinks2xml($a_text)
630  {
631  global $DIC;
632 
633  $objDefinition = $DIC["objDefinition"];
634 
635  $rtypes = $objDefinition->getAllRepositoryTypes();
636 
637  // internal links
638  //$any = "[^\]]*"; // this doesn't work :-(
639  $ws= "[ \t\r\f\v\n]*";
640  $ltypes = "page|chap|term|media|obj|dfile|sess|wpage|ppage|" . implode($rtypes, "|");
641  // empty internal links
642  while (preg_match('~\[(iln' . $ws . '((inst' . $ws . '=' . $ws . '([\"0-9])*)?' . $ws .
643  "((" . $ltypes . ")$ws=$ws([\"0-9])*)$ws" .
644  "(target$ws=$ws(\"(New|FAQ|Media)\"))?$ws(anchor$ws=$ws(\"([^\"])*\"))?$ws))\]\[\/iln\]~i", $a_text, $found)) {
645  $a_text = str_replace($found[0], "", $a_text);
646  }
647  while (preg_match('~\[(iln' . $ws . '((inst' . $ws . '=' . $ws . '([\"0-9])*)?' . $ws .
648  "((" . $ltypes . ")$ws=$ws([\"0-9])*)$ws" .
649  "(target$ws=$ws(\"(New|FAQ|Media)\"))?$ws(anchor$ws=$ws(\"([^\"])*\"))?$ws))\]~i", $a_text, $found)) {
650  $attribs = ilUtil::attribsToArray($found[2]);
651  $inst_str = $attribs["inst"];
652  // pages
653  if (isset($attribs["page"])) {
654  $tframestr = "";
655  if (!empty($found[10])) {
656  $tframestr = " TargetFrame=\"" . $found[10] . "\" ";
657  }
658  $ancstr = "";
659  if ($attribs["anchor"] != "") {
660  $ancstr = ' Anchor="' . $attribs["anchor"] . '" ';
661  }
662  $a_text = preg_replace(
663  '/\[' . $found[1] . '\]/i',
664  "<IntLink Target=\"il_" . $inst_str . "_pg_" . $attribs['page'] . "\" Type=\"PageObject\"" . $tframestr . $ancstr . ">",
665  $a_text
666  );
667  }
668  // chapters
669  elseif (isset($attribs["chap"])) {
670  if (!empty($found[10])) {
671  $tframestr = " TargetFrame=\"" . $found[10] . "\" ";
672  } else {
673  $tframestr = "";
674  }
675  $a_text = preg_replace(
676  '/\[' . $found[1] . '\]/i',
677  "<IntLink Target=\"il_" . $inst_str . "_st_" . $attribs['chap'] . "\" Type=\"StructureObject\"" . $tframestr . ">",
678  $a_text
679  );
680  }
681  // glossary terms
682  elseif (isset($attribs["term"])) {
683  switch ($found[10]) {
684  case "New":
685  $tframestr = " TargetFrame=\"New\" ";
686  break;
687 
688  default:
689  $tframestr = " TargetFrame=\"Glossary\" ";
690  break;
691  }
692  $a_text = preg_replace(
693  '/\[' . $found[1] . '\]/i',
694  "<IntLink Target=\"il_" . $inst_str . "_git_" . $attribs['term'] . "\" Type=\"GlossaryItem\" $tframestr>",
695  $a_text
696  );
697  }
698  // wiki pages
699  elseif (isset($attribs["wpage"])) {
700  $tframestr = "";
701  $a_text = preg_replace(
702  '/\[' . $found[1] . '\]/i',
703  "<IntLink Target=\"il_" . $inst_str . "_wpage_" . $attribs['wpage'] . "\" Type=\"WikiPage\" $tframestr>",
704  $a_text
705  );
706  }
707  // portfolio pages
708  elseif (isset($attribs["ppage"])) {
709  $tframestr = "";
710  $a_text = preg_replace(
711  '/\[' . $found[1] . '\]/i',
712  "<IntLink Target=\"il_" . $inst_str . "_ppage_" . $attribs['ppage'] . "\" Type=\"PortfolioPage\" $tframestr>",
713  $a_text
714  );
715  }
716  // media object
717  elseif (isset($attribs["media"])) {
718  if (!empty($found[10])) {
719  $tframestr = " TargetFrame=\"" . $found[10] . "\" ";
720  $a_text = preg_replace(
721  '/\[' . $found[1] . '\]/i',
722  "<IntLink Target=\"il_" . $inst_str . "_mob_" . $attribs['media'] . "\" Type=\"MediaObject\"" . $tframestr . ">",
723  $a_text
724  );
725  } else {
726  $a_text = preg_replace(
727  '/\[' . $found[1] . '\]/i',
728  "<IntLink Target=\"il_" . $inst_str . "_mob_" . $attribs['media'] . "\" Type=\"MediaObject\"/>",
729  $a_text
730  );
731  }
732  }
733  // direct download file (no repository object)
734  elseif (isset($attribs["dfile"])) {
735  $a_text = preg_replace(
736  '/\[' . $found[1] . '\]/i',
737  "<IntLink Target=\"il_" . $inst_str . "_dfile_" . $attribs['dfile'] . "\" Type=\"File\">",
738  $a_text
739  );
740  }
741  // repository items (id is ref_id (will be used internally but will
742  // be replaced by object id for export purposes)
743  else {
744  foreach ($objDefinition->getAllRepositoryTypes() as $t) {
745  if (isset($attribs[$t])) {
746  $obj_id = $attribs[$t];
747  }
748  }
749  if (isset($attribs["obj"])) {
750  $obj_id = $attribs["obj"];
751  }
752 
753  if ($obj_id > 0) {
754  if ($inst_str == "") {
755  $a_text = preg_replace(
756  '/\[' . $found[1] . '\]/i',
757  "<IntLink Target=\"il_" . $inst_str . "_obj_" . $obj_id . "\" Type=\"RepositoryItem\">",
758  $a_text
759  );
760  } else {
761  $a_text = preg_replace(
762  '/\[' . $found[1] . '\]/i',
763  "<IntLink Target=\"il_" . $inst_str . "_" . $found[6] . "_" . $obj_id . "\" Type=\"RepositoryItem\">",
764  $a_text
765  );
766  }
767  } else {
768  $a_text = preg_replace('/\[' . $found[1] . '\]/i', "[error: iln" . $found[1] . "]", $a_text);
769  }
770  }
771  }
772 
773  while (preg_match("~\[(iln$ws((inst$ws=$ws([\"0-9])*)?" . $ws . "media$ws=$ws([\"0-9])*)$ws)/\]~i", $a_text, $found)) {
774  $attribs = ilUtil::attribsToArray($found[2]);
775  $inst_str = $attribs["inst"];
776  $a_text = preg_replace(
777  '~\[' . $found[1] . '/\]~i',
778  "<IntLink Target=\"il_" . $inst_str . "_mob_" . $attribs['media'] . "\" Type=\"MediaObject\"/>",
779  $a_text
780  );
781  }
782 
783  // user
784  while (preg_match("~\[(iln$ws((inst$ws=$ws([\"0-9])*)?" . $ws . "user$ws=$ws(\"([^\"])*)\")$ws)/\]~i", $a_text, $found)) {
785  $attribs = ilUtil::attribsToArray($found[2]);
786  $inst_str = $attribs["inst"];
787  include_once("./Services/User/classes/class.ilObjUser.php");
788  $user_id = ilObjUser::_lookupId($attribs['user']);
789  $a_text = preg_replace(
790  '~\[' . $found[1] . '/\]~i',
791  "<IntLink Target=\"il_" . $inst_str . "_user_" . $user_id . "\" Type=\"User\"/>",
792  $a_text
793  );
794  }
795 
796  $a_text = preg_replace('~\[\/iln\]~i', "</IntLink>", $a_text);
797  return $a_text;
798  }
799 
800 
808  public static function input2xmlReplaceLists($a_text)
809  {
810  $rows = explode("<br />", $a_text . "<br />");
811  //var_dump($a_text);
812 
813  $old_level = 0;
814 
815  $text = "";
816 
817  foreach ($rows as $row) {
818  $level = 0;
819  if (str_replace("#", "*", substr($row, 0, 3)) == "***") {
820  $level = 3;
821  } elseif (str_replace("#", "*", substr($row, 0, 2)) == "**") {
822  $level = 2;
823  } elseif (str_replace("#", "*", substr($row, 0, 1)) == "*") {
824  $level = 1;
825  }
826 
827  // end previous line
828  if ($level < $old_level) {
829  for ($i = $old_level; $i > $level; $i--) {
830  $text.= "</SimpleListItem></" . $clist[$i] . ">";
831  }
832  if ($level > 0) {
833  $text.= "</SimpleListItem>";
834  }
835  } elseif ($old_level > 0 && $level > 0 && ($level == $old_level)) {
836  $text.= "</SimpleListItem>";
837  } elseif (($level == $old_level) && $text != "") {
838  $text.= "<br />";
839  }
840 
841  // start next line
842  if ($level > $old_level) {
843  for ($i = $old_level + 1; $i <= $level; $i++) {
844  if (substr($row, $i - 1, 1) == "*") {
845  $clist[$i] = "SimpleBulletList";
846  } else {
847  $clist[$i] = "SimpleNumberedList";
848  }
849  $text.= "<" . $clist[$i] . "><SimpleListItem>";
850  }
851  } elseif ($old_level > 0 && $level > 0) {
852  $text.= "<SimpleListItem>";
853  }
854  $text.= substr($row, $level);
855 
856  $old_level = $level;
857  }
858 
859  // remove "<br />" at the end
860  if (substr($text, strlen($text) - 6) == "<br />") {
861  $text = substr($text, 0, strlen($text) - 6);
862  }
863 
864  return $text;
865  }
866 
874  public static function xml2outputReplaceLists($a_text)
875  {
876  $segments = ilPCParagraph::segmentString($a_text, array("<SimpleBulletList>", "</SimpleBulletList>",
877  "</SimpleListItem>", "<SimpleListItem>", "<SimpleListItem/>", "<SimpleNumberedList>", "</SimpleNumberedList>"));
878 
879  $current_list = array();
880  $text = "";
881  for ($i=0; $i<= count($segments); $i++) {
882  if ($segments[$i] == "<SimpleBulletList>") {
883  if (count($current_list) == 0) {
884  $list_start = true;
885  }
886  array_push($current_list, "*");
887  $li = false;
888  } elseif ($segments[$i] == "<SimpleNumberedList>") {
889  if (count($current_list) == 0) {
890  $list_start = true;
891  }
892  array_push($current_list, "#");
893  $li = false;
894  } elseif ($segments[$i] == "</SimpleBulletList>") {
895  array_pop($current_list);
896  $li = false;
897  } elseif ($segments[$i] == "</SimpleNumberedList>") {
898  array_pop($current_list);
899  $li = false;
900  } elseif ($segments[$i] == "<SimpleListItem>") {
901  $li = true;
902  } elseif ($segments[$i] == "</SimpleListItem>") {
903  $li = false;
904  } elseif ($segments[$i] == "<SimpleListItem/>") {
905  if ($list_start) {
906  $text.= "<br />";
907  $list_start = false;
908  }
909  foreach ($current_list as $list) {
910  $text.= $list;
911  }
912  $text.= "<br />";
913  $li = false;
914  } else {
915  if ($li) {
916  if ($list_start) {
917  $text.= "<br />";
918  $list_start = false;
919  }
920  foreach ($current_list as $list) {
921  $text.= $list;
922  }
923  }
924  $text.= $segments[$i];
925  if ($li) {
926  $text.= "<br />";
927  }
928  $li = false;
929  }
930  }
931 
932  // remove trailing <br />, if text ends with list
933  if ($segments[count($segments) - 1] == "</SimpleBulletList>" ||
934  $segments[count($segments) - 1] == "</SimpleNumberedList>" &&
935  substr($text, strlen($text) - 6) == "<br />") {
936  $text = substr($text, 0, strlen($text) - 6);
937  }
938 
939  return $text;
940  }
941 
945  public static function segmentString($a_haystack, $a_needles)
946  {
947  $segments = array();
948 
949  $nothing_found = false;
950  while (!$nothing_found) {
951  $nothing_found = true;
952  $found = -1;
953  foreach ($a_needles as $needle) {
954  $pos = stripos($a_haystack, $needle);
955  if (is_int($pos) && ($pos < $found || $found == -1)) {
956  $found = $pos;
957  $found_needle = $needle;
958  $nothing_found = false;
959  }
960  }
961  if ($found > 0) {
962  $segments[] = substr($a_haystack, 0, $found);
963  $a_haystack = substr($a_haystack, $found);
964  }
965  if ($found > -1) {
966  $segments[] = substr($a_haystack, 0, strlen($found_needle));
967  $a_haystack = substr($a_haystack, strlen($found_needle));
968  }
969  }
970  if ($a_haystack != "") {
971  $segments[] = $a_haystack;
972  }
973 
974  return $segments;
975  }
976 
984  public static function xml2output($a_text, $a_wysiwyg = false, $a_replace_lists = true, $unmask = true)
985  {
986  // note: the order of the processing steps is crucial
987  // and should be the same as in input2xml() in REVERSE order!
988 
989  // xml to bb code
990  $any = "[^>]*";
991 
992  foreach (self::getBBMap() as $bb => $tag) {
993  $a_text = preg_replace('~<' . $tag . '[^>]*>~i', "[" . $bb . "]", $a_text);
994  $a_text = preg_replace('~</' . $tag . '>~i', "[/" . $bb . "]", $a_text);
995  $a_text = preg_replace('~<' . $tag . '/>~i', "[" . $bb . "][/" . $bb . "]", $a_text);
996  }
997 
998  // replace lists
999  if ($a_replace_lists) {
1000  //echo "<br>".htmlentities($a_text);
1001  $a_text = ilPCParagraph::xml2outputReplaceLists($a_text);
1002  //echo "<br>".htmlentities($a_text);
1003  }
1004 
1005  // internal links
1006  while (preg_match('~<IntLink(' . $any . ')>~i', $a_text, $found)) {
1007  $found[0];
1008  $attribs = ilUtil::attribsToArray($found[1]);
1009  $target = explode("_", $attribs["Target"]);
1010  $target_id = $target[count($target) - 1];
1011  $inst_str = (!is_int(strpos($attribs["Target"], "__")))
1012  ? $inst_str = "inst=\"" . $target[1] . "\" "
1013  : $inst_str = "";
1014  switch ($attribs["Type"]) {
1015  case "PageObject":
1016  $tframestr = (!empty($attribs["TargetFrame"]))
1017  ? " target=\"" . $attribs["TargetFrame"] . "\""
1018  : "";
1019  $ancstr = (!empty($attribs["Anchor"]))
1020  ? ' anchor="' . $attribs["Anchor"] . '"'
1021  : "";
1022  $a_text = preg_replace('~<IntLink' . $found[1] . '>~i', "[iln " . $inst_str . "page=\"" . $target_id . "\"$tframestr$ancstr]", $a_text);
1023  break;
1024 
1025  case "StructureObject":
1026  $tframestr = (!empty($attribs["TargetFrame"]))
1027  ? " target=\"" . $attribs["TargetFrame"] . "\""
1028  : "";
1029  $a_text = preg_replace('~<IntLink' . $found[1] . '>~i', "[iln " . $inst_str . "chap=\"" . $target_id . "\"$tframestr]", $a_text);
1030  break;
1031 
1032  case "GlossaryItem":
1033  $tframestr = (empty($attribs["TargetFrame"]) || $attribs["TargetFrame"] == "Glossary")
1034  ? ""
1035  : " target=\"" . $attribs["TargetFrame"] . "\"";
1036  $a_text = preg_replace('~<IntLink' . $found[1] . '>~i', "[iln " . $inst_str . "term=\"" . $target_id . "\"" . $tframestr . "]", $a_text);
1037  break;
1038 
1039  case "WikiPage":
1040  $tframestr = "";
1041  $a_text = preg_replace('~<IntLink' . $found[1] . '>~i', "[iln " . $inst_str . "wpage=\"" . $target_id . "\"" . $tframestr . "]", $a_text);
1042  break;
1043 
1044  case "PortfolioPage":
1045  $tframestr = "";
1046  $a_text = preg_replace('~<IntLink' . $found[1] . '>~i', "[iln " . $inst_str . "ppage=\"" . $target_id . "\"" . $tframestr . "]", $a_text);
1047  break;
1048 
1049  case "MediaObject":
1050  if (empty($attribs["TargetFrame"])) {
1051  $a_text = preg_replace('~<IntLink' . $found[1] . '>~i', "[iln " . $inst_str . "media=\"" . $target_id . "\"/]", $a_text);
1052  } else {
1053  $a_text = preg_replace('~<IntLink' . $found[1] . '>~i', "[iln media=\"" . $target_id . "\"" .
1054  " target=\"" . $attribs["TargetFrame"] . "\"]", $a_text);
1055  }
1056  break;
1057 
1058  // Repository Item (using ref id)
1059  case "RepositoryItem":
1060  if ($inst_str == "") {
1061  $target_type = ilObject::_lookupType($target_id, true);
1062  } else {
1063  $rtype = $target[count($target) - 2];
1064  $target_type = $rtype;
1065  }
1066  $a_text = preg_replace('~<IntLink' . $found[1] . '>~i', "[iln " . $inst_str . "$target_type=\"" . $target_id . "\"" . $tframestr . "]", $a_text);
1067  break;
1068 
1069  // Download File (not in repository, Object ID)
1070  case "File":
1071  $a_text = preg_replace('~<IntLink' . $found[1] . '>~i', "[iln " . $inst_str . "dfile=\"" . $target_id . "\"" . $tframestr . "]", $a_text);
1072  break;
1073 
1074  // User
1075  case "User":
1076  include_once("./Services/User/classes/class.ilObjUser.php");
1077  $a_text = preg_replace('~<IntLink' . $found[1] . '>~i', "[iln " . $inst_str . "user=\"" . ilObjUser::_lookupLogin($target_id) . "\"/]", $a_text);
1078  break;
1079 
1080  default:
1081  $a_text = preg_replace('~<IntLink' . $found[1] . '>~i', "[iln]", $a_text);
1082  break;
1083  }
1084  }
1085  $a_text = str_replace("</IntLink>", "[/iln]", $a_text);
1086 
1087  // external links
1088  while (preg_match('~<ExtLink(' . $any . ')>~i', $a_text, $found)) {
1089  $found[0];
1090  $attribs = ilUtil::attribsToArray($found[1]);
1091  //$found[1] = str_replace("?", "\?", $found[1]);
1092  $tstr = "";
1093  if (in_array($attribs["TargetFrame"], array("FAQ", "Glossary", "Media"))) {
1094  $tstr = ' target="' . $attribs["TargetFrame"] . '"';
1095  }
1096  $a_text = str_replace("<ExtLink" . $found[1] . ">", "[xln url=\"" . $attribs["Href"] . "\"$tstr]", $a_text);
1097  }
1098  $a_text = str_replace("</ExtLink>", "[/xln]", $a_text);
1099 
1100  // anchor
1101  while (preg_match('~<Anchor(' . $any . '/)>~i', $a_text, $found)) {
1102  $found[0];
1103  $attribs = ilUtil::attribsToArray($found[1]);
1104  $a_text = str_replace("<Anchor" . $found[1] . ">", "[anc name=\"" . $attribs["Name"] . "\"][/anc]", $a_text);
1105  }
1106  while (preg_match('~<Anchor(' . $any . ')>~i', $a_text, $found)) {
1107  $found[0];
1108  $attribs = ilUtil::attribsToArray($found[1]);
1109  $a_text = str_replace("<Anchor" . $found[1] . ">", "[anc name=\"" . $attribs["Name"] . "\"]", $a_text);
1110  }
1111  $a_text = str_replace("</Anchor>", "[/anc]", $a_text);
1112 
1113  // marked text
1114  while (preg_match('~<Marked(' . $any . ')>~i', $a_text, $found)) {
1115  $found[0];
1116  $attribs = ilUtil::attribsToArray($found[1]);
1117  $a_text = str_replace("<Marked" . $found[1] . ">", "[marked class=\"" . $attribs["Class"] . "\"]", $a_text);
1118  }
1119  $a_text = str_replace("</Marked>", "[/marked]", $a_text);
1120 
1121  // br to linefeed
1122  if (!$a_wysiwyg) {
1123  $a_text = str_replace("<br />", "\n", $a_text);
1124  $a_text = str_replace("<br/>", "\n", $a_text);
1125  }
1126 
1127  if (!$a_wysiwyg) {
1128  // prevent curly brackets from being swallowed up by template engine
1129  $a_text = str_replace("{", "&#123;", $a_text);
1130  $a_text = str_replace("}", "&#125;", $a_text);
1131 
1132  // unmask html
1133  if ($unmask) {
1134  $a_text = str_replace("&lt;", "<", $a_text);
1135  $a_text = str_replace("&gt;", ">", $a_text);
1136  }
1137 
1138  // this is needed to allow html like <tag attribute="value">... in paragraphs
1139  $a_text = str_replace("&quot;", "\"", $a_text);
1140 
1141  // make ampersands in (enabled) html attributes work
1142  // e.g. <a href="foo.php?n=4&t=5">hhh</a>
1143  $a_text = str_replace("&amp;", "&", $a_text);
1144 
1145  // make &gt; and $lt; work to allow (disabled) html descriptions
1146  if ($unmask) {
1147  $a_text = str_replace("&lt;", "&amp;lt;", $a_text);
1148  $a_text = str_replace("&gt;", "&amp;gt;", $a_text);
1149  }
1150  }
1151  return $a_text;
1152  //return str_replace("<br />", chr(13).chr(10), $a_text);
1153  }
1154 
1161  public function autoSplit($a_text)
1162  {
1163  $a_text = str_replace("=<SimpleBulletList>", "=<br /><SimpleBulletList>", $a_text);
1164  $a_text = str_replace("=<SimpleNumberedList>", "=<br /><SimpleNumberedList>", $a_text);
1165  $a_text = str_replace("</SimpleBulletList>=", "</SimpleBulletList><br />=", $a_text);
1166  $a_text = str_replace("</SimpleNumberedList>=", "</SimpleNumberedList><br />=", $a_text);
1167  $a_text = "<br />" . $a_text . "<br />"; // add preceding and trailing br
1168 
1169  $chunks = array();
1170  $c_text = $a_text;
1171  //echo "0";
1172  while ($c_text != "") {
1173  //var_dump($c_text); flush();
1174  //echo "1";
1175  $s1 = strpos($c_text, "<br />=");
1176  if (is_int($s1)) {
1177  //echo "2";
1178  $s2 = strpos($c_text, "<br />==");
1179  if (is_int($s2) && $s2 <= $s1) {
1180  //echo "3";
1181  $s3 = strpos($c_text, "<br />===");
1182  if (is_int($s3) && $s3 <= $s2) { // possible level three header
1183  //echo "4";
1184  $n = strpos($c_text, "<br />", $s3 + 1);
1185  if ($n > ($s3+9) && substr($c_text, $n-3, 9) == "===<br />") {
1186  //echo "5";
1187  // found level three header
1188  if ($s3 > 0 || $head != "") {
1189  //echo "6";
1190  $chunks[] = array("level" => 0,
1191  "text" => $this->removeTrailingBr($head . substr($c_text, 0, $s3)));
1192  $head = "";
1193  }
1194  $chunks[] = array("level" => 3,
1195  "text" => trim(substr($c_text, $s3+9, $n-$s3-12)));
1196  $c_text = $this->handleNextBr(substr($c_text, $n+6));
1197  } else {
1198  //echo "7";
1199  $head.= substr($c_text, 0, $n);
1200  $c_text = substr($c_text, $n);
1201  }
1202  } else { // possible level two header
1203  //echo "8";
1204  $n = strpos($c_text, "<br />", $s2 + 1);
1205  if ($n > ($s2+8) && substr($c_text, $n-2, 8) == "==<br />") {
1206  //echo "9";
1207  // found level two header
1208  if ($s2 > 0 || $head != "") {
1209  //echo "A";
1210  $chunks[] = array("level" => 0,
1211  "text" => $this->removeTrailingBr($head . substr($c_text, 0, $s2)));
1212  $head = "";
1213  }
1214  $chunks[] = array("level" => 2, "text" => trim(substr($c_text, $s2+8, $n-$s2-10)));
1215  $c_text = $this->handleNextBr(substr($c_text, $n+6));
1216  } else {
1217  //echo "B";
1218  $head.= substr($c_text, 0, $n);
1219  $c_text = substr($c_text, $n);
1220  }
1221  }
1222  } else { // possible level one header
1223  //echo "C";
1224  $n = strpos($c_text, "<br />", $s1 + 1);
1225  if ($n > ($s1+7) && substr($c_text, $n-1, 7) == "=<br />") {
1226  //echo "D";
1227  // found level one header
1228  if ($s1 > 0 || $head != "") {
1229  //echo "E";
1230  $chunks[] = array("level" => 0,
1231  "text" => $this->removeTrailingBr($head . substr($c_text, 0, $s1)));
1232  $head = "";
1233  }
1234  $chunks[] = array("level" => 1, "text" => trim(substr($c_text, $s1+7, $n-$s1-8)));
1235  $c_text = $this->handleNextBr(substr($c_text, $n+6));
1236  //echo "<br>ctext:".htmlentities($c_text)."<br>";
1237  } else {
1238  $head.= substr($c_text, 0, $n);
1239  $c_text = substr($c_text, $n);
1240  //echo "<br>head:".$head."c_text:".$c_text."<br>";
1241  }
1242  }
1243  } else {
1244  //echo "G";
1245  $chunks[] = array("level" => 0, "text" => $head . $c_text);
1246  $head = "";
1247  $c_text = "";
1248  }
1249  }
1250  if (count($chunks) == 0) {
1251  $chunks[] = array("level" => 0, "text" => "");
1252  }
1253 
1254 
1255  // remove preceding br
1256  if (substr($chunks[0]["text"], 0, 6) == "<br />") {
1257  $chunks[0]["text"] = substr($chunks[0]["text"], 6);
1258  }
1259 
1260  // remove trailing br
1261  if (substr(
1262  $chunks[count($chunks) - 1]["text"],
1263  strlen($chunks[count($chunks) - 1]["text"]) - 6,
1264  6
1265  ) == "<br />") {
1266  $chunks[count($chunks) - 1]["text"] =
1267  substr($chunks[count($chunks) - 1]["text"], 0, strlen($chunks[count($chunks) - 1]["text"]) - 6);
1268  if ($chunks[count($chunks) - 1]["text"] == "") {
1269  unset($chunks[count($chunks) - 1]);
1270  }
1271  }
1272  return $chunks;
1273  }
1274 
1278  public function handleNextBr($a_str)
1279  {
1280  // do not remove, if next line starts with a "=", otherwise two
1281  // headlines in a row will not be recognized
1282  if (substr($a_str, 0, 6) == "<br />" && substr($a_str, 6, 1) != "=") {
1283  $a_str = substr($a_str, 6);
1284  } else {
1285  // if next line starts with a "=" we need to reinsert the <br />
1286  // otherwise it will not be recognized
1287  if (substr($a_str, 0, 1) == "=") {
1288  $a_str = "<br />" . $a_str;
1289  }
1290  }
1291  return $a_str;
1292  }
1293 
1297  public function removeTrailingBr($a_str)
1298  {
1299  if (substr($a_str, strlen($a_str) - 6) == "<br />") {
1300  $a_str = substr($a_str, 0, strlen($a_str) - 6);
1301  }
1302  return $a_str;
1303  }
1304 
1308  public function getType()
1309  {
1310  return ($this->getCharacteristic() == "Code")?"src":parent::getType();
1311  }
1312 
1316 
1323  public function saveJS($a_pg_obj, $a_content, $a_char, $a_pc_id, $a_insert_at = "")
1324  {
1325  $ilUser = $this->user;
1326 
1327  $this->log->debug("step 1: " . substr($a_content, 0, 1000));
1328  $t = self::handleAjaxContent($a_content);
1329  $this->log->debug("step 2: " . substr($t["text"], 0, 1000));
1330  if ($t === false) {
1331  return false;
1332  }
1333 
1334  $pc_id = explode(":", $a_pc_id);
1335  $insert_at = explode(":", $a_insert_at);
1336  $t_id = explode(":", $t["id"]);
1337 
1338  // insert new paragraph
1339  if ($a_insert_at != "") {
1340  $par = new ilPCParagraph($this->getPage());
1341  $par->create($a_pg_obj, $insert_at[0], $insert_at[1]);
1342  } else {
1343  $par = $a_pg_obj->getContentObject($pc_id[0], $pc_id[1]);
1344  }
1345 
1346  if ($a_insert_at != "") {
1347  $pc_id = $a_pg_obj->generatePCId();
1348  $par->writePCId($pc_id);
1349  $this->inserted_pc_id = $pc_id;
1350  } else {
1351  $this->inserted_pc_id = $pc_id[1];
1352  }
1353 
1354  $par->setLanguage($ilUser->getLanguage());
1355  $par->setCharacteristic($t["class"]);
1356 
1357  $t2 = $par->input2xml($t["text"], true, false);
1358  $this->log->debug("step 3: " . substr($t2, 0, 1000));
1359 
1361  $this->log->debug("step 4: " . substr($t2, 0, 1000));
1362 
1363  $updated = $par->setText($t2, true);
1364 
1365  if ($updated !== true) {
1366  echo $updated;
1367  exit;
1368  return false;
1369  }
1370  $updated = $par->updatePage($a_pg_obj);
1371  //$updated = $a_pg_obj->update();
1372  return $updated;
1373  }
1374 
1381  public function getLastSavedPCId($a_pg_obj, $a_as_ajax_str = false)
1382  {
1383  if ($a_as_ajax_str) {
1384  $a_pg_obj->stripHierIDs();
1385  $a_pg_obj->addHierIds();
1386  $ids = "###";
1387  //var_dump($this->inserted_pc_ids);
1388  $combined = $a_pg_obj->getHierIdsForPCIds(
1389  array($this->inserted_pc_id)
1390  );
1391  foreach ($combined as $pc_id => $hier_id) {
1392  //echo "1";
1393  $ids.= $sep . $hier_id . ":" . $pc_id;
1394  $sep = ";";
1395  }
1396  $ids.= "###";
1397  return $ids;
1398  }
1399 
1400  return $this->inserted_pc_id;
1401  }
1402 
1403 
1407  public static function handleAjaxContent($a_content)
1408  {
1409  $a_content = "<dummy>" . $a_content . "</dummy>";
1410 
1411  $doc = new DOMDocument();
1412 
1413  $content = ilUtil::stripSlashes($a_content, false);
1414 
1415  // $content = str_replace("&lt;", "<", $content);
1416  // $content = str_replace("&gt;", ">", $content);
1417  //echo "<br><br>".htmlentities($content); mk();
1418  $res = $doc->loadXML($content);
1419 
1420  if (!$res) {
1421  return false;
1422  }
1423 
1424  // convert tags
1425  $xpath = new DOMXpath($doc);
1426 
1427  $tags = self::getXMLTagMap();
1428 
1429  $elements = $xpath->query("//span");
1430  include_once("./Services/Utilities/classes/class.ilDOM2Util.php");
1431  while (!is_null($elements) && !is_null($element = $elements->item(0))) {
1432  //$element = $elements->item(0);
1433  $class = $element->getAttribute("class");
1434  if (substr($class, 0, 16) == "ilc_text_inline_") {
1435  $class_arr = explode(" ", $class);
1436  $tag = substr($class_arr[0], 16);
1437  if (isset($tags[$tag])) { // known tag like strong
1438  $cnode = ilDOM2Util::changeName($element, "il" . substr($class_arr[0], 16), false);
1439  } else { // unknown tag -> marked text
1440  $cnode = ilDOM2Util::changeName($element, "ilMarked", false);
1441  $cnode->setAttribute("Class", substr($class_arr[0], 16));
1442  }
1443  for ($i = 1; $i < count($class_arr); $i++) {
1444  $tag = substr($class_arr[$i], 16);
1445  if (isset($tags[$tag])) { // known tag like strong
1446  $cnode = ilDOM2Util::addParent($cnode, "il" . substr($class_arr[$i], 16));
1447  } else { // unknown tag -> marked element
1448  $cnode = ilDOM2Util::addParent($cnode, "ilMarked");
1449  $cnode->setAttribute("Class", substr($class_arr[$i], 16));
1450  }
1451  }
1452  } else {
1453  ilDOM2Util::replaceByChilds($element);
1454  }
1455 
1456  $elements = $xpath->query("//span");
1457  }
1458 
1459  // convert tags
1460  $xpath = new DOMXpath($doc);
1461  $elements = $xpath->query("/dummy/div");
1462 
1463  $ret = array();
1464  if (!is_null($elements)) {
1465  foreach ($elements as $element) {
1466  $id = $element->getAttribute("id");
1467  $class = $element->getAttribute("class");
1468  $class = substr($class, 15);
1469  if (trim($class) == "") {
1470  $class = "Standard";
1471  }
1472 
1473  $text = $doc->saveXML($element);
1474  $text = str_replace("<br/>", "\n", $text);
1475 
1476  // remove wrapping div
1477  $pos = strpos($text, ">");
1478  $text = substr($text, $pos + 1);
1479  $pos = strrpos($text, "<");
1480  $text = substr($text, 0, $pos);
1481 
1482  // todo: remove empty spans <span ...> </span>
1483 
1484  // replace tags by bbcode
1485  foreach (ilPageContentGUI::_getCommonBBButtons() as $bb => $cl) {
1486  if (!in_array($bb, array("code", "tex", "fn", "xln"))) {
1487  $text = str_replace(
1488  "<il" . $cl . ">",
1489  "[" . $bb . "]",
1490  $text
1491  );
1492  $text = str_replace(
1493  "</il" . $cl . ">",
1494  "[/" . $bb . "]",
1495  $text
1496  );
1497  $text = str_replace("<il" . $cl . "/>", "", $text);
1498  }
1499  }
1500  $text = str_replace(
1501  array("<code>", "</code>"),
1502  array("[code]", "[/code]"),
1503  $text
1504  );
1505  $text = str_replace(
1506  array('<sup class="ilc_sup_Sup">', "</sup>"),
1507  array("[sup]", "[/sup]"),
1508  $text
1509  );
1510  $text = str_replace(
1511  array('<sub class="ilc_sub_Sub">', "</sub>"),
1512  array("[sub]", "[/sub]"),
1513  $text
1514  );
1515 
1516  $text = str_replace("<code/>", "", $text);
1517  $text = str_replace('<ul class="ilc_list_u_BulletedList"/>', "", $text);
1518  $text = str_replace('<ul class="ilc_list_o_NumberedList"/>', "", $text);
1519 
1520  // replace marked text
1521  // external links
1522  $any = "[^>]*";
1523  while (preg_match('~<ilMarked(' . $any . ')>~i', $text, $found)) {
1524  $found[0];
1525  $attribs = ilUtil::attribsToArray($found[1]);
1526  $text = str_replace("<ilMarked" . $found[1] . ">", "[marked class=\"" . $attribs["Class"] . "\"]", $text);
1527  }
1528  $text = str_replace("</ilMarked>", "[/marked]", $text);
1529 
1530 
1531  $ret[] = array("text" => $text, "id" => $id, "class" => $class);
1532  }
1533  }
1534 
1535  // we should only have one here!
1536  return $ret[0];
1537  }
1538 
1542  public static function handleAjaxContentPost($text)
1543  {
1544  $text = str_replace(
1545  array("&lt;ul&gt;", "&lt;/ul&gt;"),
1546  array("<SimpleBulletList>", "</SimpleBulletList>"),
1547  $text
1548  );
1549  $text = str_replace(
1550  array("&lt;ul class='ilc_list_u_BulletedList'&gt;", "&lt;/ul&gt;"),
1551  array("<SimpleBulletList>", "</SimpleBulletList>"),
1552  $text
1553  );
1554  $text = str_replace(
1555  array("&lt;ul class=\"ilc_list_u_BulletedList\"&gt;", "&lt;/ul&gt;"),
1556  array("<SimpleBulletList>", "</SimpleBulletList>"),
1557  $text
1558  );
1559  $text = str_replace(
1560  array("&lt;ol&gt;", "&lt;/ol&gt;"),
1561  array("<SimpleNumberedList>", "</SimpleNumberedList>"),
1562  $text
1563  );
1564  $text = str_replace(
1565  array("&lt;ol class='ilc_list_o_NumberedList'&gt;", "&lt;/ol&gt;"),
1566  array("<SimpleNumberedList>", "</SimpleNumberedList>"),
1567  $text
1568  );
1569  $text = str_replace(
1570  array("&lt;ol class=\"ilc_list_o_NumberedList\"&gt;", "&lt;/ol&gt;"),
1571  array("<SimpleNumberedList>", "</SimpleNumberedList>"),
1572  $text
1573  );
1574  $text = str_replace(
1575  array("&lt;li&gt;", "&lt;/li&gt;"),
1576  array("<SimpleListItem>", "</SimpleListItem>"),
1577  $text
1578  );
1579  $text = str_replace(
1580  array("&lt;li class='ilc_list_item_StandardListItem'&gt;", "&lt;/li&gt;"),
1581  array("<SimpleListItem>", "</SimpleListItem>"),
1582  $text
1583  );
1584  $text = str_replace(
1585  array("&lt;li class=\"ilc_list_item_StandardListItem\"&gt;", "&lt;/li&gt;"),
1586  array("<SimpleListItem>", "</SimpleListItem>"),
1587  $text
1588  );
1589 
1590  $text = str_replace(
1591  array("&lt;li class=\"ilc_list_item_StandardListItem\"/&gt;"),
1592  array("<SimpleListItem></SimpleListItem>"),
1593  $text
1594  );
1595 
1596  $text = str_replace("<SimpleBulletList><br />", "<SimpleBulletList>", $text);
1597  $text = str_replace("<SimpleNumberedList><br />", "<SimpleNumberedList>", $text);
1598  $text = str_replace("<br /><SimpleBulletList>", "<SimpleBulletList>", $text);
1599  $text = str_replace("<br /><SimpleNumberedList>", "<SimpleNumberedList>", $text);
1600  $text = str_replace("</SimpleBulletList><br />", "</SimpleBulletList>", $text);
1601  $text = str_replace("</SimpleNumberedList><br />", "</SimpleNumberedList>", $text);
1602  $text = str_replace("</SimpleListItem><br />", "</SimpleListItem>", $text);
1603 
1604  return $text;
1605  }
1606 
1614  public function updatePage($a_page)
1615  {
1616  $a_page->beforePageContentUpdate($this);
1617 
1618  $ret = $a_page->update();
1619  return $ret;
1620  }
1621 
1628  public function autoLinkGlossaries($a_glos)
1629  {
1630  if (is_array($a_glos) && count($a_glos) > 0) {
1631  include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
1632 
1633  // check which terms occur in the text (we may
1634  // get some false positives due to the strip_tags, but
1635  // we do not want to find strong or list or other stuff
1636  // within the tags
1637  $text = strip_tags($this->getText());
1638  $found_terms = array();
1639  foreach ($a_glos as $glo) {
1640  if (ilObject::_lookupType($glo) == "glo") {
1641  $terms = ilGlossaryTerm::getTermList($glo);
1642  foreach ($terms as $t) {
1643  if (is_int(stripos($text, $t["term"]))) {
1644  $found_terms[$t["id"]] = $t;
1645  }
1646  }
1647  }
1648  }
1649 
1650  // did we find anything? -> modify content
1651  if (count($found_terms) > 0) {
1652  self::linkTermsInDom($this->dom, $found_terms, $this->par_node);
1653  }
1654  }
1655  }
1656 
1663  protected static function linkTermsInDom($a_dom, $a_terms, $a_par_node = null)
1664  {
1665  // sort terms by their length (shortes first)
1666  // to prevent that nested tags are builded
1667  foreach ($a_terms as $k => $t) {
1668  $a_terms[$k]["termlength"] = strlen($t["term"]);
1669  }
1670  $a_terms = ilUtil::sortArray($a_terms, "termlength", "asc", true);
1671 
1672 
1673  if ($a_dom instanceof php4DOMDocument) {
1674  $a_dom = $a_dom->myDOMDocument;
1675  }
1676  if ($a_par_node instanceof php4DOMElement) {
1677  $a_par_node = $a_par_node->myDOMNode;
1678  }
1679 
1680  $xpath = new DOMXPath($a_dom);
1681 
1682  if ($a_par_node == null) {
1683  $parnodes = $xpath->query("//Paragraph[@Characteristic != 'Code']");
1684  } else {
1685  $parnodes = $xpath->query(".//Paragraph[@Characteristic != 'Code']", $a_par_node->parentNode);
1686  }
1687 
1688  include_once("./Services/Utilities/classes/class.ilStr.php");
1689 
1690  foreach ($parnodes as $parnode) {
1691  $textnodes = $xpath->query('.//text()', $parnode);
1692  foreach ($textnodes as $node) {
1693  $p = $node->getNodePath();
1694 
1695  // we do not change text nodes inside of links
1696  if (!is_int(strpos($p, "/IntLink")) &&
1697  !is_int(strpos($p, "/ExtLink"))) {
1698  $node_val = $node->nodeValue;
1699 
1700  // all terms
1701  foreach ($a_terms as $t) {
1702  $pos = ilStr::strIPos($node_val, $t["term"]);
1703 
1704  // if term found
1705  while (is_int($pos)) {
1706  // check if we are in a tex tag, see #22261
1707  $tex_bpos = ilStr::strrPos(ilStr::subStr($node_val, 0, $pos), "[tex]");
1708  $tex_epos = ilStr::strPos($node_val, "[/tex]", $tex_bpos);
1709  if ($tex_bpos > 0 && $tex_epos > 0 && $tex_bpos < $pos && $tex_epos > $pos) {
1710  $pos+= ilStr::strLen($t["term"]);
1711  } else {
1712 
1713  // check if the string is not included in another word
1714  // note that []
1715  $valid_limiters = array("", " ", "&nbsp;", ".", ",", ":", ";", "!", "?", "\"", "'", "(", ")");
1716  $b = ($pos > 0)
1717  ? ilStr::subStr($node_val, $pos - 1, 1)
1718  : "";
1719  $a = ilStr::subStr($node_val, $pos + ilStr::strLen($t["term"]), 1);
1720  if ((in_array($b, $valid_limiters) || htmlentities($b, null, 'utf-8') == "&nbsp;") && in_array($a, $valid_limiters)) {
1721  $mid = '[iln term="' . $t["id"] . '"]' .
1722  ilStr::subStr($node_val, $pos, ilStr::strLen($t["term"])) .
1723  "[/iln]";
1724 
1725  $node_val = ilStr::subStr($node_val, 0, $pos) .
1726  $mid .
1727  ilStr::subStr($node_val, $pos + ilStr::strLen($t["term"]));
1728 
1729  $pos += ilStr::strLen($mid);
1730  } else {
1731  $pos += ilStr::strLen($t["term"]);
1732  }
1733  }
1734  $pos = ilStr::strIPos($node_val, $t["term"], $pos);
1735  }
1736 
1737  // insert [iln] tags
1738  }
1739 
1740  $node->nodeValue = $node_val;
1741  }
1742 
1743  // var_dump($p);
1744 // var_dump($node->nodeValue);
1745  }
1746 
1747 
1748  // dump paragraph node
1749  $text = $a_dom->saveXML($parnode);
1750  $text = substr($text, 0, strlen($text) - strlen("</Paragraph>"));
1751  $text = substr($text, strpos($text, ">") + 1);
1752 
1753  // replace [iln] by tags with xml representation
1754  $text = self::intLinks2xml($text);
1755 
1756  // "set text"
1757  $temp_dom = domxml_open_mem(
1758  '<?xml version="1.0" encoding="UTF-8"?><Paragraph>' . $text . '</Paragraph>',
1760  $error
1761  );
1762  $temp_dom = $temp_dom->myDOMDocument;
1763 
1764  if (empty($error)) {
1765  // delete children of paragraph node
1766  $children = $parnode->childNodes;
1767  while ($parnode->hasChildNodes()) {
1768  $parnode->removeChild($parnode->firstChild);
1769  }
1770 
1771  // copy new content children in paragraph node
1772  $xpath_temp = new DOMXPath($temp_dom);
1773  $temp_pars = $xpath_temp->query("//Paragraph");
1774 
1775  foreach ($temp_pars as $new_par_node) {
1776  $new_childs = $new_par_node->childNodes;
1777 
1778  foreach ($new_childs as $new_child) {
1779  //$cloned_child = $new_child->cloneNode(true);
1780  $cloned_child = $a_dom->importNode($new_child, true);
1781  $parnode->appendChild($cloned_child);
1782  }
1783  }
1784  }
1785  }
1786  // exit;
1787  }
1788 
1789 
1796  public static function autoLinkGlossariesPage($a_page, $a_terms)
1797  {
1798  $a_page->buildDom();
1799  $a_dom = $a_page->getDom();
1800 
1801  self::linkTermsInDom($a_dom, $a_terms);
1802 
1803  $a_page->update();
1804  }
1805 
1814  public static function afterPageUpdate($a_page, DOMDocument $a_domdoc, $a_xml, $a_creation)
1815  {
1816  // pc paragraph
1817  self::saveMetaKeywords($a_page, $a_domdoc);
1818  self::saveAnchors($a_page, $a_domdoc);
1819  }
1820 
1826  public static function beforePageDelete($a_page)
1827  {
1828  // delete anchors
1829  self::_deleteAnchors($a_page->getParentType(), $a_page->getId(), $a_page->getLanguage());
1830  }
1831 
1840  public static function afterPageHistoryEntry($a_page, DOMDocument $a_old_domdoc, $a_old_xml, $a_old_nr)
1841  {
1842  }
1843 
1849  public static function saveAnchors($a_page, $a_domdoc)
1850  {
1851  self::_deleteAnchors($a_page->getParentType(), $a_page->getId(), $a_page->getLanguage());
1852 
1853  // get all anchors
1854  $xpath = new DOMXPath($a_domdoc);
1855  $nodes = $xpath->query('//Anchor');
1856  $saved = array();
1857  foreach ($nodes as $node) {
1858  $name = $node->getAttribute("Name");
1859  if (trim($name) != "" && !in_array($name, $saved)) {
1860  self::_saveAnchor($a_page->getParentType(), $a_page->getId(), $a_page->getLanguage(), $name);
1861  $saved[] = $name;
1862  }
1863  }
1864  }
1865 
1869  public static function _deleteAnchors($a_parent_type, $a_page_id, $a_page_lang)
1870  {
1871  global $DIC;
1872 
1873  $ilDB = $DIC->database();
1874 
1875  $ilDB->manipulate(
1876  "DELETE FROM page_anchor WHERE " .
1877  " page_parent_type = " . $ilDB->quote($a_parent_type, "text") .
1878  " AND page_id = " . $ilDB->quote($a_page_id, "integer") .
1879  " AND page_lang = " . $ilDB->quote($a_page_lang, "text")
1880  );
1881  }
1882 
1886  public static function _saveAnchor($a_parent_type, $a_page_id, $a_page_lang, $a_anchor_name)
1887  {
1888  global $DIC;
1889 
1890  $ilDB = $DIC->database();
1891 
1892  $ilDB->manipulate("INSERT INTO page_anchor " .
1893  "(page_parent_type, page_id, page_lang, anchor_name) VALUES (" .
1894  $ilDB->quote($a_parent_type, "text") . "," .
1895  $ilDB->quote($a_page_id, "integer") . "," .
1896  $ilDB->quote($a_page_lang, "text") . "," .
1897  $ilDB->quote($a_anchor_name, "text") .
1898  ")");
1899  }
1900 
1904  public static function _readAnchors($a_parent_type, $a_page_id, $a_page_lang = "-")
1905  {
1906  global $DIC;
1907 
1908  $ilDB = $DIC->database();
1909 
1910  $and_lang = ($a_page_lang != "")
1911  ? " AND page_lang = " . $ilDB->quote($a_page_lang, "text")
1912  : "";
1913 
1914  $set = $ilDB->query(
1915  "SELECT * FROM page_anchor " .
1916  " WHERE page_parent_type = " . $ilDB->quote($a_parent_type, "text") .
1917  " AND page_id = " . $ilDB->quote($a_page_id, "integer") .
1918  $and_lang
1919  );
1920  $anchors = array();
1921  while ($rec = $ilDB->fetchAssoc($set)) {
1922  $anchors[] = $rec["anchor_name"];
1923  }
1924  return $anchors;
1925  }
1926 
1933  public static function saveMetaKeywords($a_page, $a_domdoc)
1934  {
1935  // not nice, should be set by context per method
1936  if ($a_page->getParentType() == "gdf" ||
1937  $a_page->getParentType() == "lm") {
1938  // get existing keywords
1939  $keywords = array();
1940 
1941  // find all Keyw tags
1942  $xpath = new DOMXPath($a_domdoc);
1943  $nodes = $xpath->query('//Keyw');
1944  foreach ($nodes as $node) {
1945  $k = trim(strip_tags($node->nodeValue));
1946  if (!in_array($k, $keywords)) {
1947  $keywords[] = $k;
1948  }
1949  }
1950 
1951  $meta_type = ($a_page->getParentType() == "gdf")
1952  ? "gdf"
1953  : "pg";
1954  $meta_rep_id = $a_page->getParentId();
1955  $meta_id = $a_page->getId();
1956 
1957  include_once("./Services/MetaData/classes/class.ilMD.php");
1958  $md_obj = new ilMD($meta_rep_id, $meta_id, $meta_type);
1959  $mkeywords = array();
1960  $lang = "";
1961  if (is_object($md_section = $md_obj->getGeneral())) {
1962  foreach ($ids = $md_section->getKeywordIds() as $id) {
1963  $md_key = $md_section->getKeyword($id);
1964  $mkeywords[] = strtolower($md_key->getKeyword());
1965  if ($lang == "") {
1966  $lang = $md_key->getKeywordLanguageCode();
1967  }
1968  }
1969  if ($lang == "") {
1970  foreach ($ids = $md_section->getLanguageIds() as $id) {
1971  $md_lang = $md_section->getLanguage($id);
1972  if ($lang == "") {
1973  $lang = $md_lang->getLanguageCode();
1974  }
1975  }
1976  }
1977  foreach ($keywords as $k) {
1978  if (!in_array(strtolower($k), $mkeywords)) {
1979  if (trim($k) != "" && $lang != "") {
1980  $md_key = $md_section->addKeyword();
1981  $md_key->setKeyword(ilUtil::stripSlashes($k));
1982  $md_key->setKeywordLanguage(new ilMDLanguageItem($lang));
1983  $md_key->save();
1984  }
1985  $mkeywords[] = strtolower($k);
1986  }
1987  }
1988  }
1989  }
1990  }
1991 
1995  public function getJavascriptFiles($a_mode)
1996  {
1997  $adve_settings = new ilSetting("adve");
1998 
1999  if ($a_mode != "edit" && $adve_settings->get("auto_url_linking")) {
2000  include_once("./Services/Link/classes/class.ilLinkifyUtil.php");
2002  }
2003 
2004  return array();
2005  }
2006 
2013  public function getOnloadCode($a_mode)
2014  {
2015  $adve_settings = new ilSetting("adve");
2016 
2017  if ($a_mode != "edit" && $adve_settings->get("auto_url_linking")) {
2018  return array("il.ExtLink.autolink('.ilc_Paragraph, .ilc_page_fn_Footnote','ilc_link_ExtLink');");
2019  }
2020 
2021  return array();
2022  }
2023 }
static _lookupLogin($a_user_id)
lookup login
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
getLastSavedPCId($a_pg_obj, $a_as_ajax_str=false)
Get last inserted pc ids.
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41
createAfter($node)
Create paragraph node (incl.
static strLen($a_string)
Definition: class.ilStr.php:78
static attribsToArray($a_str)
converts a string of format var1 = "val1" var2 = "val2" ...
static xml2outputJS($s_text, $char, $a_pc_id)
Prepare content for js output.
static getBBMap()
Get bb to xml tag map.
static strPos($a_haystack, $a_needle, $a_offset=null)
Definition: class.ilStr.php:30
static xml2outputReplaceLists($a_text)
Replaces with *.
$target_type
Definition: goto.php:48
getSubCharacteristic()
get attribute subcharacteristic
xpath_new_context($dom_document)
static beforePageDelete($a_page)
Before page is being deleted.
getDownloadTitle()
get attribute download title
global $DIC
Definition: saml.php:7
setShowLineNumbers($a_char)
set attribute showlinenumbers
removeTrailingBr($a_str)
Remove trailing
static segmentString($a_haystack, $a_needles)
Segments a string into an array at each position of a substring.
static handleAjaxContentPost($text)
Post input2xml handling of ajax content.
domxml_open_mem($str, $mode=0, &$error=null)
static getLocalJsPaths()
Get paths of necessary js files.
input2xml($a_text, $a_wysiwyg=0, $a_handle_lists=true)
xpath_eval($xpath_context, $eval_str, $contextnode=null)
if(!array_key_exists('StateId', $_REQUEST)) $id
setDownloadTitle($a_char)
set attribute download title
setText($a_text, $a_auto_split=false)
Set (xml) content of text paragraph.
static _lookupId($a_user_str)
Lookup id by login.
$target_id
Definition: goto.php:49
static replaceByChilds($node)
Replace a node by its child.
setNode($a_node)
Set Page Content Node.
Class ilPCParagraph.
setType($a_type)
Set Type.
create(&$a_pg_obj, $a_hier_id, $a_pc_id="")
Create paragraph node (incl.
saveJS($a_pg_obj, $a_content, $a_char, $a_pc_id, $a_insert_at="")
Save input coming from ajax.
static subStr($a_str, $a_start, $a_length=null)
Definition: class.ilStr.php:15
static getXMLTagMap()
Get tag to bb map.
getLanguage()
get language
getParagraphSequenceContent($a_pg_obj)
Get paragraph sequenc of current paragraph.
static xml2output($a_text, $a_wysiwyg=false, $a_replace_lists=true, $unmask=true)
Converts xml from DB to output in edit textarea.
user()
Definition: user.php:4
Class ilPageContent.
setLanguage($a_lang)
set language
getAutoIndent()
Get AutoIndent (Code Paragraphs)
init()
Init page content component.
static strIPos($a_haystack, $a_needle, $a_offset=null)
Definition: class.ilStr.php:48
static autoLinkGlossariesPage($a_page, $a_terms)
Auto link glossary of whole page.
readPCId()
Read PC Id.
$error
Definition: Error.php:17
if($format !==null) $name
Definition: metadata.php:146
getType()
Need to override getType from ilPageContent to distinguish between Pararagraph and Source...
setSubCharacteristic($a_char)
set attribute subcharacteristic
createBeforeNode(&$node)
Create new page content (incl.
static afterPageHistoryEntry($a_page, DOMDocument $a_old_domdoc, $a_old_xml, $a_old_nr)
After page history entry has been created.
php4DomElement
static input2xmlReplaceLists($a_text)
Converts xml from DB to output in edit textarea.
foreach($_POST as $key=> $value) $res
static handleAjaxContent($a_content)
Handle ajax content.
static linkTermsInDom($a_dom, $a_terms, $a_par_node=null)
Link terms in a dom page object in bb style.
updatePage($a_page)
Update page object (it would be better to have this centralized and to change the constructors and pa...
$a_content
Definition: workflow.php:93
createAtNode(&$node)
Create new page content (incl.
setCharacteristic($a_char)
Set Characteristic of paragraph.
static strrPos($a_haystack, $a_needle, $a_offset=null)
Definition: class.ilStr.php:39
getText($a_short_mode=false)
Get (xml) content of paragraph.
$tags
Definition: croninfo.php:19
autoLinkGlossaries($a_glos)
Auto link glossaries.
$text
Definition: errorreport.php:18
static changeName($node, $name, $keep_attributes=true)
Change name of a node.
getCharacteristic()
Get characteristic of paragraph.
static getTermList( $a_glo_ref_id, $searchterm="", $a_first_letter="", $a_def="", $a_tax_node=0, $a_add_amet_fields=false, array $a_amet_filter=null, $a_include_references=false)
Get all terms for given set of glossary ids.
$ilUser
Definition: imgupload.php:18
static replaceBBCode($a_text, $a_bb, $a_tag)
Replace bb code.
static saveAnchors($a_page, $a_domdoc)
Save anchors.
$n
Definition: RandomTest.php:85
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
const IL_INSERT_AFTER
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
static _readAnchors($a_parent_type, $a_page_id, $a_page_lang="-")
Read anchors of a page.
autoSplit($a_text)
This function splits a paragraph text that has been already processed with input2xml at each header p...
static _saveAnchor($a_parent_type, $a_page_id, $a_page_lang, $a_anchor_name)
Save an anchor.
static _deleteAnchors($a_parent_type, $a_page_id, $a_page_lang)
Delete anchors of a page.
$rows
Definition: xhr_table.php:10
static addParent($node, $name)
Add parent.
static _input2xml($a_text, $a_lang, $a_wysiwyg=0, $a_handle_lists=true)
converts user input to xml
createPageContentNode($a_set_this_node=true)
Create page content node (always use this method first when adding a new element) ...
static _getCommonBBButtons()
Get common bb buttons.
const DOMXML_LOAD_PARSING
global $ilDB
$ret
Definition: parser.php:6
$i
Definition: disco.tpl.php:19
static afterPageUpdate($a_page, DOMDocument $a_domdoc, $a_xml, $a_creation)
After page has been updated (or created)
getOnloadCode($a_mode)
Get onload code.
handleNextBr($a_str)
Remove preceding
static saveMetaKeywords($a_page, $a_domdoc)
save all keywords
getJavascriptFiles($a_mode)
Get Javascript files.
if(function_exists('posix_getuid') &&posix_getuid()===0) if(!array_key_exists('t', $options)) $tag
Definition: cron.php:35
readHierId()
Read PC Id.
static intLinks2xml($a_text)
internal links to xml
getShowLineNumbers()
get attribute showlinenumbers