ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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$ 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

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

References $DIC, and user().

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
+ 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 200 of file class.ilRTE.php.

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

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

201  {
202  require_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
203 
204  $mobs = ilObjMediaObject::_getMobsOfObject($a_usage_type, $a_usage_id);
205  while(preg_match("/data\/" . CLIENT_ID . "\/mobs\/mm_([0-9]+)/i", $a_text, $found))
206  {
207  $a_text = str_replace($found[0], "", $a_text);
208  if(!in_array($found[1], $mobs))
209  {
210  // save usage if missing
211  ilObjMediaObject::_saveUsage($found[1], $a_usage_type, $a_usage_id);
212  }
213  else
214  {
215  // if already saved everything ok -> take mob out of mobs array
216  unset($mobs[$found[1]]);
217  }
218  }
219  // remaining usages are not in text anymore -> delete them
220  // and media objects (note: delete method of ilObjMediaObject
221  // checks whether object is used in another context; if yes,
222  // the object is not deleted!)
223  foreach($mobs as $mob)
224  {
225  ilObjMediaObject::_removeUsage($mob, $a_usage_type, $a_usage_id);
226  $mob_obj = new ilObjMediaObject($mob);
227  $mob_obj->delete();
228  }
229  }
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
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.
+ 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 277 of file class.ilRTE.php.

References ilObjMediaObject\_exists(), and array.

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

278  {
279  if(!strlen($a_text)) return array();
280 
281  require_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
282 
283  $mediaObjects = array();
284  switch($a_direction)
285  {
286  case 0:
287  if(preg_match_all('/src="([^"]*?\/mobs\/mm_([0-9]+)\/.*?)\"/', $a_text, $matches))
288  {
289  foreach($matches[2] as $idx => $mob)
290  {
291  if(ilObjMediaObject::_exists($mob) && !in_array($mob, $mediaObjects))
292  {
293  $mediaObjects[] = $mob;
294  }
295  }
296  }
297  break;
298 
299  default:
300  if(preg_match_all('/src="il_([0-9]+)_mob_([0-9]+)"/', $a_text, $matches))
301  {
302  foreach($matches[2] as $idx => $mob)
303  {
304  if(ilObjMediaObject::_exists($mob) && !in_array($mob, $mediaObjects))
305  {
306  $mediaObjects[] = $mob;
307  }
308  }
309  }
310  break;
311  }
312 
313  return $mediaObjects;
314  }
static _exists($a_id, $a_reference=false, $a_type=NULL)
checks wether a lm content object with specified id exists or not
Create styles array
The data for the language used.
+ 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 179 of file class.ilRTE.php.

References ilObjAdvancedEditing\_getRichTextEditor().

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

180  {
181  require_once 'Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php';
183  {
184  case 'tinymce':
185  return 'ilTinyMCE';
186  break;
187 
188  default:
189  return 'ilRTE';
190  break;
191  }
192  }
static _getRichTextEditor()
Returns the identifier for the Rich Text Editor.
+ 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 237 of file class.ilRTE.php.

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

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

238  {
239  if(!strlen($a_text)) return '';
240 
241  switch($a_direction)
242  {
243  case 0:
244  $a_text = preg_replace('/src="([^"]*?\/mobs\/mm_([0-9]+)\/.*?)\"/', 'src="il_' . IL_INST_ID . '_mob_\\2"', $a_text);
245  break;
246 
247  default:
248  require_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
249  $resulttext = $a_text;
250  if(preg_match_all('/src="il_([0-9]+)_mob_([0-9]+)"/', $a_text, $matches))
251  {
252  foreach($matches[2] as $idx => $mob)
253  {
254  if(ilObject::_lookupType($mob) == "mob")
255  {
256  $mob_obj = new ilObjMediaObject($mob);
257  $replace = "il_" . $matches[1][$idx] . "_mob_" . $mob;
258  require_once('./Services/WebAccessChecker/classes/class.ilWACSignedPath.php');
259  $path_to_file = ilWACSignedPath::signFile(ILIAS_HTTP_PATH . "/data/" . CLIENT_ID . "/mobs/mm_" . $mob . "/" . $mob_obj->getTitle());
260  $resulttext = str_replace("src=\"$replace\"", "src=\"" . $path_to_file . "\"", $resulttext);
261  }
262  }
263  }
264  $a_text = $resulttext;
265  break;
266  }
267 
268  return $a_text;
269  }
Class ilObjMediaObject.
static signFile($path_to_file)
static _lookupType($a_id, $a_reference=false)
lookup object type
+ 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

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

173  {
174  }

◆ addPlugin()

ilRTE::addPlugin (   $a_plugin_name)

Adds a plugin to the plugin list.

Parameters
string$a_plugin_nameThe name of the plugin

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

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

155  {
156  }

◆ addUserTextEditor()

ilRTE::addUserTextEditor (   $editor_selector)

Adds support for an user text editor.

Parameters
$editor_selectorstring

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

163  {
164  }

◆ 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 341 of file class.ilRTE.php.

References array.

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

342  {
343  if(is_array($a_button))
344  {
345  $this->disabled_buttons = array_unique(array_merge($this->disabled_buttons, $a_button));
346  }
347  else
348  {
349  $this->disabled_buttons = array_unique(array_merge($this->disabled_buttons, array($a_button)));
350  }
351 
352  return $this;
353  }
Create styles array
The data for the language used.
+ 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 360 of file class.ilRTE.php.

References $disabled_buttons.

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

361  {
362  if(!$as_array)
363  {
364  return implode(',', $this->disabled_buttons);
365  }
366  else
367  {
369  }
370  }
$disabled_buttons
Definition: class.ilRTE.php:72
+ Here is the caller graph for this function:

◆ getInitialWidth()

ilRTE::getInitialWidth ( )
Returns
integer

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

References $initialWidth.

Referenced by ilTinyMCE\addRTESupport().

376  {
377  return $this->initialWidth;
378  }
$initialWidth
Definition: class.ilRTE.php:60
+ 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 331 of file class.ilRTE.php.

References $root_block_element.

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

332  {
334  }
$root_block_element
Definition: class.ilRTE.php:66
+ Here is the caller graph for this function:

◆ removeAllPlugins()

ilRTE::removeAllPlugins ( )

Removes all plugins from instance.

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

References removePlugin().

125  {
126  foreach($this->plugins as $plugin)
127  {
128  $this->removePlugin($plugin);
129  }
130  }
removePlugin($a_plugin_name)
Removes a plugin from the plugin list.
+ 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 136 of file class.ilRTE.php.

137  {
138  $key = array_search($a_button_name, $this->buttons);
139  if($key !== FALSE)
140  {
141  unset($this->buttons[$key]);
142  }
143  }

◆ removePlugin()

ilRTE::removePlugin (   $a_plugin_name)

Removes a plugin from the plugin list.

Parameters
string$a_plugin_nameThe name of the plugin

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

Referenced by removeAllPlugins().

113  {
114  $key = array_search($a_plugin_name, $this->plugins);
115  if($key !== FALSE)
116  {
117  unset($this->plugins[$key]);
118  }
119  }
+ Here is the caller graph for this function:

◆ setInitialWidth()

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

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

References $initialWidth.

384  {
385  $this->initialWidth = $initialWidth;
386  }
$initialWidth
Definition: class.ilRTE.php:60

◆ 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 321 of file class.ilRTE.php.

322  {
323  $this->root_block_element = $a_root_block_element;
324  return $this;
325  }

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

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

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

◆ $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: