ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 275 of file class.ilRTE.php.

References ilObjMediaObject\_exists().

Referenced by ilObjForumGUI\quoteTopLevelPostObject(), ilObjPaymentSettingsGUI\saveStatutoryRegulationsObject(), ilObjForumGUI\setTopicCreateDefaultValues(), and ilExSubmissionTextGUI\updateAssignmentTextObject().

276  {
277  if (!strlen($a_text)) return array();
278  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
279 
280  $mediaObjects = array();
281  switch ($a_direction)
282  {
283  case 0:
284  if(preg_match_all('/src="([^"]*?\/mobs\/mm_([0-9]+)\/.*?)\"/', $a_text, $matches))
285  {
286  foreach ($matches[2] as $idx => $mob)
287  {
288  if (ilObjMediaObject::_exists($mob) && !in_array($mob, $mediaObjects))
289  {
290  $mediaObjects[] = $mob;
291  }
292  }
293  }
294  break;
295  default:
296  if(preg_match_all('/src="il_([0-9]+)_mob_([0-9]+)"/', $a_text, $matches))
297  {
298  foreach ($matches[2] as $idx => $mob)
299  {
300  if (ilObjMediaObject::_exists($mob) && !in_array($mob, $mediaObjects))
301  {
302  $mediaObjects[] = $mob;
303  }
304  }
305  }
306  break;
307  }
308  return $mediaObjects;
309  }
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\magicAfterTestOutput().

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(), and ilWACSignedPath\signFile().

Referenced by ilPurchaseBaseGUI\__sendBill(), SurveyQuestion\addMaterialTag(), ilObjSurvey\addMaterialTag(), assQuestion\addQTIMaterial(), ilObjTest\addQTIMaterial(), assMultipleChoice\calculateReachedPoints(), assQuestion\copySuggestedSolutionFiles(), ilExSubmissionTextGUI\editAssignmentTextObject(), ilForumExportGUI\executeCommand(), ilAssSelfAssessmentQuestionFormatter\format(), assLongMenuImport\fromXML(), assKprimChoiceImport\fromXML(), assFlashQuestionImport\fromXML(), assErrorTextImport\fromXML(), assFileUploadImport\fromXML(), assImagemapQuestionImport\fromXML(), assJavaAppletImport\fromXML(), assFormulaQuestionImport\fromXML(), assMultipleChoiceImport\fromXML(), assOrderingHorizontalImport\fromXML(), assOrderingQuestionImport\fromXML(), assNumericImport\fromXML(), assTextQuestionImport\fromXML(), assSingleChoiceImport\fromXML(), assTextSubsetImport\fromXML(), assClozeTestImport\fromXML(), assMatchingQuestionImport\fromXML(), ilObjTest\fromXML(), ilForum\generatePost(), ilAssMultiOptionQuestionFeedback\getAllSpecificAnswerFeedbackContents(), ilAssQuestionFeedback\getGenericFeedbackContent(), ilObjTest\getManualFeedback(), ilAssMultiOptionQuestionFeedback\getSpecificAnswerFeedbackContent(), ilExPeerReviewGUI\getSubmissionContent(), ilObjSurvey\importObject(), ilSurveyImporter\importXmlRepresentation(), assKprimChoice\loadAnswerData(), assOrderingHorizontal\loadFromDb(), SurveyTextQuestion\loadFromDb(), SurveyMultipleChoiceQuestion\loadFromDb(), assFileUpload\loadFromDb(), assTextQuestion\loadFromDb(), assTextSubset\loadFromDb(), assOrderingQuestion\loadFromDb(), assFlashQuestion\loadFromDb(), assErrorText\loadFromDb(), SurveySingleChoiceQuestion\loadFromDb(), assClozeTest\loadFromDb(), assKprimChoice\loadFromDb(), assSingleChoice\loadFromDb(), assMultipleChoice\loadFromDb(), SurveyMetricQuestion\loadFromDb(), assMatchingQuestion\loadFromDb(), assJavaApplet\loadFromDb(), assLongMenu\loadFromDb(), assImagemapQuestion\loadFromDb(), SurveyMatrixQuestion\loadFromDb(), assFormulaQuestion\loadFromDb(), ilObjSurvey\loadFromDb(), ilObjTest\loadFromDb(), assQuestion\loadFromDb(), ilExAssignmentListTextTableGUI\parse(), assQuestionImport\processNonAbstractedImageReferences(), ilObjForumGUI\quotePostObject(), ilObjForumGUI\quoteTopLevelPostObject(), assClozeTest\saveAdditionalQuestionDataToDb(), ilAssQuestionFeedback\saveGenericFeedbackContent(), assSingleChoice\savePreviewData(), assQuestion\saveQuestionDataToDb(), ilAssMultiOptionQuestionFeedback\saveSpecificAnswerFeedbackContent(), ilObjPaymentSettingsGUI\saveStatutoryRegulationsObject(), assNumeric\saveToDb(), SurveyQuestion\saveToDb(), ilObjSurvey\saveToDb(), ilObjTest\saveToDb(), ilObjForumGUI\setTopicCreateDefaultValues(), ilObjForumGUI\setTreeStateAsynchObject(), ilExSubmissionTextGUI\showAssignmentTextObject(), ilShopShoppingCartGUI\showItems(), ilForumXMLWriter\start(), ilObjPaymentSettingsGUI\StatutoryRegulationsObject(), assErrorText\toJSON(), and ilExSubmissionTextGUI\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 
256  require_once('./Services/WebAccessChecker/classes/class.ilWACSignedPath.php');
257  $path_to_file = ilWACSignedPath::signFile(ILIAS_HTTP_PATH . "/data/" . CLIENT_ID . "/mobs/mm_" . $mob . "/" . $mob_obj->getTitle());
258  $resulttext = str_replace("src=\"$replace\"", "src=\"" . $path_to_file . "\"", $resulttext);
259  }
260  }
261  }
262  $a_text = $resulttext;
263  break;
264  }
265  return $a_text;
266  }
static _exists($a_id)
checks wether a lm content object with specified id exists or not
Class ilObjMediaObject.
static signFile($path_to_file)
+ 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 321 of file class.ilRTE.php.

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

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

◆ getDisabledButtons()

ilRTE::getDisabledButtons ( )

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

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

327  {
328  // must be overwritten in sub classes
329  }
+ Here is the caller graph for this function:

◆ getInitialWidth()

ilRTE::getInitialWidth ( )
Returns
integer

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

References $initialWidth.

Referenced by ilTinyMCE\addRTESupport().

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

◆ getRTERootBlockElement()

ilRTE::getRTERootBlockElement ( )

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

317  {
318  // must be overwritten in sub classes
319  }

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

References $initialWidth.

343  {
344  $this->initialWidth = $initialWidth;
345  }
$initialWidth
Definition: class.ilRTE.php:54

◆ setRTERootBlockElement()

ilRTE::setRTERootBlockElement ( )

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

312  {
313  // must be overwritten in sub classes
314  }

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: