ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
ilRTE Class Reference

Rich Text Editor base class. More...

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

Public Member Functions

 ilRTE ($a_version="")
 
 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 ()
 
 removeButton ($a_button_name)
 Removes a button from the button list. More...
 
 addRTESupport ()
 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, $tags)
 Adds custom support for an RTE in an ILIAS form. More...
 
 _cleanupMediaObjectUsage ($a_text, $a_usage_type, $a_usage_id)
 synchronises appearances of media objects in $a_text with media object usage table More...
 
 setRTERootBlockElement ()
 
 getRTERootBlockElement ()
 
 disableButtons ()
 
 getDisabledButtons ()
 
 getInitialWidth ()
 
 setInitialWidth ($initialWidth)
 

Static Public Member Functions

static _getRTEClassname ()
 
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'
 
 $plugins
 
 $buttons
 
 $tpl
 
 $ctrl
 
 $lng
 

Protected Attributes

 $initialWidth = null
 

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

Member Function Documentation

◆ _cleanupMediaObjectUsage()

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

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

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

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

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

References ilObjMediaObject\_exists().

Referenced by ilObjForumGUI\getReplyEditForm(), ilObjPaymentSettingsGUI\saveStatutoryRegulationsObject(), ilObjForumGUI\setTopicCreateDefaultValues(), and ilObjExerciseGUI\updateAssignmentTextObject().

273  {
274  if (!strlen($a_text)) return array();
275  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
276 
277  $mediaObjects = array();
278  switch ($a_direction)
279  {
280  case 0:
281  if(preg_match_all('/src="([^"]*?\/mobs\/mm_([0-9]+)\/.*?)\"/', $a_text, $matches))
282  {
283  foreach ($matches[2] as $idx => $mob)
284  {
285  if (ilObjMediaObject::_exists($mob) && !in_array($mob, $mediaObjects))
286  {
287  $mediaObjects[] = $mob;
288  }
289  }
290  }
291  break;
292  default:
293  if(preg_match_all('/src="il_([0-9]+)_mob_([0-9]+)"/', $a_text, $matches))
294  {
295  foreach ($matches[2] as $idx => $mob)
296  {
297  if (ilObjMediaObject::_exists($mob) && !in_array($mob, $mediaObjects))
298  {
299  $mediaObjects[] = $mob;
300  }
301  }
302  }
303  break;
304  }
305  return $mediaObjects;
306  }
static _exists($a_id)
checks wether a lm content object with specified id exists or not
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getRTEClassname()

static ilRTE::_getRTEClassname ( )
static

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

References ilObjAdvancedEditing\_getRichTextEditor().

Referenced by ilObjForumGUI\cancelPostObject(), ilContainerGUI\editPageContentObject(), ilTextAreaInputGUI\insert(), and assTextQuestionGUI\outQuestionForTest().

171  {
172  include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
174  switch ($editor)
175  {
176  case "tinymce":
177  return "ilTinyMCE";
178  break;
179  default:
180  return "ilRTE";
181  break;
182  }
183  }
_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 236 of file class.ilRTE.php.

References ilObjMediaObject\_exists().

Referenced by ilPurchaseBaseGUI\__sendBill(), SurveyQuestion\addMaterialTag(), ilObjSurvey\addMaterialTag(), assQuestion\addQTIMaterial(), ilObjTest\addQTIMaterial(), assMultipleChoice\calculateReachedPoints(), assQuestion\copySuggestedSolutionFiles(), ilObjExerciseGUI\editAssignmentTextObject(), ilForumExportGUI\executeCommand(), ilAssSelfAssessmentQuestionFormatter\format(), assKprimChoiceImport\fromXML(), assErrorTextImport\fromXML(), assFileUploadImport\fromXML(), assFlashQuestionImport\fromXML(), assOrderingQuestionImport\fromXML(), assImagemapQuestionImport\fromXML(), assJavaAppletImport\fromXML(), assMultipleChoiceImport\fromXML(), assNumericImport\fromXML(), assOrderingHorizontalImport\fromXML(), assTextQuestionImport\fromXML(), assTextSubsetImport\fromXML(), assSingleChoiceImport\fromXML(), assClozeTestImport\fromXML(), assFormulaQuestionImport\fromXML(), assMatchingQuestionImport\fromXML(), ilObjTest\fromXML(), ilForum\generatePost(), ilAssMultiOptionQuestionFeedback\getAllSpecificAnswerFeedbackContents(), ilAssQuestionFeedback\getGenericFeedbackContent(), ilObjTest\getManualFeedback(), ilObjForumGUI\getReplyEditForm(), ilAssMultiOptionQuestionFeedback\getSpecificAnswerFeedbackContent(), ilObjSurvey\importObject(), ilSurveyImporter\importXmlRepresentation(), assKprimChoice\loadAnswerData(), assOrderingHorizontal\loadFromDb(), SurveyTextQuestion\loadFromDb(), SurveyMultipleChoiceQuestion\loadFromDb(), assFileUpload\loadFromDb(), assFlashQuestion\loadFromDb(), assTextQuestion\loadFromDb(), assTextSubset\loadFromDb(), assOrderingQuestion\loadFromDb(), assErrorText\loadFromDb(), SurveySingleChoiceQuestion\loadFromDb(), assClozeTest\loadFromDb(), assKprimChoice\loadFromDb(), assSingleChoice\loadFromDb(), assMultipleChoice\loadFromDb(), SurveyMetricQuestion\loadFromDb(), assMatchingQuestion\loadFromDb(), assJavaApplet\loadFromDb(), assImagemapQuestion\loadFromDb(), SurveyMatrixQuestion\loadFromDb(), assFormulaQuestion\loadFromDb(), ilObjSurvey\loadFromDb(), ilObjTest\loadFromDb(), assQuestion\loadFromDb(), ilExAssignmentListTextTableGUI\parse(), assQuestionImport\processNonAbstractedImageReferences(), ilObjForumGUI\quotePostObject(), assClozeTest\saveAdditionalQuestionDataToDb(), ilAssQuestionFeedback\saveGenericFeedbackContent(), assSingleChoice\savePreviewData(), assQuestion\saveQuestionDataToDb(), ilAssMultiOptionQuestionFeedback\saveSpecificAnswerFeedbackContent(), ilObjPaymentSettingsGUI\saveStatutoryRegulationsObject(), assNumeric\saveToDb(), ilObjSurvey\saveToDb(), SurveyQuestion\saveToDb(), ilObjTest\saveToDb(), ilObjForumGUI\setTopicCreateDefaultValues(), ilObjForumGUI\setTreeStateAsynchObject(), ilObjExerciseGUI\showAssignmentTextObject(), ilShopShoppingCartGUI\showItems(), ilForumXMLWriter\start(), ilObjPaymentSettingsGUI\StatutoryRegulationsObject(), assErrorText\toJSON(), and ilObjExerciseGUI\updateAssignmentTextObject().

237  {
238  if (!strlen($a_text)) return "";
239  switch ($a_direction)
240  {
241  case 0:
242  $a_text = preg_replace('/src="([^"]*?\/mobs\/mm_([0-9]+)\/.*?)\"/', 'src="il_' . IL_INST_ID . '_mob_\\2"', $a_text);
243  break;
244  default:
245  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
246  $resulttext = $a_text;
247  if(preg_match_all('/src="il_([0-9]+)_mob_([0-9]+)"/', $a_text, $matches))
248  {
249  foreach ($matches[2] as $idx => $mob)
250  {
251  if (ilObjMediaObject::_exists($mob))
252  {
253  $mob_obj =& new ilObjMediaObject($mob);
254  $replace = "il_" . $matches[1][$idx] . "_mob_" . $mob;
255  $resulttext = str_replace("src=\"$replace\"", "src=\"" . ILIAS_HTTP_PATH . "/data/" . CLIENT_ID . "/mobs/mm_" . $mob . "/" . $mob_obj->getTitle() . "\"", $resulttext);
256  }
257  }
258  }
259  $a_text = $resulttext;
260  break;
261  }
262  return $a_text;
263  }
static _exists($a_id)
checks wether a lm content object with specified id exists or not
Class ilObjMediaObject.
+ 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.

Adds a button to the button list

Parameters
string$a_button_nameThe name of the button public

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

89  {
90  array_push($this->buttons, $a_button_name);
91  }

◆ addCustomRTESupport()

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

Adds custom support for an RTE in an ILIAS form.

Adds custom support for an RTE in an ILIAS form

public

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

165  {
166  // must be overwritten in parent classes
167  }

◆ addPlugin()

ilRTE::addPlugin (   $a_plugin_name)

Adds a plugin to the plugin list.

Adds a plugin to the plugin list

Parameters
string$a_plugin_nameThe name of the plugin public

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

76  {
77  array_push($this->plugins, $a_plugin_name);
78  }

◆ addRTESupport()

ilRTE::addRTESupport ( )

Adds support for an RTE in an ILIAS form.

Adds support for an RTE in an ILIAS form

public

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

143  {
144  // must be overwritten in parent classes
145  }

◆ addUserTextEditor()

ilRTE::addUserTextEditor (   $editor_selector)

Adds support for an user text editor.

public

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

153  {
154  // must be overwritten in parent classes
155  }

◆ disableButtons()

ilRTE::disableButtons ( )

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

Referenced by ilTinyMCE\addCustomRTESupport(), ilTinyMCE\handleIliasImageManagerAdded(), ilTinyMCE\handleImagePluginsBeforeRendering(), and ilTinyMCE\ilTinyMCE().

319  {
320  // must be overwritten in sub classes
321  }
+ Here is the caller graph for this function:

◆ getDisabledButtons()

ilRTE::getDisabledButtons ( )

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

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

324  {
325  // must be overwritten in sub classes
326  }
+ Here is the caller graph for this function:

◆ getInitialWidth()

ilRTE::getInitialWidth ( )
Returns
integer

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

References $initialWidth.

Referenced by ilTinyMCE\addRTESupport().

332  {
333  return $this->initialWidth;
334  }
$initialWidth
Definition: class.ilRTE.php:54
+ Here is the caller graph for this function:

◆ getRTERootBlockElement()

ilRTE::getRTERootBlockElement ( )

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

314  {
315  // must be overwritten in sub classes
316  }

◆ ilRTE()

ilRTE::ilRTE (   $a_version = "")

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

References $ilCtrl, $lng, and $tpl.

58  {
59  global $tpl, $ilCtrl, $lng;
60  $this->tpl =& $tpl;
61  $this->ctrl =& $ilCtrl;
62  $this->lng =& $lng;
63  $this->plugins = array();
64  $this->buttons = array();
65  }
global $ilCtrl
Definition: ilias.php:18

◆ removeAllPlugins()

ilRTE::removeAllPlugins ( )

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

References removePlugin().

111  {
112  foreach($this->plugins as $plugin)
113  {
114  $this->removePlugin($plugin);
115  }
116  }
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.

Removes a button from the button list

Parameters
string$a_button_nameThe name of the button public

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

127  {
128  $key = array_search($a_button_name, $this->buttons);
129  if ($key !== FALSE)
130  {
131  unset($this->buttons[$key]);
132  }
133  }

◆ removePlugin()

ilRTE::removePlugin (   $a_plugin_name)

Removes a plugin from the plugin list.

Removes a plugin from the plugin list

Parameters
string$a_plugin_nameThe name of the plugin public

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

Referenced by removeAllPlugins().

102  {
103  $key = array_search($a_plugin_name, $this->plugins);
104  if ($key !== FALSE)
105  {
106  unset($this->plugins[$key]);
107  }
108  }
+ Here is the caller graph for this function:

◆ setInitialWidth()

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

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

References $initialWidth.

340  {
341  $this->initialWidth = $initialWidth;
342  }
$initialWidth
Definition: class.ilRTE.php:54

◆ setRTERootBlockElement()

ilRTE::setRTERootBlockElement ( )

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

309  {
310  // must be overwritten in sub classes
311  }

Field Documentation

◆ $buttons

ilRTE::$buttons

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

◆ $ctrl

ilRTE::$ctrl

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

◆ $initialWidth

ilRTE::$initialWidth = null
protected

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

Referenced by getInitialWidth(), and setInitialWidth().

◆ $lng

ilRTE::$lng

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

Referenced by ilRTE().

◆ $plugins

ilRTE::$plugins

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

◆ $tpl

◆ ILIAS_IMG_MANAGER_PLUGIN

const ilRTE::ILIAS_IMG_MANAGER_PLUGIN = 'ilias_image_manager_plugin'

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