PageRenderTime 45ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/plugins/editors/tinymce/tinymce.php

https://github.com/joebushi/joomla
PHP | 723 lines | 529 code | 80 blank | 114 comment | 75 complexity | c53d250284202e016cf4e47d9c416435 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
  1. <?php
  2. /**
  3. * @version $Id$
  4. * @package Joomla
  5. * @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
  6. * @license GNU General Public License version 2 or later; see LICENSE.txt
  7. */
  8. // Do not allow direct access
  9. defined('_JEXEC') or die('Restricted access');
  10. jimport('joomla.plugin.plugin');
  11. /**
  12. * TinyMCE Editor Plugin
  13. *
  14. * @package Joomla
  15. * @subpackage Editors
  16. * @since 1.5
  17. */
  18. class plgEditorTinymce extends JPlugin
  19. {
  20. /**
  21. * Initialises the Editor.
  22. *
  23. * @return string JavaScript Initialization string
  24. * @since 1.5
  25. */
  26. function onInit()
  27. {
  28. $app = JFactory::getApplication();
  29. $language = JFactory::getLanguage();
  30. $mode = (int) $this->params->get('mode',1);
  31. $theme = array('simple','advanced','advanced');
  32. $skin = $this->params->get('skin', '0');
  33. switch ($skin)
  34. {
  35. case '3':
  36. $skin = "skin : \"o2k7\", skin_variant : \"black\",";
  37. break;
  38. case '2':
  39. $skin = "skin : \"o2k7\", skin_variant : \"silver\",";
  40. break;
  41. case '1':
  42. $skin = "skin : \"o2k7\",";
  43. break;
  44. case '0':
  45. default:
  46. $skin = "skin : \"default\",";
  47. }
  48. $compressed = $this->params->def('compressed', 0);
  49. $cleanup_startup = $this->params->def('cleanup_startup', 0);
  50. $cleanup_save = $this->params->def('cleanup_save', 2);
  51. $entity_encoding = $this->params->def('entity_encoding', 'raw');
  52. if ($cleanup_startup) {
  53. $cleanup_startup = 'true';
  54. }
  55. else {
  56. $cleanup_startup = 'false';
  57. }
  58. switch ($cleanup_save)
  59. {
  60. case '0':
  61. // Never clean up on save.
  62. $cleanup = 'false';
  63. break;
  64. case '1':
  65. // Clean up front end edits only.
  66. if ($app->isadmin()) {
  67. $cleanup = 'false';
  68. }
  69. else {
  70. $cleanup = 'true';
  71. }
  72. break;
  73. default:
  74. // Always clean up on save
  75. $cleanup = 'true';
  76. }
  77. $langMode = $this->params->def('lang_mode', 0);
  78. $langPrefix = $this->params->def('lang_code', 'en');
  79. if ($langMode) {
  80. $langPrefix = substr($language->getTag(), 0, strpos($language->getTag(), '-'));
  81. }
  82. if ($language->isRTL()) {
  83. $text_direction = 'rtl';
  84. }
  85. else {
  86. $text_direction = 'ltr';
  87. }
  88. $use_content_css = $this->params->def('content_css', 1);
  89. $content_css_custom = $this->params->def('content_css_custom', '');
  90. /*
  91. * Lets get the default template for the site application
  92. */
  93. $db =& JFactory::getDBO();
  94. $query = 'SELECT template'
  95. . ' FROM #__template_styles'
  96. . ' WHERE client_id = 0'
  97. . ' AND home = 1'
  98. ;
  99. $db->setQuery( $query );
  100. $template = $db->loadResult();
  101. $content_css = '';
  102. $templates_path = JPATH_SITE.DS.'templates';
  103. // loading of css file for 'styles' dropdown
  104. if ( $content_css_custom )
  105. {
  106. // If URL, just pass it to $content_css
  107. if (strpos( $content_css_custom, 'http' ) !==false) {
  108. $content_css = 'content_css : "'. $content_css_custom .'",';
  109. // If it is not a URL, assume it is a file name in the current template folder
  110. } else {
  111. $content_css = 'content_css : "'. JURI::root() .'templates/'. $template . '/css/'. $content_css_custom .'",';
  112. // Issue warning notice if the file is not found (but pass name to $content_css anyway to avoid TinyMCE error
  113. if (!file_exists($templates_path.DS.$template.DS.'css'.DS.$content_css_custom)) {
  114. $msg = sprintf (JText::_('CUSTOMCSSFILENOTPRESENT'), $content_css_custom);
  115. JError::raiseNotice('SOME_ERROR_CODE', $msg);
  116. }
  117. }
  118. }
  119. else
  120. {
  121. // process when use_content_css is Yes and no custom file given
  122. if($use_content_css) {
  123. // first check templates folder for default template
  124. // if no editor.css file in templates folder, check system template folder
  125. if (!file_exists($templates_path.DS.$template.DS.'css'.DS.'editor.css')) {
  126. $template = 'system';
  127. // if no editor.css file in system folder, show alert
  128. if (!file_exists($templates_path.DS.'system'.DS.'css'.DS.'editor.css'))
  129. {
  130. JError::raiseNotice('SOME_ERROR_CODE', JText::_('TEMPLATECSSFILENOTPRESENT'));
  131. } else {
  132. $content_css = 'content_css : "' . JURI::root() .'templates/system/css/editor.css",';
  133. }
  134. } else {
  135. $content_css = 'content_css : "' . JURI::root() .'templates/'. $template . '/css/editor.css",';
  136. }
  137. }
  138. }
  139. $relative_urls = $this->params->def('relative_urls', '1');
  140. if ($relative_urls) { // relative
  141. $relative_urls = "true";
  142. } else { // absolute
  143. $relative_urls = "false";
  144. }
  145. $newlines = $this->params->def('newlines', 0);
  146. if ($newlines) { // br
  147. $forcenewline = "force_br_newlines : \"true\", force_p_newlines : \"false\", forced_root_block : '',";
  148. } else { // p
  149. $forcenewline = "force_br_newlines : \"false\", force_p_newlines : \"true\", forced_root_block : 'p',";
  150. }
  151. $invalid_elements = $this->params->def('invalid_elements', 'script,applet,iframe');
  152. $extended_elements = $this->params->def('extended_elements', '');
  153. // theme_advanced_* settings
  154. $toolbar = $this->params->def('toolbar', 'top');
  155. $toolbar_align = $this->params->def('toolbar_align', 'left');
  156. $html_height = $this->params->def('html_height', '550');
  157. $html_width = $this->params->def('html_width', '750');
  158. $element_path = '';
  159. if ($this->params->get('element_path', 1)) {
  160. $element_path = "theme_advanced_statusbar_location : \"bottom\", theme_advanced_path : true";
  161. } else {
  162. $element_path = "theme_advanced_statusbar_location : \"none\", theme_advanced_path : false";
  163. }
  164. $buttons1_add_before = $buttons1_add = array();
  165. $buttons2_add_before = $buttons2_add = array();
  166. $buttons3_add_before = $buttons3_add = array();
  167. $buttons4 = array();
  168. $plugins = array();
  169. if ($extended_elements != "") {
  170. $elements = explode(',', $extended_elements);
  171. }
  172. //Initial values for buttons
  173. array_push($buttons4,'cut','copy','paste');
  174. //array_push($buttons4,'|');
  175. // Plugins
  176. // fonts
  177. $fonts = $this->params->def( 'fonts', 1 );
  178. if ($fonts) {
  179. $buttons1_add[] = 'fontselect,fontsizeselect';
  180. }
  181. // paste
  182. $paste = $this->params->def('paste', 1);
  183. if ($paste) {
  184. $plugins[] = 'paste';
  185. $buttons4[] = 'pastetext';
  186. $buttons4[] = 'pasteword';
  187. $buttons4[] = 'selectall,|';
  188. }
  189. // search & replace
  190. $searchreplace = $this->params->def('searchreplace', 1);
  191. if ($searchreplace) {
  192. $plugins[] = 'searchreplace';
  193. $buttons2_add_before[] = 'search,replace,|';
  194. }
  195. // insert date and/or time plugin
  196. $insertdate = $this->params->def('insertdate', 1);
  197. $format_date = $this->params->def('format_date', '%Y-%m-%d');
  198. $inserttime = $this->params->def('inserttime', 1);
  199. $format_time = $this->params->def('format_time', '%H:%M:%S');
  200. if ($insertdate or $inserttime) {
  201. $plugins[] = 'insertdatetime';
  202. if ($insertdate) {
  203. $buttons2_add[] = 'insertdate';
  204. }
  205. if ($inserttime) {
  206. $buttons2_add[] = 'inserttime';
  207. }
  208. }
  209. // colors
  210. $colors = $this->params->def('colors', 1);
  211. if ($colors) {
  212. $buttons2_add[] = 'forecolor,backcolor';
  213. }
  214. // table
  215. $table = $this->params->def('table', 1);
  216. if ($table) {
  217. $plugins[] = 'table';
  218. $buttons3_add_before[] = 'tablecontrols';
  219. }
  220. // emotions
  221. $smilies = $this->params->def('smilies', 1);
  222. if ($smilies) {
  223. $plugins[] = 'emotions';
  224. $buttons3_add[] = 'emotions';
  225. }
  226. //media plugin
  227. $media = $this->params->def('media', 1);
  228. if ($media) {
  229. $plugins[] = 'media';
  230. $buttons3_add[] = 'media';
  231. }
  232. // horizontal line
  233. $hr = $this->params->def('hr', 1);
  234. if ($hr) {
  235. $plugins[] = 'advhr';
  236. $elements[] = 'hr[id|title|alt|class|width|size|noshade|style]';
  237. $buttons3_add[] = 'advhr';
  238. } else {
  239. $elements[] = 'hr[id|class|title|alt]';
  240. }
  241. // rtl/ltr buttons
  242. $directionality = $this->params->def('directionality', 1);
  243. if ($directionality) {
  244. $plugins[] = 'directionality';
  245. $buttons3_add[] = 'ltr,rtl';
  246. }
  247. // fullscreen
  248. $fullscreen = $this->params->def('fullscreen', 1);
  249. if ($fullscreen) {
  250. $plugins[] = 'fullscreen';
  251. $buttons2_add[] = 'fullscreen';
  252. }
  253. // layer
  254. $layer = $this->params->def('layer', 1);
  255. if ($layer) {
  256. $plugins[] = 'layer';
  257. $buttons4[] = 'insertlayer';
  258. $buttons4[] = 'moveforward';
  259. $buttons4[] = 'movebackward';
  260. $buttons4[] = 'absolute';
  261. }
  262. // style
  263. $style = $this->params->def('style', 1);
  264. if ($style) {
  265. $plugins[] = 'style';
  266. $buttons4[] = 'styleprops';
  267. }
  268. // XHTMLxtras
  269. $xhtmlxtras = $this->params->def('xhtmlxtras', 1);
  270. if ($xhtmlxtras) {
  271. $plugins[] = 'xhtmlxtras';
  272. $buttons4[] = 'cite,abbr,acronym,ins,del,attribs';
  273. }
  274. // visualchars
  275. $visualchars = $this->params->def('visualchars', 1);
  276. if ($visualchars) {
  277. $plugins[] = 'visualchars';
  278. $buttons4[] = 'visualchars';
  279. }
  280. // non-breaking
  281. $nonbreaking = $this->params->def('nonbreaking', 1);
  282. if ($nonbreaking) {
  283. $plugins[] = 'nonbreaking';
  284. $buttons4[] = 'nonbreaking';
  285. }
  286. // blockquote
  287. $blockquote = $this->params->def( 'blockquote', 1 );
  288. if ( $blockquote ) {
  289. $plugins[] = 'blockquote';
  290. $buttons4[] = 'blockquote';
  291. }
  292. // wordcount
  293. $wordcount = $this->params->def( 'wordcount', 1 );
  294. if ( $wordcount ) {
  295. $plugins[] = 'wordcount';
  296. }
  297. // template
  298. $template = $this->params->def('template', 1);
  299. if ($template) {
  300. $plugins[] = 'template';
  301. $buttons4[] = 'template';
  302. }
  303. // advimage
  304. $advimage = $this->params->def('advimage', 1);
  305. if ($advimage) {
  306. $plugins[] = 'advimage';
  307. $elements[] = 'img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name|style]';
  308. }
  309. // advlink
  310. $advlink = $this->params->def('advlink', 1);
  311. if ($advlink) {
  312. $plugins[] = 'advlink';
  313. $elements[] = 'a[id|class|name|href|target|title|onclick|rel|style]';
  314. }
  315. // autosave
  316. $autosave = $this->params->def('autosave', 1);
  317. if ($autosave) {
  318. $plugins[] = 'autosave';
  319. }
  320. // context menu
  321. $contextmenu = $this->params->def('contextmenu', 1);
  322. if ($contextmenu) {
  323. $plugins[] = 'contextmenu';
  324. }
  325. // inline popups
  326. $inlinepopups = $this->params->def('inlinepopups', 1);
  327. if ($inlinepopups) {
  328. $plugins[] = 'inlinepopups';
  329. $dialog_type = "dialog_type : \"modal\",";
  330. } else {
  331. $dialog_type = "";
  332. }
  333. // Safari compatibility
  334. $safari = $this->params->def('safari', 0);
  335. if ($safari) {
  336. $plugins[] = 'safari';
  337. }
  338. $custom_plugin = $this->params->def('custom_plugin', '');
  339. if ($custom_plugin != "") {
  340. $plugins[] = $custom_plugin;
  341. }
  342. $custom_button = $this->params->def('custom_button', '');
  343. if ($custom_button != "") {
  344. $buttons4[] = $custom_button;
  345. }
  346. // Prepare config variables
  347. $buttons1_add_before = implode(',', $buttons1_add_before);
  348. $buttons2_add_before = implode(',', $buttons2_add_before);
  349. $buttons3_add_before = implode(',', $buttons3_add_before);
  350. $buttons1_add = implode(',', $buttons1_add);
  351. $buttons2_add = implode(',', $buttons2_add);
  352. $buttons3_add = implode(',', $buttons3_add);
  353. $buttons4 = implode(',', $buttons4);
  354. $plugins = implode(',', $plugins);
  355. $elements = implode(',', $elements);
  356. switch($mode) {
  357. case 0: /* Simple mode*/
  358. if ($compressed) {
  359. $load = "\t<script type=\"text/javascript\" src=\"".
  360. JURI::root().
  361. "plugins/editors/tinymce/tinymce/jscripts/tiny_mce/tiny_mce_gzip.js\"></script>\n";
  362. $load .= "\t<script type=\"text/javascript\">
  363. tinyMCE_GZ.init({
  364. themes : \"$theme[$mode]\",
  365. languages : \"". $langPrefix . "\"
  366. });
  367. </script>";
  368. } else {
  369. $load = "\t<script type=\"text/javascript\" src=\"".
  370. JURI::root().
  371. "plugins/editors/tinymce/tinymce/jscripts/tiny_mce/tiny_mce.js\"></script>\n";
  372. }
  373. $return = $load .
  374. "\t<script type=\"text/javascript\">
  375. tinyMCE.init({
  376. // General
  377. directionality: \"$text_direction\",
  378. editor_selector : \"mce_editable\",
  379. language : \"". $langPrefix . "\",
  380. mode : \"specific_textareas\",
  381. $skin
  382. theme : \"$theme[$mode]\",
  383. // Cleanup/Output
  384. inline_styles : true,
  385. gecko_spellcheck : true,
  386. cleanup : $cleanup,
  387. cleanup_on_startup : $cleanup_startup,
  388. entity_encoding : \"$entity_encoding\",
  389. $forcenewline
  390. // URL
  391. relative_urls : $relative_urls,
  392. remove_script_host : false,
  393. // Layout
  394. $content_css
  395. document_base_url : \"". JURI::root() ."\",
  396. });
  397. </script>";
  398. break;
  399. case 1: /* Advanced mode*/
  400. if ($compressed) {
  401. $load = "\t<script type=\"text/javascript\" src=\"".
  402. JURI::root().
  403. "plugins/editors/tinymce/tinymce/jscripts/tiny_mce/tiny_mce_gzip.js\"></script>\n";
  404. $load .= "\t<script type=\"text/javascript\">
  405. tinyMCE_GZ.init({
  406. themes : \"$theme[$mode]\",
  407. languages : \"". $langPrefix . "\"
  408. });
  409. </script>";
  410. } else {
  411. $load = "\t<script type=\"text/javascript\" src=\"".
  412. JURI::root().
  413. "plugins/editors/tinymce/tinymce/jscripts/tiny_mce/tiny_mce.js\"></script>\n";
  414. }
  415. $return = $load .
  416. "\t<script type=\"text/javascript\">
  417. tinyMCE.init({
  418. // General
  419. directionality: \"$text_direction\",
  420. editor_selector : \"mce_editable\",
  421. language : \"". $langPrefix . "\",
  422. mode : \"specific_textareas\",
  423. $skin
  424. theme : \"$theme[$mode]\",
  425. // Cleanup/Output
  426. inline_styles : true,
  427. gecko_spellcheck : true,
  428. cleanup : $cleanup,
  429. cleanup_on_startup : $cleanup_startup,
  430. entity_encoding : \"$entity_encoding\",
  431. extended_valid_elements : \"$elements\",
  432. $forcenewline
  433. invalid_elements : \"$invalid_elements\",
  434. // URL
  435. relative_urls : $relative_urls,
  436. remove_script_host : false,
  437. document_base_url : \"". JURI::root() ."\",
  438. // Layout
  439. $content_css
  440. // Advanced theme
  441. theme_advanced_toolbar_location : \"$toolbar\",
  442. theme_advanced_toolbar_align : \"$toolbar_align\",
  443. theme_advanced_source_editor_height : \"$html_height\",
  444. theme_advanced_source_editor_width : \"$html_width\",
  445. $element_path
  446. });
  447. </script>";
  448. break;
  449. case 2: /* Extended mode*/
  450. if ($compressed) {
  451. $load = "\t<script type=\"text/javascript\" src=\"".
  452. JURI::root().
  453. "plugins/editors/tinymce/tinymce/jscripts/tiny_mce/tiny_mce_gzip.js\"></script>\n";
  454. $load .= "\t<script type=\"text/javascript\">
  455. tinyMCE_GZ.init({
  456. themes : \"$theme[$mode]\",
  457. plugins : \"$plugins\",
  458. languages : \"". $langPrefix . "\"
  459. });
  460. </script>";
  461. } else {
  462. $load = "\t<script type=\"text/javascript\" src=\"".
  463. JURI::root().
  464. "plugins/editors/tinymce/tinymce/jscripts/tiny_mce/tiny_mce.js\"></script>\n";
  465. }
  466. $return = $load .
  467. "\t<script type=\"text/javascript\">
  468. tinyMCE.init({
  469. // General
  470. $dialog_type
  471. directionality: \"$text_direction\",
  472. editor_selector : \"mce_editable\",
  473. language : \"". $langPrefix . "\",
  474. mode : \"specific_textareas\",
  475. plugins : \"$plugins\",
  476. $skin
  477. theme : \"$theme[$mode]\",
  478. // Cleanup/Output
  479. inline_styles : true,
  480. gecko_spellcheck : true,
  481. cleanup : $cleanup,
  482. cleanup_on_startup : $cleanup_startup,
  483. entity_encoding : \"$entity_encoding\",
  484. extended_valid_elements : \"$elements\",
  485. $forcenewline
  486. invalid_elements : \"$invalid_elements\",
  487. // URL
  488. relative_urls : $relative_urls,
  489. remove_script_host : false,
  490. document_base_url : \"". JURI::root() ."\",
  491. //Templates
  492. template_external_list_url : \"". JURI::root() ."plugins/editors/tinymce/tinymce/templates/template_list.js\",
  493. // Layout
  494. $content_css
  495. // Advanced theme
  496. theme_advanced_toolbar_location : \"$toolbar\",
  497. theme_advanced_toolbar_align : \"$toolbar_align\",
  498. theme_advanced_source_editor_height : \"$html_height\",
  499. theme_advanced_source_editor_width : \"$html_width\",
  500. $element_path,
  501. theme_advanced_buttons1_add_before : \"$buttons1_add_before\",
  502. theme_advanced_buttons2_add_before : \"$buttons2_add_before\",
  503. theme_advanced_buttons3_add_before : \"$buttons3_add_before\",
  504. theme_advanced_buttons1_add : \"$buttons1_add\",
  505. theme_advanced_buttons2_add : \"$buttons2_add\",
  506. theme_advanced_buttons3_add : \"$buttons3_add\",
  507. theme_advanced_buttons4 : \"$buttons4\",
  508. plugin_insertdate_dateFormat : \"$format_date\",
  509. plugin_insertdate_timeFormat : \"$format_time\",
  510. fullscreen_settings : {
  511. theme_advanced_path_location : \"top\"
  512. }
  513. });
  514. </script>";
  515. break;
  516. }
  517. return $return;
  518. }
  519. /**
  520. * TinyMCE WYSIWYG Editor - get the editor content
  521. *
  522. * @param string The name of the editor
  523. */
  524. function onGetContent( $editor ) {
  525. return 'tinyMCE.get(\''.$editor.'\').getContent();';
  526. }
  527. /**
  528. * TinyMCE WYSIWYG Editor - set the editor content
  529. *
  530. * @param string The name of the editor
  531. */
  532. function onSetContent($editor, $html) {
  533. return 'tinyMCE.get(\''.$editor.'\').setContent('.$html.');';
  534. }
  535. /**
  536. * TinyMCE WYSIWYG Editor - copy editor content to form field
  537. *
  538. * @param string The name of the editor
  539. */
  540. function onSave($editor) {
  541. return 'if (tinyMCE.get("'.$editor.'").isHidden()) {tinyMCE.get("'.$editor.'").show()}; tinyMCE.get("'.$editor.'").save();';
  542. }
  543. function onGetInsertMethod($name)
  544. {
  545. $doc =& JFactory::getDocument();
  546. $js= "
  547. function isBrowserIE() {
  548. return navigator.appName==\"Microsoft Internet Explorer\";
  549. }
  550. function jInsertEditorText( text, editor ) {
  551. if (isBrowserIE()) {
  552. if (window.parent.tinyMCE) {
  553. window.parent.tinyMCE.selectedInstance.selection.moveToBookmark(window.parent.global_ie_bookmark);
  554. }
  555. }
  556. tinyMCE.execInstanceCommand(editor, 'mceInsertContent',false,text);
  557. }
  558. var global_ie_bookmark = false;
  559. function IeCursorFix() {
  560. if (isBrowserIE()) {
  561. tinyMCE.execCommand('mceInsertContent', false, '');
  562. global_ie_bookmark = tinyMCE.activeEditor.selection.getBookmark(false);
  563. }
  564. return true;
  565. }";
  566. $doc->addScriptDeclaration($js);
  567. return true;
  568. }
  569. /**
  570. * Display the editor area.
  571. *
  572. * @param string The name of the editor area.
  573. * @param string The content of the field.
  574. * @param string The width of the editor area.
  575. * @param string The height of the editor area.
  576. * @param int The number of columns for the editor area.
  577. * @param int The number of rows for the editor area.
  578. * @param boolean True and the editor buttons will be displayed.
  579. * @param string An optional ID for the textarea (note: since 1.6). If not supplied the name is used.
  580. */
  581. function onDisplay($name, $content, $width, $height, $col, $row, $buttons = true, $id = null)
  582. {
  583. if (empty($id)) {
  584. $id = $name;
  585. }
  586. // Only add "px" to width and height if they are not given as a percentage
  587. if (is_numeric($width)) {
  588. $width .= 'px';
  589. }
  590. if (is_numeric($height)) {
  591. $height .= 'px';
  592. }
  593. $editor = "<textarea name=\"$name\" id=\"$id\" cols=\"$col\" rows=\"$row\" style=\"width:{$width}; height:{$height};\" class=\"mce_editable\">$content</textarea>\n" .
  594. $this->_displayButtons($id, $buttons) .
  595. $this->_toogleButton($id);
  596. return $editor;
  597. }
  598. function _displayButtons($name, $buttons)
  599. {
  600. // Load modal popup behavior
  601. JHTML::_('behavior.modal', 'a.modal-button');
  602. $args['name'] = $name;
  603. $args['event'] = 'onGetInsertMethod';
  604. $return = '';
  605. $results[] = $this->update($args);
  606. foreach ($results as $result) {
  607. if (is_string($result) && trim($result)) {
  608. $return .= $result;
  609. }
  610. }
  611. if(!empty($buttons))
  612. {
  613. $results = $this->_subject->getButtons($name, $buttons);
  614. /*
  615. * This will allow plugins to attach buttons or change the behavior on the fly using AJAX
  616. */
  617. $return .= "\n<div id=\"editor-xtd-buttons\">\n";
  618. foreach ($results as $button)
  619. {
  620. /*
  621. * Results should be an object
  622. */
  623. if ( $button->get('name') )
  624. {
  625. $modal = ($button->get('modal')) ? 'class="modal-button"' : null;
  626. $href = ($button->get('link')) ? 'href="'.JURI::base().$button->get('link').'"' : null;
  627. $onclick = ($button->get('onclick')) ? 'onclick="'.$button->get('onclick').'"' : 'onclick="IeCursorFix(); return false;"';
  628. $return .= "<div class=\"button2-left\"><div class=\"".$button->get('name')."\"><a ".$modal." title=\"".$button->get('text')."\" ".$href." ".$onclick." rel=\"".$button->get('options')."\">".$button->get('text')."</a></div></div>\n";
  629. }
  630. }
  631. $return .= "</div>\n";
  632. }
  633. return $return;
  634. }
  635. function _toogleButton($name)
  636. {
  637. $return = '';
  638. $return .= "\n<div class=\"toggle-editor\">\n";
  639. $return .= "<div class=\"button2-left\"><div class=\"blank\"><a href=\"#\" onclick=\"javascript:tinyMCE.execCommand('mceToggleEditor', false, '$name');return false;\" title=\"Toggle editor\">Toggle editor</a></div></div>";
  640. $return .= "</div>\n";
  641. return $return;
  642. }
  643. }