From bf5fafb2e0dfd7a53352b6a4fec1adead7b9ee75 Mon Sep 17 00:00:00 2001 From: Stanislas Rolland Date: Tue, 19 Aug 2008 02:06:47 +0000 Subject: [PATCH] Follow-up for feature #4686: htmlArea RTE Spell Checker: add u modifier to preg_* operations git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@4001 709f56b5-9817-0410-a4d7-c38de5d9e867 --- ChangeLog | 4 ++++ typo3/sysext/rtehtmlarea/ChangeLog | 4 ++++ .../class.tx_rtehtmlarea_spellchecker.php | 9 ++++++--- .../rtehtmlarea/pi1/class.tx_rtehtmlarea_pi1.php | 16 ++++++++-------- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index efeed6d4536..ffc26f654dc 100755 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2008-08-18 Stanislas Rolland + + * Follow-up for feature #4686: htmlArea RTE Spell Checker: add u modifier to preg_* operations + 2008-08-18 Dmitry Dulepov * Fixed bug #8627: Translation of the belog-module (thanks to Christopher Stelmaszyk and Christian Kuhn) diff --git a/typo3/sysext/rtehtmlarea/ChangeLog b/typo3/sysext/rtehtmlarea/ChangeLog index deaad14e1aa..278e74b267f 100644 --- a/typo3/sysext/rtehtmlarea/ChangeLog +++ b/typo3/sysext/rtehtmlarea/ChangeLog @@ -1,3 +1,7 @@ +2008-08-18 Stanislas Rolland + + * Follow-up for feature #4686: htmlArea RTE Spell Checker: add u modifier to preg_* operations + 2008-08-16 Stanislas Rolland * Added feature #9109: Enable altMountPoints feature in RTE element browser (Thanks to Steffen Kamper) diff --git a/typo3/sysext/rtehtmlarea/extensions/SpellChecker/class.tx_rtehtmlarea_spellchecker.php b/typo3/sysext/rtehtmlarea/extensions/SpellChecker/class.tx_rtehtmlarea_spellchecker.php index a6e93a86164..626da9530ff 100644 --- a/typo3/sysext/rtehtmlarea/extensions/SpellChecker/class.tx_rtehtmlarea_spellchecker.php +++ b/typo3/sysext/rtehtmlarea/extensions/SpellChecker/class.tx_rtehtmlarea_spellchecker.php @@ -2,7 +2,7 @@ /*************************************************************** * Copyright notice * -* (c) 2008 Stanislas Rolland +* (c) 2008 Stanislas Rolland * All rights reserved * * This script is part of the Typo3 project. The Typo3 project is @@ -24,7 +24,7 @@ /** * Spell Checker plugin for htmlArea RTE * - * @author Stanislas Rolland + * @author Stanislas Rolland * * TYPO3 SVN ID: $Id$ * @@ -52,7 +52,10 @@ class tx_rtehtmlarea_spellchecker extends tx_rtehtmlareaapi { public function main($parentObject) { global $TYPO3_CONF_VARS; - return parent::main($parentObject) && t3lib_extMgm::isLoaded('static_info_tables') && !in_array($this->htmlAreaRTE->language, t3lib_div::trimExplode(',', $TYPO3_CONF_VARS['EXTCONF'][$this->htmlAreaRTE->ID]['noSpellCheckLanguages'])); + return parent::main($parentObject) + && t3lib_extMgm::isLoaded('static_info_tables') + && !in_array($this->htmlAreaRTE->language, t3lib_div::trimExplode(',', $TYPO3_CONF_VARS['EXTCONF'][$this->htmlAreaRTE->ID]['noSpellCheckLanguages'])) + && ($this->htmlAreaRTE->contentCharset == 'iso-8859-1' || $this->htmlAreaRTE->contentCharset == 'utf-8'); } /** diff --git a/typo3/sysext/rtehtmlarea/pi1/class.tx_rtehtmlarea_pi1.php b/typo3/sysext/rtehtmlarea/pi1/class.tx_rtehtmlarea_pi1.php index c3ceb0e3168..ddb2fef3e20 100644 --- a/typo3/sysext/rtehtmlarea/pi1/class.tx_rtehtmlarea_pi1.php +++ b/typo3/sysext/rtehtmlarea/pi1/class.tx_rtehtmlarea_pi1.php @@ -2,7 +2,7 @@ /*************************************************************** * Copyright notice * -* (c) 2003-2008 Stanislas Rolland +* (c) 2003-2008 Stanislas Rolland * All rights reserved * * This script is part of the Typo3 project. The Typo3 project is @@ -24,7 +24,7 @@ /** * Spell checking plugin 'tx_rtehtmlarea_pi1' for the htmlArea RTE extension. * - * @author Stanislas Rolland + * @author Stanislas Rolland * * TYPO3 SVN ID: $Id$ * @@ -268,7 +268,7 @@ class tx_rtehtmlarea_pi1 extends tslib_pibase { if (!xml_set_element_handler($parser, 'startHandler', 'endHandler')) echo('Bad xml handler setting'); if (!xml_set_character_data_handler($parser, 'collectDataHandler')) echo('Bad xml handler setting'); if (!xml_set_default_handler($parser, 'defaultHandler')) echo('Bad xml handler setting'); - if (!xml_parse($parser,'parserCharset . '"?> ' . str_replace(' ', ' ', $content) . ' ')) echo('Bad parsing'); + if (!xml_parse($parser,'parserCharset . '"?> ' . preg_replace('/ /'.(($this->parserCharset == 'utf-8')?'u':''), ' ', $content) . ' ')) echo('Bad parsing'); if (xml_get_error_code($parser)) { die('Line '.xml_get_current_line_number($parser).': '.xml_error_string(xml_get_error_code($parser))); } @@ -290,7 +290,7 @@ class tx_rtehtmlarea_pi1 extends tslib_pibase { '; $this->result .= ''; - $this->result .= preg_replace('/'.preg_quote('').'['.preg_quote(chr(10).chr(13).chr(32)).']*/', '', $this->text); + $this->result .= preg_replace('/'.preg_quote('').'['.preg_quote(chr(10).chr(13).chr(32)).']*/'.(($this->parserCharset == 'utf-8')?'u':''), '', $this->text); $this->result .= '
'.$dictionaries.'
'; // Closing @@ -370,9 +370,9 @@ class tx_rtehtmlarea_pi1 extends tslib_pibase { function spellCheckHandler($xml_parser, $string) { $incurrent=array(); $stringText = $string; - $words = preg_split('/\W+/', $stringText); + $words = preg_split((($this->parserCharset == 'utf-8')?'/\P{L}+/u':'/\W+/'), $stringText); while( list(,$word) = each($words) ) { - $word = str_replace(' ', '', $word); + $word = preg_replace('/ /'.(($this->parserCharset == 'utf-8')?'u':''), '', $word); if( $word && !is_numeric($word)) { if($this->pspell_is_available && !$this->forceCommandMode) { if (!pspell_check($this->pspell_link, $word)) { @@ -391,7 +391,7 @@ class tx_rtehtmlarea_pi1 extends tslib_pibase { unset($suggest); } if( !in_array($word, $incurrent) ) { - $stringText = preg_replace('/\b'.$word.'\b/', ''.$word.'', $stringText); + $stringText = preg_replace('/\b'.$word.'\b/'.(($this->parserCharset == 'utf-8')?'u':''), ''.$word.'', $stringText); $incurrent[] = $word; } } @@ -427,7 +427,7 @@ class tx_rtehtmlarea_pi1 extends tslib_pibase { unset($suggestions); } if (!in_array($word, $incurrent)) { - $stringText = preg_replace('/\b'.$word.'\b/', ''.$word.'', $stringText); + $stringText = preg_replace('/\b'.$word.'\b/'.(($this->parserCharset == 'utf-8')?'u':''), ''.$word.'', $stringText); $incurrent[] = $word; } } -- 2.20.1