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
00047 function ilRTE()
00048 {
00049 global $tpl;
00050 $this->tpl =& $tpl;
00051 $this->plugins = array();
00052 $this->buttons = array();
00053 }
00054
00063 function addPlugin($a_plugin_name)
00064 {
00065 array_push($this->plugins, $a_plugin_name);
00066 }
00067
00076 function addButton($a_button_name)
00077 {
00078 array_push($this->buttons, $a_button_name);
00079 }
00080
00089 function removePlugin($a_plugin_name)
00090 {
00091 $key = array_search($a_plugin_name, $this->plugins);
00092 if ($key !== FALSE)
00093 {
00094 unset($this->plugins[$key]);
00095 }
00096 }
00097
00106 function removeButton($a_button_name)
00107 {
00108 $key = array_search($a_button_name, $this->buttons);
00109 if ($key !== FALSE)
00110 {
00111 unset($this->buttons[$key]);
00112 }
00113 }
00114
00122 function addRTESupport()
00123 {
00124
00125 }
00126
00127 function _getRTEClassname()
00128 {
00129 include_once "./classes/class.ilObjAdvancedEditing.php";
00130 $editor = ilObjAdvancedEditing::_getRichTextEditor();
00131 switch ($editor)
00132 {
00133 case "tinymce":
00134 return "ilTinyMCE";
00135 break;
00136 default:
00137 return "ilRTE";
00138 break;
00139 }
00140 }
00141
00150 function _cleanupMediaObjectUsage($a_text, $a_usage_type, $a_usage_id)
00151 {
00152
00153 include_once("./content/classes/Media/class.ilObjMediaObject.php");
00154 $mobs = ilObjMediaObject::_getMobsOfObject($a_usage_type,
00155 $a_usage_id);
00156
00157 while (eregi("data\/".CLIENT_ID."\/mobs\/mm_([0-9]+)", $a_text, $found))
00158 {
00159 $a_text = str_replace($found[0], "", $a_text);
00160 if (!in_array($found[1], $mobs))
00161 {
00162
00163 ilObjMediaObject::_saveUsage($found[1], $a_usage_type,
00164 $a_usage_id);
00165 }
00166 else
00167 {
00168
00169 unset($mobs[$found[1]]);
00170 }
00171 }
00172
00173
00174
00175
00176 foreach($mobs as $mob)
00177 {
00178 ilObjMediaObject::_removeUsage($mob, $a_usage_type,
00179 $a_usage_id);
00180 $mob_obj =& new ilObjMediaObject($mob);
00181 $mob_obj->delete();
00182 }
00183 }
00184
00193 function _replaceMediaObjectImageSrc($a_text, $a_direction = 0)
00194 {
00195 switch ($a_direction)
00196 {
00197 case 0:
00198 $a_text = preg_replace("/src\=\"(.*?\/mobs\/mm_([0-9]+)\/.*?)\"/", "src=\"il_" . IL_INST_ID . "_mob_" . "\\2" . "\"", $a_text);
00199 break;
00200 default:
00201 include_once("./content/classes/Media/class.ilObjMediaObject.php");
00202 $resulttext = $a_text;
00203 if (preg_match_all("/src\=\"il_([0-9]+)_mob_([0-9]+)\"/", $a_text, $matches))
00204 {
00205 foreach ($matches[2] as $idx => $mob)
00206 {
00207 $mob_obj =& new ilObjMediaObject($mob);
00208 $replace = "il_" . $matches[1][$idx] . "_mob_" . $mob;
00209 $resulttext = str_replace("src=\"$replace\"", "src=\"" . ILIAS_HTTP_PATH . "/data/" . CLIENT_ID . "/mobs/mm_" . $mob . "/" . $mob_obj->getTitle() . "\"", $resulttext);
00210 }
00211 }
00212 $a_text = $resulttext;
00213 break;
00214 }
00215 return $a_text;
00216 }
00217
00218 }
00219
00220 ?>