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