19 declare(strict_types=1);
62 $this->tpl = $DIC[
'tpl'];
63 $this->
ctrl = $DIC[
'ilCtrl'];
64 $this->
lng = $DIC[
'lng'];
65 $this->browser = $DIC->http()->agent();
66 $this->client_init = $DIC[
'ilClientIniFile'];
67 $this->
user = $DIC[
'ilUser'];
70 public function addPlugin(
string $a_plugin_name): void
72 $this->plugins[] = $a_plugin_name;
75 public function addButton(
string $a_button_name): void
77 $this->buttons[] = $a_button_name;
82 $key = array_search($a_plugin_name, $this->plugins,
true);
84 unset($this->plugins[$key]);
90 foreach ($this->plugins as
$plugin) {
97 $key = array_search($a_button_name, $this->buttons,
true);
99 unset($this->buttons[$key]);
108 string $a_module =
'',
109 bool $allowFormElements =
false,
110 ?
string $cfg_template =
null 131 $editor = (
new ilRTESettings($DIC[
'lng'], $DIC[
'ilUser']))->getRichTextEditor();
132 if (strtolower($editor) ===
'tinymce') {
133 return ilTinyMCE::class;
148 while (preg_match(
'/src=".*" data-id="([0-9]+)"/', $a_text, $found)) {
149 $a_text = str_replace($found[0],
'', $a_text);
150 $found_mob_id = (
int) $found[1];
157 unset($mobs[$found_mob_id]);
164 foreach ($mobs as $mob) {
183 $start =
'<span class="latex">';
196 if (!is_int($epos)) {
201 $tex =
ilStr::subStr($text, $spos + $start_len, $epos - $spos - $start_len);
204 $replace =
'[tex]' . $tex .
'[/tex]';
212 if ($cpos >= ilStr::strlen($text)) {
230 int $a_direction = 0,
233 if ($a_text ===
'') {
237 if ($nic ===
'' && defined(
'IL_INST_ID')) {
241 if ($a_direction === 0) {
242 $a_text = preg_replace(
243 '/src=".*" data-id="([0-9]+)"/',
244 'src="il_' . $nic .
'_mob_\\1"',
248 $resulttext = $a_text;
249 if (preg_match_all(
'/src="(il_[0-9]+_mob_([0-9]+))"/', $a_text, $matches)) {
250 foreach ($matches[2] as $idx => $mob) {
253 $path_to_file = $mob_obj->getStandardSrc();
254 $resulttext = str_replace(
"src=\"{$matches[1][$idx]}\"",
"src=\"{$path_to_file}\" data-id=\"{$matches[2][$idx]}\"", $resulttext);
258 $a_text = $resulttext;
272 if ($a_text ===
'') {
277 if ($a_direction === 0) {
278 $is_matching = preg_match_all(
'/src=".*" data-id="([0-9]+)"/', $a_text, $matches);
280 $is_matching = preg_match_all(
'/src="il_[0-9]+_mob_([0-9]+)"/', $a_text, $matches);
284 foreach ($matches[1] as $mob) {
288 $mediaObjects[] = $mob;
293 return $mediaObjects;
298 $this->root_block_element = $a_root_block_element;
314 if (is_array($a_button)) {
315 $this->disabled_buttons = array_unique(array_merge($this->disabled_buttons, $a_button));
317 $this->disabled_buttons = array_unique(array_merge($this->disabled_buttons, [$a_button]));
331 return implode(
',', $this->disabled_buttons);
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...
static _getMediaObjects(string $a_text, int $a_direction=0)
Returns all media objects found in the passed string.
static _getRTEClassname()
addRTESupport(Language $lng, ilObjUser $user, int $obj_id, string $obj_type, string $a_module='', bool $allowFormElements=false, ?string $cfg_template=null)
static strIPos(string $a_haystack, string $a_needle, int $a_offset=0)
This library is borrowed from the phpGroupWare API http://www.phpgroupware.org/api Modifications made...
addPlugin(string $a_plugin_name)
disableButtons($a_button)
Sets buttons which should be disabled in the RTE.
removePlugin(string $a_plugin_name)
AgentDetermination $browser
addCustomRTESupport(int $obj_id, string $obj_type, array $tags)
Adds custom support for an RTE in an ILIAS form.
static subStr(string $a_str, int $a_start, ?int $a_length=null)
static _cleanupMediaObjectUsage(string $a_text, string $a_usage_type, int $a_usage_id)
Synchronises appearances of media objects in $a_text with media object usage table.
static replaceLatexSpan(string $text)
Replace the latex delimiters used by the rich text editor Unfortunately these can't be processed by M...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static strLen(string $a_string)
string $root_block_element
addUserTextEditor(string $editor_selector)
Rich Text Editor base class This class provides access methods to a Rich Text Editor (RTE) integrated...
setInitialWidth(?int $initialWidth)
getDisabledButtons(bool $as_list=true)
Returns the disabled RTE buttons.
setRTERootBlockElement(?string $a_root_block_element)
addButton(string $a_button_name)
removeButton(string $a_button_name)
ilGlobalTemplateInterface $tpl
static _lookupType(int $id, bool $reference=false)