ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilRTE Class Reference

Rich Text Editor base class This class provides access methods to a Rich Text Editor (RTE) integrated in ILIAS. More...

+ Inheritance diagram for ilRTE:
+ Collaboration diagram for ilRTE:

Public Member Functions

 __construct ($a_version='')
 ilRTE constructor. More...
 
 addPlugin ($a_plugin_name)
 Adds a plugin to the plugin list. More...
 
 addButton ($a_button_name)
 Adds a button to the button list. More...
 
 removePlugin ($a_plugin_name)
 Removes a plugin from the plugin list. More...
 
 removeAllPlugins ()
 Removes all plugins from instance. More...
 
 removeButton ($a_button_name)
 Removes a button from the button list. More...
 
 addRTESupport ($obj_id, $obj_type, $a_module="", $allowFormElements=false, $cfg_template=null, $hide_switch=false)
 Adds support for an RTE in an ILIAS form. More...
 
 addUserTextEditor ($editor_selector)
 Adds support for an user text editor. More...
 
 addCustomRTESupport ($obj_id, $obj_type, array $tags)
 Adds custom support for an RTE in an ILIAS form. More...
 
 setRTERootBlockElement ($a_root_block_element)
 Setter for the RTE root block element. More...
 
 getRTERootBlockElement ()
 Getter for the RTE root block element. More...
 
 disableButtons ($a_button)
 Sets buttons which should be disabled in the RTE. More...
 
 getDisabledButtons ($as_array=true)
 Returns the disabled RTE buttons. More...
 
 getInitialWidth ()
 
 setInitialWidth ($initialWidth)
 

Static Public Member Functions

static _getRTEClassname ()
 
static _cleanupMediaObjectUsage ($a_text, $a_usage_type, $a_usage_id)
 Synchronises appearances of media objects in $a_text with media object usage table. More...
 
static _replaceMediaObjectImageSrc ($a_text, $a_direction=0, $nic=IL_INST_ID)
 Replaces image source from mob image urls with the mob id or replaces mob id with the correct image source. More...
 
static _getMediaObjects ($a_text, $a_direction=0)
 Returns all media objects found in the passed string. More...
 

Data Fields

const ILIAS_IMG_MANAGER_PLUGIN = 'ilias_image_manager_plugin'
 

Protected Attributes

 $plugins = array()
 
 $buttons = array()
 
 $tpl
 
 $ctrl
 
 $user
 
 $lng
 
 $browser
 
 $client_init
 
 $initialWidth = null
 
 $root_block_element = null
 
 $disabled_buttons = array()
 

Detailed Description

Rich Text Editor base class This class provides access methods to a Rich Text Editor (RTE) integrated in ILIAS.

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Version
$Id$ @module class.ilRTE.php

Definition at line 12 of file class.ilRTE.php.

Constructor & Destructor Documentation

◆ __construct()

ilRTE::__construct (   $a_version = '')

ilRTE constructor.

Parameters
string$a_version

Reimplemented in ilTinyMCE.

Definition at line 78 of file class.ilRTE.php.

79 {
80 global $DIC;
81
82 $this->tpl = $DIC['tpl'];
83 $this->ctrl = $DIC['ilCtrl'];
84 $this->lng = $DIC['lng'];
85 $this->browser = $DIC['ilBrowser'];
86 $this->client_init = $DIC['ilClientIniFile'];
87 $this->user = $DIC['ilUser'];
88 }
user()
Definition: user.php:4
global $DIC
Definition: saml.php:7

References $DIC, and user().

+ Here is the call graph for this function:

Member Function Documentation

◆ _cleanupMediaObjectUsage()

static ilRTE::_cleanupMediaObjectUsage (   $a_text,
  $a_usage_type,
  $a_usage_id 
)
static

Synchronises appearances of media objects in $a_text with media object usage table.

Parameters
string$a_texttext, including media object tags
string$a_usage_typetype of context of usage, e.g. cat:html
int$a_usage_idif of context of usage, e.g. category id

Definition at line 196 of file class.ilRTE.php.

197 {
198 require_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
199
200 $mobs = ilObjMediaObject::_getMobsOfObject($a_usage_type, $a_usage_id);
201 while (preg_match("/data\/" . CLIENT_ID . "\/mobs\/mm_([0-9]+)/i", $a_text, $found)) {
202 $a_text = str_replace($found[0], "", $a_text);
203 if (!in_array($found[1], $mobs)) {
204 // save usage if missing
205 ilObjMediaObject::_saveUsage($found[1], $a_usage_type, $a_usage_id);
206 } else {
207 // if already saved everything ok -> take mob out of mobs array
208 unset($mobs[$found[1]]);
209 }
210 }
211 // remaining usages are not in text anymore -> delete them
212 // and media objects (note: delete method of ilObjMediaObject
213 // checks whether object is used in another context; if yes,
214 // the object is not deleted!)
215 foreach ($mobs as $mob) {
216 ilObjMediaObject::_removeUsage($mob, $a_usage_type, $a_usage_id);
217 $mob_obj = new ilObjMediaObject($mob);
218 $mob_obj->delete();
219 }
220 }
Class ilObjMediaObject.
static _saveUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
Save usage of mob within another container (e.g.
static _getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
static _removeUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
Remove usage of mob in another container.
$mobs

References $mobs, ilObjMediaObject\_getMobsOfObject(), ilObjMediaObject\_removeUsage(), and ilObjMediaObject\_saveUsage().

Referenced by ilObjTest\cleanupMediaobjectUsage(), assQuestion\cleanupMediaObjectUsage(), ilContainerGUI\savePageContentObject(), and SurveyQuestion\saveToDb().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getMediaObjects()

static ilRTE::_getMediaObjects (   $a_text,
  $a_direction = 0 
)
static

Returns all media objects found in the passed string.

Parameters
string$a_texttext, including media object tags
integer$a_direction0 to find image src, 1 to find mob id
Returns
array array of media objects

Definition at line 266 of file class.ilRTE.php.

267 {
268 if (!strlen($a_text)) {
269 return array();
270 }
271
272 require_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
273
274 $mediaObjects = array();
275 switch ($a_direction) {
276 case 0:
277 if (preg_match_all('/src="([^"]*?\/mobs\/mm_([0-9]+)\/.*?)\"/', $a_text, $matches)) {
278 foreach ($matches[2] as $idx => $mob) {
279 if (ilObjMediaObject::_exists($mob) && !in_array($mob, $mediaObjects)) {
280 $mediaObjects[] = $mob;
281 }
282 }
283 }
284 break;
285
286 default:
287 if (preg_match_all('/src="il_([0-9]+)_mob_([0-9]+)"/', $a_text, $matches)) {
288 foreach ($matches[2] as $idx => $mob) {
289 if (ilObjMediaObject::_exists($mob) && !in_array($mob, $mediaObjects)) {
290 $mediaObjects[] = $mob;
291 }
292 }
293 }
294 break;
295 }
296
297 return $mediaObjects;
298 }
static _exists($a_id, $a_reference=false, $a_type=null)
checks wether a lm content object with specified id exists or not

References ilObjMediaObject\_exists().

Referenced by ilForumDraftsHistory\addMobsToDraftsHistory(), ilObjForumGUI\addThreadObject(), ilObjForumGUI\autosaveDraftAsyncObject(), ilObjForumGUI\autosaveThreadDraftAsyncObject(), ilObjForumGUI\deleteMobsOfDraft(), ilForumUtil\moveMediaObjects(), ilForumUtil\saveMediaObjects(), and ilExSubmissionTextGUI\updateAssignmentTextObject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getRTEClassname()

static ilRTE::_getRTEClassname ( )
static
Returns
string

Definition at line 176 of file class.ilRTE.php.

177 {
178 require_once 'Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php';
180 case 'tinymce':
181 return 'ilTinyMCE';
182 break;
183
184 default:
185 return 'ilRTE';
186 break;
187 }
188 }
static _getRichTextEditor()
Returns the identifier for the Rich Text Editor.

References ilObjAdvancedEditing\_getRichTextEditor().

Referenced by ilContainerGUI\editPageContentObject(), ilTextAreaInputGUI\insert(), and assTextQuestionGUI\magicAfterTestOutput().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _replaceMediaObjectImageSrc()

static ilRTE::_replaceMediaObjectImageSrc (   $a_text,
  $a_direction = 0,
  $nic = IL_INST_ID 
)
static

Replaces image source from mob image urls with the mob id or replaces mob id with the correct image source.

Parameters
string$a_texttext, including media object tags
integer$a_direction0 to replace image src => mob id, 1 to replace mob id => image src
Returns
string The text containing the replaced media object src

Definition at line 228 of file class.ilRTE.php.

229 {
230 if (!strlen($a_text)) {
231 return '';
232 }
233
234 switch ($a_direction) {
235 case 0:
236 $a_text = preg_replace('/src="([^"]*?\/mobs\/mm_([0-9]+)\/.*?)\"/', 'src="il_' . IL_INST_ID . '_mob_\\2"', $a_text);
237 break;
238
239 default:
240 require_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
241 $resulttext = $a_text;
242 if (preg_match_all('/src="il_([0-9]+)_mob_([0-9]+)"/', $a_text, $matches)) {
243 foreach ($matches[2] as $idx => $mob) {
244 if (ilObject::_lookupType($mob) == "mob") {
245 $mob_obj = new ilObjMediaObject($mob);
246 $replace = "il_" . $matches[1][$idx] . "_mob_" . $mob;
247 require_once('./Services/WebAccessChecker/classes/class.ilWACSignedPath.php');
248 $path_to_file = ilWACSignedPath::signFile(ILIAS_HTTP_PATH . "/data/" . CLIENT_ID . "/mobs/mm_" . $mob . "/" . $mob_obj->getTitle());
249 $resulttext = str_replace("src=\"$replace\"", "src=\"" . $path_to_file . "\"", $resulttext);
250 }
251 }
252 }
253 $a_text = $resulttext;
254 break;
255 }
256
257 return $a_text;
258 }
static _lookupType($a_id, $a_reference=false)
lookup object type
static signFile($path_to_file)

References ilObject\_lookupType(), and ilWACSignedPath\signFile().

Referenced by SurveyQuestion\addMaterialTag(), ilObjSurvey\addMaterialTag(), ilObjTest\addQTIMaterial(), assQuestion\addQTIMaterial(), ilObjForumGUI\addThreadObject(), ilObjForumGUI\autosaveDraftAsyncObject(), ilObjForumGUI\autosaveThreadDraftAsyncObject(), ilObjForumGUI\doHistoryCheck(), ilExSubmissionTextGUI\editAssignmentTextObject(), ilObjForumGUI\editThreadDraftObject(), ilAssSelfAssessmentQuestionFormatter\format(), assClozeTestImport\fromXML(), assErrorTextImport\fromXML(), assFileUploadImport\fromXML(), assFlashQuestionImport\fromXML(), assFormulaQuestionImport\fromXML(), assImagemapQuestionImport\fromXML(), assJavaAppletImport\fromXML(), assKprimChoiceImport\fromXML(), assLongMenuImport\fromXML(), assMatchingQuestionImport\fromXML(), assMultipleChoiceImport\fromXML(), assNumericImport\fromXML(), assOrderingHorizontalImport\fromXML(), assOrderingQuestionImport\fromXML(), assSingleChoiceImport\fromXML(), assTextQuestionImport\fromXML(), assTextSubsetImport\fromXML(), ilObjTest\fromXML(), ilForum\generatePost(), ilAssMultiOptionQuestionFeedback\getAllSpecificAnswerFeedbackContents(), ilAssQuestionFeedback\getGenericFeedbackContent(), ilObjTest\getManualFeedback(), ilAssMultiOptionQuestionFeedback\getSpecificAnswerFeedbackContent(), ilExPeerReviewGUI\getSubmissionContent(), ilObjSurvey\importObject(), ilSurveyImporter\importXmlRepresentation(), assKprimChoice\loadAnswerData(), SurveyMatrixQuestion\loadFromDb(), SurveyMetricQuestion\loadFromDb(), SurveyMultipleChoiceQuestion\loadFromDb(), SurveySingleChoiceQuestion\loadFromDb(), SurveyTextQuestion\loadFromDb(), assClozeTest\loadFromDb(), assErrorText\loadFromDb(), assFileUpload\loadFromDb(), assFlashQuestion\loadFromDb(), assFormulaQuestion\loadFromDb(), assImagemapQuestion\loadFromDb(), assJavaApplet\loadFromDb(), assLongMenu\loadFromDb(), assMatchingQuestion\loadFromDb(), assMultipleChoice\loadFromDb(), assOrderingHorizontal\loadFromDb(), assOrderingQuestion\loadFromDb(), assQuestion\loadFromDb(), assSingleChoice\loadFromDb(), assTextQuestion\loadFromDb(), assTextSubset\loadFromDb(), assKprimChoice\loadFromDb(), ilObjSurvey\loadFromDb(), ilObjTest\loadFromDb(), ilExAssignmentListTextTableGUI\parse(), assQuestionImport\processNonAbstractedImageReferences(), ilObjForumGUI\publishDraftObject(), ilObjForumGUI\publishThreadDraftObject(), ilObjForumGUI\renderDraftContent(), ilObjForumGUI\renderPostContent(), ilForumExportGUI\renderPostHtml(), assClozeTest\saveAdditionalQuestionDataToDb(), ilAssQuestionFeedback\saveGenericFeedbackContent(), assQuestion\saveQuestionDataToDb(), ilAssMultiOptionQuestionFeedback\saveSpecificAnswerFeedbackContent(), ilObjForumGUI\saveThreadAsDraftObject(), SurveyQuestion\saveToDb(), ilObjTest\saveToDb(), ilObjSurvey\saveToDb(), ilExSubmissionTextGUI\showAssignmentTextObject(), ilForumXMLWriter\start(), assErrorText\toJSON(), ilExSubmissionTextGUI\updateAssignmentTextObject(), and ilObjForumGUI\updateThreadDraftObject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addButton()

ilRTE::addButton (   $a_button_name)

Adds a button to the button list.

Parameters
string$a_button_nameThe name of the button

Definition at line 103 of file class.ilRTE.php.

104 {
105 array_push($this->buttons, $a_button_name);
106 }

◆ addCustomRTESupport()

ilRTE::addCustomRTESupport (   $obj_id,
  $obj_type,
array  $tags 
)

Adds custom support for an RTE in an ILIAS form.

Parameters
$obj_idinteger
$obj_typestring
$tagsarray

Reimplemented in ilTinyMCE.

Definition at line 169 of file class.ilRTE.php.

170 {
171 }

◆ addPlugin()

ilRTE::addPlugin (   $a_plugin_name)

Adds a plugin to the plugin list.

Parameters
string$a_plugin_nameThe name of the plugin

Reimplemented in ilTinyMCE.

Definition at line 94 of file class.ilRTE.php.

95 {
96 array_push($this->plugins, $a_plugin_name);
97 }

◆ addRTESupport()

ilRTE::addRTESupport (   $obj_id,
  $obj_type,
  $a_module = "",
  $allowFormElements = false,
  $cfg_template = null,
  $hide_switch = false 
)

Adds support for an RTE in an ILIAS form.

Parameters
$obj_idinteger
$obj_typestring
$a_modulestring
$allowFormElementsbool
$cfg_templatebool
$hide_switchbool

Reimplemented in ilTinyMCE.

Definition at line 151 of file class.ilRTE.php.

152 {
153 }

◆ addUserTextEditor()

ilRTE::addUserTextEditor (   $editor_selector)

Adds support for an user text editor.

Parameters
$editor_selectorstring

Reimplemented in ilTinyMCE.

Definition at line 159 of file class.ilRTE.php.

160 {
161 }

◆ disableButtons()

ilRTE::disableButtons (   $a_button)

Sets buttons which should be disabled in the RTE.

Parameters
array | string$a_buttonEither a button string or an array of button strings
Returns
self

Definition at line 325 of file class.ilRTE.php.

326 {
327 if (is_array($a_button)) {
328 $this->disabled_buttons = array_unique(array_merge($this->disabled_buttons, $a_button));
329 } else {
330 $this->disabled_buttons = array_unique(array_merge($this->disabled_buttons, array($a_button)));
331 }
332
333 return $this;
334 }

Referenced by ilTinyMCE\addCustomRTESupport(), ilTinyMCE\addInternalTinyMCEImageManager(), ilTinyMCE\handleIliasImageManagerRemoved(), and ilTinyMCE\handleImagePluginsBeforeRendering().

+ Here is the caller graph for this function:

◆ getDisabledButtons()

ilRTE::getDisabledButtons (   $as_array = true)

Returns the disabled RTE buttons.

Parameters
bool$as_arrayShould the disabled buttons be returned as a string or as an array
Returns
array|string

Definition at line 341 of file class.ilRTE.php.

342 {
343 if (!$as_array) {
344 return implode(',', $this->disabled_buttons);
345 } else {
347 }
348 }
$disabled_buttons
Definition: class.ilRTE.php:72

References $disabled_buttons.

Referenced by ilTinyMCE\_buildAdvancedButtonsFromHTMLTags(), ilTinyMCE\_buildAdvancedTableButtonsFromHTMLTags(), and ilTinyMCE\_buildButtonsFromHTMLTags().

+ Here is the caller graph for this function:

◆ getInitialWidth()

ilRTE::getInitialWidth ( )
Returns
integer

Definition at line 353 of file class.ilRTE.php.

354 {
355 return $this->initialWidth;
356 }
$initialWidth
Definition: class.ilRTE.php:60

References $initialWidth.

Referenced by ilTinyMCE\addRTESupport().

+ Here is the caller graph for this function:

◆ getRTERootBlockElement()

ilRTE::getRTERootBlockElement ( )

Getter for the RTE root block element.

Returns
string Root block element of the RTE

Definition at line 315 of file class.ilRTE.php.

316 {
318 }
$root_block_element
Definition: class.ilRTE.php:66

References $root_block_element.

Referenced by ilTinyMCE\addCustomRTESupport(), and ilTinyMCE\addRTESupport().

+ Here is the caller graph for this function:

◆ removeAllPlugins()

ilRTE::removeAllPlugins ( )

Removes all plugins from instance.

Definition at line 123 of file class.ilRTE.php.

124 {
125 foreach ($this->plugins as $plugin) {
126 $this->removePlugin($plugin);
127 }
128 }
removePlugin($a_plugin_name)
Removes a plugin from the plugin list.

References removePlugin().

+ Here is the call graph for this function:

◆ removeButton()

ilRTE::removeButton (   $a_button_name)

Removes a button from the button list.

Parameters
string$a_button_nameThe name of the button

Definition at line 134 of file class.ilRTE.php.

135 {
136 $key = array_search($a_button_name, $this->buttons);
137 if ($key !== false) {
138 unset($this->buttons[$key]);
139 }
140 }
$key
Definition: croninfo.php:18

References $key.

◆ removePlugin()

ilRTE::removePlugin (   $a_plugin_name)

Removes a plugin from the plugin list.

Parameters
string$a_plugin_nameThe name of the plugin

Reimplemented in ilTinyMCE.

Definition at line 112 of file class.ilRTE.php.

113 {
114 $key = array_search($a_plugin_name, $this->plugins);
115 if ($key !== false) {
116 unset($this->plugins[$key]);
117 }
118 }

References $key.

Referenced by removeAllPlugins().

+ Here is the caller graph for this function:

◆ setInitialWidth()

ilRTE::setInitialWidth (   $initialWidth)
Parameters
integer$initialWidth

Definition at line 361 of file class.ilRTE.php.

362 {
363 $this->initialWidth = $initialWidth;
364 }

References $initialWidth.

◆ setRTERootBlockElement()

ilRTE::setRTERootBlockElement (   $a_root_block_element)

Setter for the RTE root block element.

Parameters
string$a_root_block_elementRoot block element
Returns
self

Definition at line 305 of file class.ilRTE.php.

306 {
307 $this->root_block_element = $a_root_block_element;
308 return $this;
309 }

Field Documentation

◆ $browser

ilRTE::$browser
protected

Definition at line 50 of file class.ilRTE.php.

◆ $buttons

ilRTE::$buttons = array()
protected

Definition at line 25 of file class.ilRTE.php.

◆ $client_init

ilRTE::$client_init
protected

Definition at line 55 of file class.ilRTE.php.

◆ $ctrl

ilRTE::$ctrl
protected

Definition at line 35 of file class.ilRTE.php.

◆ $disabled_buttons

ilRTE::$disabled_buttons = array()
protected

Definition at line 72 of file class.ilRTE.php.

Referenced by getDisabledButtons().

◆ $initialWidth

ilRTE::$initialWidth = null
protected

Definition at line 60 of file class.ilRTE.php.

Referenced by getInitialWidth(), and setInitialWidth().

◆ $lng

ilRTE::$lng
protected

Definition at line 45 of file class.ilRTE.php.

◆ $plugins

ilRTE::$plugins = array()
protected

Definition at line 20 of file class.ilRTE.php.

◆ $root_block_element

ilRTE::$root_block_element = null
protected

Definition at line 66 of file class.ilRTE.php.

Referenced by getRTERootBlockElement().

◆ $tpl

ilRTE::$tpl
protected

◆ $user

ilRTE::$user
protected

Definition at line 40 of file class.ilRTE.php.

◆ ILIAS_IMG_MANAGER_PLUGIN

const ilRTE::ILIAS_IMG_MANAGER_PLUGIN = 'ilias_image_manager_plugin'

Definition at line 14 of file class.ilRTE.php.

Referenced by ilSurveyEditorGUI\initHeadingForm().


The documentation for this class was generated from the following file: