tinymce.inc 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. <?php
  2. /**
  3. * @file
  4. * Editor integration functions for TinyMCE.
  5. */
  6. /**
  7. * Plugin implementation of hook_editor().
  8. *
  9. * @todo wysiwyg_<editor>_alter() to add/inject optional libraries like gzip.
  10. */
  11. function wysiwyg_tinymce_editor() {
  12. $editor['tinymce'] = array(
  13. 'title' => 'TinyMCE',
  14. 'vendor url' => 'http://tinymce.moxiecode.com',
  15. 'download url' => 'http://tinymce.moxiecode.com/download.php',
  16. 'library path' => wysiwyg_get_path('tinymce') . '/jscripts/tiny_mce',
  17. 'libraries' => array(
  18. '' => array(
  19. 'title' => 'Minified',
  20. 'files' => array('tiny_mce.js'),
  21. ),
  22. 'src' => array(
  23. 'title' => 'Source',
  24. 'files' => array('tiny_mce_src.js'),
  25. ),
  26. ),
  27. 'version callback' => 'wysiwyg_tinymce_version',
  28. 'themes callback' => 'wysiwyg_tinymce_themes',
  29. 'settings callback' => 'wysiwyg_tinymce_settings',
  30. 'plugin callback' => 'wysiwyg_tinymce_plugins',
  31. 'plugin settings callback' => 'wysiwyg_tinymce_plugin_settings',
  32. 'proxy plugin' => array(
  33. 'drupal' => array(
  34. 'load' => TRUE,
  35. 'proxy' => TRUE,
  36. ),
  37. ),
  38. 'proxy plugin settings callback' => 'wysiwyg_tinymce_proxy_plugin_settings',
  39. 'versions' => array(
  40. '2.1' => array(
  41. 'js files' => array('tinymce-2.js'),
  42. 'css files' => array('tinymce-2.css'),
  43. 'download url' => 'http://sourceforge.net/project/showfiles.php?group_id=103281&package_id=111430&release_id=557383',
  44. ),
  45. // @todo Starting from 3.3, tiny_mce.js may support JS aggregation.
  46. '3.1' => array(
  47. 'js files' => array('tinymce-3.js'),
  48. 'css files' => array('tinymce-3.css'),
  49. 'libraries' => array(
  50. '' => array(
  51. 'title' => 'Minified',
  52. 'files' => array(
  53. 'tiny_mce.js' => array('preprocess' => FALSE),
  54. ),
  55. ),
  56. 'jquery' => array(
  57. 'title' => 'jQuery',
  58. 'files' => array('tiny_mce_jquery.js'),
  59. ),
  60. 'src' => array(
  61. 'title' => 'Source',
  62. 'files' => array('tiny_mce_src.js'),
  63. ),
  64. ),
  65. ),
  66. ),
  67. );
  68. return $editor;
  69. }
  70. /**
  71. * Detect editor version.
  72. *
  73. * @param $editor
  74. * An array containing editor properties as returned from hook_editor().
  75. *
  76. * @return
  77. * The installed editor version.
  78. */
  79. function wysiwyg_tinymce_version($editor) {
  80. $script = $editor['library path'] . '/tiny_mce.js';
  81. if (!file_exists($script)) {
  82. return;
  83. }
  84. $script = fopen($script, 'r');
  85. // Version is contained in the first 200 chars.
  86. $line = fgets($script, 200);
  87. fclose($script);
  88. // 2.x: this.majorVersion="2";this.minorVersion="1.3"
  89. // 3.x: majorVersion:'3',minorVersion:'2.0.1'
  90. if (preg_match('@majorVersion[=:]["\'](\d).+?minorVersion[=:]["\']([\d\.]+)@', $line, $version)) {
  91. return $version[1] . '.' . $version[2];
  92. }
  93. }
  94. /**
  95. * Determine available editor themes or check/reset a given one.
  96. *
  97. * @param $editor
  98. * A processed hook_editor() array of editor properties.
  99. * @param $profile
  100. * A wysiwyg editor profile.
  101. *
  102. * @return
  103. * An array of theme names. The first returned name should be the default
  104. * theme name.
  105. */
  106. function wysiwyg_tinymce_themes($editor, $profile) {
  107. /*
  108. $themes = array();
  109. $dir = $editor['library path'] . '/themes/';
  110. if (is_dir($dir) && $dh = opendir($dir)) {
  111. while (($file = readdir($dh)) !== FALSE) {
  112. if (!in_array($file, array('.', '..', 'CVS', '.svn')) && is_dir($dir . $file)) {
  113. $themes[$file] = $file;
  114. }
  115. }
  116. closedir($dh);
  117. asort($themes);
  118. }
  119. return $themes;
  120. */
  121. return array('advanced', 'simple');
  122. }
  123. /**
  124. * Return runtime editor settings for a given wysiwyg profile.
  125. *
  126. * @param $editor
  127. * A processed hook_editor() array of editor properties.
  128. * @param $config
  129. * An array containing wysiwyg editor profile settings.
  130. * @param $theme
  131. * The name of a theme/GUI/skin to use.
  132. *
  133. * @return
  134. * A settings array to be populated in
  135. * Drupal.settings.wysiwyg.configs.{editor}
  136. */
  137. function wysiwyg_tinymce_settings($editor, $config, $theme) {
  138. $settings = array(
  139. 'button_tile_map' => TRUE, // @todo Add a setting for this.
  140. 'document_base_url' => base_path(),
  141. 'mode' => 'none',
  142. 'plugins' => array(),
  143. 'theme' => $theme,
  144. 'width' => '100%',
  145. // Strict loading mode must be enabled; otherwise TinyMCE would use
  146. // document.write() in IE and Chrome.
  147. 'strict_loading_mode' => TRUE,
  148. // TinyMCE's URL conversion magic breaks Drupal modules that use a special
  149. // syntax for paths. This makes 'relative_urls' obsolete.
  150. 'convert_urls' => FALSE,
  151. // The default entity_encoding ('named') converts too many characters in
  152. // languages (like Greek). Since Drupal supports Unicode, we only convert
  153. // HTML control characters and invisible characters. TinyMCE always converts
  154. // XML default characters '&', '<', '>'.
  155. 'entities' => '160,nbsp,173,shy,8194,ensp,8195,emsp,8201,thinsp,8204,zwnj,8205,zwj,8206,lrm,8207,rlm',
  156. );
  157. if (isset($config['apply_source_formatting'])) {
  158. $settings['apply_source_formatting'] = $config['apply_source_formatting'];
  159. }
  160. if (isset($config['convert_fonts_to_spans'])) {
  161. $settings['convert_fonts_to_spans'] = $config['convert_fonts_to_spans'];
  162. }
  163. if (isset($config['language'])) {
  164. $settings['language'] = $config['language'];
  165. }
  166. if (isset($config['paste_auto_cleanup_on_paste'])) {
  167. $settings['paste_auto_cleanup_on_paste'] = $config['paste_auto_cleanup_on_paste'];
  168. }
  169. if (isset($config['preformatted'])) {
  170. $settings['preformatted'] = $config['preformatted'];
  171. }
  172. if (isset($config['remove_linebreaks'])) {
  173. $settings['remove_linebreaks'] = $config['remove_linebreaks'];
  174. }
  175. if (isset($config['verify_html'])) {
  176. $settings['verify_html'] = (bool) $config['verify_html'];
  177. }
  178. if (!empty($config['css_classes'])) {
  179. $settings['theme_advanced_styles'] = implode(';', array_filter(explode("\n", str_replace("\r", '', $config['css_classes']))));
  180. }
  181. if (isset($config['css_setting'])) {
  182. if ($config['css_setting'] == 'theme') {
  183. $settings['content_css'] = implode(',', wysiwyg_get_css());
  184. }
  185. else if ($config['css_setting'] == 'self' && isset($config['css_path'])) {
  186. $settings['content_css'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme()));
  187. }
  188. }
  189. // Find the enabled buttons and the button row they belong on.
  190. // Also map the plugin metadata for each button.
  191. // @todo What follows is a pain; needs a rewrite.
  192. // $settings['buttons'] are stacked into $settings['theme_advanced_buttons1']
  193. // later.
  194. $settings['buttons'] = array();
  195. if (!empty($config['buttons']) && is_array($config['buttons'])) {
  196. // Only array keys in $settings['extensions'] matter; added to
  197. // $settings['plugins'] later.
  198. $settings['extensions'] = array();
  199. // $settings['extended_valid_elements'] are just stacked, unique'd later,
  200. // and transformed into a comma-separated string in
  201. // wysiwyg_add_editor_settings().
  202. // @todo Needs a complete plugin API redesign using arrays for
  203. // tag => attributes definitions and array_merge_recursive().
  204. $settings['extended_valid_elements'] = array();
  205. $plugins = wysiwyg_get_plugins($editor['name']);
  206. foreach ($config['buttons'] as $plugin => $buttons) {
  207. foreach ($buttons as $button => $enabled) {
  208. // Iterate separately over buttons and extensions properties.
  209. foreach (array('buttons', 'extensions') as $type) {
  210. // Skip unavailable plugins.
  211. if (!isset($plugins[$plugin][$type][$button])) {
  212. continue;
  213. }
  214. // Add buttons.
  215. if ($type == 'buttons') {
  216. $settings['buttons'][] = $button;
  217. }
  218. // Add external Drupal plugins to the list of extensions.
  219. if ($type == 'buttons' && !empty($plugins[$plugin]['proxy'])) {
  220. $settings['extensions'][_wysiwyg_tinymce_plugin_name('add', $button)] = 1;
  221. }
  222. // Add external plugins to the list of extensions.
  223. else if ($type == 'buttons' && empty($plugins[$plugin]['internal'])) {
  224. $settings['extensions'][_wysiwyg_tinymce_plugin_name('add', $plugin)] = 1;
  225. }
  226. // Add internal buttons that also need to be loaded as extension.
  227. else if ($type == 'buttons' && !empty($plugins[$plugin]['load'])) {
  228. $settings['extensions'][$plugin] = 1;
  229. }
  230. // Add plain extensions.
  231. else if ($type == 'extensions' && !empty($plugins[$plugin]['load'])) {
  232. $settings['extensions'][$plugin] = 1;
  233. }
  234. // Allow plugins to add valid HTML elements.
  235. if (!empty($plugins[$plugin]['extended_valid_elements'])) {
  236. $settings['extended_valid_elements'] = array_merge($settings['extended_valid_elements'], $plugins[$plugin]['extended_valid_elements']);
  237. }
  238. // Allow plugins to add or override global configuration settings.
  239. if (!empty($plugins[$plugin]['options'])) {
  240. $settings = array_merge($settings, $plugins[$plugin]['options']);
  241. }
  242. }
  243. }
  244. }
  245. // Clean-up.
  246. $settings['extended_valid_elements'] = array_unique($settings['extended_valid_elements']);
  247. if ($settings['extensions']) {
  248. $settings['plugins'] = array_keys($settings['extensions']);
  249. }
  250. unset($settings['extensions']);
  251. }
  252. // Add theme-specific settings.
  253. switch ($theme) {
  254. case 'advanced':
  255. $settings += array(
  256. 'theme_advanced_resize_horizontal' => FALSE,
  257. 'theme_advanced_resizing_use_cookie' => FALSE,
  258. 'theme_advanced_path_location' => isset($config['path_loc']) ? $config['path_loc'] : 'bottom',
  259. 'theme_advanced_resizing' => isset($config['resizing']) ? $config['resizing'] : 1,
  260. 'theme_advanced_toolbar_location' => isset($config['toolbar_loc']) ? $config['toolbar_loc'] : 'top',
  261. 'theme_advanced_toolbar_align' => isset($config['toolbar_align']) ? $config['toolbar_align'] : 'left',
  262. );
  263. if (isset($config['block_formats'])) {
  264. $settings['theme_advanced_blockformats'] = $config['block_formats'];
  265. }
  266. if (isset($settings['buttons'])) {
  267. // These rows explicitly need to be set to be empty, otherwise TinyMCE
  268. // loads its default buttons of the advanced theme for each row.
  269. $settings += array(
  270. 'theme_advanced_buttons1' => array(),
  271. 'theme_advanced_buttons2' => array(),
  272. 'theme_advanced_buttons3' => array(),
  273. );
  274. // @todo Allow to sort/arrange editor buttons.
  275. for ($i = 0; $i < count($settings['buttons']); $i++) {
  276. $settings['theme_advanced_buttons1'][] = $settings['buttons'][$i];
  277. }
  278. }
  279. break;
  280. }
  281. unset($settings['buttons']);
  282. // Convert the config values into the form expected by TinyMCE.
  283. $csv_settings = array('plugins', 'extended_valid_elements', 'theme_advanced_buttons1', 'theme_advanced_buttons2', 'theme_advanced_buttons3');
  284. foreach ($csv_settings as $key) {
  285. if (isset($settings[$key]) && is_array($settings[$key])) {
  286. $settings[$key] = implode(',', $settings[$key]);
  287. }
  288. }
  289. return $settings;
  290. }
  291. /**
  292. * Build a JS settings array of native external plugins that need to be loaded separately.
  293. *
  294. * TinyMCE requires that external plugins (i.e. not residing in the editor's
  295. * directory) are loaded (once) upon initializing the editor.
  296. */
  297. function wysiwyg_tinymce_plugin_settings($editor, $profile, $plugins) {
  298. $settings = array();
  299. foreach ($plugins as $name => $plugin) {
  300. if (!empty($plugin['load'])) {
  301. // Add path for native external plugins; internal ones are loaded
  302. // automatically.
  303. if (empty($plugin['internal']) && isset($plugin['filename'])) {
  304. $settings[$name] = base_path() . $plugin['path'] . '/' . $plugin['filename'];
  305. }
  306. }
  307. }
  308. return $settings;
  309. }
  310. /**
  311. * Build a JS settings array for Drupal plugins loaded via the proxy plugin.
  312. */
  313. function wysiwyg_tinymce_proxy_plugin_settings($editor, $profile, $plugins) {
  314. $settings = array();
  315. foreach ($plugins as $name => $plugin) {
  316. // Populate required plugin settings.
  317. $settings[$name] = $plugin['dialog settings'] + array(
  318. 'title' => $plugin['title'],
  319. 'icon' => base_path() . $plugin['icon path'] . '/' . $plugin['icon file'],
  320. 'iconTitle' => $plugin['icon title'],
  321. );
  322. if (isset($plugin['css file'])) {
  323. $settings[$name]['css'] = base_path() . $plugin['css path'] . '/' . $plugin['css file'];
  324. }
  325. }
  326. return $settings;
  327. }
  328. /**
  329. * Add or remove leading hiven to/of external plugin names.
  330. *
  331. * TinyMCE requires that external plugins, which should not be loaded from
  332. * its own plugin repository are prefixed with a hiven in the name.
  333. *
  334. * @param string $op
  335. * Operation to perform, 'add' or 'remove' (hiven).
  336. * @param string $name
  337. * A plugin name.
  338. */
  339. function _wysiwyg_tinymce_plugin_name($op, $name) {
  340. if ($op == 'add') {
  341. if (strpos($name, '-') !== 0) {
  342. return '-' . $name;
  343. }
  344. return $name;
  345. }
  346. else if ($op == 'remove') {
  347. if (strpos($name, '-') === 0) {
  348. return substr($name, 1);
  349. }
  350. return $name;
  351. }
  352. }
  353. /**
  354. * Return internal plugins for this editor; semi-implementation of hook_wysiwyg_plugin().
  355. */
  356. function wysiwyg_tinymce_plugins($editor) {
  357. $plugins = array(
  358. 'default' => array(
  359. 'path' => $editor['library path'] . '/themes/advanced',
  360. 'buttons' => array(
  361. 'bold' => t('Bold'), 'italic' => t('Italic'), 'underline' => t('Underline'),
  362. 'strikethrough' => t('Strike-through'),
  363. 'justifyleft' => t('Align left'), 'justifycenter' => t('Align center'), 'justifyright' => t('Align right'), 'justifyfull' => t('Justify'),
  364. 'bullist' => t('Bullet list'), 'numlist' => t('Numbered list'),
  365. 'outdent' => t('Outdent'), 'indent' => t('Indent'),
  366. 'undo' => t('Undo'), 'redo' => t('Redo'),
  367. 'link' => t('Link'), 'unlink' => t('Unlink'), 'anchor' => t('Anchor'),
  368. 'image' => t('Image'),
  369. 'cleanup' => t('Clean-up'),
  370. 'forecolor' => t('Forecolor'), 'backcolor' => t('Backcolor'),
  371. 'sup' => t('Superscript'), 'sub' => t('Subscript'),
  372. 'blockquote' => t('Blockquote'), 'code' => t('Source code'),
  373. 'hr' => t('Horizontal rule'),
  374. 'cut' => t('Cut'), 'copy' => t('Copy'), 'paste' => t('Paste'),
  375. 'visualaid' => t('Visual aid'),
  376. 'removeformat' => t('Remove format'),
  377. 'charmap' => t('Character map'),
  378. 'help' => t('Help'),
  379. ),
  380. 'internal' => TRUE,
  381. ),
  382. 'advhr' => array(
  383. 'path' => $editor['library path'] . '/plugins/advhr',
  384. 'buttons' => array('advhr' => t('Advanced horizontal rule')),
  385. 'extended_valid_elements' => array('hr[class|width|size|noshade]'),
  386. 'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/advhr',
  387. 'internal' => TRUE,
  388. 'load' => TRUE,
  389. ),
  390. 'advimage' => array(
  391. 'path' => $editor['library path'] . '/plugins/advimage',
  392. 'extensions' => array('advimage' => t('Advanced image')),
  393. 'extended_valid_elements' => array('img[src|alt|title|align|width|height|usemap|hspace|vspace|border|style|class|onmouseover|onmouseout|id|name]'),
  394. 'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/advimage',
  395. 'internal' => TRUE,
  396. 'load' => TRUE,
  397. ),
  398. 'advlink' => array(
  399. 'path' => $editor['library path'] . '/plugins/advlink',
  400. 'extensions' => array('advlink' => t('Advanced link')),
  401. 'extended_valid_elements' => array('a[name|href|target|title|class|onfocus|onblur|onclick|ondlbclick|onmousedown|onmouseup|onmouseover|onmouseout|onkeypress|onkeydown|onkeyup|id|style|rel]'),
  402. 'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/advlink',
  403. 'internal' => TRUE,
  404. 'load' => TRUE,
  405. ),
  406. 'autosave' => array(
  407. 'path' => $editor['library path'] . '/plugins/autosave',
  408. 'extensions' => array('autosave' => t('Auto save')),
  409. 'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/autosave',
  410. 'internal' => TRUE,
  411. 'load' => TRUE,
  412. ),
  413. 'contextmenu' => array(
  414. 'path' => $editor['library path'] . '/plugins/contextmenu',
  415. 'extensions' => array('contextmenu' => t('Context menu')),
  416. 'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/contextmenu',
  417. 'internal' => TRUE,
  418. 'load' => TRUE,
  419. ),
  420. 'directionality' => array(
  421. 'path' => $editor['library path'] . '/plugins/directionality',
  422. 'buttons' => array('ltr' => t('Left-to-right'), 'rtl' => t('Right-to-left')),
  423. 'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/directionality',
  424. 'internal' => TRUE,
  425. 'load' => TRUE,
  426. ),
  427. 'emotions' => array(
  428. 'path' => $editor['library path'] . '/plugins/emotions',
  429. 'buttons' => array('emotions' => t('Emotions')),
  430. 'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/emotions',
  431. 'internal' => TRUE,
  432. 'load' => TRUE,
  433. ),
  434. 'font' => array(
  435. 'path' => $editor['library path'] . '/plugins/font',
  436. 'buttons' => array('formatselect' => t('HTML block format'), 'fontselect' => t('Font'), 'fontsizeselect' => t('Font size'), 'styleselect' => t('Font style')),
  437. 'extended_valid_elements' => array('font[face|size|color|style],span[class|align|style]'),
  438. 'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/font',
  439. 'internal' => TRUE,
  440. ),
  441. 'fullscreen' => array(
  442. 'path' => $editor['library path'] . '/plugins/fullscreen',
  443. 'buttons' => array('fullscreen' => t('Fullscreen')),
  444. 'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/fullscreen',
  445. 'internal' => TRUE,
  446. 'load' => TRUE,
  447. ),
  448. 'inlinepopups' => array(
  449. 'path' => $editor['library path'] . '/plugins/inlinepopups',
  450. 'extensions' => array('inlinepopups' => t('Inline popups')),
  451. 'options' => array(
  452. 'dialog_type' => array('modal'),
  453. ),
  454. 'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/inlinepopups',
  455. 'internal' => TRUE,
  456. 'load' => TRUE,
  457. ),
  458. 'insertdatetime' => array(
  459. 'path' => $editor['library path'] . '/plugins/insertdatetime',
  460. 'buttons' => array('insertdate' => t('Insert date'), 'inserttime' => t('Insert time')),
  461. 'options' => array(
  462. 'plugin_insertdate_dateFormat' => '%Y-%m-%d',
  463. 'plugin_insertdate_timeFormat' => '%H:%M:%S',
  464. ),
  465. 'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/insertdatetime',
  466. 'internal' => TRUE,
  467. 'load' => TRUE,
  468. ),
  469. 'layer' => array(
  470. 'path' => $editor['library path'] . '/plugins/layer',
  471. 'buttons' => array('insertlayer' => t('Insert layer'), 'moveforward' => t('Move forward'), 'movebackward' => t('Move backward'), 'absolute' => t('Absolute')),
  472. 'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/layer',
  473. 'internal' => TRUE,
  474. 'load' => TRUE,
  475. ),
  476. 'paste' => array(
  477. 'path' => $editor['library path'] . '/plugins/paste',
  478. 'buttons' => array('pastetext' => t('Paste text'), 'pasteword' => t('Paste from Word'), 'selectall' => t('Select all')),
  479. 'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/paste',
  480. 'internal' => TRUE,
  481. 'load' => TRUE,
  482. ),
  483. 'preview' => array(
  484. 'path' => $editor['library path'] . '/plugins/preview',
  485. 'buttons' => array('preview' => t('Preview')),
  486. 'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/preview',
  487. 'internal' => TRUE,
  488. 'load' => TRUE,
  489. ),
  490. 'print' => array(
  491. 'path' => $editor['library path'] . '/plugins/print',
  492. 'buttons' => array('print' => t('Print')),
  493. 'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/print',
  494. 'internal' => TRUE,
  495. 'load' => TRUE,
  496. ),
  497. 'searchreplace' => array(
  498. 'path' => $editor['library path'] . '/plugins/searchreplace',
  499. 'buttons' => array('search' => t('Search'), 'replace' => t('Replace')),
  500. 'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/searchreplace',
  501. 'internal' => TRUE,
  502. 'load' => TRUE,
  503. ),
  504. 'style' => array(
  505. 'path' => $editor['library path'] . '/plugins/style',
  506. 'buttons' => array('styleprops' => t('Style properties')),
  507. 'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/style',
  508. 'internal' => TRUE,
  509. 'load' => TRUE,
  510. ),
  511. 'table' => array(
  512. 'path' => $editor['library path'] . '/plugins/table',
  513. 'buttons' => array('tablecontrols' => t('Table')),
  514. 'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/table',
  515. 'internal' => TRUE,
  516. 'load' => TRUE,
  517. ),
  518. );
  519. if (version_compare($editor['installed version'], '3', '<')) {
  520. $plugins['flash'] = array(
  521. 'path' => $editor['library path'] . '/plugins/flash',
  522. 'buttons' => array('flash' => t('Flash')),
  523. 'extended_valid_elements' => array('img[class|src|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name|obj|param|embed]'),
  524. 'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/flash',
  525. 'internal' => TRUE,
  526. 'load' => TRUE,
  527. );
  528. }
  529. if (version_compare($editor['installed version'], '2.0.6', '>')) {
  530. $plugins['media'] = array(
  531. 'path' => $editor['library path'] . '/plugins/media',
  532. 'buttons' => array('media' => t('Media')),
  533. 'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/media',
  534. 'internal' => TRUE,
  535. 'load' => TRUE,
  536. );
  537. $plugins['xhtmlxtras'] = array(
  538. 'path' => $editor['library path'] . '/plugins/xhtmlxtras',
  539. 'buttons' => array('cite' => t('Citation'), 'del' => t('Deleted'), 'abbr' => t('Abbreviation'), 'acronym' => t('Acronym'), 'ins' => t('Inserted'), 'attribs' => t('HTML attributes')),
  540. 'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/xhtmlxtras',
  541. 'internal' => TRUE,
  542. 'load' => TRUE,
  543. );
  544. }
  545. if (version_compare($editor['installed version'], '3', '>')) {
  546. $plugins['bbcode'] = array(
  547. 'path' => $editor['library path'] . '/plugins/bbcode',
  548. 'extensions' => array('bbcode' => t('BBCode')),
  549. 'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/bbcode',
  550. 'internal' => TRUE,
  551. 'load' => TRUE,
  552. );
  553. if (version_compare($editor['installed version'], '3.3', '<')) {
  554. $plugins['safari'] = array(
  555. 'path' => $editor['library path'] . '/plugins/safari',
  556. 'extensions' => array('safari' => t('Safari compatibility')),
  557. 'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/safari',
  558. 'internal' => TRUE,
  559. 'load' => TRUE,
  560. );
  561. }
  562. }
  563. if (version_compare($editor['installed version'], '3.2.5', '>=')) {
  564. $plugins['autoresize'] = array(
  565. 'path' => $editor['library path'] . '/plugins/autoresize',
  566. 'extensions' => array('autoresize' => t('Auto resize')),
  567. 'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/autoresize',
  568. 'internal' => TRUE,
  569. 'load' => TRUE,
  570. );
  571. }
  572. if (version_compare($editor['installed version'], '3.3', '>=')) {
  573. $plugins['advlist'] = array(
  574. 'path' => $editor['library path'] . '/plugins/advlist',
  575. 'extensions' => array('advlist' => t('Advanced list')),
  576. 'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/advlist',
  577. 'internal' => TRUE,
  578. 'load' => TRUE,
  579. );
  580. }
  581. if (version_compare($editor['installed version'], '3.2.6', '>=')) {
  582. $plugins['wordcount'] = array(
  583. 'path' => $editor['library path'] . '/plugins/wordcount',
  584. 'extensions' => array('wordcount' => t('Word count')),
  585. 'url' => 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/wordcount',
  586. 'internal' => TRUE,
  587. 'load' => TRUE,
  588. );
  589. }
  590. return $plugins;
  591. }