[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/plugins/editors/ -> tinymce.php (source)

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


Generated: Wed Mar 28 15:54:07 2012 Cross-referenced by PHPXref 0.7.1