tinymce.inc 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  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. 'theme' => 'advanced',
  179. 'skin' => 'o2k7',
  180. 'skin_variant' => "silver",
  181. 'width' => '100%',
  182. // Strict loading mode must be enabled; otherwise TinyMCE would use
  183. // document.write() in IE and Chrome.
  184. 'strict_loading_mode' => TRUE,
  185. // TinyMCE's URL conversion magic breaks Drupal modules that use a special
  186. // syntax for paths. This makes 'relative_urls' obsolete.
  187. 'convert_urls' => FALSE,
  188. // The default entity_encoding ('named') converts too many characters in
  189. // languages (like Greek). Since Drupal supports Unicode, we only convert
  190. // HTML control characters and invisible characters. TinyMCE always converts
  191. // XML default characters '&', '<', '>'.
  192. 'entities' => '160,nbsp,173,shy,8194,ensp,8195,emsp,8201,thinsp,8204,zwnj,8205,zwj,8206,lrm,8207,rlm',
  193. );
  194. if (isset($config['apply_source_formatting'])) {
  195. $settings['apply_source_formatting'] = $config['apply_source_formatting'];
  196. }
  197. if (isset($config['convert_fonts_to_spans'])) {
  198. $settings['convert_fonts_to_spans'] = $config['convert_fonts_to_spans'];
  199. }
  200. if (isset($config['language'])) {
  201. $settings['language'] = $config['language'];
  202. }
  203. if (isset($config['paste_auto_cleanup_on_paste'])) {
  204. $settings['paste_auto_cleanup_on_paste'] = $config['paste_auto_cleanup_on_paste'];
  205. }
  206. if (isset($config['preformatted'])) {
  207. $settings['preformatted'] = $config['preformatted'];
  208. }
  209. if (isset($config['remove_linebreaks'])) {
  210. $settings['remove_linebreaks'] = $config['remove_linebreaks'];
  211. }
  212. if (isset($config['verify_html'])) {
  213. // TinyMCE performs a type-agnostic comparison on this particular setting.
  214. $settings['verify_html'] = (bool) $config['verify_html'];
  215. }
  216. if (!empty($config['css_classes'])) {
  217. $settings['theme_advanced_styles'] = implode(';', array_filter(explode("\n", str_replace("\r", '', $config['css_classes']))));
  218. }
  219. if (isset($config['css_setting'])) {
  220. if ($config['css_setting'] == 'theme') {
  221. $settings['content_css'] = implode(',', wysiwyg_get_css());
  222. }
  223. elseif ($config['css_setting'] == 'self' && isset($config['css_path'])) {
  224. $settings['content_css'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => drupal_get_path('theme', variable_get('theme_default', NULL))));
  225. }
  226. }
  227. // Find the enabled buttons and the button row they belong on.
  228. // Also map the plugin metadata for each button.
  229. // @todo What follows is a pain; needs a rewrite.
  230. // $settings['buttons'] are stacked into $settings['theme_advanced_buttons1']
  231. // later.
  232. $settings['buttons'] = array();
  233. if (!empty($config['buttons']) && is_array($config['buttons'])) {
  234. // Only array keys in $settings['extensions'] matter; added to
  235. // $settings['plugins'] later.
  236. $settings['extensions'] = array();
  237. // $settings['extended_valid_elements'] are just stacked, unique'd later,
  238. // and transformed into a comma-separated string in
  239. // wysiwyg_add_editor_settings().
  240. // @todo Needs a complete plugin API redesign using arrays for
  241. // tag => attributes definitions and array_merge_recursive().
  242. $settings['extended_valid_elements'] = array();
  243. $plugins = wysiwyg_get_plugins($editor['name']);
  244. foreach ($config['buttons'] as $plugin => $buttons) {
  245. foreach ($buttons as $button => $enabled) {
  246. // Iterate separately over buttons and extensions properties.
  247. foreach (array('buttons', 'extensions') as $type) {
  248. // Skip unavailable plugins.
  249. if (!isset($plugins[$plugin][$type][$button])) {
  250. continue;
  251. }
  252. // Add buttons.
  253. if ($type == 'buttons') {
  254. $settings['buttons'][] = $button;
  255. }
  256. // Add external Drupal plugins to the list of extensions.
  257. if ($type == 'buttons' && !empty($plugins[$plugin]['proxy'])) {
  258. $settings['extensions'][_wysiwyg_tinymce_plugin_name('add', $button)] = 1;
  259. }
  260. // Add external plugins to the list of extensions.
  261. elseif ($type == 'buttons' && empty($plugins[$plugin]['internal'])) {
  262. $settings['extensions'][_wysiwyg_tinymce_plugin_name('add', $plugin)] = 1;
  263. }
  264. // Add internal buttons that also need to be loaded as extension.
  265. elseif ($type == 'buttons' && !empty($plugins[$plugin]['load'])) {
  266. $settings['extensions'][$plugin] = 1;
  267. }
  268. // Add plain extensions.
  269. elseif ($type == 'extensions' && !empty($plugins[$plugin]['load'])) {
  270. $settings['extensions'][$plugin] = 1;
  271. }
  272. // Allow plugins to add valid HTML elements.
  273. if (!empty($plugins[$plugin]['extended_valid_elements'])) {
  274. $settings['extended_valid_elements'] = array_merge($settings['extended_valid_elements'], $plugins[$plugin]['extended_valid_elements']);
  275. }
  276. // Allow plugins to add or override global configuration settings.
  277. if (!empty($plugins[$plugin]['options'])) {
  278. $settings = array_merge($settings, $plugins[$plugin]['options']);
  279. }
  280. }
  281. }
  282. }
  283. // Clean-up.
  284. $settings['extended_valid_elements'] = array_unique($settings['extended_valid_elements']);
  285. if ($settings['extensions']) {
  286. $settings['plugins'] = array_keys($settings['extensions']);
  287. }
  288. unset($settings['extensions']);
  289. }
  290. // Add theme-specific settings.
  291. switch ($theme) {
  292. case 'advanced':
  293. $settings += array(
  294. 'theme_advanced_resize_horizontal' => FALSE,
  295. 'theme_advanced_resizing_use_cookie' => FALSE,
  296. 'theme_advanced_statusbar_location' => isset($config['path_loc']) ? $config['path_loc'] : 'bottom',
  297. 'theme_advanced_resizing' => isset($config['resizing']) ? $config['resizing'] : 1,
  298. 'theme_advanced_toolbar_location' => isset($config['toolbar_loc']) ? $config['toolbar_loc'] : 'top',
  299. 'theme_advanced_toolbar_align' => isset($config['toolbar_align']) ? $config['toolbar_align'] : 'left',
  300. );
  301. if (isset($config['block_formats'])) {
  302. $settings['theme_advanced_blockformats'] = $config['block_formats'];
  303. }
  304. if (isset($settings['buttons'])) {
  305. // These rows explicitly need to be set to be empty, otherwise TinyMCE
  306. // loads its default buttons of the advanced theme for each row.
  307. $settings += array(
  308. 'theme_advanced_buttons1' => array(),
  309. 'theme_advanced_buttons2' => array(),
  310. 'theme_advanced_buttons3' => array(),
  311. );
  312. // @todo Allow to sort/arrange editor buttons.
  313. for ($i = 0; $i < count($settings['buttons']); $i++) {
  314. $settings['theme_advanced_buttons1'][] = $settings['buttons'][$i];
  315. }
  316. }
  317. break;
  318. }
  319. unset($settings['buttons']);
  320. // Convert the config values into the form expected by TinyMCE.
  321. $csv_settings = array('plugins', 'extended_valid_elements', 'theme_advanced_buttons1', 'theme_advanced_buttons2', 'theme_advanced_buttons3');
  322. foreach ($csv_settings as $key) {
  323. if (isset($settings[$key]) && is_array($settings[$key])) {
  324. $settings[$key] = implode(',', $settings[$key]);
  325. }
  326. }
  327. return $settings;
  328. }
  329. /**
  330. * Build a JS settings array of native external plugins that need to be loaded separately.
  331. *
  332. * TinyMCE requires that external plugins (i.e. not residing in the editor's
  333. * directory) are loaded (once) upon initializing the editor.
  334. */
  335. function wysiwyg_tinymce_plugin_settings($editor, $profile, $plugins) {
  336. $settings = array();
  337. foreach ($plugins as $name => $plugin) {
  338. if (!empty($plugin['load'])) {
  339. // Add path for native external plugins; internal ones are loaded
  340. // automatically.
  341. if (empty($plugin['internal']) && isset($plugin['filename'])) {
  342. $settings[$name] = base_path() . $plugin['path'] . '/' . $plugin['filename'];
  343. }
  344. }
  345. }
  346. return $settings;
  347. }
  348. /**
  349. * Build a JS settings array for Drupal plugins loaded via the proxy plugin.
  350. */
  351. function wysiwyg_tinymce_proxy_plugin_settings($editor, $profile, $plugins) {
  352. $settings = array();
  353. foreach ($plugins as $name => $plugin) {
  354. // Populate required plugin settings.
  355. $settings[$name] = $plugin['dialog settings'] + array(
  356. 'title' => $plugin['title'],
  357. 'icon' => base_path() . $plugin['icon path'] . '/' . $plugin['icon file'],
  358. 'iconTitle' => $plugin['icon title'],
  359. );
  360. if (isset($plugin['css file'])) {
  361. $settings[$name]['css'] = base_path() . $plugin['css path'] . '/' . $plugin['css file'];
  362. }
  363. }
  364. return $settings;
  365. }
  366. /**
  367. * Add or remove leading hiven to/of external plugin names.
  368. *
  369. * TinyMCE requires that external plugins, which should not be loaded from
  370. * its own plugin repository are prefixed with a hiven in the name.
  371. *
  372. * @param string $op
  373. * Operation to perform, 'add' or 'remove' (hiven).
  374. * @param string $name
  375. * A plugin name.
  376. */
  377. function _wysiwyg_tinymce_plugin_name($op, $name) {
  378. if ($op == 'add') {
  379. if (strpos($name, '-') !== 0) {
  380. return '-' . $name;
  381. }
  382. return $name;
  383. }
  384. elseif ($op == 'remove') {
  385. if (strpos($name, '-') === 0) {
  386. return substr($name, 1);
  387. }
  388. return $name;
  389. }
  390. }
  391. /**
  392. * Return internal plugins for this editor; semi-implementation of hook_wysiwyg_plugin().
  393. */
  394. function wysiwyg_tinymce_plugins($editor) {
  395. $plugins = array(
  396. 'default' => array(
  397. 'path' => $editor['library path'] . '/themes/advanced',
  398. 'buttons' => array(
  399. 'bold' => t('Bold'), 'italic' => t('Italic'), 'underline' => t('Underline'),
  400. 'strikethrough' => t('Strike-through'),
  401. 'justifyleft' => t('Align left'), 'justifycenter' => t('Align center'), 'justifyright' => t('Align right'), 'justifyfull' => t('Justify'),
  402. 'bullist' => t('Bullet list'), 'numlist' => t('Numbered list'),
  403. 'outdent' => t('Outdent'), 'indent' => t('Indent'),
  404. 'undo' => t('Undo'), 'redo' => t('Redo'),
  405. 'link' => t('Link'), 'unlink' => t('Unlink'), 'anchor' => t('Anchor'),
  406. 'image' => t('Image'),
  407. 'cleanup' => t('Clean-up'),
  408. 'formatselect' => t('Block format'), 'styleselect' => t('Styles'),
  409. 'fontselect' => t('Font'), 'fontsizeselect' => t('Font size'),
  410. 'forecolor' => t('Forecolor'), 'backcolor' => t('Backcolor'),
  411. 'sup' => t('Superscript'), 'sub' => t('Subscript'),
  412. 'blockquote' => t('Blockquote'), 'code' => t('Source code'),
  413. 'hr' => t('Horizontal rule'),
  414. 'cut' => t('Cut'), 'copy' => t('Copy'), 'paste' => t('Paste'),
  415. 'visualaid' => t('Visual aid'),
  416. 'removeformat' => t('Remove format'),
  417. 'charmap' => t('Character map'),
  418. 'help' => t('Help'),
  419. ),
  420. 'internal' => TRUE,
  421. ),
  422. 'advhr' => array(
  423. 'path' => $editor['library path'] . '/plugins/advhr',
  424. 'buttons' => array('advhr' => t('Advanced horizontal rule')),
  425. 'extended_valid_elements' => array('hr[class|width|size|noshade]'),
  426. 'url' => 'http://www.tinymce.com/wiki.php/Plugin:advhr',
  427. 'internal' => TRUE,
  428. 'load' => TRUE,
  429. ),
  430. 'advimage' => array(
  431. 'path' => $editor['library path'] . '/plugins/advimage',
  432. 'extensions' => array('advimage' => t('Advanced image')),
  433. 'extended_valid_elements' => array('img[src|alt|title|align|width|height|usemap|hspace|vspace|border|style|class|onmouseover|onmouseout|id|name|longdesc]'),
  434. 'url' => 'http://www.tinymce.com/wiki.php/Plugin:advimage',
  435. 'internal' => TRUE,
  436. 'load' => TRUE,
  437. ),
  438. 'advlink' => array(
  439. 'path' => $editor['library path'] . '/plugins/advlink',
  440. 'extensions' => array('advlink' => t('Advanced link')),
  441. 'extended_valid_elements' => array('a[name|href|target|title|class|onfocus|onblur|onclick|ondlbclick|onmousedown|onmouseup|onmouseover|onmouseout|onkeypress|onkeydown|onkeyup|id|style|rel]'),
  442. 'url' => 'http://www.tinymce.com/wiki.php/Plugin:advlink',
  443. 'internal' => TRUE,
  444. 'load' => TRUE,
  445. ),
  446. 'autosave' => array(
  447. 'path' => $editor['library path'] . '/plugins/autosave',
  448. 'extensions' => array('autosave' => t('Auto save')),
  449. 'url' => 'http://www.tinymce.com/wiki.php/Plugin:autosave',
  450. 'internal' => TRUE,
  451. 'load' => TRUE,
  452. ),
  453. 'contextmenu' => array(
  454. 'path' => $editor['library path'] . '/plugins/contextmenu',
  455. 'extensions' => array('contextmenu' => t('Context menu')),
  456. 'url' => 'http://www.tinymce.com/wiki.php/Plugin:contextmenu',
  457. 'internal' => TRUE,
  458. 'load' => TRUE,
  459. ),
  460. 'directionality' => array(
  461. 'path' => $editor['library path'] . '/plugins/directionality',
  462. 'buttons' => array('ltr' => t('Left-to-right'), 'rtl' => t('Right-to-left')),
  463. 'url' => 'http://www.tinymce.com/wiki.php/Plugin:directionality',
  464. 'internal' => TRUE,
  465. 'load' => TRUE,
  466. ),
  467. 'emotions' => array(
  468. 'path' => $editor['library path'] . '/plugins/emotions',
  469. 'buttons' => array('emotions' => t('Emotions')),
  470. 'url' => 'http://www.tinymce.com/wiki.php/Plugin:emotions',
  471. 'internal' => TRUE,
  472. 'load' => TRUE,
  473. ),
  474. 'fullscreen' => array(
  475. 'path' => $editor['library path'] . '/plugins/fullscreen',
  476. 'buttons' => array('fullscreen' => t('Fullscreen')),
  477. 'url' => 'http://www.tinymce.com/wiki.php/Plugin:fullscreen',
  478. 'internal' => TRUE,
  479. 'load' => TRUE,
  480. ),
  481. 'inlinepopups' => array(
  482. 'path' => $editor['library path'] . '/plugins/inlinepopups',
  483. 'extensions' => array('inlinepopups' => t('Inline popups')),
  484. 'options' => array(
  485. 'dialog_type' => array('modal'),
  486. ),
  487. 'url' => 'http://www.tinymce.com/wiki.php/Plugin:inlinepopups',
  488. 'internal' => TRUE,
  489. 'load' => TRUE,
  490. ),
  491. 'insertdatetime' => array(
  492. 'path' => $editor['library path'] . '/plugins/insertdatetime',
  493. 'buttons' => array('insertdate' => t('Insert date'), 'inserttime' => t('Insert time')),
  494. 'options' => array(
  495. 'plugin_insertdate_dateFormat' => '%Y-%m-%d',
  496. 'plugin_insertdate_timeFormat' => '%H:%M:%S',
  497. ),
  498. 'url' => 'http://www.tinymce.com/wiki.php/Plugin:insertdatetime',
  499. 'internal' => TRUE,
  500. 'load' => TRUE,
  501. ),
  502. 'layer' => array(
  503. 'path' => $editor['library path'] . '/plugins/layer',
  504. 'buttons' => array('insertlayer' => t('Insert layer'), 'moveforward' => t('Move forward'), 'movebackward' => t('Move backward'), 'absolute' => t('Absolute')),
  505. 'url' => 'http://www.tinymce.com/wiki.php/Plugin:layer',
  506. 'internal' => TRUE,
  507. 'load' => TRUE,
  508. ),
  509. 'paste' => array(
  510. 'path' => $editor['library path'] . '/plugins/paste',
  511. 'buttons' => array('pastetext' => t('Paste text'), 'pasteword' => t('Paste from Word'), 'selectall' => t('Select all')),
  512. 'url' => 'http://www.tinymce.com/wiki.php/Plugin:paste',
  513. 'internal' => TRUE,
  514. 'load' => TRUE,
  515. ),
  516. 'preview' => array(
  517. 'path' => $editor['library path'] . '/plugins/preview',
  518. 'buttons' => array('preview' => t('Preview')),
  519. 'url' => 'http://www.tinymce.com/wiki.php/Plugin:preview',
  520. 'internal' => TRUE,
  521. 'load' => TRUE,
  522. ),
  523. 'print' => array(
  524. 'path' => $editor['library path'] . '/plugins/print',
  525. 'buttons' => array('print' => t('Print')),
  526. 'url' => 'http://www.tinymce.com/wiki.php/Plugin:print',
  527. 'internal' => TRUE,
  528. 'load' => TRUE,
  529. ),
  530. 'searchreplace' => array(
  531. 'path' => $editor['library path'] . '/plugins/searchreplace',
  532. 'buttons' => array('search' => t('Search'), 'replace' => t('Replace')),
  533. 'url' => 'http://www.tinymce.com/wiki.php/Plugin:searchreplace',
  534. 'internal' => TRUE,
  535. 'load' => TRUE,
  536. ),
  537. 'style' => array(
  538. 'path' => $editor['library path'] . '/plugins/style',
  539. 'buttons' => array('styleprops' => t('Advanced CSS styles')),
  540. 'url' => 'http://www.tinymce.com/wiki.php/Plugin:style',
  541. 'internal' => TRUE,
  542. 'load' => TRUE,
  543. ),
  544. 'table' => array(
  545. 'path' => $editor['library path'] . '/plugins/table',
  546. 'buttons' => array('tablecontrols' => t('Table')),
  547. 'url' => 'http://www.tinymce.com/wiki.php/Plugin:table',
  548. 'internal' => TRUE,
  549. 'load' => TRUE,
  550. ),
  551. );
  552. if (version_compare($editor['installed version'], '3', '<')) {
  553. $plugins['flash'] = array(
  554. 'path' => $editor['library path'] . '/plugins/flash',
  555. 'buttons' => array('flash' => t('Flash')),
  556. 'extended_valid_elements' => array('img[class|src|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name|obj|param|embed]'),
  557. 'internal' => TRUE,
  558. 'load' => TRUE,
  559. );
  560. }
  561. if (version_compare($editor['installed version'], '2.0.6', '>')) {
  562. $plugins['media'] = array(
  563. 'path' => $editor['library path'] . '/plugins/media',
  564. 'buttons' => array('media' => t('Media')),
  565. 'url' => 'http://www.tinymce.com/wiki.php/Plugin:media',
  566. 'internal' => TRUE,
  567. 'load' => TRUE,
  568. );
  569. $plugins['xhtmlxtras'] = array(
  570. 'path' => $editor['library path'] . '/plugins/xhtmlxtras',
  571. 'buttons' => array('cite' => t('Citation'), 'del' => t('Deleted'), 'abbr' => t('Abbreviation'), 'acronym' => t('Acronym'), 'ins' => t('Inserted'), 'attribs' => t('HTML attributes')),
  572. 'url' => 'http://www.tinymce.com/wiki.php/Plugin:xhtmlxtras',
  573. 'internal' => TRUE,
  574. 'load' => TRUE,
  575. );
  576. }
  577. if (version_compare($editor['installed version'], '3', '>')) {
  578. $plugins['bbcode'] = array(
  579. 'path' => $editor['library path'] . '/plugins/bbcode',
  580. 'extensions' => array('bbcode' => t('BBCode')),
  581. 'url' => 'http://www.tinymce.com/wiki.php/Plugin:bbcode',
  582. 'internal' => TRUE,
  583. 'load' => TRUE,
  584. );
  585. if (version_compare($editor['installed version'], '3.3', '<')) {
  586. $plugins['safari'] = array(
  587. 'path' => $editor['library path'] . '/plugins/safari',
  588. 'extensions' => array('safari' => t('Safari compatibility')),
  589. 'internal' => TRUE,
  590. 'load' => TRUE,
  591. );
  592. }
  593. }
  594. if (version_compare($editor['installed version'], '3.2.5', '>=')) {
  595. $plugins['autoresize'] = array(
  596. 'path' => $editor['library path'] . '/plugins/autoresize',
  597. 'extensions' => array('autoresize' => t('Auto resize')),
  598. 'url' => 'http://www.tinymce.com/wiki.php/Plugin:autoresize',
  599. 'internal' => TRUE,
  600. 'load' => TRUE,
  601. );
  602. }
  603. if (version_compare($editor['installed version'], '3.3', '>=')) {
  604. $plugins['advlist'] = array(
  605. 'path' => $editor['library path'] . '/plugins/advlist',
  606. 'extensions' => array('advlist' => t('Advanced list')),
  607. 'url' => 'http://www.tinymce.com/wiki.php/Plugin:advlist',
  608. 'internal' => TRUE,
  609. 'load' => TRUE,
  610. );
  611. }
  612. if (version_compare($editor['installed version'], '3.2.6', '>=')) {
  613. $plugins['wordcount'] = array(
  614. 'path' => $editor['library path'] . '/plugins/wordcount',
  615. 'extensions' => array('wordcount' => t('Word count')),
  616. 'internal' => TRUE,
  617. 'load' => TRUE,
  618. );
  619. }
  620. if (version_compare($editor['installed version'], '3.4.1', '>=')) {
  621. $plugins['lists'] = array(
  622. 'path' => $editor['library path'] . 'plugins/lists',
  623. 'extensions' => array('lists' => t('List normalizer')),
  624. 'url' => 'http://www.tinymce.com/wiki.php/Plugin:lists',
  625. 'internal' => TRUE,
  626. 'load' => TRUE,
  627. 'extended_valid_elements' => array(
  628. 'li[class|dir|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title|type|value]',
  629. 'ol[class|compact|dir|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|start|style|title|type]',
  630. 'ul[class|compact|dir|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title|type]',
  631. ),
  632. );
  633. }
  634. return $plugins;
  635. }