Changeset 428
- Timestamp:
- Oct 31, 2013 8:41:52 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.1dev/lib/SpellCheck.inc.php
r427 r428 199 199 { 200 200 $corrections = array(); 201 // Split words on punctuation except apostrophes 201 // Split words on punctuation except apostrophes (this regex is used in several places in this class). 202 202 // http://stackoverflow.com/questions/790596/split-a-text-into-single-words 203 $words = preg_split("/((^\p{P}+)|(\p{P}*\s+\p{P}*)| ([\p{Pd}ââ-]+)|(\+|(\p{P}+$))/", $string);203 $words = preg_split("/((^\p{P}+)|(\p{P}*\s+\p{P}*)|[\p{Pd}ââ-]+|(\p{P}+$))/", $string); 204 204 // Remove non-word elements. 205 205 $words = preg_grep('/\w+/', $words); … … 235 235 { 236 236 $errors = array(); 237 $words = preg_split('/([\W]+?)/', $string, -1, PREG_SPLIT_DELIM_CAPTURE); 237 // Split words on punctuation except apostrophes (this regex is used in several places in this class). 238 // http://stackoverflow.com/questions/790596/split-a-text-into-single-words 239 $words = preg_split("/((^\p{P}+)|(\p{P}*\s+\p{P}*)|[\p{Pd}ââ-]+|(\p{P}+$))/", $string); 238 240 // Remove non-word elements. 239 241 $check_words = preg_grep('/\w+/', $words); … … 265 267 */ 266 268 function getStringHighlighted($string, $show_footnote=false) 267 { 268 $words = preg_split('/([\W]+?)/', $string, -1, PREG_SPLIT_DELIM_CAPTURE); 269 { 270 // Split words on punctuation except apostrophes (this regex is used in several places in this class). 271 // http://stackoverflow.com/questions/790596/split-a-text-into-single-words 272 $words = preg_split("/((^\p{P}+)|(\p{P}*\s+\p{P}*)|[\p{Pd}ââ-]+|(\p{P}+$))/", $string); 269 273 $check_words = preg_grep('/\w+/', $words); 270 274 $cnt = 0; … … 272 276 foreach ($check_words as $i => $word) { 273 277 if (!$this->check($word)) { 274 $footnote = $show_footnote ? '<sup >' . ++$cnt . '</sup>' : '';275 $words[$i] = $this->getParam('highlight_start') . $word. $this->getParam('highlight_end') . $footnote;276 } 277 } 278 } 279 return join(' ', $words);278 $footnote = $show_footnote ? '<sup style="color:#999;">' . ++$cnt . '</sup>' : ''; 279 $words[$i] = $this->getParam('highlight_start') . strip_tags($word) . $this->getParam('highlight_end') . $footnote; 280 } 281 } 282 } 283 return join(' ', $words); 280 284 } 281 285 … … 296 300 <?php 297 301 298 $form_words = $this->getStringSuggestions(getFormData($form_name));302 $form_words = array_values($this->getStringSuggestions(getFormData($form_name))); 299 303 if (is_array($form_words) && !empty($form_words)) { 300 304 ?><ol><?php … … 302 306 ?> 303 307 <li> 308 <label style="color:#999;"><sub style="vertical-align:text-top;"><?php echo $i + 1; ?></sub></label> 304 309 <select name="spelling_suggestions[<?php echo $form_name ?>][<?php echo $i ?>]" onchange="document.forms[0].elements['spelling_corrections[<?php echo $form_name ?>][<?php echo $i ?>]'].value = this.value;"> 305 310 <?php $original_word = array_shift($words); ?> … … 352 357 function applyFormCorrections($form_name) 353 358 { 354 $form_words = preg_split('/([\W]+?)/', getFormData($form_name), -1, PREG_SPLIT_DELIM_CAPTURE); 359 // Split words on punctuation except apostrophes (this regex is used in several places in this class). 360 // http://stackoverflow.com/questions/790596/split-a-text-into-single-words 361 $form_words = preg_split("/((^\p{P}+)|(\p{P}*\s+\p{P}*)|[\p{Pd}ââ-]+|(\p{P}+$))/", getFormData($form_name)); 355 362 $suggestions = getFormData('spelling_suggestions'); 356 363 $corrections = getFormData('spelling_corrections');
Note: See TracChangeset
for help on using the changeset viewer.