Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00034 class ilRTE
00035 {
00043 var $plugins;
00044 var $buttons;
00045 var $tpl;
00046 var $ctrl;
00047 var $lng;
00048
00049 function ilRTE()
00050 {
00051 global $tpl, $ilCtrl, $lng;
00052 $this->tpl =& $tpl;
00053 $this->ctrl =& $ilCtrl;
00054 $this->lng =& $lng;
00055 $this->plugins = array();
00056 $this->buttons = array();
00057 }
00058
00067 function addPlugin($a_plugin_name)
00068 {
00069 array_push($this->plugins, $a_plugin_name);
00070 }
00071
00080 function addButton($a_button_name)
00081 {
00082 array_push($this->buttons, $a_button_name);
00083 }
00084
00093 function removePlugin($a_plugin_name)
00094 {
00095 $key = array_search($a_plugin_name, $this->plugins);
00096 if ($key !== FALSE)
00097 {
00098 unset($this->plugins[$key]);
00099 }
00100 }
00101
00110 function removeButton($a_button_name)
00111 {
00112 $key = array_search($a_button_name, $this->buttons);
00113 if ($key !== FALSE)
00114 {
00115 unset($this->buttons[$key]);
00116 }
00117 }
00118
00126 function addRTESupport()
00127 {
00128
00129 }
00130
00138 function addCustomRTESupport($obj_id, $obj_type, $tags)
00139 {
00140
00141 }
00142
00143
00144 function _getRTEClassname()
00145 {
00146 include_once "./classes/class.ilObjAdvancedEditing.php";
00147 $editor = ilObjAdvancedEditing::_getRichTextEditor();
00148 switch ($editor)
00149 {
00150 case "tinymce":
00151 return "ilTinyMCE";
00152 break;
00153 default:
00154 return "ilRTE";
00155 break;
00156 }
00157 }
00158
00167 function _cleanupMediaObjectUsage($a_text, $a_usage_type, $a_usage_id)
00168 {
00169
00170 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
00171 $mobs = ilObjMediaObject::_getMobsOfObject($a_usage_type,
00172 $a_usage_id);
00173 while (eregi("data\/".CLIENT_ID."\/mobs\/mm_([0-9]+)", $a_text, $found))
00174 {
00175 $a_text = str_replace($found[0], "", $a_text);
00176 if (!in_array($found[1], $mobs))
00177 {
00178
00179 ilObjMediaObject::_saveUsage($found[1], $a_usage_type,
00180 $a_usage_id);
00181 }
00182 else
00183 {
00184
00185 unset($mobs[$found[1]]);
00186 }
00187 }
00188
00189
00190
00191
00192 foreach($mobs as $mob)
00193 {
00194 ilObjMediaObject::_removeUsage($mob, $a_usage_type,
00195 $a_usage_id);
00196 $mob_obj =& new ilObjMediaObject($mob);
00197 $mob_obj->delete();
00198 }
00199 }
00200
00209 function _replaceMediaObjectImageSrc($a_text, $a_direction = 0)
00210 {
00211 switch ($a_direction)
00212 {
00213 case 0:
00214 $a_text = preg_replace("/src\=\"(.*?\/mobs\/mm_([0-9]+)\/.*?)\"/", "src=\"il_" . IL_INST_ID . "_mob_" . "\\2" . "\"", $a_text);
00215 break;
00216 default:
00217 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
00218 $resulttext = $a_text;
00219 if (preg_match_all("/src\=\"il_([0-9]+)_mob_([0-9]+)\"/", $a_text, $matches))
00220 {
00221 foreach ($matches[2] as $idx => $mob)
00222 {
00223 $mob_obj =& new ilObjMediaObject($mob);
00224 $replace = "il_" . $matches[1][$idx] . "_mob_" . $mob;
00225 $resulttext = str_replace("src=\"$replace\"", "src=\"" . ILIAS_HTTP_PATH . "/data/" . CLIENT_ID . "/mobs/mm_" . $mob . "/" . $mob_obj->getTitle() . "\"", $resulttext);
00226 }
00227 }
00228 $a_text = $resulttext;
00229 break;
00230 }
00231 return $a_text;
00232 }
00233 }
00234
00235 ?>