ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
class.ilPCLegacyAnswerFormText.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 private const string ELEMENT_TAG = 'LegacyAnswerFormText';
24 private const string TEXT_ATTRIBUTE = 'Text';
25 private const string TEXT_PLACEHOLDER = '\[\[\[LEGACY_ANSWER_FORM_TEXT_((?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?)\]\]\]';
26
27 public function init(): void
28 {
29 $this->setType('laft');
30 }
31
32 #[\Override]
33 public function modifyPageContentPostXsl(
34 string $output,
35 string $mode,
36 bool $abstract_only = false
37 ): string {
38 if ($this->pg_obj::class !== QstsQuestionPage::class) {
39 return $output;
40 }
41
42 return mb_ereg_replace_callback(
43 self::TEXT_PLACEHOLDER,
44 static fn(array $matches): string => \ilRTE::_replaceMediaObjectImageSrc(
45 base64_decode($matches[1])
46 ),
47 $output
48 );
49 }
50
51 public function create(
52 string $legacy_answer_form_text
53 ): void {
54 $this->createInitialChildNode(
55 $this->hier_id,
56 '',
57 self::ELEMENT_TAG,
58 [self::TEXT_ATTRIBUTE => $legacy_answer_form_text]
59 );
60 }
61}
create(string $legacy_answer_form_text)
modifyPageContentPostXsl(string $output, string $mode, bool $abstract_only=false)
Modify page content after xsl.
Content object of ilPageObject (see ILIAS DTD).
setType(string $a_type)
Set Type.
static _replaceMediaObjectImageSrc(string $a_text, int $a_direction=0, string $nic='')
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
if(!file_exists('../ilias.ini.php'))