コード例 #1
0
ファイル: Utility.php プロジェクト: MaxServ/typo3-realurl
 /**
  * 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;
 }
コード例 #2
0
 /**
  * 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);
     }
 }
コード例 #3
0
 /**
  * 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;
 }
コード例 #4
0
 /**
  * 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) . ')';
 }
コード例 #5
0
 /**
  * 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, '.');
 }
コード例 #6
0
 /**
  * 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 .= '>';
     }
 }
コード例 #7
0
 /**
  * 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);
     }
 }
コード例 #8
0
 /**
  * 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';
     }
 }
コード例 #9
0
ファイル: Indexer.php プロジェクト: plan2net/TYPO3.CMS
 /**
  * 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;
 }
コード例 #10
0
 /**
  * Load the language strings into JavaScript
  */
 protected function loadJavaScriptLanguageStrings()
 {
     if (!empty($this->inlineLanguageLabelFiles)) {
         foreach ($this->inlineLanguageLabelFiles as $languageLabelFile) {
             $this->includeLanguageFileForInline($languageLabelFile['fileRef'], $languageLabelFile['selectionPrefix'], $languageLabelFile['stripFromSelectionName'], $languageLabelFile['errorMode']);
         }
     }
     $this->inlineLanguageLabelFiles = [];
     // Convert settings back to UTF-8 since json_encode() only works with UTF-8:
     if (TYPO3_MODE === 'FE' && $this->getCharSet() !== 'utf-8') {
         if ($this->inlineSettings) {
             $this->csConvObj->convArray($this->inlineSettings, $this->getCharSet(), 'utf-8');
         }
     }
 }
コード例 #11
0
 /**
  * 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();
 }
コード例 #12
0
 /**
  * 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);
 }
コード例 #13
0
ファイル: OrdermailHooks.php プロジェクト: AndreasA/commerce
    /**
     * 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);
    }
コード例 #14
0
ファイル: Lexer.php プロジェクト: khanhdeux/typo3test
 /**
  * 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;
     }
 }
コード例 #15
0
 /**
  * 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);
 }
コード例 #16
0
 /**
  * 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);
 }
コード例 #17
0
 /**
  * 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;
     }
 }
コード例 #18
0
ファイル: PageRenderer.php プロジェクト: samuweiss/TYPO3-Site
    /**
     * 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) {
            // Set clear.gif, move it on top, add handler code
            $code = '';
            if (count($this->extOnReadyCode)) {
                foreach ($this->extOnReadyCode as $block) {
                    $code .= $block;
                }
            }
            $out .= $this->inlineJavascriptWrap[0] . '
				Ext.ns("TYPO3");
				Ext.BLANK_IMAGE_URL = "' . htmlspecialchars(GeneralUtility::locationHeaderUrl($this->backPath . 'gfx/clear.gif')) . '";' . LF . $inlineSettings . 'Ext.onReady(function() {' . ($this->enableExtJSQuickTips ? 'Ext.QuickTips.init();' . LF : '') . $code . ' });' . $this->inlineJavascriptWrap[1];
            $this->extOnReadyCode = array();
            // Include TYPO3.l10n object
            if (TYPO3_MODE === 'BE') {
                $out .= '<script src="' . $this->processJsFile($this->backPath . 'sysext/lang/Resources/Public/JavaScript/Typo3Lang.js') . '" type="text/javascript" charset="utf-8"></script>' . LF;
            }
            if ($this->extJScss) {
                if (isset($GLOBALS['TBE_STYLES']['extJS']['all'])) {
                    $this->addCssLibrary($this->backPath . $GLOBALS['TBE_STYLES']['extJS']['all'], 'stylesheet', 'all', '', TRUE);
                } else {
                    $this->addCssLibrary($this->backPath . $this->extJsPath . 'resources/css/ext-all-notheme.css', 'stylesheet', 'all', '', TRUE);
                }
            }
            if ($this->extJStheme) {
                if (isset($GLOBALS['TBE_STYLES']['extJS']['theme'])) {
                    $this->addCssLibrary($this->backPath . $GLOBALS['TBE_STYLES']['extJS']['theme'], 'stylesheet', 'all', '', TRUE);
                } else {
                    $this->addCssLibrary($this->backPath . $this->extJsPath . 'resources/css/xtheme-blue.css', 'stylesheet', 'all', '', TRUE);
                }
            }
        } else {
            // no extJS loaded, but still inline settings
            if ($inlineSettings !== '') {
                // make sure the global TYPO3 is available
                $inlineSettings = 'var TYPO3 = TYPO3 || {};' . CRLF . $inlineSettings;
                $out .= $this->inlineJavascriptWrap[0] . $inlineSettings . $this->inlineJavascriptWrap[1];
            }
        }
        return $out;
    }
コード例 #19
0
ファイル: Indexer.php プロジェクト: graurus/testgit_t37
 /**
  * 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;
 }
コード例 #20
0
 /**
  * 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;
     }
 }
コード例 #21
0
 /**
  * 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');
 }
コード例 #22
0
 /**
  * @test
  */
 public function utf8_strlenForNonEmptyAsciiOnlyStringReturnsNumberOfCharacters()
 {
     $this->assertEquals(10, $this->subject->utf8_strlen('good omens'));
 }
コード例 #23
0
 /**
  * Returns the title of the search result row
  *
  * @param array $row Result row
  * @return string Title from row
  */
 public function makeTitle($row)
 {
     $add = '';
     if ($this->multiplePagesType($row['item_type'])) {
         $dat = unserialize($row['cHashParams']);
         $pp = explode('-', $dat['key']);
         if ($pp[0] != $pp[1]) {
             $add = ', ' . $this->pi_getLL('word_pages') . ' ' . $dat['key'];
         } else {
             $add = ', ' . $this->pi_getLL('word_page') . ' ' . $pp[0];
         }
     }
     $outputString = $this->charsetConverter->crop('utf-8', $row['item_title'], $this->conf['results.']['titleCropAfter'], $this->conf['results.']['titleCropSignifier']);
     return $outputString . $add;
 }
コード例 #24
0
 /**
  * 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
  * @deprecated since TYPO3 v8, will be removed in TYPO3 v9
  */
 public function makeEntities($str)
 {
     GeneralUtility::logDeprecatedFunction();
     // Convert string back again, but using the full entity conversion:
     return $this->csConvObj->utf8_to_entities($str);
 }
コード例 #25
0
 /**
  * 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(......)
  */
 public function JScharCode($str)
 {
     // Convert the UTF-8 string into a array of char numbers:
     $nArr = $this->csConvObj->utf8_to_numberarray($str);
     return 'String.fromCharCode(' . implode(',', $nArr) . ')';
 }
コード例 #26
0
 /**
  * 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;
 }
コード例 #27
0
 /**
  * Convert character set and HTML entities in the value of input content array keys
  *
  * @param array $contentArr Standard content array
  * @param string $charset 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->conv($contentArr[$key], $charset, 'utf-8');
             }
             // decode all numeric / html-entities in the string to real characters:
             $contentArr[$key] = $this->csObj->entities_to_utf8($contentArr[$key]);
         }
     }
 }
コード例 #28
0
    /**
     * Main class of Spell Checker plugin
     *
     * @param ServerRequestInterface $request
     * @param ResponseInterface $response
     * @return ResponseInterface
     * @throws \InvalidArgumentException
     * @throws \UnexpectedValueException
     */
    public function processRequest(ServerRequestInterface $request, ResponseInterface $response)
    {
        $this->csConvObj = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Charset\CharsetConverter::class);
        // Setting start time
        $time_start = microtime(true);
        $this->pspell_is_available = in_array('pspell', get_loaded_extensions());
        $this->AspellDirectory = trim($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extKey]['plugins']['SpellChecker']['AspellDirectory']) ?: '/usr/bin/aspell';
        // Setting command mode if requested and available
        $this->forceCommandMode = trim($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extKey]['plugins']['SpellChecker']['forceCommandMode']) ?: 0;
        if (!$this->pspell_is_available || $this->forceCommandMode) {
            $AspellVersionString = explode('Aspell', shell_exec($this->AspellDirectory . ' -v'));
            $AspellVersion = substr($AspellVersionString[1], 0, 4);
            if ((double) $AspellVersion < 0.5 && (!$this->pspell_is_available || $this->forceCommandMode)) {
                echo 'Configuration problem: Aspell version ' . $AspellVersion . ' too old. Spell checking cannot be performed in command mode.';
            }
            $this->defaultAspellEncoding = trim(shell_exec($this->AspellDirectory . ' config encoding'));
        }
        // Setting the list of dictionaries
        $dictionaryList = shell_exec($this->AspellDirectory . ' dump dicts');
        $dictionaryList = implode(',', GeneralUtility::trimExplode(LF, $dictionaryList, true));
        $dictionaryArray = GeneralUtility::trimExplode(',', $dictionaryList, true);
        $restrictToDictionaries = GeneralUtility::_POST('restrictToDictionaries');
        if ($restrictToDictionaries) {
            $dictionaryArray = array_intersect($dictionaryArray, GeneralUtility::trimExplode(',', $restrictToDictionaries, 1));
        }
        if (empty($dictionaryArray)) {
            $dictionaryArray[] = 'en';
        }
        $this->dictionary = GeneralUtility::_POST('dictionary');
        uasort($dictionaryArray, 'strcoll');
        $dictionaryList = implode(',', $dictionaryArray);
        // Setting the dictionary
        if (empty($this->dictionary) || !in_array($this->dictionary, $dictionaryArray)) {
            $this->dictionary = 'en';
        }
        // Setting the pspell suggestion mode
        $this->pspellMode = GeneralUtility::_POST('pspell_mode') ? GeneralUtility::_POST('pspell_mode') : $this->pspellMode;
        switch ($this->pspellMode) {
            case 'ultra':
            case 'fast':
                $pspellModeFlag = PSPELL_FAST;
                break;
            case 'bad-spellers':
                $pspellModeFlag = PSPELL_BAD_SPELLERS;
                break;
            case 'normal':
            default:
                $pspellModeFlag = PSPELL_NORMAL;
                // sanitize $this->pspellMode
                $this->pspellMode = 'normal';
        }
        // Setting the charset
        if (GeneralUtility::_POST('pspell_charset')) {
            $this->charset = trim(GeneralUtility::_POST('pspell_charset'));
        }
        if (strtolower($this->charset) == 'iso-8859-1') {
            $this->parserCharset = strtolower($this->charset);
        }
        // In some configurations, Aspell uses 'iso8859-1' instead of 'iso-8859-1'
        $this->aspellEncoding = $this->parserCharset;
        if ($this->parserCharset == 'iso-8859-1' && strstr($this->defaultAspellEncoding, '8859-1')) {
            $this->aspellEncoding = $this->defaultAspellEncoding;
        }
        // However, we are going to work only in the parser charset
        if ($this->pspell_is_available && !$this->forceCommandMode) {
            $this->pspell_link = pspell_new($this->dictionary, '', '', $this->parserCharset, $pspellModeFlag);
        }
        // Setting the path to main dictionary
        $this->setMainDictionaryPath();
        // Setting the path to user personal dictionary, if any
        $this->setPersonalDictionaryPath();
        $this->fixPersonalDictionaryCharacterSet();
        $cmd = GeneralUtility::_POST('cmd');
        if ($cmd == 'learn') {
            // Only availble for BE_USERS, die silently if someone has gotten here by accident
            if (TYPO3_MODE !== 'BE' || !is_object($GLOBALS['BE_USER'])) {
                die('');
            }
            // Updating the personal word list
            $to_p_dict = GeneralUtility::_POST('to_p_dict');
            $to_p_dict = $to_p_dict ? $to_p_dict : [];
            $to_r_list = GeneralUtility::_POST('to_r_list');
            $to_r_list = $to_r_list ? $to_r_list : [];
            header('Content-Type: text/plain; charset=' . strtoupper($this->parserCharset));
            header('Pragma: no-cache');
            if ($to_p_dict || $to_r_list) {
                $tmpFileName = GeneralUtility::tempnam($this->filePrefix);
                $filehandle = fopen($tmpFileName, 'wb');
                if ($filehandle) {
                    // Get the character set of the main dictionary
                    // We need to convert the input into the character set of the main dictionary
                    $mainDictionaryCharacterSet = $this->getMainDictionaryCharacterSet();
                    // Write the personal words addition commands to the temporary file
                    foreach ($to_p_dict as $personal_word) {
                        $cmd = '&' . $this->csConvObj->conv($personal_word, $this->parserCharset, $mainDictionaryCharacterSet) . LF;
                        fwrite($filehandle, $cmd, strlen($cmd));
                    }
                    // Write the replacent pairs addition commands to the temporary file
                    foreach ($to_r_list as $replace_pair) {
                        $cmd = '$$ra ' . $this->csConvObj->conv($replace_pair[0], $this->parserCharset, $mainDictionaryCharacterSet) . ' , ' . $this->csConvObj->conv($replace_pair[1], $this->parserCharset, $mainDictionaryCharacterSet) . LF;
                        fwrite($filehandle, $cmd, strlen($cmd));
                    }
                    $cmd = '#' . LF;
                    $result = fwrite($filehandle, $cmd, strlen($cmd));
                    if ($result === false) {
                        GeneralUtility::sysLog('SpellChecker tempfile write error: ' . $tmpFileName, $this->extKey, GeneralUtility::SYSLOG_SEVERITY_ERROR);
                    } else {
                        // Assemble the Aspell command
                        $aspellCommand = (TYPO3_OS === 'WIN' ? 'type ' : 'cat ') . escapeshellarg($tmpFileName) . ' | ' . $this->AspellDirectory . ' -a --mode=none' . ($this->personalDictionaryPath ? ' --home-dir=' . escapeshellarg($this->personalDictionaryPath) : '') . ' --lang=' . escapeshellarg($this->dictionary) . ' --encoding=' . escapeshellarg($mainDictionaryCharacterSet) . ' 2>&1';
                        $aspellResult = shell_exec($aspellCommand);
                        // Close and delete the temporary file
                        fclose($filehandle);
                        GeneralUtility::unlink_tempfile($tmpFileName);
                    }
                } else {
                    GeneralUtility::sysLog('SpellChecker tempfile open error: ' . $tmpFileName, $this->extKey, GeneralUtility::SYSLOG_SEVERITY_ERROR);
                }
            }
            flush();
            die;
        } 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) . '">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=' . $this->parserCharset . '" />
<link rel="stylesheet" type="text/css" media="all" href="' . (TYPO3_MODE == 'BE' ? '../' : '') . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath($this->extKey) . '/Resources/Public/Css/Skin/Plugins/spell-checker-iframe.css" />
<script type="text/javascript">
/*<![CDATA[*/
<!--
';
            // Getting the input content
            $content = GeneralUtility::_POST('content');
            // Parsing the input HTML
            $parser = xml_parser_create(strtoupper($this->parserCharset));
            // Disables the functionality to allow external entities to be loaded when parsing the XML, must be kept
            $previousValueOfEntityLoader = libxml_disable_entity_loader(true);
            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, 'collectDataHandler')) {
                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> ' . preg_replace('/&nbsp;/' . ($this->parserCharset == 'utf-8' ? 'u' : ''), ' ', $content) . ' </spellchecker>')) {
                echo 'Bad parsing';
            }
            if (xml_get_error_code($parser)) {
                throw new \UnexpectedValueException('Line ' . xml_get_current_line_number($parser) . ': ' . xml_error_string(xml_get_error_code($parser)), 1294585788);
            }
            libxml_disable_entity_loader($previousValueOfEntityLoader);
            xml_parser_free($parser);
            if ($this->pspell_is_available && !$this->forceCommandMode) {
                pspell_clear_session($this->pspell_link);
            }
            $this->result .= 'var suggestedWords = {' . $this->suggestedWords . '};
var dictionaries = "' . $dictionaryList . '";
var selectedDictionary = "' . $this->dictionary . '";
';
            // Calculating parsing and spell checkting time
            $time = number_format(microtime(true) - $time_start, 2, ',', ' ');
            // Insert spellcheck info
            $this->result .= 'var spellcheckInfo = { "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.RTEarea[' . GeneralUtility::quoteJSvalue(GeneralUtility::_POST('editorId')) . '].editor.getPlugin(\'SpellChecker\').spellCheckComplete();">';
            $this->result .= preg_replace('/' . preg_quote('<?xml') . '.*' . preg_quote('?>') . '[' . preg_quote(LF . CR . chr(32)) . ']*/' . ($this->parserCharset == 'utf-8' ? 'u' : ''), '', $this->text);
            // Closing
            $this->result .= '
</body></html>';
            // Outputting
            $response = $response->withHeader('Content-Type', 'text/html; charset=' . strtoupper($this->parserCharset));
            $response->getBody()->write($this->result);
            return $response;
        }
    }
コード例 #29
0
 /**
  * Splitting a string for ImageTTFBBox up into an array where each part has its own configuration options.
  *
  * @param string $string UTF-8 string
  * @param array $splitRendering Split-rendering configuration from GIFBUILDER TEXT object.
  * @param int $fontSize Current fontsize
  * @param string $fontFile Current font file
  * @return array Array with input string splitted according to configuration
  */
 public function splitString($string, $splitRendering, $fontSize, $fontFile)
 {
     // Initialize by setting the whole string and default configuration as the first entry.
     $result = array();
     $result[] = array('str' => $string, 'fontSize' => $fontSize, 'fontFile' => $fontFile);
     // Traverse the split-rendering configuration:
     // Splitting will create more entries in $result with individual configurations.
     if (is_array($splitRendering)) {
         $sKeyArray = TemplateService::sortedKeyList($splitRendering);
         // Traverse configured options:
         foreach ($sKeyArray as $key) {
             $cfg = $splitRendering[$key . '.'];
             // Process each type of split rendering keyword:
             switch ((string) $splitRendering[$key]) {
                 case 'highlightWord':
                     if ((string) $cfg['value'] !== '') {
                         $newResult = array();
                         // Traverse the current parts of the result array:
                         foreach ($result as $part) {
                             // Explode the string value by the word value to highlight:
                             $explodedParts = explode($cfg['value'], $part['str']);
                             foreach ($explodedParts as $c => $expValue) {
                                 if ((string) $expValue !== '') {
                                     $newResult[] = array_merge($part, array('str' => $expValue));
                                 }
                                 if ($c + 1 < count($explodedParts)) {
                                     $newResult[] = array('str' => $cfg['value'], 'fontSize' => $cfg['fontSize'] ? $cfg['fontSize'] : $part['fontSize'], 'fontFile' => $cfg['fontFile'] ? $cfg['fontFile'] : $part['fontFile'], 'color' => $cfg['color'], 'xSpaceBefore' => $cfg['xSpaceBefore'], 'xSpaceAfter' => $cfg['xSpaceAfter'], 'ySpaceBefore' => $cfg['ySpaceBefore'], 'ySpaceAfter' => $cfg['ySpaceAfter']);
                                 }
                             }
                         }
                         // Set the new result as result array:
                         if (!empty($newResult)) {
                             $result = $newResult;
                         }
                     }
                     break;
                 case 'charRange':
                     if ((string) $cfg['value'] !== '') {
                         // Initialize range:
                         $ranges = GeneralUtility::trimExplode(',', $cfg['value'], true);
                         foreach ($ranges as $i => $rangeDef) {
                             $ranges[$i] = GeneralUtility::intExplode('-', $ranges[$i]);
                             if (!isset($ranges[$i][1])) {
                                 $ranges[$i][1] = $ranges[$i][0];
                             }
                         }
                         $newResult = array();
                         // Traverse the current parts of the result array:
                         foreach ($result as $part) {
                             // Initialize:
                             $currentState = -1;
                             $bankAccum = '';
                             // Explode the string value by the word value to highlight:
                             $utf8Chars = $this->csConvObj->utf8_to_numberarray($part['str'], true, true);
                             foreach ($utf8Chars as $utfChar) {
                                 // Find number and evaluate position:
                                 $uNumber = (int) $this->csConvObj->utf8CharToUnumber($utfChar);
                                 $inRange = 0;
                                 foreach ($ranges as $rangeDef) {
                                     if ($uNumber >= $rangeDef[0] && (!$rangeDef[1] || $uNumber <= $rangeDef[1])) {
                                         $inRange = 1;
                                         break;
                                     }
                                 }
                                 if ($currentState == -1) {
                                     $currentState = $inRange;
                                 }
                                 // Initialize first char
                                 // Switch bank:
                                 if ($inRange != $currentState && $uNumber !== 9 && $uNumber !== 10 && $uNumber !== 13 && $uNumber !== 32) {
                                     // Set result:
                                     if ($bankAccum !== '') {
                                         $newResult[] = array('str' => $bankAccum, 'fontSize' => $currentState && $cfg['fontSize'] ? $cfg['fontSize'] : $part['fontSize'], 'fontFile' => $currentState && $cfg['fontFile'] ? $cfg['fontFile'] : $part['fontFile'], 'color' => $currentState ? $cfg['color'] : '', 'xSpaceBefore' => $currentState ? $cfg['xSpaceBefore'] : '', 'xSpaceAfter' => $currentState ? $cfg['xSpaceAfter'] : '', 'ySpaceBefore' => $currentState ? $cfg['ySpaceBefore'] : '', 'ySpaceAfter' => $currentState ? $cfg['ySpaceAfter'] : '');
                                     }
                                     // Initialize new settings:
                                     $currentState = $inRange;
                                     $bankAccum = '';
                                 }
                                 // Add char to bank:
                                 $bankAccum .= $utfChar;
                             }
                             // Set result for FINAL part:
                             if ($bankAccum !== '') {
                                 $newResult[] = array('str' => $bankAccum, 'fontSize' => $currentState && $cfg['fontSize'] ? $cfg['fontSize'] : $part['fontSize'], 'fontFile' => $currentState && $cfg['fontFile'] ? $cfg['fontFile'] : $part['fontFile'], 'color' => $currentState ? $cfg['color'] : '', 'xSpaceBefore' => $currentState ? $cfg['xSpaceBefore'] : '', 'xSpaceAfter' => $currentState ? $cfg['xSpaceAfter'] : '', 'ySpaceBefore' => $currentState ? $cfg['ySpaceBefore'] : '', 'ySpaceAfter' => $currentState ? $cfg['ySpaceAfter'] : '');
                             }
                         }
                         // Set the new result as result array:
                         if (!empty($newResult)) {
                             $result = $newResult;
                         }
                     }
                     break;
             }
         }
     }
     return $result;
 }