19use PHPUnit\Framework\TestCase;
51 'xx [str]xx[/str] xx',
52 'xx [iln cat="106"] xx',
56 foreach ($cases as $case) {
58 $use_internal_errors = libxml_use_internal_errors(
true);
59 $sxe = simplexml_load_string(
"<?xml version='1.0'?><dummy>" .
$text .
"</dummy>");
60 libxml_use_internal_errors($use_internal_errors);
85 =>
'xx <Strong>xx</Strong> xx',
87 =>
'xx <Comment>xx</Comment> xx',
89 =>
'xx <Emph>xx</Emph> xx',
91 =>
'xx <Footnote>xx</Footnote> xx',
92 'xx [code]xx[/code] xx'
93 =>
'xx <Code>xx</Code> xx',
95 =>
'xx <Accent>xx</Accent> xx',
97 =>
'xx <Important>xx</Important> xx',
99 =>
'xx <Keyw>xx</Keyw> xx',
100 'xx [sub]xx[/sub] xx'
101 =>
'xx <Sub>xx</Sub> xx',
102 'xx [sup]xx[/sup] xx'
103 =>
'xx <Sup>xx</Sup> xx',
104 'xx [quot]xx[/quot] xx'
105 =>
'xx <Quotation>xx</Quotation> xx',
108 'xx [iln cat="106"] xx [/iln] xx'
109 =>
'xx <IntLink Target="il__obj_106" Type="RepositoryItem"> xx </IntLink> xx',
110 'xx [iln cat="106" anchor="moin"] xx [/iln] xx'
111 =>
'xx <IntLink Target="il__obj_106" Type="RepositoryItem" Anchor="moin"> xx </IntLink> xx',
112 'xx [iln page="106"] xx [/iln] xx'
113 =>
'xx <IntLink Target="il__pg_106" Type="PageObject"> xx </IntLink> xx',
114 'xx [iln page="106"] xx xx'
117 =>
'xx xx [/iln] xx',
118 'xx [iln chap="106"] xx [/iln] xx'
119 =>
'xx <IntLink Target="il__st_106" Type="StructureObject"> xx </IntLink> xx',
120 'xx [iln inst="123" page="106"] xx [/iln] xx'
121 =>
'xx <IntLink Target="il_123_pg_106" Type="PageObject"> xx </IntLink> xx',
122 'xx [iln page="106" target="FAQ"] xx [/iln] xx'
123 =>
'xx <IntLink Target="il__pg_106" Type="PageObject" TargetFrame="FAQ"> xx </IntLink> xx',
124 'xx [iln page="106" target="New" anchor="test"] xx [/iln] xx'
125 =>
'xx <IntLink Target="il__pg_106" Type="PageObject" TargetFrame="New" Anchor="test"> xx </IntLink> xx',
126 'xx [iln term="106"] xx [/iln] xx'
127 =>
'xx <IntLink Target="il__git_106" Type="GlossaryItem" TargetFrame="Glossary"> xx </IntLink> xx',
128 'xx [iln term="106" target="New"] xx [/iln] xx'
129 =>
'xx <IntLink Target="il__git_106" Type="GlossaryItem" TargetFrame="New"> xx </IntLink> xx',
130 'xx [iln wpage="106"] xx [/iln] xx'
131 =>
'xx <IntLink Target="il__wpage_106" Type="WikiPage"> xx </IntLink> xx',
132 'xx [iln wpage="106" anchor="test"] xx [/iln] xx'
133 =>
'xx <IntLink Target="il__wpage_106" Type="WikiPage" Anchor="test"> xx </IntLink> xx',
134 'xx [iln ppage="106"] xx [/iln] xx'
135 =>
'xx <IntLink Target="il__ppage_106" Type="PortfolioPage"> xx </IntLink> xx',
136 'xx [iln media="545"/] xx '
137 =>
'xx <IntLink Target="il__mob_545" Type="MediaObject"/> xx',
138 'xx [iln media="108" target="New"] xx [/iln] xx'
139 =>
'xx <IntLink Target="il__mob_108" Type="MediaObject" TargetFrame="New"> xx </IntLink> xx',
140 'xx [iln media="108" target="Media"] xx [/iln] xx'
141 =>
'xx <IntLink Target="il__mob_108" Type="MediaObject" TargetFrame="Media"> xx </IntLink> xx',
142 'xx [iln dfile="546"] xx [/iln] xx'
143 =>
'xx <IntLink Target="il__dfile_546" Type="File"> xx </IntLink> xx',
146 'xx' . chr(13) . chr(10) .
'yy'
148 'xx' . chr(13) .
'yy'
150 'xx' . chr(10) .
'yy'
154 '<ul class="ilc_list_u_BulletedList"><li class="ilc_list_item_StandardListItem">aa</li><li class="ilc_list_item_StandardListItem">bb</li><li class="ilc_list_item_StandardListItem">cc</li></ul>'
155 =>
'<ul class="ilc_list_u_BulletedList"><li class="ilc_list_item_StandardListItem">aa</li><li class="ilc_list_item_StandardListItem">bb</li><li class="ilc_list_item_StandardListItem">cc</li></ul>',
158 'xx [xln url="http://"][/xln] xxxx'
160 'xx [xln url="http://ilias.de"]www[/xln] xxxx'
161 =>
'xx <ExtLink Href="http://ilias.de">www</ExtLink> xxxx',
162 'xx [xln url="http://ilias.php?x=1&y=2"]www[/xln] xxxx'
163 =>
'xx <ExtLink Href="http://ilias.php?x=1&y=2">www</ExtLink> xxxx',
164 'xx [xln url="https://bs.lehrplan.ch/index.php?code=a|10|0|1|0|1"]curriculum[/xln] xxxx'
165 =>
'xx <ExtLink Href="https://bs.lehrplan.ch/index.php?code=a|10|0|1|0|1">curriculum</ExtLink> xxxx',
166 'xx [xln url="http://ilias.de/my+document.pdf"]doc[/xln] xxxx'
167 =>
'xx <ExtLink Href="http://ilias.de/my+document.pdf">doc</ExtLink> xxxx',
168 'xx [xln url="http://ilias.de/my(document.pdf"]doc[/xln] xxxx'
169 =>
'xx <ExtLink Href="http://ilias.de/my(document.pdf">doc</ExtLink> xxxx',
170 'xx [xln url="http://ilias.de/my)document.pdf"]doc[/xln] xxxx'
171 =>
'xx <ExtLink Href="http://ilias.de/my)document.pdf">doc</ExtLink> xxxx',
172 'xx [xln url="http://ilias.de/my$document.pdf"]doc[/xln] xxxx'
173 =>
'xx <ExtLink Href="http://ilias.de/my$document.pdf">doc</ExtLink> xxxx',
174 'xx [xln url="http://ilias.de/my*document.pdf"]doc[/xln] xxxx'
175 =>
'xx <ExtLink Href="http://ilias.de/my*document.pdf">doc</ExtLink> xxxx',
178 'xx [anc name="test"]test[/anc] xxxx'
179 =>
'xx <Anchor Name="test">test</Anchor> xxxx',
182 'xx [marked class="test"]test[/marked] xxxx'
183 =>
'xx <Marked Class="test">test</Marked> xxxx',
187 =>
"xx <br /> \xa0 xxxx",
189 'xx [xln url="http://ilias.de/my+document.pdf\xa0"]doc[/xln] xxxx'
190 =>
'xx [error: xln url="http://ilias.de/my+document.pdf\xa0"]doc</ExtLink> xxxx',
198 foreach ($cases as $in => $expected) {
213 '<ul class="ilc_list_u_BulletedList"><li class="ilc_list_item_StandardListItem">aa</li><li class="ilc_list_item_StandardListItem">bb</li><li class="ilc_list_item_StandardListItem">cc</li></ul>'
214 =>
'<SimpleBulletList Class="BulletedList"><SimpleListItem Class="StandardListItem">aa</SimpleListItem><SimpleListItem Class="StandardListItem">bb</SimpleListItem><SimpleListItem Class="StandardListItem">cc</SimpleListItem></SimpleBulletList>',
215 '<ul class="ilc_list_u_BulletedList"><li class="ilc_list_item_StandardListItem"/></ul>'
216 =>
'<SimpleBulletList Class="BulletedList"><SimpleListItem Class="StandardListItem"></SimpleListItem></SimpleBulletList>'
219 foreach ($cases as $in => $expected) {
235 '<div>First<br>Second<br><br>Fourth</div>'
237 "text" =>
"First\nSecond\n\nFourth",
239 "class" =>
'Standard'
241 '<div>First<br />Second<br/>Third</div>'
243 "text" =>
"First\nSecond\nThird",
245 "class" =>
'Standard'
248 '<div id="1:1234" class="ilc_text_block_Standard">xxx<span class="ilc_text_inline_Strong">xxx</span>xxx</div>'
250 "text" =>
'xxx[str]xxx[/str]xxx',
252 "class" =>
'Standard'
255 '<div id="1:1235" class="ilc_text_block_Mnemonic">xxx<span class="ilc_text_inline_Emph">xxx</span>xxx</div>'
257 "text" =>
'xxx[emp]xxx[/emp]xxx',
259 "class" =>
'Mnemonic'
262 '<div id="1:1236" class="ilc_text_block_Headline1">xxx<span class="ilc_text_inline_Important">xxx</span>xxx</div>'
264 "text" =>
'xxx[imp]xxx[/imp]xxx',
266 "class" =>
'Headline1'
269 '<div id="1:1237" class="ilc_text_block_Standard">xxx a<sup class="ilc_sup_Sup">b*c</sup> xxx</div>'
271 "text" =>
'xxx a[sup]b*c[/sup] xxx',
273 "class" =>
'Standard'
276 '<div id="1:1238" class="ilc_text_block_Standard">xxx a<sub class="ilc_sub_Sub">2</sub> xxx</div>'
278 "text" =>
'xxx a[sub]2[/sub] xxx',
280 "class" =>
'Standard'
283 '<div id="1:1237" class="ilc_text_block_Standard">xxx a<sup>b*c</sup> xxx</div>'
285 "text" =>
'xxx a[sup]b*c[/sup] xxx',
287 "class" =>
'Standard'
290 '<div id="1:1238" class="ilc_text_block_Standard">xxx a<sub>2</sub> xxx</div>'
292 "text" =>
'xxx a[sub]2[/sub] xxx',
294 "class" =>
'Standard'
297 '<div id="1:1239" class="ilc_text_block_Headline2">xxx <span class="ilc_text_inline_Comment">xxx</span> xxx</div>'
299 "text" =>
'xxx [com]xxx[/com] xxx',
301 "class" =>
'Headline2'
304 '<div id="1:1240" class="ilc_text_block_Headline3">xxx <span class="ilc_text_inline_Quotation">xxx</span> xxx</div>'
306 "text" =>
'xxx [quot]xxx[/quot] xxx',
308 "class" =>
'Headline3'
311 '<div id="1:1241" class="ilc_text_block_Book">xxx <span class="ilc_text_inline_Accent">xxx</span> xxx</div>'
313 "text" =>
'xxx [acc]xxx[/acc] xxx',
318 '<div id="1:1242" class="ilc_text_block_Numbers">xxx <code>xxx</code> xxx</div>'
320 "text" =>
'xxx [code]xxx[/code] xxx',
325 '<div id="1:1243" class="ilc_text_block_Verse">xxx <span class="ilc_text_inline_Mnemonic">xxx</span> xxx</div>'
327 "text" =>
'xxx [marked class="Mnemonic"]xxx[/marked] xxx',
332 '<div id="1:1244" class="ilc_text_block_List">xxx <span class="ilc_text_inline_Attention">xxx</span> xxx</div>'
334 "text" =>
'xxx [marked class="Attention"]xxx[/marked] xxx',
340 foreach ($cases as $in => $expected) {
364 '<div id="1:1234" class="ilc_text_block_List"><ul class="ilc_list_u_BulletedList"><li class="ilc_list_item_StandardListItem">one</li><li class="ilc_list_item_StandardListItem">two</li><li class="ilc_list_item_StandardListItem">three</li></ul></div>'
366 "text" =>
'<ul class="ilc_list_u_BulletedList"><li class="ilc_list_item_StandardListItem">one</li><li class="ilc_list_item_StandardListItem">two</li><li class="ilc_list_item_StandardListItem">three</li></ul>',
371 '<div id="1:1235" class="ilc_text_block_List"><ol class="ilc_list_o_NumberedList"><li class="ilc_list_item_StandardListItem">one</li><li class="ilc_list_item_StandardListItem">two</li><li class="ilc_list_item_StandardListItem">three</li></ol></div>'
373 "text" =>
'<ol class="ilc_list_o_NumberedList"><li class="ilc_list_item_StandardListItem">one</li><li class="ilc_list_item_StandardListItem">two</li><li class="ilc_list_item_StandardListItem">three</li></ol>',
379 foreach ($cases as $in => $expected) {
405 ilPCParagraph::class,
414 $pc->create(
$page,
"pg");
416 '<PageObject HierId="pg"><PageContent><Paragraph Language=""></Paragraph></PageContent></PageObject>',
417 $page->getXMLFromDom()
430 $pc->create(
$page,
"pg");
437 'test & the < and the > and the \ also'
438 =>
'test &amp; the &lt; and the &gt; and the \ also',
439 'xxx <span class="ilc_text_inline_Strong">xxx</span> xxx'
440 =>
'xxx <Strong>xxx</Strong> xxx',
443 foreach ($cases as $html => $expected) {
444 $html =
'<div id="1:1234" class="ilc_text_block_Standard">' . $html .
'</div>';
446 $pc->setText($xml,
false);
448 $expected =
'<PageObject HierId="pg"><PageContent><Paragraph Language="">' . $expected .
'</Paragraph></PageContent></PageObject>';
457 $page->getXMLFromDom()
466 $pc->create(
$page,
"pg");
467 $pc->setLanguage(
"en");
468 $pc->setCharacteristic(
"MyChar");
472 $pc->getCharacteristic()
474 $page->stripHierIDs();
477<PageObject><PageContent><Paragraph Language=
"en" Characteristic=
"MyChar"></Paragraph></PageContent></PageObject>
481 $page->getXMLFromDom()
489 $pc->create(
$page,
"pg");
490 $pc->setLanguage(
"en");
491 $pc->setSubCharacteristic(
"MySubChar");
495 $pc->getSubCharacteristic()
497 $page->stripHierIDs();
500<PageObject><PageContent><Paragraph Language=
"en" SubCharacteristic=
"MySubChar"></Paragraph></PageContent></PageObject>
504 $page->getXMLFromDom()
512 $pc->create(
$page,
"pg");
513 $pc->setLanguage(
"en");
514 $pc->setAutoIndent(
"1");
520 $page->stripHierIDs();
523<PageObject><PageContent><Paragraph Language=
"en" AutoIndent=
"1"></Paragraph></PageContent></PageObject>
527 $page->getXMLFromDom()
535 $pc->create(
$page,
"pg");
536 $pc->setLanguage(
"en");
537 $pc->setDownloadTitle(
"title.txt");
541 $pc->getDownloadTitle()
543 $page->stripHierIDs();
546<PageObject><PageContent><Paragraph Language=
"en" DownloadTitle=
"title.txt"></Paragraph></PageContent></PageObject>
550 $page->getXMLFromDom()
558 $pc->create(
$page,
"pg");
559 $pc->setLanguage(
"en");
560 $pc->setShowLineNumbers(
"y");
564 $pc->getShowLineNumbers()
566 $page->stripHierIDs();
569<PageObject><PageContent><Paragraph Language=
"en" ShowLineNumbers=
"y"></Paragraph></PageContent></PageObject>
573 $page->getXMLFromDom()
581 $pc->create(
$page,
"pg");
582 $pc->setLanguage(
"en");
588 $page->stripHierIDs();
591<PageObject><PageContent><Paragraph Language=
"en"></Paragraph></PageContent></PageObject>
595 $page->getXMLFromDom()
legacyHtmlToXml(string $content)
assertXmlEquals(string $expected_xml_as_string, string $html_xml_string)
testHandleAjaxContentLists()
Test HTML to BB transformation, lists (are not transformed in this first step)
test_input2xmlValidXml()
Test _input2xml for validity.
testHandleAjaxContentPost()
Test handleAjaxContentPost.
test_input2xmlEmpty()
Test _input2xml (empty)
testHandleAjaxContentSpans()
Test HTML to BB transformation, spans.
test_input2xmlResult()
Test _input2xml.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static handleAjaxContentPost(string $text)
Post input2xml handling of ajax content.
static _input2xml(string $a_text, string $a_lang, bool $a_wysiwyg=false, bool $a_handle_lists=true)
Converts user input to xml User input comes as bb code information, e.g.
static handleAjaxContent(string $a_content)
Handle ajax content.
foreach($_POST as $key=> $value) $res