Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
spell_checker.inc
1 <?php
18 global $ROOT_PATH;
19 include_once($ROOT_PATH.'wysiwyg_plugin.inc');
20 
33 {
34 
35 
42  function spell_checker(&$wysiwyg)
43  {
44  wysiwyg_plugin::wysiwyg_plugin($wysiwyg);
45  if (function_exists('pspell_suggest')) {
46  $this->_add_button('spellchecker','spellchecker','Check Spelling','false','54');
47  }
48 
49  }//end constructor
50 
51 
69  function _add_button($id, $cmd, $tooltip, $textmode, $position, $context='')
70  {
71  // checks for the required PEAR package before adding the plugin to the editor
72  // use include_once so that it will still run if the package is not installed
73  @include_once('XML/XML_HTMLSax.php');
74 
75  if (defined('XML_HTMLSAX')) {
76  parent::_add_button($id, $cmd, $tooltip, $textmode, $position, $context='');
77  } else {
78  trigger_localised_error('CORE0252', E_USER_WARNING, '"Spell Checker"', 'Required PEAR Package "XML_HTMLSax" not installed');
79  }
80 
81  }//end _add_button()
82 
83 
92  function paint_generic()
93  {
94  ?>
95  <script type="text/javascript" language="Javascript">
96  // Called when the user clicks on "InsertImage" button
97  HTMLArea.prototype._spellChecker = function() {
98  var editor = this; // for nested functions
99 
100  // set focus in case we havnt selected anything
101  if (HTMLArea.is_ie) {
102  this._docContent.focus();
103  } else if (HTMLArea.ie_gecko) {
104  this.focusEditor();
105  }
106 
107  // disable the toolbar
108  this._tmp['disable_toolbar'] = true;
109  this.updateToolbar(false);
110 
111  editor_<?php echo $this->wysiwyg->name?>._object = this;
112 
113  var popup_height = 410;
114 
115  // A bit more breathing room for Safari
116  if (HTMLArea.is_safari) popup_height += 15;
117 
118  this._popupDialog("spellChecker", "<?php echo $this->get_popup_href('spell_checker_popup.php')?>?editor_name=<?php echo $this->wysiwyg->name?>", 605, popup_height, false, function(param) {
119  if (!param) {
120  // user must have pressed Cancel
121  return false;
122  }
123 
124  editor.setHTML(param["html"]);
125 
126  }, null);
127  };
128  </script>
129  <?php
130 
131  }//end paint_generic()
132 
133 
141  {
142  ?>
143  case "spellchecker":
144  this._spellChecker();
145  return;
146  break;
147  <?php
148 
149  }//end print_plugin_button_click()
150 
151 
161  public static function check_usable()
162  {
163  if (function_exists('pspell_suggest')) return TRUE;
164  return translate('wysiwyg_pspell_not_installed');
165 
166  }//end check_usable()
167 
168 
169 }//end class
170 
171 ?>