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$ @module 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.

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 }
Class ilObjMediaObject.
_saveUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
Save usage of mob within another container (e.g.
_getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
_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 ilObjSurvey\cleanupMediaobjectUsage(), 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 275 of file class.ilRTE.php.

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

References ilObjMediaObject\_exists().

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

+ 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.

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.

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

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 {
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 signFile($path_to_file)

References ilObjMediaObject\_exists(), and ilWACSignedPath\signFile().

Referenced by ilPurchaseBaseGUI\__sendBill(), SurveyQuestion\addMaterialTag(), ilObjSurvey\addMaterialTag(), ilObjTest\addQTIMaterial(), assQuestion\addQTIMaterial(), ilExSubmissionTextGUI\editAssignmentTextObject(), ilAssSelfAssessmentQuestionFormatter\format(), assClozeTestImport\fromXML(), assErrorTextImport\fromXML(), assFileUploadImport\fromXML(), assFlashQuestionImport\fromXML(), assFormulaQuestionImport\fromXML(), assImagemapQuestionImport\fromXML(), assJavaAppletImport\fromXML(), assMatchingQuestionImport\fromXML(), assNumericImport\fromXML(), assOrderingHorizontalImport\fromXML(), assOrderingQuestionImport\fromXML(), assSingleChoiceImport\fromXML(), assTextQuestionImport\fromXML(), assTextSubsetImport\fromXML(), assKprimChoiceImport\fromXML(), assLongMenuImport\fromXML(), assMultipleChoiceImport\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(), assClozeTest\saveAdditionalQuestionDataToDb(), ilAssQuestionFeedback\saveGenericFeedbackContent(), assQuestion\saveQuestionDataToDb(), ilAssMultiOptionQuestionFeedback\saveSpecificAnswerFeedbackContent(), ilObjPaymentSettingsGUI\saveStatutoryRegulationsObject(), SurveyQuestion\saveToDb(), ilObjTest\saveToDb(), ilObjSurvey\saveToDb(), ilExSubmissionTextGUI\showAssignmentTextObject(), ilShopShoppingCartGUI\showItems(), ilForumXMLWriter\start(), ilObjPaymentSettingsGUI\StatutoryRegulationsObject(), assErrorText\toJSON(), and ilExSubmissionTextGUI\updateAssignmentTextObject().

+ 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 @access 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

@access public

Reimplemented in ilTinyMCE.

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 @access public

Reimplemented in ilTinyMCE.

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

@access 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.

@access public

Reimplemented in ilTinyMCE.

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.

322 {
323 // must be overwritten in sub classes
324 }

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

+ Here is the caller graph for this function:

◆ getDisabledButtons()

ilRTE::getDisabledButtons ( )

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

327 {
328 // must be overwritten in sub classes
329 }

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

335 {
336 return $this->initialWidth;
337 }
$initialWidth
Definition: class.ilRTE.php:54

References $initialWidth.

Referenced by ilTinyMCE\addRTESupport().

+ Here is the caller graph for this function:

◆ getRTERootBlockElement()

ilRTE::getRTERootBlockElement ( )

Reimplemented in ilTinyMCE.

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.

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

References $ilCtrl, $lng, and $tpl.

◆ removeAllPlugins()

ilRTE::removeAllPlugins ( )

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

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.

References removePlugin().

+ 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 @access 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 @access public

Reimplemented in ilTinyMCE.

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

102 {
103 $key = array_search($a_plugin_name, $this->plugins);
104 if ($key !== FALSE)
105 {
106 unset($this->plugins[$key]);
107 }
108 }

Referenced by removeAllPlugins().

+ Here is the caller graph for this function:

◆ setInitialWidth()

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

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

343 {
344 $this->initialWidth = $initialWidth;
345 }

References $initialWidth.

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