Skip to content

Commit

Permalink
MDL-34674 use browser built-in spell checking in all browsers except …
Browse files Browse the repository at this point in the history
…< IE10
  • Loading branch information
skodak committed Apr 12, 2013
1 parent b3661ab commit 0ac9708
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 11 deletions.
2 changes: 1 addition & 1 deletion error/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
?>
<p><?php echo get_string('pleasereport', 'error'); ?>
<p><form action="<?php echo $CFG->wwwroot ?>/error/index.php" method="post">
<textarea rows="3" cols="50" name="text" id="text"></textarea><br />
<textarea rows="3" cols="50" name="text" id="text" spellcheck="true"></textarea><br />
<input type="hidden" name="referer" value="<?php p($httpreferer) ?>">
<input type="hidden" name="requested" value="<?php p($requesturi) ?>">
<input type="submit" value="<?php echo get_string('sendmessage', 'error'); ?>">
Expand Down
4 changes: 2 additions & 2 deletions lib/adminlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1920,7 +1920,7 @@ public function output_html($data, $query='') {
}

return format_admin_setting($this, $this->visiblename,
'<div class="form-textarea" ><textarea rows="'. $this->rows .'" cols="'. $this->cols .'" id="'. $this->get_id() .'" name="'. $this->get_full_name() .'">'. s($data) .'</textarea></div>',
'<div class="form-textarea" ><textarea rows="'. $this->rows .'" cols="'. $this->cols .'" id="'. $this->get_id() .'" name="'. $this->get_full_name() .'" spellcheck="true">'. s($data) .'</textarea></div>',
$this->description, true, '', $defaultinfo, $query);
}
}
Expand Down Expand Up @@ -1966,7 +1966,7 @@ public function output_html($data, $query='') {
$editor->use_editor($this->get_id(), array('noclean'=>true));

return format_admin_setting($this, $this->visiblename,
'<div class="form-textarea"><textarea rows="'. $this->rows .'" cols="'. $this->cols .'" id="'. $this->get_id() .'" name="'. $this->get_full_name() .'">'. s($data) .'</textarea></div>',
'<div class="form-textarea"><textarea rows="'. $this->rows .'" cols="'. $this->cols .'" id="'. $this->get_id() .'" name="'. $this->get_full_name() .'" spellcheck="true">'. s($data) .'</textarea></div>',
$this->description, true, '', $defaultinfo, $query);
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/deprecatedlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1909,7 +1909,7 @@ function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $v
$editorclass = '';
}

$str .= "\n".'<textarea class="form-textarea" id="'. $id .'" name="'. $name .'" rows="'. $rows .'" cols="'. $cols .'">'."\n";
$str .= "\n".'<textarea class="form-textarea" id="'. $id .'" name="'. $name .'" rows="'. $rows .'" cols="'. $cols .'" spellcheck="true">'."\n";
if ($usehtmleditor) {
$str .= htmlspecialchars($value); // needed for editing of cleaned text!
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

$string['pluginname'] = 'Check spelling';
$string['pluginname'] = 'Legacy spell checker';

/* This plugin abuses strings from the standard TinyMCE spellchecker plugin, there is no need to duplicate them here. */
13 changes: 13 additions & 0 deletions lib/editor/tinymce/plugins/spellchecker/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ protected function update_init_params(array &$params, context $context,
array $options = null) {
global $CFG;

if (!$this->is_legacy_browser()) {
return;
}

// Check at least one language is supported.
$spelllanguagelist = $this->get_config('spelllanguagelist', '');
if ($spelllanguagelist !== '') {
Expand All @@ -48,4 +52,13 @@ protected function update_init_params(array &$params, context $context,
$params['spellchecker_languages'] = $spelllanguagelist;
}
}

protected function is_legacy_browser() {
// IE8 and IE9 are the only supported browsers that do not have spellchecker.
if (check_browser_version('MSIE', 5) and !check_browser_version('MSIE', 10)) {
return true;
}
// The rest of browsers supports spellchecking or is horribly outdated and we do not care...
return false;
}
}
2 changes: 1 addition & 1 deletion lib/form/editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ function toHtml() {
if (!is_null($this->getAttribute('onblur')) && !is_null($this->getAttribute('onchange'))) {
$editorrules = ' onblur="'.htmlspecialchars($this->getAttribute('onblur')).'" onchange="'.htmlspecialchars($this->getAttribute('onchange')).'"';
}
$str .= '<div><textarea id="'.$id.'" name="'.$elname.'[text]" rows="'.$rows.'" cols="'.$cols.'"';
$str .= '<div><textarea id="'.$id.'" name="'.$elname.'[text]" rows="'.$rows.'" cols="'.$cols.'" spellcheck="true"';
$classes = array();
if (isset($this->_options['collapsed']) && $this->_options['collapsed']) {
$this->_options['collapsible'] = 1;
Expand Down
4 changes: 2 additions & 2 deletions mod/assignment/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1521,7 +1521,7 @@ function display_submissions($message='') {
} else if ($quickgrade) {
$comment = '<div id="com'.$auser->id.'">'
. '<textarea tabindex="'.$tabindex++.'" name="submissioncomment['.$auser->id.']" id="submissioncomment'
. $auser->id.'" rows="2" cols="20">'.($auser->submissioncomment).'</textarea></div>';
. $auser->id.'" rows="2" cols="20" spellcheck="true">'.($auser->submissioncomment).'</textarea></div>';
} else {
$comment = '<div id="com'.$auser->id.'">'.shorten_text(strip_tags($auser->submissioncomment),15).'</div>';
}
Expand Down Expand Up @@ -1549,7 +1549,7 @@ function display_submissions($message='') {
} else if ($quickgrade) {
$comment = '<div id="com'.$auser->id.'">'
. '<textarea tabindex="'.$tabindex++.'" name="submissioncomment['.$auser->id.']" id="submissioncomment'
. $auser->id.'" rows="2" cols="20">'.($auser->submissioncomment).'</textarea></div>';
. $auser->id.'" rows="2" cols="20" spellcheck="true">'.($auser->submissioncomment).'</textarea></div>';
} else {
$comment = '<div id="com'.$auser->id.'">&nbsp;</div>';
}
Expand Down
2 changes: 1 addition & 1 deletion mod/data/field/textarea/field.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function display_add_field($recordid=0) {
}
$editor->use_editor($field, $options, $fpoptions);
$str .= '<input type="hidden" name="'.$field.'_itemid" value="'.$draftitemid.'" />';
$str .= '<div><textarea id="'.$field.'" name="'.$field.'" rows="'.$this->field->param3.'" cols="'.$this->field->param2.'">'.s($text).'</textarea></div>';
$str .= '<div><textarea id="'.$field.'" name="'.$field.'" rows="'.$this->field->param3.'" cols="'.$this->field->param2.'" spellcheck="true">'.s($text).'</textarea></div>';
$str .= '<div><label class="accesshide" for="' . $field . '_content1">' . get_string('format') . '</label>';
$str .= '<select id="' . $field . '_content1" name="'.$field.'_content1">';
foreach ($formats as $key=>$desc) {
Expand Down
2 changes: 1 addition & 1 deletion user/addnote.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
$checkbox .= html_writer::select($state_names, 'states[' . $k . ']', empty($states[$k]) ? NOTES_STATE_PUBLIC : $states[$k], false, array('id' => 'menustates'));
$table->data[] = array(
'<input type="hidden" name="userid['.$k.']" value="'.$v.'" />'. fullname($user, true),
'<textarea name="contents['. $k . ']" rows="2" cols="40">' . strip_tags(@$contents[$k]) . '</textarea>',
'<textarea name="contents['. $k . ']" rows="2" cols="40" spellcheck="true">' . strip_tags(@$contents[$k]) . '</textarea>',
$checkbox
);
}
Expand Down
2 changes: 1 addition & 1 deletion user/groupaddnote.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
echo '</p>';

echo '<p>' . get_string('content', 'notes');
echo '<br /><textarea name="content" rows="5" cols="50">' . strip_tags(@$content) . '</textarea></p>';
echo '<br /><textarea name="content" rows="5" cols="50" spellcheck="true">' . strip_tags(@$content) . '</textarea></p>';

echo '<p>';
echo html_writer::label(get_string('publishstate', 'notes'), 'menustate');
Expand Down

0 comments on commit 0ac9708

Please sign in to comment.