[ Index ] |
|
Code source de Joomla 1.0.13 |
1 <?php 2 /** 3 * @version $Id: tinymce.php 5991 2006-12-12 19:59:11Z friesengeist $ 4 * @package Joomla 5 * @copyright Copyright (C) 2005 Open Source Matters. All rights reserved. 6 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php 7 * Joomla! is free software. This version may have been modified pursuant 8 * to the GNU General Public License, and as distributed it includes or 9 * is derivative of works licensed under the GNU General Public License or 10 * other free or open source software licenses. 11 * See COPYRIGHT.php for copyright notices and details. 12 */ 13 14 // no direct access 15 defined( '_VALID_MOS' ) or die( 'Restricted access' ); 16 17 $_MAMBOTS->registerFunction( 'onInitEditor', 'botTinymceEditorInit' ); 18 $_MAMBOTS->registerFunction( 'onGetEditorContents', 'botTinymceEditorGetContents' ); 19 $_MAMBOTS->registerFunction( 'onEditorArea', 'botTinymceEditorEditorArea' ); 20 21 /** 22 * TinyMCE WYSIWYG Editor - javascript initialisation 23 */ 24 function botTinymceEditorInit() { 25 global $mosConfig_live_site, $database, $mosConfig_absolute_path, $mainframe; 26 27 // load tinymce info 28 $query = "SELECT params" 29 . "\n FROM #__mambots" 30 . "\n WHERE element = 'tinymce'" 31 . "\n AND folder = 'editors'" 32 ; 33 $database->setQuery( $query ); 34 $database->loadObject($mambot); 35 36 $params = new mosParameters( $mambot->params ); 37 38 $theme = $params->get( 'theme', 'advanced' ); 39 // handling for former default option 40 if ($theme == 'default' ) { 41 $theme = 'advanced'; 42 } 43 44 $toolbar = $params->def( 'toolbar', 'top' ); 45 $html_height = $params->def( 'html_height', '550' ); 46 $html_width = $params->def( 'html_width', '750' ); 47 $text_direction = $params->def( 'text_direction', 'ltr' ); 48 $content_css = $params->def( 'content_css', 1 ); 49 $content_css_custom = $params->def( 'content_css_custom', '' ); 50 $invalid_elements = $params->def( 'invalid_elements', 'script,applet,iframe' ); 51 $newlines = $params->def( 'newlines', 0 ); 52 $cleanup = $params->def( 'cleanup', 1 ); 53 $cleanup_startup = $params->set( 'cleanup_startup', 0 ); // Currently disabled due to bugs in TinyMCE 54 $compressed = $params->def( 'compressed', 0 ); 55 $relative_urls = $params->def( 'relative_urls', 0 ); 56 57 // Plugins 58 // preview 59 $preview = $params->def( 'preview', 1 ); 60 $preview_height = $params->def( 'preview_height', '550' ); 61 $preview_width = $params->def( 'preview_width', '750' ); 62 // insert date 63 $insertdate = $params->def( 'insertdate', 1 ); 64 $format_date = $params->def( 'format_date', '%Y-%m-%d' ); 65 // insert time 66 $inserttime = $params->def( 'inserttime', 1 ); 67 $format_time = $params->def( 'format_time', '%H:%M:%S' ); 68 // search & replace 69 $searchreplace = $params->def( 'searchreplace', 1 ); 70 // emotions 71 $smilies = $params->def( 'smilies', 1 ); 72 // flash 73 $flash = $params->def( 'flash', 1 ); 74 // table 75 $table = $params->def( 'table', 1 ); 76 // horizontal line 77 $hr = $params->def( 'hr', 1 ); 78 // fullscreen 79 $fullscreen = $params->def( 'fullscreen', 1 ); 80 // autosave 81 $autosave = $params->def( 'autosave', 0 ); 82 // layer 83 $layer = $params->def( 'layer', 1 ); 84 // style 85 $style = $params->def( 'style', 1 ); 86 // visualchars 87 $visualchars = $params->def( 'visualchars', 1 ); 88 // media 89 $media = $params->def( 'media', 1 ); 90 // nonbreaking 91 $nonbreaking = $params->def( 'nonbreaking', 1 ); 92 93 if ( $relative_urls ) { 94 $relative_urls = 'true'; 95 } else { 96 $relative_urls = 'false'; 97 } 98 99 if ( $content_css_custom ) { 100 $content_css = 'content_css : "'. $content_css_custom .'", '; 101 } else { 102 $query = "SELECT template" 103 . "\n FROM #__templates_menu" 104 . "\n WHERE client_id = 0" 105 . "\n AND menuid = 0" 106 ; 107 $database->setQuery( $query ); 108 $template = $database->loadResult(); 109 110 $file_path = $mosConfig_absolute_path .'/templates/'. $template .'/css/'; 111 if ( $content_css ) { 112 $file = 'template.css'; 113 } else { 114 $file = 'editor_content.css'; 115 } 116 117 $content_css = 'content_css : "'. $mosConfig_live_site .'/templates/'. $template .'/css/'; 118 119 if ( file_exists( $file_path .'/'. $file ) ) { 120 $content_css = $content_css . $file .'", '; 121 } else { 122 $content_css = $content_css . 'template_css.css", '; 123 } 124 } 125 126 $plugins[] = ''; 127 $buttons2[] = ''; 128 $buttons3[] = ''; 129 $elements[] = ''; 130 131 if ( $cleanup ) { 132 $cleanup = 'true'; 133 } else { 134 $cleanup = 'false'; 135 } 136 137 if ( $cleanup_startup ) { 138 $cleanup_startup = 'true'; 139 } else { 140 $cleanup_startup = 'false'; 141 } 142 143 if ( $newlines ) { 144 $br_newlines = 'true'; 145 $p_newlines = 'false'; 146 } else { 147 $br_newlines = 'false'; 148 $p_newlines = 'true'; 149 } 150 151 // Tiny Compressed mode 152 if ( $compressed ) { 153 $load = '<script type="text/javascript" src="'. $mosConfig_live_site .'/mambots/editors/tinymce/jscripts/tiny_mce/tiny_mce_gzip.js"></script>'; 154 $load_init = ' 155 <script type="text/javascript"> 156 tinyMCE_GZ.init({ 157 plugins : \'style,layer,table,save,advhr,advimage,advlink,emotions,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking\', 158 themes : \'simple,advanced\', 159 languages : \'en\', 160 disk_cache : true, 161 debug : false 162 }); 163 </script>'; 164 } else { 165 $load = '<script type="text/javascript" src="'. $mosConfig_live_site .'/mambots/editors/tinymce/jscripts/tiny_mce/tiny_mce_src.js"></script>'; 166 $load_init = ''; 167 } 168 169 // preview 170 if ( $preview ) { 171 $plugins[] = 'preview'; 172 $buttons2[] = 'preview'; 173 } 174 // search & replace 175 if ( $searchreplace ) { 176 $plugins[] = 'searchreplace'; 177 $buttons2[] = 'search,replace'; 178 } 179 180 $plugins[] = 'insertdatetime'; 181 // insert date 182 if ( $insertdate ) { 183 $buttons2[] = 'insertdate'; 184 } 185 186 // insert time 187 if ( $inserttime ) { 188 $buttons2[] = 'inserttime'; 189 } 190 // emotions 191 if ( $smilies ) { 192 $plugins[] = 'emotions'; 193 $buttons2[] = 'emotions'; 194 } 195 196 // horizontal line 197 if ( $hr ) { 198 $plugins[] = 'advhr'; 199 $elements[] = 'hr[class|width|size|noshade]'; 200 $buttons3[] = 'advhr'; 201 } 202 // flash 203 if ( $flash ) { 204 $plugins[] = 'flash'; 205 $buttons3[] = 'flash'; 206 } 207 // table 208 if ( $table ) { 209 $plugins[] = 'table'; 210 $buttons3[] = 'tablecontrols'; 211 } 212 // fullscreen 213 if ( $fullscreen ) { 214 $plugins[] = 'fullscreen'; 215 $buttons3[] = 'fullscreen'; 216 } 217 // autosave 218 if ( $autosave ) { 219 $plugins[] = 'autosave'; 220 } 221 // layer 222 if ( $layer ) { 223 $plugins[] = 'layer'; 224 $buttons2[] = 'insertlayer'; 225 $buttons2[] = 'moveforward'; 226 $buttons2[] = 'movebackward'; 227 $buttons2[] = 'absolute'; 228 } 229 // style 230 if ( $style ) { 231 $plugins[] = 'style'; 232 $buttons3[] = 'styleprops'; 233 } 234 // visualchars 235 if ( $visualchars ) { 236 $plugins[] = 'visualchars'; 237 $buttons3[] = 'visualchars'; 238 } 239 // media 240 if ( $media ) { 241 $plugins[] = 'media'; 242 $buttons3[] = 'media'; 243 } 244 // nonbreaking 245 if ( $nonbreaking ) { 246 $plugins[] = 'nonbreaking'; 247 $buttons3[] = 'nonbreaking'; 248 } 249 250 $buttons2 = implode( ', ', $buttons2 ); 251 $buttons3 = implode( ', ', $buttons3 ); 252 $plugins = implode( ', ', $plugins ); 253 $elements = implode( ', ', $elements ); 254 255 return <<<EOD 256 $load 257 $load_init 258 <script type="text/javascript"> 259 tinyMCE.init({ 260 theme : "$theme", 261 language : "en", 262 mode : "specific_textareas", 263 document_base_url : "$mosConfig_live_site/", 264 relative_urls : $relative_urls, 265 remove_script_host : false, 266 save_callback : "TinyMCE_Save", 267 invalid_elements : "$invalid_elements", 268 theme_advanced_toolbar_location : "$toolbar", 269 theme_advanced_source_editor_height : "$html_height", 270 theme_advanced_source_editor_width : "$html_width", 271 directionality: "$text_direction", 272 force_br_newlines : "$br_newlines", 273 force_p_newlines : "$p_newlines", 274 $content_css 275 debug : false, 276 cleanup : $cleanup, 277 cleanup_on_startup : $cleanup_startup, 278 safari_warning : false, 279 plugins : "advlink, advimage, $plugins", 280 theme_advanced_buttons2_add : "$buttons2", 281 theme_advanced_buttons3_add : "$buttons3", 282 plugin_insertdate_dateFormat : "$format_date", 283 plugin_insertdate_timeFormat : "$format_time", 284 plugin_preview_width : "$preview_width", 285 plugin_preview_height : "$preview_height", 286 extended_valid_elements : "a[name|href|target|title|onclick], img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name], $elements", 287 disk_cache : true, 288 debug : false, 289 fullscreen_settings : { 290 theme_advanced_path_location : "top" 291 } 292 }); 293 function TinyMCE_Save(editor_id, content, node) 294 { 295 base_url = tinyMCE.settings['document_base_url']; 296 var vHTML = content; 297 if (true == true){ 298 vHTML = tinyMCE.regexpReplace(vHTML, 'href\s*=\s*"?'+base_url+'', 'href="', 'gi'); 299 vHTML = tinyMCE.regexpReplace(vHTML, 'src\s*=\s*"?'+base_url+'', 'src="', 'gi'); 300 vHTML = tinyMCE.regexpReplace(vHTML, 'mce_real_src\s*=\s*"?', '', 'gi'); 301 vHTML = tinyMCE.regexpReplace(vHTML, 'mce_real_href\s*=\s*"?', '', 'gi'); 302 } 303 return vHTML; 304 } 305 </script> 306 EOD; 307 } 308 /** 309 * TinyMCE WYSIWYG Editor - copy editor contents to form field 310 * @param string The name of the editor area 311 * @param string The name of the form field 312 */ 313 function botTinymceEditorGetContents( $editorArea, $hiddenField ) { 314 return <<<EOD 315 316 tinyMCE.triggerSave(); 317 EOD; 318 } 319 /** 320 * TinyMCE WYSIWYG Editor - display the editor 321 * @param string The name of the editor area 322 * @param string The content of the field 323 * @param string The name of the form field 324 * @param string The width of the editor area 325 * @param string The height of the editor area 326 * @param int The number of columns for the editor area 327 * @param int The number of rows for the editor area 328 */ 329 function botTinymceEditorEditorArea( $name, $content, $hiddenField, $width, $height, $col, $row ) { 330 global $mosConfig_live_site, $_MAMBOTS; 331 332 $results = $_MAMBOTS->trigger( 'onCustomEditorButton' ); 333 $buttons = array(); 334 foreach ($results as $result) { 335 if ( $result[0] ) { 336 $buttons[] = '<img src="'.$mosConfig_live_site.'/mambots/editors-xtd/'.$result[0].'" onclick="tinyMCE.execCommand(\'mceInsertContent\',false,\''.$result[1].'\')" alt="'.$result[1].'" />'; 337 } 338 } 339 $buttons = implode( "", $buttons ); 340 341 return <<<EOD 342 343 <textarea id="$hiddenField" name="$hiddenField" cols="$col" rows="$row" style="width:{$width}px; height:{$height}px;" mce_editable="true">$content</textarea> 344 <br />$buttons 345 EOD; 346 } 347 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Wed Nov 21 14:43:32 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |