start.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. * Extended TinyMCE - a wysiwyg editor
  4. *
  5. */
  6. elgg_register_event_handler('init', 'system', 'extended_tinymce_init');
  7. function extended_tinymce_init() {
  8. elgg_extend_view('css/elgg', 'extended_tinymce/css');
  9. elgg_extend_view('css/admin', 'extended_tinymce/css');
  10. elgg_define_js('extended_tinymce', array(
  11. 'src' => 'mod/extended_tinymce/vendor/tinymce/js/tinymce/jquery.tinymce.min.js',
  12. 'deps' => array('jquery', 'elgg'),
  13. ));
  14. elgg_extend_view('input/longtext', 'extended_tinymce/init');
  15. elgg_extend_view('js/embed/embed', 'js/elgg/extended_tinymce/insert.js');
  16. // extend allowed styles for tinymce editor as filtered by htmlawed
  17. elgg_register_plugin_hook_handler('allowed_styles', 'htmlawed', 'extended_tinymce_allowed_styles');
  18. }
  19. function extended_tinymce_allowed_styles($hook, $type, $items, $vars) {
  20. $allowed_styles = array(
  21. 'color', 'cursor', 'text-align', 'vertical-align', 'font-size', 'font-family',
  22. 'font-weight', 'font-style', 'border', 'border-top', 'border-color', 'background-color',
  23. 'border-bottom', 'border-left', 'border-right',
  24. 'margin', 'margin-top', 'margin-bottom', 'margin-left',
  25. 'margin-right', 'padding', 'float', 'text-decoration'
  26. );
  27. return $allowed_styles;
  28. }
  29. function extended_tinymce_get_site_language() {
  30. if ($site_language = elgg_get_config('language')) {
  31. $path = elgg_get_plugins_path() . "extended_tinymce/vendor/tinymce/js/tinymce/langs";
  32. if (file_exists("$path/$site_language.js")) {
  33. return $site_language;
  34. }
  35. }
  36. return 'en';
  37. }
  38. function extended_tinymce_get_user_language() {
  39. $user_language = get_current_language();
  40. $path = elgg_get_plugins_path() . "extended_tinymce/vendor/tinymce/js/tinymce/langs";
  41. if (!file_exists("$path/$user_language.js")) {
  42. return extended_tinymce_get_site_language();
  43. }
  44. return $user_language;
  45. }