⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 class.tx_rtehtmlarea_pi1.php

📁 Typo3, 开源里边最强大的
💻 PHP
📖 第 1 页 / 共 2 页
字号:
					$AspellCommand = 'cat ' . escapeshellarg($tmpFileName) . ' | ' . $this->AspellDirectory . ' -a --mode=none' . $this->personalDictsArg . ' --lang=' . escapeshellarg($this->dictionary) . ' --encoding=' . escapeshellarg($this->parserCharset) . ' 2>&1';					print $AspellCommand . "\n";					print shell_exec($AspellCommand);					t3lib_div::unlink_tempfile($tmpFileName);					echo('Personal word list was updated.');				} else {					echo('SpellChecker tempfile open error.');				}			} else {				echo('Nothing to add to the personal word list.');			}			flush();			exit();		} else {				// Check spelling content				// Initialize output			$this->result = '<?xml version="1.0" encoding="' . $this->parserCharset . '"?><!DOCTYPE html     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="' . substr($this->dictionary, 0, 2) . '" lang="' . substr($this->dictionary, 0, 2) . '"><html><head><meta http-equiv="Content-Type" content="text/html; charset=' . $this->parserCharset . '" /><link rel="stylesheet" type="text/css" media="all" href="spell-check-style.css" /><script type="text/javascript">/*<![CDATA[*/<!--';				// Getting the input content			$content = t3lib_div::_POST('content');				// Parsing the input HTML			$parser = xml_parser_create(strtoupper($this->parserCharset));			xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);			xml_set_object($parser, &$this);			if( !xml_set_element_handler( $parser, 'startHandler', 'endHandler')) echo('Bad xml handler setting');			if( !xml_set_character_data_handler ( $parser, 'spellCheckHandler')) echo('Bad xml handler setting');			if( !xml_set_default_handler( $parser, 'defaultHandler')) echo('Bad xml handler setting');			if(! xml_parse($parser,'<?xml version="1.0" encoding="' . $this->parserCharset . '"?><spellchecker> ' . mb_ereg_replace('&nbsp;', ' ', $content) . ' </spellchecker>')) 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)));			}			xml_parser_free($parser);			if($this->pspell_is_available && !$this->forceCommandMode) {				pspell_clear_session ($this->pspell_link);			}			$this->result .= 'var suggested_words = {' . $this->suggestedWords . '};';				// Calculating parsing and spell checkting time			$time = number_format(microtime(true) - $time_start, 2, ',', ' ');				// Insert spellcheck info			$this->result .= 'var spellcheck_info = { "Total words":"'.$this->wordCount.'","Misspelled words":"'.sizeof($this->misspelled).'","Total suggestions":"'.$this->suggestionCount.'","Total words suggested":"'.$this->suggestedWordCount.'","Spelling checked in":"'.$time.'" };// -->/*]]>*/</script></head>';			$this->result .= '<body onload="window.parent.finishedSpellChecking();">';			$this->result .= preg_replace('/'.preg_quote('<?xml').'.*'.preg_quote('?>').'['.preg_quote(chr(10).chr(13).chr(32)).']*/', '', $this->text);			$this->result .= '<div id="HA-spellcheck-dictionaries">'.$dictionaries.'</div>';				// Closing			$this->result .= '</body></html>';				// Outputting			echo $this->result;		}	}  // end of function main	function startHandler($xml_parser, $tag, $attributes) {		switch($tag) {			case 'spellchecker':				break;			case 'br':			case 'BR':			case 'img':			case 'IMG':			case 'hr':			case 'HR':			case 'area':			case 'AREA':				$this->text .= '<'. mb_strtolower($tag) . ' ';				foreach( $attributes as $key => $val) {					$this->text .= $key . '="' . $val . '" ';				}				$this->text .= ' />';				break;			default:				$this->text .= '<'. mb_strtolower($tag) . ' ';				foreach( $attributes as $key => $val) {					$this->text .= $key . '="' . $val . '" ';				}				$this->text .= '>';				break;		}		return;	}	function endHandler($xml_parser, $tag) {		switch($tag) {			case 'spellchecker':				break;			case 'br':			case 'BR':			case 'img':			case 'IMG':			case 'hr':			case 'HR':			case 'input':			case 'INPUT':			case 'area':			case 'AREA':				break;			default:				$this->text .= '</' . $tag . '>';				break;		}		return;	}	function spellCheckHandler($xml_parser, $string) {		$incurrent=array();		$stringText = $string;		$words = mb_split('\W+', $stringText);		while( list(,$word) = each($words) ) {			$word = mb_ereg_replace(' ', '', $word);			if( $word && !is_numeric($word)) {				if($this->pspell_is_available && !$this->forceCommandMode) {					if (!pspell_check($this->pspell_link, $word)) {						if(!in_array($word, $this->misspelled)) {							if(sizeof($this->misspelled) != 0 ) {								$this->suggestedWords .= ',';							}							$suggest = array();							$suggest = pspell_suggest($this->pspell_link, $word);							if(sizeof($suggest) != 0 ) {								$this->suggestionCount++;								$this->suggestedWordCount += sizeof($suggest);							}							$this->suggestedWords .= '"'.$word.'":"'.implode(',',$suggest).'"';							$this->misspelled[] = $word;							unset($suggest);						}						if( !in_array($word, $incurrent) ) {							$stringText = mb_ereg_replace('\b'.$word.'\b', '<span class="HA-spellcheck-error">'.$word.'</span>', $stringText);							$incurrent[] = $word;						}					}				} else {					$tmpFileName = t3lib_div::tempnam($this->filePrefix);					if(!$filehandle = fopen($tmpFileName,'wb')) echo('SpellChecker tempfile open error');					if(!fwrite($filehandle, $word)) echo('SpellChecker tempfile write error');					if(!fclose($filehandle)) echo('SpellChecker tempfile close error');					$AspellCommand = 'cat ' . escapeshellarg($tmpFileName) . ' | ' . $this->AspellDirectory . ' -a check --mode=none --sug-mode=' . escapeshellarg($this->pspellMode) . $this->personalDictsArg . ' --lang=' . escapeshellarg($this->dictionary) . ' --encoding=' . escapeshellarg($this->parserCharset) . ' 2>&1';					$AspellAnswer = shell_exec($AspellCommand);					$AspellResultLines = array();					$AspellResultLines = t3lib_div::trimExplode(chr(10), $AspellAnswer, 1);					if(substr($AspellResultLines[0],0,6) == 'Error:') echo("{$AspellAnswer}");					t3lib_div::unlink_tempfile($tmpFileName);					if(substr($AspellResultLines['1'],0,1) != '*') {						if(!in_array($word, $this->misspelled)) {							if(sizeof($this->misspelled) != 0 ) {								$this->suggestedWords .= ',';							}							$suggest = array();							$suggestions = array();							if (substr($AspellResultLines['1'],0,1) == '&') {								$suggestions = t3lib_div::trimExplode(':', $AspellResultLines['1'], 1);								$suggest =  t3lib_div::trimExplode(',', $suggestions['1'], 1);							}							if (sizeof($suggest) != 0) {								$this->suggestionCount++;								$this->suggestedWordCount += sizeof($suggest);							}							$this->suggestedWords .= '"'.$word.'":"'.implode(',',$suggest).'"';							$this->misspelled[] = $word;							unset($suggest);							unset($suggestions);						}						if (!in_array($word, $incurrent)) {							$stringText = mb_ereg_replace('\b'.$word.'\b', '<span class="HA-spellcheck-error">'.$word.'</span>', $stringText);							$incurrent[] = $word;						}					}				unset($AspellResultLines);				}				$this->wordCount++;			}		}		$this->text .= $stringText;		unset($incurrent);		return;	}	function defaultHandler($xml_parser, $string) {		$this->text .= $string;		return;	}} // end of classif (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/pi1/class.tx_rtehtmlarea_pi1.php']) {	include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/pi1/class.tx_rtehtmlarea_pi1.php']);}?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -