tinymce.inc 25 KB

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