ILIAS  release_4-4 Revision
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 ()
 

Static Public Member Functions

static _getRTEClassname ()
 
static _replaceMediaObjectImageSrc ($a_text, $a_direction=0)
 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
 

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 187 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().

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

References ilObjMediaObject\_exists().

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

267  {
268  if (!strlen($a_text)) return array();
269  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
270 
271  $mediaObjects = array();
272  switch ($a_direction)
273  {
274  case 0:
275  if(preg_match_all("/src\=\"(.*?\/mobs\/mm_([0-9]+)\/.*?)\"/", $a_text, $matches))
276  {
277  foreach ($matches[2] as $idx => $mob)
278  {
279  if (ilObjMediaObject::_exists($mob) && !in_array($mob, $mediaObjects))
280  {
281  $mediaObjects[] = $mob;
282  }
283  }
284  }
285  break;
286  default:
287 
288  if(preg_match_all("/src\=\"il_([0-9]+)_mob_([0-9]+)\"/", $a_text, $matches))
289  {
290  foreach ($matches[2] as $idx => $mob)
291  {
292  if (ilObjMediaObject::_exists($mob) && !in_array($mob, $mediaObjects))
293  {
294  $mediaObjects[] = $mob;
295  }
296  }
297  }
298  break;
299  }
300  return $mediaObjects;
301  }
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 164 of file class.ilRTE.php.

References ilObjAdvancedEditing\_getRichTextEditor().

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

165  {
166  include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
168  switch ($editor)
169  {
170  case "tinymce":
171  return "ilTinyMCE";
172  break;
173  default:
174  return "ilRTE";
175  break;
176  }
177  }
_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 
)
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 230 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(), assQuestion\formatSAQuestion(), assErrorTextImport\fromXML(), assFileUploadImport\fromXML(), assFlashQuestionImport\fromXML(), assJavaAppletImport\fromXML(), assMultipleChoiceImport\fromXML(), assNumericImport\fromXML(), assOrderingHorizontalImport\fromXML(), assOrderingQuestionImport\fromXML(), assImagemapQuestionImport\fromXML(), assTextSubsetImport\fromXML(), assTextQuestionImport\fromXML(), assClozeTestImport\fromXML(), assSingleChoiceImport\fromXML(), assFormulaQuestionImport\fromXML(), assMatchingQuestionImport\fromXML(), ilObjTest\fromXML(), ilForum\generatePost(), ilAssQuestionFeedback\getGenericFeedbackContent(), ilObjTest\getManualFeedback(), ilObjForumGUI\getReplyEditForm(), ilAssMultiOptionQuestionFeedback\getSpecificAnswerFeedbackContent(), ilObjSurvey\importObject(), ilSurveyImporter\importXmlRepresentation(), assOrderingHorizontal\loadFromDb(), SurveyTextQuestion\loadFromDb(), SurveyMultipleChoiceQuestion\loadFromDb(), assFileUpload\loadFromDb(), assFlashQuestion\loadFromDb(), assTextQuestion\loadFromDb(), assTextSubset\loadFromDb(), assOrderingQuestion\loadFromDb(), assErrorText\loadFromDb(), assClozeTest\loadFromDb(), SurveySingleChoiceQuestion\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(), ilObjForumGUI\quotePostObject(), ilAssQuestionFeedback\saveGenericFeedbackContent(), assQuestion\saveQuestionDataToDb(), ilAssMultiOptionQuestionFeedback\saveSpecificAnswerFeedbackContent(), ilObjPaymentSettingsGUI\saveStatutoryRegulationsObject(), assNumeric\saveToDb(), ilObjSurvey\saveToDb(), SurveyQuestion\saveToDb(), ilObjTest\saveToDb(), assSingleChoice\saveWorkingData(), ilObjForumGUI\setTopicCreateDefaultValues(), ilObjForumGUI\setTreeStateAsynchObject(), ilObjExerciseGUI\showAssignmentTextObject(), ilShopShoppingCartGUI\showItems(), ilForumXMLWriter\start(), ilObjPaymentSettingsGUI\StatutoryRegulationsObject(), assImagemapQuestion\toJSON(), assSingleChoice\toJSON(), assMultipleChoice\toJSON(), assErrorText\toJSON(), and ilObjExerciseGUI\updateAssignmentTextObject().

231  {
232  if (!strlen($a_text)) return "";
233  switch ($a_direction)
234  {
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  default:
239  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
240  $resulttext = $a_text;
241  if (preg_match_all("/src\=\"il_([0-9]+)_mob_([0-9]+)\"/", $a_text, $matches))
242  {
243  foreach ($matches[2] as $idx => $mob)
244  {
245  if (ilObjMediaObject::_exists($mob))
246  {
247  $mob_obj =& new ilObjMediaObject($mob);
248  $replace = "il_" . $matches[1][$idx] . "_mob_" . $mob;
249  $resulttext = str_replace("src=\"$replace\"", "src=\"" . ILIAS_HTTP_PATH . "/data/" . CLIENT_ID . "/mobs/mm_" . $mob . "/" . $mob_obj->getTitle() . "\"", $resulttext);
250  }
251  }
252  }
253  $a_text = $resulttext;
254  break;
255  }
256  return $a_text;
257  }
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 82 of file class.ilRTE.php.

83  {
84  array_push($this->buttons, $a_button_name);
85  }

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

159  {
160  // must be overwritten in parent classes
161  }

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

70  {
71  array_push($this->plugins, $a_plugin_name);
72  }

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

137  {
138  // must be overwritten in parent classes
139  }

◆ addUserTextEditor()

ilRTE::addUserTextEditor (   $editor_selector)

Adds support for an user text editor.

public

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

147  {
148  // must be overwritten in parent classes
149  }

◆ disableButtons()

ilRTE::disableButtons ( )

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

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

314  {
315  // must be overwritten in sub classes
316  }
+ Here is the caller graph for this function:

◆ getDisabledButtons()

ilRTE::getDisabledButtons ( )

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

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

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

◆ getRTERootBlockElement()

ilRTE::getRTERootBlockElement ( )

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

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

◆ ilRTE()

ilRTE::ilRTE (   $a_version = "")

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

References $ilCtrl, $lng, and $tpl.

52  {
53  global $tpl, $ilCtrl, $lng;
54  $this->tpl =& $tpl;
55  $this->ctrl =& $ilCtrl;
56  $this->lng =& $lng;
57  $this->plugins = array();
58  $this->buttons = array();
59  }
global $ilCtrl
Definition: ilias.php:18

◆ removeAllPlugins()

ilRTE::removeAllPlugins ( )

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

References removePlugin().

105  {
106  foreach($this->plugins as $plugin)
107  {
108  $this->removePlugin($plugin);
109  }
110  }
removePlugin($a_plugin_name)
Removes a plugin from the plugin list.
Definition: class.ilRTE.php:95
+ 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 120 of file class.ilRTE.php.

121  {
122  $key = array_search($a_button_name, $this->buttons);
123  if ($key !== FALSE)
124  {
125  unset($this->buttons[$key]);
126  }
127  }

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

Referenced by removeAllPlugins().

96  {
97  $key = array_search($a_plugin_name, $this->plugins);
98  if ($key !== FALSE)
99  {
100  unset($this->plugins[$key]);
101  }
102  }
+ Here is the caller graph for this function:

◆ setRTERootBlockElement()

ilRTE::setRTERootBlockElement ( )

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

304  {
305  // must be overwritten in sub classes
306  }

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.

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