本文整理匯總了PHP中TYPO3\CMS\Core\Charset\CharsetConverter::entities_to_utf8方法的典型用法代碼示例。如果您正苦於以下問題:PHP CharsetConverter::entities_to_utf8方法的具體用法?PHP CharsetConverter::entities_to_utf8怎麽用?PHP CharsetConverter::entities_to_utf8使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類TYPO3\CMS\Core\Charset\CharsetConverter
的用法示例。
在下文中一共展示了CharsetConverter::entities_to_utf8方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: charsetEntity2utf8
/**
* Convert character set and HTML entities in the value of input content array keys
*
* @param array Standard content array
* @param string Charset of the input content (converted to utf-8)
* @return void
*/
public function charsetEntity2utf8(&$contentArr, $charset)
{
// Convert charset if necessary
foreach ($contentArr as $key => $value) {
if ((string) $contentArr[$key] !== '') {
if ($charset !== 'utf-8') {
$contentArr[$key] = $this->csObj->utf8_encode($contentArr[$key], $charset);
}
// decode all numeric / html-entities in the string to real characters:
$contentArr[$key] = $this->csObj->entities_to_utf8($contentArr[$key], TRUE);
}
}
}
示例2: getSearchWords
/**
* Splits the search word input into an array where each word is represented by an array with key "sword" holding the search word and key "oper" holding the SQL operator (eg. AND, OR)
*
* Only words with 2 or more characters are accepted
* Max 200 chars total
* Space is used to split words, "" can be used search for a whole string
* AND, OR and NOT are prefix words, overruling the default operator
* +/|/- equals AND, OR and NOT as operators.
* All search words are converted to lowercase.
*
* $defOp is the default operator. 1=OR, 0=AND
*
* @param bool $defOp If TRUE, the default operator will be OR, not AND
* @return array Returns array with search words if any found
*/
public function getSearchWords($defOp)
{
// Shorten search-word string to max 200 bytes (does NOT take multibyte charsets into account - but never mind, shortening the string here is only a run-away feature!)
$inSW = substr($this->piVars['sword'], 0, 200);
// Convert to UTF-8 + conv. entities (was also converted during indexing!)
$inSW = $this->charsetConverter->conv($inSW, $this->frontendController->metaCharset, 'utf-8');
$inSW = $this->charsetConverter->entities_to_utf8($inSW);
$sWordArray = false;
if ($hookObj = $this->hookRequest('getSearchWords')) {
$sWordArray = $hookObj->getSearchWords_splitSWords($inSW, $defOp);
} else {
if ($this->piVars['type'] == 20) {
// type = Sentence
$sWordArray = array(array('sword' => trim($inSW), 'oper' => 'AND'));
} else {
$searchWords = \TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility::getExplodedSearchString($inSW, $defOp == 1 ? 'OR' : 'AND', $this->operator_translate_table);
if (is_array($searchWords)) {
$sWordArray = $this->procSearchWordsByLexer($searchWords);
}
}
}
return $sWordArray;
}
示例3: getSearchWords
/**
* Splits the search word input into an array where each word is represented by an array with key "sword"
* holding the search word and key "oper" holding the SQL operator (eg. AND, OR)
*
* Only words with 2 or more characters are accepted
* Max 200 chars total
* Space is used to split words, "" can be used search for a whole string
* AND, OR and NOT are prefix words, overruling the default operator
* +/|/- equals AND, OR and NOT as operators.
* All search words are converted to lowercase.
*
* $defOp is the default operator. 1=OR, 0=AND
*
* @param bool $defaultOperator If TRUE, the default operator will be OR, not AND
* @return array Search words if any found
*/
protected function getSearchWords($defaultOperator)
{
// Shorten search-word string to max 200 bytes (does NOT take multibyte charsets into account - but never mind,
// shortening the string here is only a run-away feature!)
$searchWords = substr($this->sword, 0, 200);
// Convert to UTF-8 + conv. entities (was also converted during indexing!)
$searchWords = $this->charsetConverter->conv($searchWords, $GLOBALS['TSFE']->metaCharset, 'utf-8');
$searchWords = $this->charsetConverter->entities_to_utf8($searchWords);
$sWordArray = false;
if ($hookObj = $this->hookRequest('getSearchWords')) {
$sWordArray = $hookObj->getSearchWords_splitSWords($searchWords, $defaultOperator);
} else {
// sentence
if ($this->searchData['searchType'] == 20) {
$sWordArray = array(array('sword' => trim($searchWords), 'oper' => 'AND'));
} else {
// case-sensitive. Defines the words, which will be
// operators between words
$operatorTranslateTable = array(array('+', 'AND'), array('|', 'OR'), array('-', 'AND NOT'), array($this->charsetConverter->conv_case('utf-8', LocalizationUtility::translate('localizedOperandAnd', 'IndexedSearch'), 'toLower'), 'AND'), array($this->charsetConverter->conv_case('utf-8', LocalizationUtility::translate('localizedOperandOr', 'IndexedSearch'), 'toLower'), 'OR'), array($this->charsetConverter->conv_case('utf-8', LocalizationUtility::translate('localizedOperandNot', 'IndexedSearch'), 'toLower'), 'AND NOT'));
$swordArray = \TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility::getExplodedSearchString($searchWords, $defaultOperator == 1 ? 'OR' : 'AND', $operatorTranslateTable);
if (is_array($swordArray)) {
$sWordArray = $this->procSearchWordsByLexer($swordArray);
}
}
}
return $sWordArray;
}