ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
4require_once("./Services/COPage/classes/class.ilPageContent.php");
5
17{
18 var $dom;
19 var $par_node; // node of Paragraph element
20
21
22 static protected $bb_tags = array(
23 "com" => "Comment",
24 "emp" => "Emph",
25 "str" => "Strong",
26 "fn" => "Footnote",
27 "code" => "Code",
28 "acc" => "Accent",
29 "imp" => "Important",
30 "kw" => "Keyw",
31 "sub" => "Sub",
32 "sup" => "Sup",
33 "quot" => "Quotation",
34 );
35
39 function init()
40 {
41 $this->setType("par");
42 }
43
49 protected static function getBBMap()
50 {
51 return self::$bb_tags;
52 }
53
59 protected static function getXMLTagMap()
60 {
61 return array_flip(self::$bb_tags);
62 }
63
64
65
71 function setNode($a_node)
72 {
73 parent::setNode($a_node); // this is the PageContent node
74
75 $childs = $a_node->child_nodes();
76 for ($i=0; $i<count($childs); $i++)
77 {
78 if ($childs[$i]->node_name() == "Paragraph")
79 {
80 $this->par_node = $childs[$i]; //... and this the Paragraph node
81 }
82 }
83 }
84
85
92 {
93 $this->node = $this->createPageContentNode();
94 $this->par_node = $this->dom->create_element("Paragraph");
95 $this->par_node = $this->node->append_child($this->par_node);
96 $this->par_node->set_attribute("Language", "");
97 $node->append_child ($this->node);
98 }
99
106 {
107 $this->node = $this->createPageContentNode();
108 $this->par_node = $this->dom->create_element("Paragraph");
109 $this->par_node = $this->node->append_child($this->par_node);
110 $this->par_node->set_attribute("Language", "");
111 $node->insert_before($this->node, $node);
112 }
113
121 {
122 $this->node = $this->createPageContentNode(false);
123 if($succ_node = $node->next_sibling())
124 {
125 $this->node = $succ_node->insert_before($this->node, $succ_node);
126 }
127 else
128 {
129 $parent_node = $node->parent_node();
130 $this->node = $parent_node->append_child($this->node);
131 }
132 $this->par_node = $this->dom->create_element("Paragraph");
133 $this->par_node = $this->node->append_child($this->par_node);
134 $this->par_node->set_attribute("Language", "");
135 }
136
144 function create(&$a_pg_obj, $a_hier_id, $a_pc_id = "")
145 {
146//echo "-$a_pc_id-";
147//echo "<br>-".htmlentities($a_pg_obj->getXMLFromDom())."-<br><br>"; mk();
148 $this->node = $this->dom->create_element("PageContent");
149
150 // this next line kicks out placeholders, if something is inserted
151 $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
152
153 $this->par_node = $this->dom->create_element("Paragraph");
154 $this->par_node = $this->node->append_child($this->par_node);
155 $this->par_node->set_attribute("Language", "");
156 }
157
164 function setText($a_text, $a_auto_split = false)
165 {
166 if (!is_array($a_text))
167 {
168 $text = array(array("level" => 0, "text" => $a_text));
169 }
170 else
171 {
172 $text = $a_text;
173 }
174
175 if ($a_auto_split)
176 {
177 $text = $this->autoSplit($a_text);
178 }
179
180 // DOMXML_LOAD_PARSING, DOMXML_LOAD_VALIDATING, DOMXML_LOAD_RECOVERING
181 $check = "";
182 foreach ($text as $t)
183 {
184 $check.= "<Paragraph>".$t["text"]."</Paragraph>";
185 }
186 /*$temp_dom = domxml_open_mem('<?xml version="1.0" encoding="UTF-8"?><Paragraph>'.$text[0]["text"].'</Paragraph>',
187 DOMXML_LOAD_PARSING, $error);*/
188 $temp_dom = domxml_open_mem('<?xml version="1.0" encoding="UTF-8"?><Paragraph>'.$check.'</Paragraph>',
189 DOMXML_LOAD_PARSING, $error);
190 //$this->text = $a_text;
191
192 // remove all childs
193 if(empty($error))
194 {
195 $temp_dom = domxml_open_mem('<?xml version="1.0" encoding="UTF-8"?><Paragraph>'.$text[0]["text"].'</Paragraph>',
196 DOMXML_LOAD_PARSING, $error);
197
198 // delete children of paragraph node
199 $children = $this->par_node->child_nodes();
200 for($i=0; $i<count($children); $i++)
201 {
202 $this->par_node->remove_child($children[$i]);
203 }
204
205 // copy new content children in paragraph node
206 $xpc = xpath_new_context($temp_dom);
207 $path = "//Paragraph";
208 $res = xpath_eval($xpc, $path);
209 if (count($res->nodeset) == 1)
210 {
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 {
216 $cloned_child = $new_childs[$i]->clone_node(true);
217 $this->par_node->append_child($cloned_child);
218 }
219 $orig_characteristic = $this->getCharacteristic();
220
221 // if headlines are entered and current characteristic is a headline
222 // use no characteristic as standard
223 if ((count($text) > 1) && (substr($orig_characteristic, 0, 8) == "Headline"))
224 {
225 $orig_characteristic = "";
226 }
227 if ($text[0]["level"] > 0)
228 {
229 $this->par_node->set_attribute("Characteristic", 'Headline'.$text[0]["level"]);
230 }
231 }
232
233 $ok = true;
234
235 $c_node = $this->node;
236 // add other chunks afterwards
237 for ($i=1; $i<count($text); $i++)
238 {
239 if ($ok)
240 {
241 $next_par = new ilPCParagraph($this->getPage());
242 $next_par->createAfter($c_node);
243 $next_par->setLanguage($this->getLanguage());
244 if ($text[$i]["level"] > 0)
245 {
246 $next_par->setCharacteristic("Headline".$text[$i]["level"]);
247 }
248 else
249 {
250 $next_par->setCharacteristic($orig_characteristic);
251 }
252 $ok = $next_par->setText($text[$i]["text"], false);
253 $c_node = $next_par->node;
254 }
255 }
256
257 return true;
258 }
259 else
260 {
261 // We want the correct number of \n here to have the real lines numbers
262 $text = str_replace("<br>", "\n", $check); // replace <br> with \n to get correct line
263 $text = str_replace("<br/>", "\n", $text);
264 $text = str_replace("<br />", "\n", $text);
265 $text = str_replace("</SimpleListItem>", "</SimpleListItem>\n", $text);
266 $text = str_replace("<SimpleBulletList>", "\n<SimpleBulletList>", $text);
267 $text = str_replace("<SimpleNumberedList>", "\n<SimpleNumberedList>", $text);
268 $text = str_replace("<Paragraph>\n", "<Paragraph>", $text);
269 $text = str_replace("</Paragraph>", "</Paragraph>\n", $text);
270 include_once("./Services/Dom/classes/class.ilDomDocument.php");
271 $doc = new ilDOMDocument();
272 $text = '<?xml version="1.0" encoding="UTF-8"?><Paragraph>'.$text.'</Paragraph>';
273//echo htmlentities($text);
274 $this->success = $doc->loadXML($text);
275 $error = $doc->errors;
276 $estr = "";
277 foreach ($error as $e)
278 {
279 $e = str_replace(" in Entity", "", $e);
280 $estr.= $e."<br />";
281 }
282 if (DEVMODE)
283 {
284 $estr.= "<br />".$text;
285 }
286
287 return $estr;
288 }
289 }
290
296 function getText($a_short_mode = false)
297 {
298 if (is_object($this->par_node))
299 {
300 $content = "";
301 $childs = $this->par_node->child_nodes();
302 for($i=0; $i<count($childs); $i++)
303 {
304 $content .= $this->dom->dump_node($childs[$i]);
305 }
306 return $content;
307 }
308 else
309 {
310 return "";
311 }
312 }
313
317 function getParagraphSequenceContent($a_pg_obj)
318 {
319 $childs = $this->par_node->parent_node()->parent_node()->child_nodes();
320 $seq = array();
321 $cur_seq = array();
322 $found = false;
323 $pc_id = $this->readPCId();
324 $hier_id = $this->readHierId();
325 for($i=0; $i<count($childs); $i++)
326 {
327 $pchilds = $childs[$i]->child_nodes();
328 if ($pchilds[0]->node_name() == "Paragraph" &&
329 $pchilds[0]->get_attribute("Characteristic") != "Code")
330 {
331 $cur_seq[] = $childs[$i];
332
333 // check whether this is the sequence of the current paragraph
334 if ($childs[$i]->get_attribute("PCID") == $pc_id &&
335 $childs[$i]->get_attribute("HierId") == $hier_id)
336 {
337 $found = true;
338 }
339
340 // if this is the current sequenc, get it
341 if ($found)
342 {
343 $seq = $cur_seq;
344 }
345 }
346 else
347 {
348 // non-paragraph element found -> init the current sequence
349 $cur_seq = array();
350 $found = false;
351 }
352 }
353
354 $content = "";
355 $ids = "###";
356 $id_sep = "";
357 foreach ($seq as $p_node)
358 {
359 $ids.= $id_sep.$p_node->get_attribute("HierId").":".$p_node->get_attribute("PCID");
360 $po = $a_pg_obj->getContentObject($p_node->get_attribute("HierId"),
361 $p_node->get_attribute("PCID"));
362 $s_text = $po->getText();
363 $s_text = $po->xml2output($s_text, true, false);
364 $char = $po->getCharacteristic();
365 if ($char == "")
366 {
367 $char = "Standard";
368 }
369 $s_text = ilPCParagraphGUI::xml2outputJS($s_text, $char, $po->readPCId());
370 $content.= $s_text;
371 $id_sep = ";";
372 }
373 $ids.= "###";
374
375 return $ids.$content;
376 }
377
383 function setCharacteristic($a_char)
384 {
385 if (!empty($a_char))
386 {
387 $this->par_node->set_attribute("Characteristic", $a_char);
388 }
389 else
390 {
391 if ($this->par_node->has_attribute("Characteristic"))
392 {
393 $this->par_node->remove_attribute("Characteristic");
394 }
395 }
396 }
397
404 {
405 if (is_object($this->par_node))
406 {
407 return $this->par_node->get_attribute("Characteristic");
408 }
409 }
410
411
415 function setSubCharacteristic($a_char)
416 {
417 if (!empty($a_char))
418 {
419 $this->par_node->set_attribute("SubCharacteristic", $a_char);
420 }
421 else
422 {
423 if ($this->par_node->has_attribute("SubCharacteristic"))
424 {
425 $this->par_node->remove_attribute("SubCharacteristic");
426 }
427 }
428 }
429
435 function getAutoIndent()
436 {
437 return $this->par_node->get_attribute("AutoIndent");
438 }
439
440 function setAutoIndent($a_char)
441 {
442 if (!empty($a_char))
443 {
444 $this->par_node->set_attribute("AutoIndent", $a_char);
445 }
446 else
447 {
448 if ($this->par_node->has_attribute("AutoIndent"))
449 {
450 $this->par_node->remove_attribute("AutoIndent");
451 }
452 }
453 }
454
459 {
460 return $this->par_node->get_attribute("SubCharacteristic");
461 }
462
467 function setDownloadTitle($a_char)
468 {
469 if (!empty($a_char))
470 {
471 $this->par_node->set_attribute("DownloadTitle", $a_char);
472 }
473 else
474 {
475 if ($this->par_node->has_attribute("DownloadTitle"))
476 {
477 $this->par_node->remove_attribute("DownloadTitle");
478 }
479 }
480 }
481
486 {
487 return $this->par_node->get_attribute("DownloadTitle");
488 }
489
494 function setShowLineNumbers($a_char)
495 {
496 $a_char = empty($a_char)?"n":$a_char;
497
498 $this->par_node->set_attribute("ShowLineNumbers", $a_char);
499 }
500
506 {
507 return $this->par_node->get_attribute("ShowLineNumbers");
508 }
509
513 function setLanguage($a_lang)
514 {
515 $this->par_node->set_attribute("Language", $a_lang);
516 }
517
521 function getLanguage()
522 {
523 return $this->par_node->get_attribute("Language");
524 }
525
526 function input2xml($a_text, $a_wysiwyg = 0, $a_handle_lists = true)
527 {
528 return $this->_input2xml($a_text, $this->getLanguage(), $a_wysiwyg, $a_handle_lists);
529 }
530
539 static protected function replaceBBCode($a_text, $a_bb, $a_tag)
540 {
541 $a_text = preg_replace('/\['.$a_bb.'\]/i',"<".$a_tag.">",$a_text);
542 $a_text = preg_replace('/\[\/'.$a_bb.'\]/i',"</".$a_tag.">",$a_text);
543 return $a_text;
544 }
545
546
550 static function _input2xml($a_text, $a_lang, $a_wysiwyg = 0, $a_handle_lists = true)
551 {
552 if (!$a_wysiwyg)
553 {
554 $a_text = ilUtil::stripSlashes($a_text, false);
555 }
556
557 if ($a_wysiwyg)
558 {
559 $a_text = str_replace("<br />", chr(10), $a_text);
560 }
561
562 // note: the order of the processing steps is crucial
563 // and should be the same as in xml2output() in REVERSE order!
564 $a_text = trim($a_text);
565
566//echo "<br>between:".htmlentities($a_text);
567
568 // mask html
569if (!$a_wysiwyg)
570{
571 $a_text = str_replace("&","&amp;",$a_text);
572}
573 $a_text = str_replace("<","&lt;",$a_text);
574 $a_text = str_replace(">","&gt;",$a_text);
575
576 // Reconvert PageTurn and BibItemIdentifier
577 $a_text = preg_replace('/&lt;([\s\/]*?PageTurn.*?)&gt;/i',"<$1>",$a_text);
578 $a_text = preg_replace('/&lt;([\s\/]*?BibItemIdentifier.*?)&gt;/i',"<$1>",$a_text);
579
580//echo "<br>second:".htmlentities($a_text);
581
582 // mask curly brackets
583/*
584echo htmlentities($a_text);
585 $a_text = str_replace("{", "&#123;", $a_text);
586 $a_text = str_replace("}", "&#125;", $a_text);
587echo htmlentities($a_text);*/
588 // linefeed to br
589 $a_text = str_replace(chr(13).chr(10),"<br />",$a_text);
590 $a_text = str_replace(chr(13),"<br />", $a_text);
591 $a_text = str_replace(chr(10),"<br />", $a_text);
592
593 if ($a_handle_lists)
594 {
595 $a_text = ilPCParagraph::input2xmlReplaceLists($a_text);
596 }
597
598 foreach (self::getBBMap() as $bb => $tag)
599 {
600 // remove empty tags
601 $a_text = str_replace("[".$bb."][/".$bb."]", "", $a_text);
602
603 // replace bb code by tag
604 $a_text = self::replaceBBCode($a_text, $bb, $tag);
605 }
606
607 $a_text = self::intLinks2xml($a_text);
608
609 // external link
610 $ws= "[ \t\r\f\v\n]*";
611 // remove empty external links
612 while (preg_match("~\[(xln$ws(url$ws=$ws\"([^\"])*\")$ws(target$ws=$ws(\"(Glossary|FAQ|Media)\"))?$ws)\]\[\/xln\]~i", $a_text, $found))
613 {
614 $a_text = str_replace($found[0], "",$a_text);
615 }
616 while (preg_match('~\[(xln$ws(url$ws=$ws(([^]])*)))$ws\]\[\/xln\]~i', $a_text, $found))
617 {
618 $a_text = str_replace($found[0], "",$a_text);
619 }
620 // external links
621 while (preg_match("~\[(xln$ws(url$ws=$ws\"([^\"])*\")$ws(target$ws=$ws(\"(Glossary|FAQ|Media)\"))?$ws)\]~i", $a_text, $found))
622 {
623 $attribs = ilUtil::attribsToArray($found[2]);
624 if (isset($attribs["url"]))
625 {
626 $a2 = ilUtil::attribsToArray($found[4]);
627 $tstr = "";
628 if (in_array($a2["target"], array("FAQ", "Glossary", "Media")))
629 {
630 $tstr = ' TargetFrame="'.$a2["target"].'"';
631 }
632 $a_text = str_replace("[".$found[1]."]", "<ExtLink Href=\"".$attribs["url"]."\"$tstr>", $a_text);
633 }
634 else
635 {
636 $a_text = str_replace("[".$found[1]."]", "[error: xln".$found[1]."]",$a_text);
637 }
638 }
639
640 // ie/tinymce fix for links without "", see bug #8391
641 while (preg_match('~\[(xln$ws(url$ws=$ws(([^]])*)))$ws\]~i', $a_text, $found))
642 {
643 if ($found[3] != "")
644 {
645 $a_text = str_replace("[".$found[1]."]", "<ExtLink Href=\"".$found[3]."\">", $a_text);
646 }
647 else
648 {
649 $a_text = str_replace("[".$found[1]."]", "[error: xln".$found[1]."]",$a_text);
650 }
651 }
652 $a_text = preg_replace('~\[\/xln\]~i',"</ExtLink>",$a_text);
653
654 // anchor
655 $ws= "[ \t\r\f\v\n]*";
656 while (preg_match("~\[(anc$ws(name$ws=$ws\"([^\"])*\")$ws)\]~i", $a_text, $found))
657 {
658 $attribs = ilUtil::attribsToArray($found[2]);
659 $a_text = str_replace("[".$found[1]."]", "<Anchor Name=\"".$attribs["name"]."\">", $a_text);
660 }
661 $a_text = preg_replace("~\[\/anc\]~i", "</Anchor>",$a_text);
662
663 // marked text
664 while (preg_match("~\[(marked$ws(class$ws=$ws\"([^\"])*\")$ws)\]~i", $a_text, $found))
665 {
666 $attribs = ilUtil::attribsToArray($found[2]);
667 if (isset($attribs["class"]))
668 {
669 $a_text = str_replace("[".$found[1]."]", "<Marked Class=\"".$attribs["class"]."\">", $a_text);
670 }
671 else
672 {
673 $a_text = str_replace("[".$found[1]."]", "[error:marked".$found[1]."]",$a_text);
674 }
675 }
676 $a_text = preg_replace('~\[\/marked\]~i',"</Marked>",$a_text);
677
678
679//echo htmlentities($a_text); exit;
680 return $a_text;
681 }
682
689 static function intLinks2xml($a_text)
690 {
691 global $objDefinition;
692
693 $rtypes = $objDefinition->getAllRepositoryTypes();
694
695 // internal links
696 //$any = "[^\]]*"; // this doesn't work :-(
697 $ws= "[ \t\r\f\v\n]*";
698 $ltypes = "page|chap|term|media|obj|dfile|sess|wpage|".implode($rtypes, "|");
699 // empty internal links
700 while (preg_match('~\[(iln'.$ws.'((inst'.$ws.'='.$ws.'([\"0-9])*)?'.$ws.
701 "((".$ltypes.")$ws=$ws([\"0-9])*)$ws".
702 "(target$ws=$ws(\"(New|FAQ|Media)\"))?$ws(anchor$ws=$ws(\"([^\"])*\"))?$ws))\]\[\/iln\]~i", $a_text, $found))
703 {
704 $a_text = str_replace($found[0], "",$a_text);
705 }
706 while (preg_match('~\[(iln'.$ws.'((inst'.$ws.'='.$ws.'([\"0-9])*)?'.$ws.
707 "((".$ltypes.")$ws=$ws([\"0-9])*)$ws".
708 "(target$ws=$ws(\"(New|FAQ|Media)\"))?$ws(anchor$ws=$ws(\"([^\"])*\"))?$ws))\]~i", $a_text, $found))
709 {
710 $attribs = ilUtil::attribsToArray($found[2]);
711 $inst_str = $attribs["inst"];
712 // pages
713 if (isset($attribs["page"]))
714 {
715 $tframestr = "";
716 if (!empty($found[10]))
717 {
718 $tframestr = " TargetFrame=\"".$found[10]."\" ";
719 }
720 $ancstr = "";
721 if ($attribs["anchor"] != "")
722 {
723 $ancstr = ' Anchor="'.$attribs["anchor"].'" ';
724 }
725 $a_text = preg_replace('/\['.$found[1].'\]/i',
726 "<IntLink Target=\"il_".$inst_str."_pg_".$attribs[page]."\" Type=\"PageObject\"".$tframestr.$ancstr.">", $a_text);
727 }
728 // chapters
729 else if (isset($attribs["chap"]))
730 {
731 if (!empty($found[10]))
732 {
733 $tframestr = " TargetFrame=\"".$found[10]."\" ";
734 }
735 else
736 {
737 $tframestr = "";
738 }
739 $a_text = preg_replace('/\['.$found[1].'\]/i',
740 "<IntLink Target=\"il_".$inst_str."_st_".$attribs[chap]."\" Type=\"StructureObject\"".$tframestr.">", $a_text);
741 }
742 // glossary terms
743 else if (isset($attribs["term"]))
744 {
745 switch ($found[10])
746 {
747 case "New":
748 $tframestr = " TargetFrame=\"New\" ";
749 break;
750
751 default:
752 $tframestr = " TargetFrame=\"Glossary\" ";
753 break;
754 }
755 $a_text = preg_replace('/\['.$found[1].'\]/i',
756 "<IntLink Target=\"il_".$inst_str."_git_".$attribs[term]."\" Type=\"GlossaryItem\" $tframestr>", $a_text);
757 }
758 // wiki pages
759 else if (isset($attribs["wpage"]))
760 {
761 $tframestr = "";
762/* switch ($found[10])
763 {
764 case "New":
765 $tframestr = " TargetFrame=\"New\" ";
766 break;
767
768 default:
769 $tframestr = " TargetFrame=\"Glossary\" ";
770 break;
771 }*/
772 $a_text = preg_replace('/\['.$found[1].'\]/i',
773 "<IntLink Target=\"il_".$inst_str."_wpage_".$attribs[wpage]."\" Type=\"WikiPage\" $tframestr>", $a_text);
774 }
775 // media object
776 else if (isset($attribs["media"]))
777 {
778 if (!empty($found[10]))
779 {
780 $tframestr = " TargetFrame=\"".$found[10]."\" ";
781 $a_text = preg_replace('/\['.$found[1].'\]/i',
782 "<IntLink Target=\"il_".$inst_str."_mob_".$attribs[media]."\" Type=\"MediaObject\"".$tframestr.">", $a_text);
783 }
784 else
785 {
786 $a_text = preg_replace('/\['.$found[1].'\]/i',
787 "<IntLink Target=\"il_".$inst_str."_mob_".$attribs[media]."\" Type=\"MediaObject\"/>", $a_text);
788 }
789 }
790 // direct download file (no repository object)
791 else if (isset($attribs["dfile"]))
792 {
793 $a_text = preg_replace('/\['.$found[1].'\]/i',
794 "<IntLink Target=\"il_".$inst_str."_dfile_".$attribs[dfile]."\" Type=\"File\">", $a_text);
795 }
796 // repository items (id is ref_id (will be used internally but will
797 // be replaced by object id for export purposes)
798 else
799 {
800 foreach ($objDefinition->getAllRepositoryTypes() as $t)
801 {
802 if (isset($attribs[$t]))
803 {
804 $obj_id = $attribs[$t];
805 }
806 }
807 if (isset($attribs["obj"]))
808 {
809 $obj_id = $attribs["obj"];
810 }
811
812 if ($obj_id > 0)
813 {
814 if ($inst_str == "")
815 {
816 $a_text = preg_replace('/\['.$found[1].'\]/i',
817 "<IntLink Target=\"il_".$inst_str."_obj_".$obj_id."\" Type=\"RepositoryItem\">", $a_text);
818 }
819 else
820 {
821 $a_text = preg_replace('/\['.$found[1].'\]/i',
822 "<IntLink Target=\"il_".$inst_str."_".$found[6]."_".$obj_id."\" Type=\"RepositoryItem\">", $a_text);
823 }
824 }
825 else
826 {
827 $a_text = preg_replace('/\['.$found[1].'\]/i', "[error: iln".$found[1]."]",$a_text);
828 }
829 }
830 }
831
832 while (preg_match("~\[(iln$ws((inst$ws=$ws([\"0-9])*)?".$ws."media$ws=$ws([\"0-9])*)$ws)/\]~i", $a_text, $found))
833 {
834 $attribs = ilUtil::attribsToArray($found[2]);
835 $inst_str = $attribs["inst"];
836 $a_text = preg_replace('~\['.$found[1].'/\]~i',
837 "<IntLink Target=\"il_".$inst_str."_mob_".$attribs[media]."\" Type=\"MediaObject\"/>", $a_text);
838 }
839
840 // user
841 while (preg_match("~\[(iln$ws((inst$ws=$ws([\"0-9])*)?".$ws."user$ws=$ws(\"([^\"])*)\")$ws)/\]~i", $a_text, $found))
842 {
843 $attribs = ilUtil::attribsToArray($found[2]);
844 $inst_str = $attribs["inst"];
845 include_once("./Services/User/classes/class.ilObjUser.php");
846 $user_id = ilObjUser::_lookupId($attribs[user]);
847 $a_text = preg_replace('~\['.$found[1].'/\]~i',
848 "<IntLink Target=\"il_".$inst_str."_user_".$user_id."\" Type=\"User\"/>", $a_text);
849 }
850
851 $a_text = preg_replace('~\[\/iln\]~i',"</IntLink>",$a_text);
852 return $a_text;
853 }
854
855
863 static function input2xmlReplaceLists($a_text)
864 {
865 $rows = explode("<br />", $a_text."<br />");
866//var_dump($a_text);
867
868 $old_level = 0;
869
870 $text = "";
871
872 foreach ($rows as $row)
873 {
874 $level = 0;
875 if (str_replace("#", "*", substr($row, 0, 3)) == "***")
876 {
877 $level = 3;
878 }
879 else if (str_replace("#", "*", substr($row, 0, 2)) == "**")
880 {
881 $level = 2;
882 }
883 else if (str_replace("#", "*", substr($row, 0, 1)) == "*")
884 {
885 $level = 1;
886 }
887
888 // end previous line
889 if ($level < $old_level)
890 {
891 for ($i = $old_level; $i > $level; $i--)
892 {
893 $text.= "</SimpleListItem></".$clist[$i].">";
894 }
895 if ($level > 0)
896 {
897 $text.= "</SimpleListItem>";
898 }
899 }
900 else if ($old_level > 0 && $level > 0 && ($level == $old_level))
901 {
902 $text.= "</SimpleListItem>";
903 }
904 else if (($level == $old_level) && $text != "")
905 {
906 $text.= "<br />";
907 }
908
909 // start next line
910 if ($level > $old_level)
911 {
912 for($i = $old_level + 1; $i <= $level; $i++)
913 {
914 if (substr($row, $i - 1, 1) == "*")
915 {
916 $clist[$i] = "SimpleBulletList";
917 }
918 else
919 {
920 $clist[$i] = "SimpleNumberedList";
921 }
922 $text.= "<".$clist[$i]."><SimpleListItem>";
923 }
924 }
925 else if ($old_level > 0 && $level > 0)
926 {
927 $text.= "<SimpleListItem>";
928 }
929 $text.= substr($row, $level);
930
931 $old_level = $level;
932 }
933
934 // remove "<br />" at the end
935 if (substr($text, strlen($text) - 6) == "<br />")
936 {
937 $text = substr($text, 0, strlen($text) - 6);
938 }
939
940 return $text;
941 }
942
950 static function xml2outputReplaceLists($a_text)
951 {
952 $segments = ilPCParagraph::segmentString($a_text, array("<SimpleBulletList>", "</SimpleBulletList>",
953 "</SimpleListItem>", "<SimpleListItem>", "<SimpleListItem/>", "<SimpleNumberedList>", "</SimpleNumberedList>"));
954
955 $current_list = array();
956 $text = "";
957 for ($i=0; $i<= count($segments); $i++)
958 {
959 if ($segments[$i] == "<SimpleBulletList>")
960 {
961 if (count($current_list) == 0)
962 {
963 $list_start = true;
964 }
965 array_push($current_list, "*");
966 $li = false;
967 }
968 else if ($segments[$i] == "<SimpleNumberedList>")
969 {
970 if (count($current_list) == 0)
971 {
972 $list_start = true;
973 }
974 array_push($current_list, "#");
975 $li = false;
976 }
977 else if ($segments[$i] == "</SimpleBulletList>")
978 {
979 array_pop($current_list);
980 $li = false;
981 }
982 else if ($segments[$i] == "</SimpleNumberedList>")
983 {
984 array_pop($current_list);
985 $li = false;
986 }
987 else if ($segments[$i] == "<SimpleListItem>")
988 {
989 $li = true;
990 }
991 else if ($segments[$i] == "</SimpleListItem>")
992 {
993 $li = false;
994 }
995 else if ($segments[$i] == "<SimpleListItem/>")
996 {
997 if ($list_start)
998 {
999 $text.= "<br />";
1000 $list_start = false;
1001 }
1002 foreach($current_list as $list)
1003 {
1004 $text.= $list;
1005 }
1006 $text.= "<br />";
1007 $li = false;
1008 }
1009 else
1010 {
1011 if ($li)
1012 {
1013 if ($list_start)
1014 {
1015 $text.= "<br />";
1016 $list_start = false;
1017 }
1018 foreach($current_list as $list)
1019 {
1020 $text.= $list;
1021 }
1022 }
1023 $text.= $segments[$i];
1024 if ($li)
1025 {
1026 $text.= "<br />";
1027 }
1028 $li = false;
1029 }
1030 }
1031
1032 // remove trailing <br />, if text ends with list
1033 if ($segments[count($segments) - 1] == "</SimpleBulletList>" ||
1034 $segments[count($segments) - 1] == "</SimpleNumberedList>" &&
1035 substr($text, strlen($text) - 6) == "<br />")
1036 {
1037 $text = substr($text, 0, strlen($text) - 6);
1038 }
1039
1040 return $text;
1041 }
1042
1046 static function segmentString($a_haystack, $a_needles)
1047 {
1048 $segments = array();
1049
1050 $nothing_found = false;
1051 while (!$nothing_found)
1052 {
1053 $nothing_found = true;
1054 $found = -1;
1055 foreach($a_needles as $needle)
1056 {
1057 $pos = stripos($a_haystack, $needle);
1058 if (is_int($pos) && ($pos < $found || $found == -1))
1059 {
1060 $found = $pos;
1061 $found_needle = $needle;
1062 $nothing_found = false;
1063 }
1064 }
1065 if ($found > 0)
1066 {
1067 $segments[] = substr($a_haystack, 0, $found);
1068 $a_haystack = substr($a_haystack, $found);
1069 }
1070 if ($found > -1)
1071 {
1072 $segments[] = substr($a_haystack, 0, strlen($found_needle));
1073 $a_haystack = substr($a_haystack, strlen($found_needle));
1074 }
1075 }
1076 if ($a_haystack != "")
1077 {
1078 $segments[] = $a_haystack;
1079 }
1080
1081 return $segments;
1082 }
1083
1091 static function xml2output($a_text, $a_wysiwyg = false, $a_replace_lists = true)
1092 {
1093 // note: the order of the processing steps is crucial
1094 // and should be the same as in input2xml() in REVERSE order!
1095
1096 // xml to bb code
1097 $any = "[^>]*";
1098
1099 foreach (self::getBBMap() as $bb => $tag)
1100 {
1101 $a_text = preg_replace('~<'.$tag.'[^>]*>~i',"[".$bb."]", $a_text);
1102 $a_text = preg_replace('~</'.$tag.'>~i',"[/".$bb."]", $a_text);
1103 $a_text = preg_replace('~<'.$tag.'/>~i',"[".$bb."][/".$bb."]", $a_text);
1104 }
1105
1106 // replace lists
1107 if ($a_replace_lists)
1108 {
1109//echo "<br>".htmlentities($a_text);
1110 $a_text = ilPCParagraph::xml2outputReplaceLists($a_text);
1111//echo "<br>".htmlentities($a_text);
1112 }
1113
1114 // internal links
1115 while (preg_match('~<IntLink('.$any.')>~i', $a_text, $found))
1116 {
1117 $found[0];
1118 $attribs = ilUtil::attribsToArray($found[1]);
1119 $target = explode("_", $attribs["Target"]);
1120 $target_id = $target[count($target) - 1];
1121 $inst_str = (!is_int(strpos($attribs["Target"], "__")))
1122 ? $inst_str = "inst=\"".$target[1]."\" "
1123 : $inst_str = "";
1124 switch($attribs["Type"])
1125 {
1126 case "PageObject":
1127 $tframestr = (!empty($attribs["TargetFrame"]))
1128 ? " target=\"".$attribs["TargetFrame"]."\""
1129 : "";
1130 $ancstr = (!empty($attribs["Anchor"]))
1131 ? ' anchor="'.$attribs["Anchor"].'"'
1132 : "";
1133 $a_text = preg_replace('~<IntLink'.$found[1].'>~i',"[iln ".$inst_str."page=\"".$target_id."\"$tframestr$ancstr]",$a_text);
1134 break;
1135
1136 case "StructureObject":
1137 $tframestr = (!empty($attribs["TargetFrame"]))
1138 ? " target=\"".$attribs["TargetFrame"]."\""
1139 : "";
1140 $a_text = preg_replace('~<IntLink'.$found[1].'>~i',"[iln ".$inst_str."chap=\"".$target_id."\"$tframestr]",$a_text);
1141 break;
1142
1143 case "GlossaryItem":
1144 $tframestr = (empty($attribs["TargetFrame"]) || $attribs["TargetFrame"] == "Glossary")
1145 ? ""
1146 : " target=\"".$attribs["TargetFrame"]."\"";
1147 $a_text = preg_replace('~<IntLink'.$found[1].'>~i',"[iln ".$inst_str."term=\"".$target_id."\"".$tframestr."]",$a_text);
1148 break;
1149
1150 case "WikiPage":
1151 $tframestr = "";
1152 /*$tframestr = (empty($attribs["TargetFrame"]) || $attribs["TargetFrame"] == "Glossary")
1153 ? ""
1154 : " target=\"".$attribs["TargetFrame"]."\"";*/
1155 $a_text = preg_replace('~<IntLink'.$found[1].'>~i',"[iln ".$inst_str."wpage=\"".$target_id."\"".$tframestr."]",$a_text);
1156 break;
1157
1158 case "MediaObject":
1159 if (empty($attribs["TargetFrame"]))
1160 {
1161 $a_text = preg_replace('~<IntLink'.$found[1].'>~i',"[iln ".$inst_str."media=\"".$target_id."\"/]",$a_text);
1162 }
1163 else
1164 {
1165 $a_text = preg_replace('~<IntLink'.$found[1].'>~i',"[iln media=\"".$target_id."\"".
1166 " target=\"".$attribs["TargetFrame"]."\"]",$a_text);
1167 }
1168 break;
1169
1170 // Repository Item (using ref id)
1171 case "RepositoryItem":
1172 if ($inst_str == "")
1173 {
1175 }
1176 else
1177 {
1178 $rtype = $target[count($target) - 2];
1179 $target_type = $rtype;
1180 }
1181 $a_text = preg_replace('~<IntLink'.$found[1].'>~i',"[iln ".$inst_str."$target_type=\"".$target_id."\"".$tframestr."]",$a_text);
1182 break;
1183
1184 // Download File (not in repository, Object ID)
1185 case "File":
1186 $a_text = preg_replace('~<IntLink'.$found[1].'>~i',"[iln ".$inst_str."dfile=\"".$target_id."\"".$tframestr."]",$a_text);
1187 break;
1188
1189 // User
1190 case "User":
1191 include_once("./Services/User/classes/class.ilObjUser.php");
1192 $a_text = preg_replace('~<IntLink'.$found[1].'>~i',"[iln ".$inst_str."user=\"".ilObjUser::_lookupLogin($target_id)."\"/]",$a_text);
1193 break;
1194
1195 default:
1196 $a_text = preg_replace('~<IntLink'.$found[1].'>~i',"[iln]",$a_text);
1197 break;
1198 }
1199 }
1200 $a_text = str_replace("</IntLink>","[/iln]",$a_text);
1201
1202 // external links
1203 while (preg_match('~<ExtLink('.$any.')>~i', $a_text, $found))
1204 {
1205 $found[0];
1206 $attribs = ilUtil::attribsToArray($found[1]);
1207 //$found[1] = str_replace("?", "\?", $found[1]);
1208 $tstr = "";
1209 if (in_array($attribs["TargetFrame"], array("FAQ", "Glossary", "Media")))
1210 {
1211 $tstr = ' target="'.$attribs["TargetFrame"].'"';
1212 }
1213 $a_text = str_replace("<ExtLink".$found[1].">","[xln url=\"".$attribs["Href"]."\"$tstr]",$a_text);
1214 }
1215 $a_text = str_replace("</ExtLink>","[/xln]",$a_text);
1216
1217 // anchor
1218 while (preg_match('~<Anchor('.$any.'/)>~i', $a_text, $found))
1219 {
1220 $found[0];
1221 $attribs = ilUtil::attribsToArray($found[1]);
1222 $a_text = str_replace("<Anchor".$found[1].">","[anc name=\"".$attribs["Name"]."\"][/anc]",$a_text);
1223 }
1224 while (preg_match('~<Anchor('.$any.')>~i', $a_text, $found))
1225 {
1226 $found[0];
1227 $attribs = ilUtil::attribsToArray($found[1]);
1228 $a_text = str_replace("<Anchor".$found[1].">","[anc name=\"".$attribs["Name"]."\"]",$a_text);
1229 }
1230 $a_text = str_replace("</Anchor>","[/anc]",$a_text);
1231
1232 // marked text
1233 while (preg_match('~<Marked('.$any.')>~i', $a_text, $found))
1234 {
1235 $found[0];
1236 $attribs = ilUtil::attribsToArray($found[1]);
1237 $a_text = str_replace("<Marked".$found[1].">","[marked class=\"".$attribs["Class"]."\"]",$a_text);
1238 }
1239 $a_text = str_replace("</Marked>","[/marked]",$a_text);
1240
1241 // br to linefeed
1242 if (!$a_wysiwyg)
1243 {
1244 $a_text = str_replace("<br />", "\n", $a_text);
1245 $a_text = str_replace("<br/>", "\n", $a_text);
1246 }
1247
1248if (!$a_wysiwyg)
1249{
1250 // prevent curly brackets from being swallowed up by template engine
1251 $a_text = str_replace("{", "&#123;", $a_text);
1252 $a_text = str_replace("}", "&#125;", $a_text);
1253
1254 // unmask html
1255 $a_text = str_replace("&lt;", "<", $a_text);
1256 $a_text = str_replace("&gt;", ">",$a_text);
1257
1258 // this is needed to allow html like <tag attribute="value">... in paragraphs
1259 $a_text = str_replace("&quot;", "\"", $a_text);
1260
1261 // make ampersands in (enabled) html attributes work
1262 // e.g. <a href="foo.php?n=4&t=5">hhh</a>
1263 $a_text = str_replace("&amp;", "&", $a_text);
1264
1265 // make &gt; and $lt; work to allow (disabled) html descriptions
1266 $a_text = str_replace("&lt;", "&amp;lt;", $a_text);
1267 $a_text = str_replace("&gt;", "&amp;gt;", $a_text);
1268}
1269 return $a_text;
1270 //return str_replace("<br />", chr(13).chr(10), $a_text);
1271 }
1272
1279 function autoSplit($a_text)
1280 {
1281 $a_text = str_replace ("=<SimpleBulletList>", "=<br /><SimpleBulletList>", $a_text);
1282 $a_text = str_replace ("=<SimpleNumberedList>", "=<br /><SimpleNumberedList>", $a_text);
1283 $a_text = str_replace ("</SimpleBulletList>=", "</SimpleBulletList><br />=", $a_text);
1284 $a_text = str_replace ("</SimpleNumberedList>=", "</SimpleNumberedList><br />=", $a_text);
1285 $a_text = "<br />".$a_text."<br />"; // add preceding and trailing br
1286
1287 $chunks = array();
1288 $c_text = $a_text;
1289//echo "0";
1290 while ($c_text != "")
1291 {
1292//var_dump($c_text); flush();
1293//echo "1";
1294 $s1 = strpos($c_text, "<br />=");
1295 if (is_int($s1))
1296 {
1297//echo "2";
1298 $s2 = strpos($c_text, "<br />==");
1299 if (is_int($s2) && $s2 <= $s1)
1300 {
1301//echo "3";
1302 $s3 = strpos($c_text, "<br />===");
1303 if (is_int($s3) && $s3 <= $s2) // possible level three header
1304 {
1305//echo "4";
1306 $n = strpos($c_text, "<br />", $s3 + 1);
1307 if ($n > ($s3+9) && substr($c_text, $n-3, 9) == "===<br />")
1308 {
1309//echo "5";
1310 // found level three header
1311 if ($s3 > 0 || $head != "")
1312 {
1313//echo "6";
1314 $chunks[] = array("level" => 0,
1315 "text" => $this->removeTrailingBr($head.substr($c_text, 0, $s3)));
1316 $head = "";
1317 }
1318 $chunks[] = array("level" => 3,
1319 "text" => trim(substr($c_text, $s3+9, $n-$s3-12)));
1320 $c_text = $this->handleNextBr(substr($c_text, $n+6));
1321 }
1322 else
1323 {
1324//echo "7";
1325 $head.= substr($c_text, 0, $n);
1326 $c_text = substr($c_text, $n);
1327 }
1328 }
1329 else // possible level two header
1330 {
1331//echo "8";
1332 $n = strpos($c_text, "<br />", $s2 + 1);
1333 if ($n > ($s2+8) && substr($c_text, $n-2, 8) == "==<br />")
1334 {
1335//echo "9";
1336 // found level two header
1337 if ($s2 > 0 || $head != "")
1338 {
1339//echo "A";
1340 $chunks[] = array("level" => 0,
1341 "text" => $this->removeTrailingBr($head.substr($c_text, 0, $s2)));
1342 $head = "";
1343 }
1344 $chunks[] = array("level" => 2, "text" => trim(substr($c_text, $s2+8, $n-$s2-10)));
1345 $c_text = $this->handleNextBr(substr($c_text, $n+6));
1346 }
1347 else
1348 {
1349//echo "B";
1350 $head.= substr($c_text, 0, $n);
1351 $c_text = substr($c_text, $n);
1352 }
1353 }
1354 }
1355 else // possible level one header
1356 {
1357//echo "C";
1358 $n = strpos($c_text, "<br />", $s1 + 1);
1359 if ($n > ($s1+7) && substr($c_text, $n-1, 7) == "=<br />")
1360 {
1361//echo "D";
1362 // found level one header
1363 if ($s1 > 0 || $head != "")
1364 {
1365//echo "E";
1366 $chunks[] = array("level" => 0,
1367 "text" => $this->removeTrailingBr($head.substr($c_text, 0, $s1)));
1368 $head = "";
1369 }
1370 $chunks[] = array("level" => 1, "text" => trim(substr($c_text, $s1+7, $n-$s1-8)));
1371 $c_text = $this->handleNextBr(substr($c_text, $n+6));
1372//echo "<br>ctext:".htmlentities($c_text)."<br>";
1373 }
1374 else
1375 {
1376 $head.= substr($c_text, 0, $n);
1377 $c_text = substr($c_text, $n);
1378//echo "<br>head:".$head."c_text:".$c_text."<br>";
1379 }
1380 }
1381 }
1382 else
1383 {
1384//echo "G";
1385 $chunks[] = array("level" => 0, "text" => $head.$c_text);
1386 $head = "";
1387 $c_text = "";
1388 }
1389 }
1390 if (count($chunks) == 0)
1391 {
1392 $chunks[] = array("level" => 0, "text" => "");
1393 }
1394
1395
1396 // remove preceding br
1397 if (substr($chunks[0]["text"], 0, 6) == "<br />")
1398 {
1399 $chunks[0]["text"] = substr($chunks[0]["text"], 6);
1400 }
1401
1402 // remove trailing br
1403 if (substr($chunks[count($chunks) - 1]["text"],
1404 strlen($chunks[count($chunks) - 1]["text"]) - 6, 6) == "<br />")
1405 {
1406 $chunks[count($chunks) - 1]["text"] =
1407 substr($chunks[count($chunks) - 1]["text"], 0, strlen($chunks[count($chunks) - 1]["text"]) - 6);
1408 if ($chunks[count($chunks) - 1]["text"] == "")
1409 {
1410 unset($chunks[count($chunks) - 1]);
1411 }
1412 }
1413 return $chunks;
1414 }
1415
1419 function handleNextBr($a_str)
1420 {
1421 // do not remove, if next line starts with a "=", otherwise two
1422 // headlines in a row will not be recognized
1423 if (substr($a_str, 0, 6) == "<br />" && substr($a_str, 6, 1) != "=")
1424 {
1425 $a_str = substr($a_str, 6);
1426 }
1427 else
1428 {
1429 // if next line starts with a "=" we need to reinsert the <br />
1430 // otherwise it will not be recognized
1431 if (substr($a_str, 0, 1) == "=")
1432 {
1433 $a_str = "<br />".$a_str;
1434 }
1435 }
1436 return $a_str;
1437 }
1438
1442 function removeTrailingBr($a_str)
1443 {
1444 if (substr($a_str, strlen($a_str) - 6) == "<br />")
1445 {
1446 $a_str = substr($a_str, 0, strlen($a_str) - 6);
1447 }
1448 return $a_str;
1449 }
1450
1454 function getType()
1455 {
1456 return ($this->getCharacteristic() == "Code")?"src":parent::getType();
1457 }
1458
1462
1469 function saveJS($a_pg_obj, $a_content, $a_char, $a_pc_id, $a_insert_at = "")
1470 {
1471 global $ilUser;
1472
1473 $this->log->debug("step 1: ".substr($a_content, 0, 1000));
1475 $this->log->debug("step 2: ".substr($t["text"], 0, 1000));
1476 if ($t === false)
1477 {
1478 return false;
1479 }
1480
1481 $pc_id = explode(":", $a_pc_id);
1482 $insert_at = explode(":", $a_insert_at);
1483 $t_id = explode(":", $t["id"]);
1484
1485 // insert new paragraph
1486 if ($a_insert_at != "")
1487 {
1488 $par = new ilPCParagraph($this->getPage());
1489 $par->create($a_pg_obj, $insert_at[0], $insert_at[1]);
1490 }
1491 else
1492 {
1493 $par = $a_pg_obj->getContentObject($pc_id[0], $pc_id[1]);
1494 }
1495
1496 if ($a_insert_at != "")
1497 {
1498 $pc_id = $a_pg_obj->generatePCId();
1499 $par->writePCId($pc_id);
1500 $this->inserted_pc_id = $pc_id;
1501 }
1502 else
1503 {
1504 $this->inserted_pc_id = $pc_id[1];
1505 }
1506
1507 $par->setLanguage($ilUser->getLanguage());
1508 $par->setCharacteristic($t["class"]);
1509
1510 $t2 = $par->input2xml($t["text"], true, false);
1511 $this->log->debug("step 3: ".substr($t2, 0, 1000));
1512
1514 $this->log->debug("step 4: ".substr($t2, 0, 1000));
1515
1516 $updated = $par->setText($t2, true);
1517
1518 if ($updated !== true)
1519 {
1520 echo $updated; exit;
1521 return false;
1522 }
1523 $updated = $par->updatePage($a_pg_obj);
1524 //$updated = $a_pg_obj->update();
1525 return $updated;
1526 }
1527
1534 function getLastSavedPCId($a_pg_obj, $a_as_ajax_str = false)
1535 {
1536 if ($a_as_ajax_str)
1537 {
1538 $a_pg_obj->stripHierIDs();
1539 $a_pg_obj->addHierIds();
1540 $ids = "###";
1541//var_dump($this->inserted_pc_ids);
1542 $combined = $a_pg_obj->getHierIdsForPCIds(
1543 array($this->inserted_pc_id));
1544 foreach ($combined as $pc_id => $hier_id)
1545 {
1546//echo "1";
1547 $ids.= $sep.$hier_id.":".$pc_id;
1548 $sep = ";";
1549 }
1550 $ids.= "###";
1551 return $ids;
1552 }
1553
1554 return $this->inserted_pc_id;
1555 }
1556
1557
1562 {
1563 $a_content = "<dummy>".$a_content."</dummy>";
1564
1565 $doc = new DOMDocument();
1566
1567 $content = ilUtil::stripSlashes($a_content, false);
1568
1569// $content = str_replace("&lt;", "<", $content);
1570// $content = str_replace("&gt;", ">", $content);
1571//echo "<br><br>".htmlentities($content); mk();
1572 $res = $doc->loadXML($content);
1573
1574 if (!$res)
1575 {
1576 return false;
1577 }
1578
1579 // convert tags
1580 $xpath = new DOMXpath($doc);
1581
1582 $tags = self::getXMLTagMap();
1583
1584 $elements = $xpath->query("//span");
1585 include_once("./Services/Utilities/classes/class.ilDOM2Util.php");
1586 while (!is_null($elements) && !is_null($element = $elements->item(0)))
1587 {
1588 //$element = $elements->item(0);
1589 $class = $element->getAttribute("class");
1590 if (substr($class, 0, 16) == "ilc_text_inline_")
1591 {
1592 $class_arr = explode(" ", $class);
1593 $tag = substr($class_arr[0], 16);
1594 if (isset($tags[$tag])) // known tag like strong
1595 {
1596 $cnode = ilDOM2Util::changeName($element, "il" . substr($class_arr[0], 16), false);
1597 }
1598 else // unknown tag -> marked text
1599 {
1600 $cnode = ilDOM2Util::changeName($element, "ilMarked", false);
1601 $cnode->setAttribute("Class", substr($class_arr[0], 16));
1602 }
1603 for ($i = 1; $i < count($class_arr); $i++)
1604 {
1605 $tag = substr($class_arr[$i], 16);
1606 if (isset($tags[$tag])) // known tag like strong
1607 {
1608 $cnode = ilDOM2Util::addParent($cnode, "il" . substr($class_arr[$i], 16));
1609 }
1610 else // unknown tag -> marked element
1611 {
1612 $cnode = ilDOM2Util::addParent($cnode, "ilMarked");
1613 $cnode->setAttribute("Class", substr($class_arr[$i], 16));
1614 }
1615 }
1616 }
1617 else
1618 {
1620 }
1621
1622 $elements = $xpath->query("//span");
1623 }
1624
1625 // convert tags
1626 $xpath = new DOMXpath($doc);
1627 $elements = $xpath->query("/dummy/div");
1628
1629 $ret = array();
1630 if (!is_null($elements))
1631 {
1632 foreach ($elements as $element)
1633 {
1634 $id = $element->getAttribute("id");
1635 $class = $element->getAttribute("class");
1636 $class = substr($class, 15);
1637 if (trim($class) == "")
1638 {
1639 $class = "Standard";
1640 }
1641
1642 $text = $doc->saveXML($element);
1643 $text = str_replace("<br/>", "\n", $text);
1644
1645 // remove wrapping div
1646 $pos = strpos($text, ">");
1647 $text = substr($text, $pos + 1);
1648 $pos = strrpos($text, "<");
1649 $text = substr($text, 0, $pos);
1650
1651 // todo: remove empty spans <span ...> </span>
1652
1653 // replace tags by bbcode
1654 foreach (ilPageContentGUI::_getCommonBBButtons() as $bb => $cl)
1655 {
1656 if (!in_array($bb, array("code", "tex", "fn", "xln")))
1657 {
1658 $text = str_replace("<il".$cl.">",
1659 "[".$bb."]", $text);
1660 $text = str_replace("</il".$cl.">",
1661 "[/".$bb."]", $text);
1662 $text = str_replace("<il".$cl."/>", "", $text);
1663 }
1664 }
1665 $text = str_replace(array("<code>", "</code>"),
1666 array("[code]", "[/code]"), $text);
1667 $text = str_replace(array('<sup class="ilc_sup_Sup">', "</sup>"),
1668 array("[sup]", "[/sup]"), $text);
1669 $text = str_replace(array('<sub class="ilc_sub_Sub">', "</sub>"),
1670 array("[sub]", "[/sub]"), $text);
1671
1672 $text = str_replace("<code/>", "", $text);
1673 $text = str_replace('<ul class="ilc_list_u_BulletedList"/>', "", $text);
1674 $text = str_replace('<ul class="ilc_list_o_NumberedList"/>', "", $text);
1675
1676 // replace marked text
1677 // external links
1678 $any = "[^>]*";
1679 while (preg_match('~<ilMarked('.$any.')>~i', $text, $found))
1680 {
1681 $found[0];
1682 $attribs = ilUtil::attribsToArray($found[1]);
1683 $text = str_replace("<ilMarked".$found[1].">","[marked class=\"".$attribs["Class"]."\"]",$text);
1684 }
1685 $text = str_replace("</ilMarked>","[/marked]", $text);
1686
1687
1688 $ret[] = array("text" => $text, "id" => $id, "class" => $class);
1689 }
1690 }
1691
1692 // we should only have one here!
1693 return $ret[0];
1694 }
1695
1700 {
1701 $text = str_replace(array("&lt;ul&gt;", "&lt;/ul&gt;"),
1702 array("<SimpleBulletList>", "</SimpleBulletList>"), $text);
1703 $text = str_replace(array("&lt;ul class='ilc_list_u_BulletedList'&gt;", "&lt;/ul&gt;"),
1704 array("<SimpleBulletList>", "</SimpleBulletList>"), $text);
1705 $text = str_replace(array("&lt;ul class=\"ilc_list_u_BulletedList\"&gt;", "&lt;/ul&gt;"),
1706 array("<SimpleBulletList>", "</SimpleBulletList>"), $text);
1707 $text = str_replace(array("&lt;ol&gt;", "&lt;/ol&gt;"),
1708 array("<SimpleNumberedList>", "</SimpleNumberedList>"), $text);
1709 $text = str_replace(array("&lt;ol class='ilc_list_o_NumberedList'&gt;", "&lt;/ol&gt;"),
1710 array("<SimpleNumberedList>", "</SimpleNumberedList>"), $text);
1711 $text = str_replace(array("&lt;ol class=\"ilc_list_o_NumberedList\"&gt;", "&lt;/ol&gt;"),
1712 array("<SimpleNumberedList>", "</SimpleNumberedList>"), $text);
1713 $text = str_replace(array("&lt;li&gt;", "&lt;/li&gt;"),
1714 array("<SimpleListItem>", "</SimpleListItem>"), $text);
1715 $text = str_replace(array("&lt;li class='ilc_list_item_StandardListItem'&gt;", "&lt;/li&gt;"),
1716 array("<SimpleListItem>", "</SimpleListItem>"), $text);
1717 $text = str_replace(array("&lt;li class=\"ilc_list_item_StandardListItem\"&gt;", "&lt;/li&gt;"),
1718 array("<SimpleListItem>", "</SimpleListItem>"), $text);
1719
1720 $text = str_replace(array("&lt;li class=\"ilc_list_item_StandardListItem\"/&gt;"),
1721 array("<SimpleListItem></SimpleListItem>"), $text);
1722
1723 $text = str_replace("<SimpleBulletList><br />", "<SimpleBulletList>", $text);
1724 $text = str_replace("<SimpleNumberedList><br />", "<SimpleNumberedList>", $text);
1725 $text = str_replace("<br /><SimpleBulletList>", "<SimpleBulletList>", $text);
1726 $text = str_replace("<br /><SimpleNumberedList>", "<SimpleNumberedList>", $text);
1727 $text = str_replace("</SimpleBulletList><br />", "</SimpleBulletList>", $text);
1728 $text = str_replace("</SimpleNumberedList><br />", "</SimpleNumberedList>", $text);
1729 $text = str_replace("</SimpleListItem><br />", "</SimpleListItem>", $text);
1730
1731 return $text;
1732 }
1733
1741 function updatePage($a_page)
1742 {
1743 $a_page->beforePageContentUpdate($this);
1744
1745 $ret = $a_page->update();
1746 return $ret;
1747 }
1748
1755 function autoLinkGlossaries($a_glos)
1756 {
1757 if (is_array($a_glos) && count($a_glos) > 0)
1758 {
1759 include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
1760
1761 // check which terms occur in the text (we may
1762 // get some false positives due to the strip_tags, but
1763 // we do not want to find strong or list or other stuff
1764 // within the tags
1765 $text = strip_tags($this->getText());
1766 $found_terms = array();
1767 foreach ($a_glos as $glo)
1768 {
1769 if (ilObject::_lookupType($glo) == "glo")
1770 {
1771 $terms = ilGlossaryTerm::getTermList($glo);
1772 foreach ($terms as $t)
1773 {
1774 if (is_int(stripos($text, $t["term"])))
1775 {
1776 $found_terms[$t["id"]] = $t;
1777 }
1778 }
1779 }
1780 }
1781
1782 // did we find anything? -> modify content
1783 if (count($found_terms) > 0)
1784 {
1785 self::linkTermsInDom($this->dom, $found_terms, $this->par_node);
1786 }
1787 }
1788 }
1789
1796 protected static function linkTermsInDom($a_dom, $a_terms, $a_par_node = null)
1797 {
1798 // sort terms by their length (shortes first)
1799 // to prevent that nested tags are builded
1800 foreach ($a_terms as $k => $t)
1801 {
1802 $a_terms[$k]["termlength"] = strlen($t["term"]);
1803 }
1804 $a_terms = ilUtil::sortArray($a_terms, "termlength", "asc", true);
1805
1806
1807 if ($a_dom instanceof php4DOMDocument)
1808 {
1809 $a_dom = $a_dom->myDOMDocument;
1810 }
1811 if ($a_par_node instanceof php4DOMElement)
1812 {
1813 $a_par_node = $a_par_node->myDOMNode;
1814 }
1815
1816 $xpath = new DOMXPath($a_dom);
1817
1818 if ($a_par_node == null)
1819 {
1820 $parnodes = $xpath->query("//Paragraph[@Characteristic != 'Code']");
1821 }
1822 else
1823 {
1824 $parnodes = $xpath->query(".//Paragraph[@Characteristic != 'Code']", $a_par_node->parentNode);
1825 }
1826
1827 include_once("./Services/Utilities/classes/class.ilStr.php");
1828
1829 foreach ($parnodes as $parnode)
1830 {
1831 $textnodes = $xpath->query('.//text()', $parnode);
1832 foreach ($textnodes as $node)
1833 {
1834 $p = $node->getNodePath();
1835
1836 // we do not change text nodes inside of links
1837 if (!is_int(strpos($p, "/IntLink")) &&
1838 !is_int(strpos($p, "/ExtLink")))
1839 {
1840 $node_val = $node->nodeValue;
1841
1842 // all terms
1843 foreach ($a_terms as $t)
1844 {
1845 $pos = ilStr::strIPos($node_val, $t["term"]);
1846
1847 // if term found
1848 while (is_int($pos))
1849 {
1850 // check if we are in a tex tag, see #22261
1851 $tex_bpos = ilStr::strrPos(ilStr::subStr($node_val, 0, $pos), "[tex]");
1852 $tex_epos = ilStr::strPos($node_val, "[/tex]", $tex_bpos);
1853 if ($tex_bpos > 0 && $tex_epos > 0 && $tex_bpos < $pos && $tex_epos > $pos)
1854 {
1855 $pos+= ilStr::strLen($t["term"]);
1856 }
1857 else
1858 {
1859
1860 // check if the string is not included in another word
1861 // note that []
1862 $valid_limiters = array("", " ", "&nbsp;", ".", ",", ":", ";", "!", "?", "\"", "'", "(", ")");
1863 $b = ($pos > 0)
1864 ? ilStr::subStr($node_val, $pos - 1, 1)
1865 : "";
1866 $a = ilStr::subStr($node_val, $pos + ilStr::strLen($t["term"]), 1);
1867 if ((in_array($b, $valid_limiters) || htmlentities($b, null, 'utf-8') == "&nbsp;") && in_array($a, $valid_limiters))
1868 {
1869 $mid = '[iln term="' . $t["id"] . '"]' .
1870 ilStr::subStr($node_val, $pos, ilStr::strLen($t["term"])) .
1871 "[/iln]";
1872
1873 $node_val = ilStr::subStr($node_val, 0, $pos) .
1874 $mid .
1875 ilStr::subStr($node_val, $pos + ilStr::strLen($t["term"]));
1876
1877 $pos += ilStr::strLen($mid);
1878 } else
1879 {
1880 $pos += ilStr::strLen($t["term"]);
1881 }
1882 }
1883 $pos = ilStr::strIPos($node_val, $t["term"], $pos);
1884 }
1885
1886 // insert [iln] tags
1887 }
1888
1889 $node->nodeValue = $node_val;
1890 }
1891
1892// var_dump($p);
1893// var_dump($node->nodeValue);
1894 }
1895
1896
1897 // dump paragraph node
1898 $text = $a_dom->saveXML($parnode);
1899 $text = substr($text, 0, strlen($text) - strlen("</Paragraph>"));
1900 $text = substr($text, strpos($text, ">") + 1);
1901
1902 // replace [iln] by tags with xml representation
1904
1905 // "set text"
1906 $temp_dom = domxml_open_mem('<?xml version="1.0" encoding="UTF-8"?><Paragraph>'.$text.'</Paragraph>',
1907 DOMXML_LOAD_PARSING, $error);
1908 $temp_dom = $temp_dom->myDOMDocument;
1909
1910 if(empty($error))
1911 {
1912 // delete children of paragraph node
1913 $children = $parnode->childNodes;
1914 while ($parnode->hasChildNodes())
1915 {
1916 $parnode->removeChild($parnode->firstChild);
1917 }
1918
1919 // copy new content children in paragraph node
1920 $xpath_temp = new DOMXPath($temp_dom);
1921 $temp_pars = $xpath_temp->query("//Paragraph");
1922
1923 foreach ($temp_pars as $new_par_node)
1924 {
1925 $new_childs = $new_par_node->childNodes;
1926
1927 foreach($new_childs as $new_child)
1928 {
1929 //$cloned_child = $new_child->cloneNode(true);
1930 $cloned_child = $a_dom->importNode($new_child, true);
1931 $parnode->appendChild($cloned_child);
1932 }
1933 }
1934 }
1935 }
1936// exit;
1937 }
1938
1939
1946 static function autoLinkGlossariesPage($a_page, $a_terms)
1947 {
1948 $a_page->buildDom();
1949 $a_dom = $a_page->getDom();
1950
1951 self::linkTermsInDom($a_dom, $a_terms);
1952
1953 $a_page->update();
1954 }
1955
1964 static function afterPageUpdate($a_page, DOMDocument $a_domdoc, $a_xml, $a_creation)
1965 {
1966 // pc paragraph
1967 self::saveMetaKeywords($a_page, $a_domdoc);
1968 self::saveAnchors($a_page, $a_domdoc);
1969 }
1970
1976 static function beforePageDelete($a_page)
1977 {
1978 // delete anchors
1979 self::_deleteAnchors($a_page->getParentType(), $a_page->getId(), $a_page->getLanguage());
1980 }
1981
1990 static function afterPageHistoryEntry($a_page, DOMDocument $a_old_domdoc, $a_old_xml, $a_old_nr)
1991 {
1992 }
1993
1999 static function saveAnchors($a_page, $a_domdoc)
2000 {
2001 self::_deleteAnchors($a_page->getParentType(), $a_page->getId(), $a_page->getLanguage());
2002
2003 // get all anchors
2004 $xpath = new DOMXPath($a_domdoc);
2005 $nodes = $xpath->query('//Anchor');
2006 $saved = array();
2007 foreach ($nodes as $node)
2008 {
2009 $name = $node->getAttribute("Name");
2010 if (trim($name) != "" && !in_array($name, $saved))
2011 {
2012 self::_saveAnchor($a_page->getParentType(), $a_page->getId(), $a_page->getLanguage(), $name);
2013 $saved[] = $name;
2014 }
2015 }
2016
2017 }
2018
2022 static function _deleteAnchors($a_parent_type, $a_page_id, $a_page_lang)
2023 {
2024 global $ilDB;
2025
2026 $ilDB->manipulate("DELETE FROM page_anchor WHERE ".
2027 " page_parent_type = ".$ilDB->quote($a_parent_type, "text").
2028 " AND page_id = ".$ilDB->quote($a_page_id, "integer").
2029 " AND page_lang = ".$ilDB->quote($a_page_lang, "text")
2030 );
2031 }
2032
2036 static function _saveAnchor($a_parent_type, $a_page_id, $a_page_lang, $a_anchor_name)
2037 {
2038 global $ilDB;
2039
2040 $ilDB->manipulate("INSERT INTO page_anchor ".
2041 "(page_parent_type, page_id, page_lang, anchor_name) VALUES (".
2042 $ilDB->quote($a_parent_type, "text").",".
2043 $ilDB->quote($a_page_id, "integer").",".
2044 $ilDB->quote($a_page_lang, "text").",".
2045 $ilDB->quote($a_anchor_name, "text").
2046 ")");
2047 }
2048
2052 static function _readAnchors($a_parent_type, $a_page_id, $a_page_lang = "-")
2053 {
2054 global $ilDB;
2055
2056 $and_lang = ($a_page_lang != "")
2057 ? " AND page_lang = ".$ilDB->quote($a_page_lang, "text")
2058 : "";
2059
2060 $set = $ilDB->query("SELECT * FROM page_anchor ".
2061 " WHERE page_parent_type = ".$ilDB->quote($a_parent_type, "text").
2062 " AND page_id = ".$ilDB->quote($a_page_id, "integer").
2063 $and_lang
2064 );
2065 $anchors = array();
2066 while ($rec = $ilDB->fetchAssoc($set))
2067 {
2068 $anchors[] = $rec["anchor_name"];
2069 }
2070 return $anchors;
2071 }
2072
2079 static function saveMetaKeywords($a_page, $a_domdoc)
2080 {
2081 // not nice, should be set by context per method
2082 if ($a_page->getParentType() == "gdf" ||
2083 $a_page->getParentType() == "lm")
2084 {
2085 // get existing keywords
2086 $keywords = array();
2087
2088 // find all Keyw tags
2089 $xpath = new DOMXPath($a_domdoc);
2090 $nodes = $xpath->query('//Keyw');
2091 foreach($nodes as $node)
2092 {
2093 $k = trim(strip_tags($node->nodeValue));
2094 if (!in_array($k, $keywords))
2095 {
2096 $keywords[] = $k;
2097 }
2098 }
2099
2100 $meta_type = ($a_page->getParentType() == "gdf")
2101 ? "gdf"
2102 : "pg";
2103 $meta_rep_id = $a_page->getParentId();
2104 $meta_id = $a_page->getId();
2105
2106 include_once("./Services/MetaData/classes/class.ilMD.php");
2107 $md_obj = new ilMD($meta_rep_id, $meta_id, $meta_type);
2108 $mkeywords = array();
2109 $lang = "";
2110 if(is_object($md_section = $md_obj->getGeneral()))
2111 {
2112 foreach($ids = $md_section->getKeywordIds() as $id)
2113 {
2114 $md_key = $md_section->getKeyword($id);
2115 $mkeywords[] = strtolower($md_key->getKeyword());
2116 if ($lang == "")
2117 {
2118 $lang = $md_key->getKeywordLanguageCode();
2119 }
2120 }
2121 if ($lang == "")
2122 {
2123 foreach($ids = $md_section->getLanguageIds() as $id)
2124 {
2125 $md_lang = $md_section->getLanguage($id);
2126 if ($lang == "")
2127 {
2128 $lang = $md_lang->getLanguageCode();
2129 }
2130 }
2131 }
2132 foreach ($keywords as $k)
2133 {
2134 if (!in_array(strtolower($k), $mkeywords))
2135 {
2136 if (trim($k) != "" && $lang != "")
2137 {
2138 $md_key = $md_section->addKeyword();
2139 $md_key->setKeyword(ilUtil::stripSlashes($k));
2140 $md_key->setKeywordLanguage(new ilMDLanguageItem($lang));
2141 $md_key->save();
2142 }
2143 $mkeywords[] = strtolower($k);
2144 }
2145 }
2146 }
2147 }
2148 }
2149
2153 function getJavascriptFiles($a_mode)
2154 {
2155 $adve_settings = new ilSetting("adve");
2156
2157 if ($a_mode != "edit" && $adve_settings->get("auto_url_linking"))
2158 {
2159 include_once("./Services/Link/classes/class.ilLinkifyUtil.php");
2161 }
2162
2163 return array();
2164 }
2165
2172 function getOnloadCode($a_mode)
2173 {
2174 $adve_settings = new ilSetting("adve");
2175
2176 if ($a_mode != "edit" && $adve_settings->get("auto_url_linking"))
2177 {
2178 return array("il.ExtLink.autolink('.ilc_Paragraph','ilc_link_ExtLink');");
2179 }
2180
2181 return array();
2182 }
2183
2184
2185}
2186?>
user()
Definition: user.php:4
$error
Definition: Error.php:17
$n
Definition: RandomTest.php:80
$path
Definition: aliased.php:25
An exception for terminatinating execution or to throw for unit testing.
const IL_INSERT_AFTER
static addParent($node, $name)
Add parent.
static replaceByChilds($node)
Replace a node by its child.
static changeName($node, $name, $keep_attributes=true)
Change name of a node.
static getTermList($a_glo_id, $searchterm="", $a_first_letter="", $a_def="", $a_tax_node=0, $a_add_amet_fields=false, array $a_amet_filter=null, $a_include_references=false)
Get all terms for given set of glossary ids.
static getLocalJsPaths()
Get paths of necessary js files.
static _lookupLogin($a_user_id)
lookup login
static _lookupId($a_user_str)
Lookup id by login.
static _lookupType($a_id, $a_reference=false)
lookup object type
static xml2outputJS($s_text, $char, $a_pc_id)
Prepare content for js output.
Class ilPCParagraph.
getText($a_short_mode=false)
Get (xml) content of paragraph.
handleNextBr($a_str)
Remove preceding
static getXMLTagMap()
Get tag to bb map.
static intLinks2xml($a_text)
internal links to xml
removeTrailingBr($a_str)
Remove trailing
static _saveAnchor($a_parent_type, $a_page_id, $a_page_lang, $a_anchor_name)
Save an anchor.
getLastSavedPCId($a_pg_obj, $a_as_ajax_str=false)
Get last inserted pc ids.
static _readAnchors($a_parent_type, $a_page_id, $a_page_lang="-")
Read anchors of a page.
getType()
Need to override getType from ilPageContent to distinguish between Pararagraph and Source.
static _input2xml($a_text, $a_lang, $a_wysiwyg=0, $a_handle_lists=true)
converts user input to xml
static autoLinkGlossariesPage($a_page, $a_terms)
Auto link glossary of whole page.
static linkTermsInDom($a_dom, $a_terms, $a_par_node=null)
Link terms in a dom page object in bb style.
setNode($a_node)
Set Page Content Node.
getShowLineNumbers()
get attribute showlinenumbers
autoLinkGlossaries($a_glos)
Auto link glossaries.
static saveAnchors($a_page, $a_domdoc)
Save anchors.
static handleAjaxContent($a_content)
Handle ajax content.
init()
Init page content component.
setSubCharacteristic($a_char)
set attribute subcharacteristic
createAtNode(&$node)
Create new page content (incl.
input2xml($a_text, $a_wysiwyg=0, $a_handle_lists=true)
static xml2output($a_text, $a_wysiwyg=false, $a_replace_lists=true)
Converts xml from DB to output in edit textarea.
createAfter($node)
Create paragraph node (incl.
static input2xmlReplaceLists($a_text)
Converts xml from DB to output in edit textarea.
static beforePageDelete($a_page)
Before page is being deleted.
setDownloadTitle($a_char)
set attribute download title
create(&$a_pg_obj, $a_hier_id, $a_pc_id="")
Create paragraph node (incl.
static xml2outputReplaceLists($a_text)
Replaces with *.
getAutoIndent()
Get AutoIndent (Code Paragraphs)
getDownloadTitle()
get attribute download title
static afterPageUpdate($a_page, DOMDocument $a_domdoc, $a_xml, $a_creation)
After page has been updated (or created)
setText($a_text, $a_auto_split=false)
Set (xml) content of text paragraph.
static replaceBBCode($a_text, $a_bb, $a_tag)
Replace bb code.
getOnloadCode($a_mode)
Get onload code.
static getBBMap()
Get bb to xml tag map.
setShowLineNumbers($a_char)
set attribute showlinenumbers
setLanguage($a_lang)
set language
static afterPageHistoryEntry($a_page, DOMDocument $a_old_domdoc, $a_old_xml, $a_old_nr)
After page history entry has been created.
setCharacteristic($a_char)
Set Characteristic of paragraph.
static handleAjaxContentPost($text)
Post input2xml handling of ajax content.
static saveMetaKeywords($a_page, $a_domdoc)
save all keywords
static segmentString($a_haystack, $a_needles)
Segments a string into an array at each position of a substring.
saveJS($a_pg_obj, $a_content, $a_char, $a_pc_id, $a_insert_at="")
Save input coming from ajax.
getLanguage()
get language
createBeforeNode(&$node)
Create new page content (incl.
autoSplit($a_text)
This function splits a paragraph text that has been already processed with input2xml at each header p...
getParagraphSequenceContent($a_pg_obj)
Get paragraph sequenc of current paragraph.
updatePage($a_page)
Update page object (it would be better to have this centralized and to change the constructors and pa...
getSubCharacteristic()
get attribute subcharacteristic
static _deleteAnchors($a_parent_type, $a_page_id, $a_page_lang)
Delete anchors of a page.
getCharacteristic()
Get characteristic of paragraph.
getJavascriptFiles($a_mode)
Get Javascript files.
static _getCommonBBButtons()
Get common bb buttons.
Class ilPageContent.
createPageContentNode($a_set_this_node=true)
Create page content node (always use this method first when adding a new element)
readHierId()
Read PC Id.
readPCId()
Read PC Id.
setType($a_type)
Set Type.
ILIAS Setting Class.
static strPos($a_haystack, $a_needle, $a_offset=NULL)
Definition: class.ilStr.php:34
static strrPos($a_haystack, $a_needle, $a_offset=NULL)
Definition: class.ilStr.php:46
static strLen($a_string)
Definition: class.ilStr.php:91
static strIPos($a_haystack, $a_needle, $a_offset=NULL)
Definition: class.ilStr.php:58
static subStr($a_str, $a_start, $a_length=NULL)
Definition: class.ilStr.php:15
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static attribsToArray($a_str)
converts a string of format var1 = "val1" var2 = "val2" ... into an array
$text
$target_id
Definition: goto.php:51
$target_type
Definition: goto.php:50
xpath_eval($xpath_context, $eval_str, $contextnode=null)
domxml_open_mem($str, $mode=0, &$error=NULL)
xpath_new_context($dom_document)
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
Definition: langwiz.php:349
$li
Definition: langwiz.php:233
$ret
Definition: parser.php:6
global $ilDB
$ilUser
Definition: imgupload.php:18
$a_content
Definition: workflow.php:94