作者:vip3ou
项目:TYPO3.CM
/**
* Returns a string where any character not matching [.a-zA-Z0-9_-] is substituted by '_'
* Trailing dots are removed
*
* @param string $fileName Input string, typically the body of a filename
* @param string $charset Charset of the a filename (defaults to current charset; depending on context)
* @return string Output string with any characters not matching [.a-zA-Z0-9_-] is substituted by '_' and trailing dots removed
* @todo Deprecate, but still in use by the core
* @deprecated but still in use in the Core. Don't use in your extensions!
*/
public function cleanFileName($fileName, $charset = '')
{
// Handle UTF-8 characters
if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['UTF8filesystem']) {
// allow ".", "-", 0-9, a-z, A-Z and everything beyond U+C0 (latin capital letter a with grave)
$cleanFileName = preg_replace('/[' . self::UNSAFE_FILENAME_CHARACTER_EXPRESSION . ']/u', '_', trim($fileName));
} else {
// Get conversion object or initialize if needed
if (!is_object($this->csConvObj)) {
$this->csConvObj = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Charset\CharsetConverter::class);
}
// Define character set
if (!$charset) {
if (TYPO3_MODE == 'FE') {
$charset = $GLOBALS['TSFE']->renderCharset;
} else {
// Backend
$charset = 'utf-8';
}
}
// If a charset was found, convert filename
if ($charset) {
$fileName = $this->csConvObj->specCharsToASCII($charset, $fileName);
}
// Replace unwanted characters by underscores
$cleanFileName = preg_replace('/[' . self::UNSAFE_FILENAME_CHARACTER_EXPRESSION . '\\xC0-\\xFF]/', '_', trim($fileName));
}
// Strip trailing dots and return
return rtrim($cleanFileName, '.');
}
作者:dachcom-digita
项目:TYPO3.CM
/**
* Converts the subject and the expected result into utf-8.
*
* @param string $subject the subject, will be modified
* @param string $expected the expected result, will be modified
*/
protected function handleCharset(&$subject, &$expected)
{
$charsetConverter = new CharsetConverter();
$subject = $charsetConverter->conv($subject, 'iso-8859-1', 'utf-8');
$expected = $charsetConverter->conv($expected, 'iso-8859-1', 'utf-8');
}
作者:MaxSer
项目:typo3-realur
/**
* Converts a given string to a string that can be used as a URL segment.
* The result is not url-encoded.
*
* @param string $string
* @param string $spaceCharacter
* @return string
*/
public function convertToSafeString($string, $spaceCharacter = '-')
{
$processedTitle = $this->csConvertor->conv_case('utf-8', $string, 'toLower');
$processedTitle = strip_tags($processedTitle);
$processedTitle = preg_replace('/[ \\-+_]+/', $spaceCharacter, $processedTitle);
$processedTitle = $this->csConvertor->specCharsToASCII('utf-8', $processedTitle);
$processedTitle = preg_replace('/[^\\p{L}0-9' . preg_quote($spaceCharacter) . ']/u', '', $processedTitle);
$processedTitle = preg_replace('/' . preg_quote($spaceCharacter) . '{2,}/', $spaceCharacter, $processedTitle);
$processedTitle = trim($processedTitle, $spaceCharacter);
// TODO Post-processing hook here
$processedTitle = strtolower($processedTitle);
return $processedTitle;
}
作者:rickymathe
项目:TYPO3.CM
/**
* Check if $value is valid. If it is not valid, needs to add an error
* to result.
*
* @param mixed $value
* @return void
*/
public function isValid($value)
{
$length = $this->charsetConverter->strlen('utf-8', $value);
if ($length < (int) $this->options['minimum']) {
$this->addError($this->renderMessage($this->options['errorMessage'][0], $this->options['errorMessage'][1], 'error'), 1441999425);
return;
}
if (!isset($this->options['maximum']) || $this->options['maximum'] === '') {
$this->options['maximum'] = null;
}
if ($this->options['maximum'] !== null && $length > (int) $this->options['maximum']) {
$this->addError($this->renderMessage($this->options['errorMessage'][0], $this->options['errorMessage'][1], 'error'), 1441999425);
}
}
作者:plan2ne
项目:TYPO3.CM
/**
* Returns TRUE if submitted value validates according to rule
*
* @return bool
* @see \TYPO3\CMS\Form\Validation\ValidatorInterface::isValid()
*/
public function isValid()
{
if ($this->requestHandler->has($this->fieldName)) {
$value = $this->requestHandler->getByMethod($this->fieldName);
$length = $this->charsetConverter->strlen('utf-8', $value);
if ($length < $this->minimum) {
return FALSE;
}
if ($this->maximum !== NULL && $length > $this->maximum) {
return FALSE;
}
}
return TRUE;
}
作者:Mr-Robot
项目:TYPO3.CM
/**
* Converts the input string to a JavaScript function returning the same string, but charset-safe.
* Used for confirm and alert boxes where we must make sure that any string content
* does not break the script AND want to make sure the charset is preserved.
* Originally I used the JS function unescape() in combination with PHP function
* rawurlencode() in order to pass strings in a safe way. This could still be done
* for iso-8859-1 charsets but now I have applied the same method here for all charsets.
*
* @param string $str Input string, encoded with UTF-8
* @return string Output string, a JavaScript function: "String.fromCharCode(......)
* @depreacted since 6.2 - will be removed two versions later; use GeneralUtility::quoteJSvalue() instead
*/
public function JScharCode($str)
{
GeneralUtility::logDeprecatedFunction();
// Convert the UTF-8 string into a array of char numbers:
$nArr = $this->csConvObj->utf8_to_numberarray($str);
return 'String.fromCharCode(' . implode(',', $nArr) . ')';
}
作者:adroll
项目:TYPO3.CM
/**
* Handler for the opening of a tag
*/
public function startHandler($xml_parser, $tag, $attributes)
{
if ((string) $this->xmlCharacterData !== '') {
$this->spellCheckHandler($xml_parser, $this->xmlCharacterData);
$this->xmlCharacterData = '';
}
switch ($tag) {
case 'spellchecker':
break;
case 'br':
case 'BR':
case 'img':
case 'IMG':
case 'hr':
case 'HR':
case 'area':
case 'AREA':
$this->text .= '<' . $this->csConvObj->conv_case($this->parserCharset, $tag, 'toLower') . ' ';
foreach ($attributes as $key => $val) {
$this->text .= $key . '="' . $val . '" ';
}
$this->text .= ' />';
break;
default:
$this->text .= '<' . $this->csConvObj->conv_case($this->parserCharset, $tag, 'toLower') . ' ';
foreach ($attributes as $key => $val) {
$this->text .= $key . '="' . $val . '" ';
}
$this->text .= '>';
}
}
作者:dachcom-digita
项目:TYPO3.CM
/**
* Check if $value is valid. If it is not valid, needs to add an error
* to result.
*
* @param mixed $value
* @return void
*/
public function isValid($value)
{
if (empty($value) || !is_string($value)) {
return;
}
$allowedOptionsArray = GeneralUtility::trimExplode(',', $this->options['array'], true);
if (!empty($this->options['ignorecase'])) {
$value = $this->charsetConverter->conv_case('utf-8', $value, 'toLower');
foreach ($allowedOptionsArray as &$option) {
$option = $this->charsetConverter->conv_case('utf-8', $option, 'toLower');
}
}
if (!in_array($value, $allowedOptionsArray, !empty($this->options['strict']))) {
$this->addError($this->renderMessage($this->options['errorMessage'][0], $this->options['errorMessage'][1], 'error'), 1442002594);
}
}
作者:nicksergi
项目:TYPO3v4-Cor
/**
* Sets character sets for the language key.
*
* @param string $languageKey
* @param string $charset
* @return void
*/
protected function setCharsets($languageKey, $charset)
{
$this->sourceCharset = $this->csConvObj->parse_charset($this->csConvObj->charSetArray[$languageKey] ? $this->csConvObj->charSetArray[$languageKey] : 'utf-8');
if ($charset) {
$this->targetCharset = $this->csConvObj->parse_charset($charset);
} else {
$this->targetCharset = 'utf-8';
}
}
作者:plan2ne
项目:TYPO3.CM
/**
* Extracts the sample description text from the content array.
*
* @param array Content array
* @return string Description string
*/
public function bodyDescription($contentArr)
{
// Setting description
$maxL = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->conf['index_descrLgd'], 0, 255, 200);
if ($maxL) {
$bodyDescription = str_replace(array(' ', TAB, CR, LF), ' ', $contentArr['body']);
// Shorten the string:
$bodyDescription = $this->csObj->strtrunc('utf-8', $bodyDescription, $maxL);
}
return $bodyDescription;
}
作者:jweiland-ne
项目:clubdirector
/**
* search records.
*
* @param string $search
*
* @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface
*/
public function searchClubs($search)
{
// strtolower is not UTF-8 compatible
// $search = strtolower($search);
$longStreetSearch = $search;
$smallStreetSearch = $search;
// unify street search
if (strtolower($this->charsetConverter->utf8_substr($search, -6) === 'straße')) {
$smallStreetSearch = str_ireplace('straße', 'str', $search);
}
if (strtolower($this->charsetConverter->utf8_substr($search, -4)) === 'str.') {
$longStreetSearch = str_ireplace('str.', 'straße', $search);
$smallStreetSearch = str_ireplace('str.', 'str', $search);
}
if (strtolower($this->charsetConverter->utf8_substr($search, -3)) === 'str') {
$longStreetSearch = str_ireplace('str', 'straße', $search);
}
$query = $this->createQuery();
return $query->matching($query->logicalOr($query->like('title', '%' . $search . '%'), $query->like('sortTitle', '%' . $search . '%'), $query->like('addresses.street', '%' . $longStreetSearch . '%'), $query->like('addresses.street', '%' . $smallStreetSearch . '%'), $query->like('addresses.zip', '%' . $search . '%'), $query->like('addresses.city', '%' . $search . '%'), $query->like('contactPerson', '%' . $search . '%'), $query->like('description', '%' . $search . '%'), $query->like('tags', '%' . $search . '%')))->execute();
}
作者:nicksergi
项目:TYPO3v4-Cor
/**
* Returns backslash encoded numeric format. Does not use backslash
* character escapes such as, \" or \' as these may cause parsing problems.
* For example, if a javascript attribute, such as onmouseover, contains
* a \" that will close the entire attribute and allow an attacker to inject
* another script attribute.
*
* @param string $character utf-8 character that needs to be encoded
* @return string encoded character
*/
protected function encodeCharacter($character)
{
if ($this->isImmuneCharacter($character)) {
return $character;
}
$ordinalValue = $this->charsetConversion->utf8CharToUnumber($character);
// Check for alphanumeric characters
$hex = $this->getHexForNonAlphanumeric($ordinalValue);
if ($hex === NULL) {
return $character;
}
// Encode up to 256 with \\xHH
if ($ordinalValue < 256) {
$pad = substr('00', strlen($hex));
return '\\x' . $pad . strtoupper($hex);
}
// Otherwise encode with \\uHHHH
$pad = substr('0000', strlen($hex));
return '\\u' . $pad . strtoupper($hex);
}
作者:Andreas
项目:commerc
/**
* This method converts an sends mails.
*
* @param array $mailconf Mail configuration
* @param array $orderdata Order data
* @param string $template Template
*
* @return bool of \TYPO3\CMS\Core\Mail\MailMessage
*/
protected function ordermoveSendMail(array $mailconf, array &$orderdata, &$template)
{
// First line is subject
$parts = explode(chr(10), $mailconf['plain']['content'], 2);
// add mail subject
$mailconf['alternateSubject'] = trim($parts[0]);
// replace plaintext content
$mailconf['plain']['content'] = trim($parts[1]);
/**
* Convert Text to charset
*/
$this->csConvObj->initCharset('utf-8');
$this->csConvObj->initCharset('8bit');
$mailconf['plain']['content'] = $this->csConvObj->conv($mailconf['plain']['content'], 'utf-8', 'utf-8');
$mailconf['alternateSubject'] = $this->csConvObj->conv($mailconf['alternateSubject'], 'utf-8', 'utf-8');
if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/Classes/Hook/class.tx_commerce_ordermailhooks.php']['ordermoveSendMail'])) {
GeneralUtility::deprecationLog('
hook
$GLOBALS[\'TYPO3_CONF_VARS\'][\'EXTCONF\'][\'commerce/Classes/Hook/class.tx_commerce_ordermailhooks.php\'][\'ordermoveSendMail\']
is deprecated since commerce 1.0.0, it will be removed in commerce 1.4.0, please use instead
$GLOBALS[\'TYPO3_CONF_VARS\'][\'EXTCONF\'][\'commerce/Classes/Hook/OrdermailHooks.php\'][\'ordermoveSendMail\']
');
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/Classes/Hook/class.tx_commerce_ordermailhooks.php']['ordermoveSendMail'] as $classRef) {
$hookObj = GeneralUtility::getUserObj($classRef);
if (method_exists($hookObj, 'postOrdermoveSendMail')) {
$hookObj->postOrdermoveSendMail($mailconf, $orderdata, $template);
}
}
}
if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/Classes/Hook/OrdermailHooks.php']['ordermoveSendMail'])) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/Classes/Hook/OrdermailHooks.php']['ordermoveSendMail'] as $classRef) {
$hookObj = GeneralUtility::getUserObj($classRef);
if (method_exists($hookObj, 'postOrdermoveSendMail')) {
$hookObj->postOrdermoveSendMail($mailconf, $orderdata, $template);
}
}
}
return Tx_Commerce_Utility_GeneralUtility::sendMail($mailconf);
}
作者:khanhdeu
项目:typo3tes
/**
* Add word to word-array
* This function should be used to make sure CJK sequences are split up in the right way
*
* @param array Array of accumulated words
* @param string Complete Input string from where to extract word
* @param integer Start position of word in input string
* @param integer The Length of the word string from start position
* @return void
* @todo Define visibility
*/
public function addWords(&$words, &$wordString, $start, $len)
{
// Get word out of string:
$theWord = substr($wordString, $start, $len);
// Get next chars unicode number and find type:
$bc = 0;
$cp = $this->utf8_ord($theWord, $bc);
list($cType) = $this->charType($cp);
// If string is a CJK sequence we follow this algorithm:
/*
DESCRIPTION OF (CJK) ALGORITHMContinuous letters and numbers make up words. Spaces and symbols
separate letters and numbers into words. This is sufficient for
all western text.CJK doesn't use spaces or separators to separate words, so the only
way to really find out what constitutes a word would be to have a
dictionary and advanced heuristics. Instead, we form pairs from
consecutive characters, in such a way that searches will find only
characters that appear more-or-less the right sequence. For example:ABCDE => AB BC CD DEThis works okay since both the index and the search query is split
in the same manner, and since the set of characters is huge so the
extra matches are not significant.(Hint taken from ZOPEs chinese user group)[Kasper: As far as I can see this will only work well with or-searches!]
*/
if ($cType == 'cjk') {
// Find total string length:
$strlen = $this->csObj->utf8_strlen($theWord);
// Traverse string length and add words as pairs of two chars:
for ($a = 0; $a < $strlen; $a++) {
if ($strlen == 1 || $a < $strlen - 1) {
$words[] = $this->csObj->utf8_substr($theWord, $a, 2);
}
}
} else {
// Normal "single-byte" chars:
// Remove chars:
foreach ($this->lexerConf['removeChars'] as $skipJoin) {
$theWord = str_replace($this->csObj->UnumberToChar($skipJoin), '', $theWord);
}
// Add word:
$words[] = $theWord;
}
}
作者:BenjaminBec
项目:commerc
/**
* This method converts an sends mails.
*
* @param array $mailconf Mail configuration
* @param array $orderdata Order data
* @param string $template Template
*
* @return bool of \TYPO3\CMS\Core\Mail\MailMessage
*/
protected function ordermoveSendMail(array $mailconf, array &$orderdata, &$template)
{
// First line is subject
$parts = explode(chr(10), $mailconf['plain']['content'], 2);
// add mail subject
$mailconf['alternateSubject'] = trim($parts[0]);
// replace plaintext content
$mailconf['plain']['content'] = trim($parts[1]);
/*
* Convert Text to charset
*/
$this->csConvObj->initCharset('utf-8');
$this->csConvObj->initCharset('8bit');
$mailconf['plain']['content'] = $this->csConvObj->conv($mailconf['plain']['content'], 'utf-8', 'utf-8');
$mailconf['alternateSubject'] = $this->csConvObj->conv($mailconf['alternateSubject'], 'utf-8', 'utf-8');
$hooks = \CommerceTeam\Commerce\Factory\HookFactory::getHooks('Hook/OrdermailHooks', 'ordermoveSendMail');
foreach ($hooks as $hook) {
if (method_exists($hook, 'postOrdermoveSendMail')) {
$hook->postOrdermoveSendMail($mailconf, $orderdata, $template);
}
}
return \CommerceTeam\Commerce\Utility\GeneralUtility::sendMail($mailconf);
}
作者:plan2ne
项目:TYPO3.CM
/**
* Will convert the input strings special chars (all above 127) to entities.
* The string is expected to be encoded in UTF-8
* This function is used to create strings that can be used in the Click Menu
* (Context Sensitive Menus). The reason is that the values that are dynamically
* written into the <div> layer is decoded as iso-8859-1 no matter what charset
* is used in the document otherwise (only MSIE, Mozilla is OK).
* So by converting we by-pass this problem.
*
* @param string $str Input string
* @return string Output string
*/
public function makeEntities($str)
{
// Convert string back again, but using the full entity conversion:
return $this->csConvObj->utf8_to_entities($str);
}
作者:nicksergi
项目:TYPO3v4-Cor
/**
* Converts the $_POST array from metaCharset (page HTML charset from input form) to renderCharset (internal processing) IF the two charsets are different.
*
* @return void
* @todo Define visibility
*/
public function convPOSTCharset()
{
if ($this->renderCharset != $this->metaCharset && is_array($_POST) && count($_POST)) {
$this->csConvObj->convArray($_POST, $this->metaCharset, $this->renderCharset);
$GLOBALS['HTTP_POST_VARS'] = $_POST;
}
}
作者:samuweis
项目:TYPO3-Sit
/**
* Helper function for render the main JavaScript libraries,
* currently: RequireJS, jQuery, PrototypeJS, Scriptaculous, SVG, ExtJs
*
* @return string Content with JavaScript libraries
*/
protected function renderMainJavaScriptLibraries()
{
$out = '';
// Include RequireJS
if ($this->addRequireJs) {
// load the paths of the requireJS configuration
$out .= GeneralUtility::wrapJS('var require = ' . json_encode($this->requireJsConfig)) . LF;
// directly after that, include the require.js file
$out .= '<script src="' . $this->processJsFile($this->backPath . $this->requireJsPath . 'require.js') . '" type="text/javascript"></script>' . LF;
}
if ($this->addSvg) {
$out .= '<script src="' . $this->processJsFile($this->backPath . $this->svgPath . 'svg.js') . '" data-path="' . $this->backPath . $this->svgPath . '"' . ($this->enableSvgDebug ? ' data-debug="true"' : '') . '></script>' . LF;
}
// Include jQuery Core for each namespace, depending on the version and source
if (!empty($this->jQueryVersions)) {
foreach ($this->jQueryVersions as $namespace => $jQueryVersion) {
$out .= $this->renderJqueryScriptTag($jQueryVersion['version'], $jQueryVersion['source'], $namespace);
}
}
if ($this->addPrototype) {
$out .= '<script src="' . $this->processJsFile($this->backPath . $this->prototypePath . 'prototype.js') . '" type="text/javascript"></script>' . LF;
unset($this->jsFiles[$this->backPath . $this->prototypePath . 'prototype.js']);
}
if ($this->addScriptaculous) {
$mods = array();
foreach ($this->addScriptaculousModules as $key => $value) {
if ($this->addScriptaculousModules[$key]) {
$mods[] = $key;
}
}
// Resolve dependencies
if (in_array('dragdrop', $mods) || in_array('controls', $mods)) {
$mods = array_merge(array('effects'), $mods);
}
if (count($mods)) {
foreach ($mods as $module) {
$out .= '<script src="' . $this->processJsFile($this->backPath . $this->scriptaculousPath . $module . '.js') . '" type="text/javascript"></script>' . LF;
unset($this->jsFiles[$this->backPath . $this->scriptaculousPath . $module . '.js']);
}
}
$out .= '<script src="' . $this->processJsFile($this->backPath . $this->scriptaculousPath . 'scriptaculous.js') . '" type="text/javascript"></script>' . LF;
unset($this->jsFiles[$this->backPath . $this->scriptaculousPath . 'scriptaculous.js']);
}
// Include extCore, but only if ExtJS is not included
if ($this->addExtCore && !$this->addExtJS) {
$out .= '<script src="' . $this->processJsFile($this->backPath . $this->extCorePath . 'ext-core' . ($this->enableExtCoreDebug ? '-debug' : '') . '.js') . '" type="text/javascript"></script>' . LF;
unset($this->jsFiles[$this->backPath . $this->extCorePath . 'ext-core' . ($this->enableExtCoreDebug ? '-debug' : '') . '.js']);
}
// Include extJS
if ($this->addExtJS) {
// Use the base adapter all the time
$out .= '<script src="' . $this->processJsFile($this->backPath . $this->extJsPath . 'adapter/' . ($this->enableExtJsDebug ? str_replace('.js', '-debug.js', $this->extJSadapter) : $this->extJSadapter)) . '" type="text/javascript"></script>' . LF;
$out .= '<script src="' . $this->processJsFile($this->backPath . $this->extJsPath . 'ext-all' . ($this->enableExtJsDebug ? '-debug' : '') . '.js') . '" type="text/javascript"></script>' . LF;
// Add extJS localization
// Load standard ISO mapping and modify for use with ExtJS
$localeMap = $this->locales->getIsoMapping();
$localeMap[''] = 'en';
$localeMap['default'] = 'en';
// Greek
$localeMap['gr'] = 'el_GR';
// Norwegian Bokmaal
$localeMap['no'] = 'no_BO';
// Swedish
$localeMap['se'] = 'se_SV';
$extJsLang = isset($localeMap[$this->lang]) ? $localeMap[$this->lang] : $this->lang;
// TODO autoconvert file from UTF8 to current BE charset if necessary!!!!
$extJsLocaleFile = $this->extJsPath . 'locale/ext-lang-' . $extJsLang . '.js';
if (file_exists(PATH_typo3 . $extJsLocaleFile)) {
$out .= '<script src="' . $this->processJsFile($this->backPath . $extJsLocaleFile) . '" type="text/javascript" charset="utf-8"></script>' . LF;
}
// Remove extjs from JScodeLibArray
unset($this->jsFiles[$this->backPath . $this->extJsPath . 'ext-all.js'], $this->jsFiles[$this->backPath . $this->extJsPath . 'ext-all-debug.js']);
}
if (count($this->inlineLanguageLabelFiles)) {
foreach ($this->inlineLanguageLabelFiles as $languageLabelFile) {
$this->includeLanguageFileForInline($languageLabelFile['fileRef'], $languageLabelFile['selectionPrefix'], $languageLabelFile['stripFromSelectionName'], $languageLabelFile['$errorMode']);
}
}
$this->inlineLanguageLabelFiles = array();
// Convert labels/settings back to UTF-8 since json_encode() only works with UTF-8:
if ($this->getCharSet() !== 'utf-8') {
if ($this->inlineLanguageLabels) {
$this->csConvObj->convArray($this->inlineLanguageLabels, $this->getCharSet(), 'utf-8');
}
if ($this->inlineSettings) {
$this->csConvObj->convArray($this->inlineSettings, $this->getCharSet(), 'utf-8');
}
}
if (TYPO3_MODE === 'BE') {
$this->addAjaxUrlsToInlineSettings();
}
$inlineSettings = $this->inlineLanguageLabels ? 'TYPO3.lang = ' . json_encode($this->inlineLanguageLabels) . ';' : '';
$inlineSettings .= $this->inlineSettings ? 'TYPO3.settings = ' . json_encode($this->inlineSettings) . ';' : '';
if ($this->addExtCore || $this->addExtJS) {
//.........这里部分代码省略.........
作者:grauru
项目:testgit_t3
/**
* Extracts the sample description text from the content array.
*
* @param array $contentArr Content array
* @return string Description string
*/
public function bodyDescription($contentArr)
{
// Setting description
$maxL = MathUtility::forceIntegerInRange($this->conf['index_descrLgd'], 0, 255, 200);
if ($maxL) {
$bodyDescription = preg_replace('/\\s+/u', ' ', $contentArr['body']);
// Shorten the string:
$bodyDescription = $this->csObj->strtrunc('utf-8', $bodyDescription, $maxL);
}
return $bodyDescription;
}
作者:plan2ne
项目:TYPO3.CM
/**
* Split a string into an array of individual characters
* The function will look at $this->nativeCharset and if that is set, the input string is expected to be UTF-8 encoded, possibly with entities in it. Otherwise the string is supposed to be a single-byte charset which is just splitted by a for-loop.
*
* @param string $theText The text string to split
* @param bool $returnUnicodeNumber Return Unicode numbers instead of chars.
* @return array Numerical array with a char as each value.
*/
public function singleChars($theText, $returnUnicodeNumber = FALSE)
{
if ($this->nativeCharset) {
// Get an array of separated UTF-8 chars
return $this->csConvObj->utf8_to_numberarray($theText, 1, $returnUnicodeNumber ? 0 : 1);
} else {
$output = array();
$c = strlen($theText);
for ($a = 0; $a < $c; $a++) {
$output[] = substr($theText, $a, 1);
}
return $output;
}
}