[TASK] Use csConv API methods 85/45685/2
authorBenni Mack <benni@typo3.org>
Fri, 8 Jan 2016 10:18:31 +0000 (11:18 +0100)
committerMorton Jonuschat <m.jonuschat@mojocode.de>
Fri, 8 Jan 2016 19:50:43 +0000 (20:50 +0100)
There are several places in the core that use
TYPO3's homebrew charset conversion over the configured mbstring/iconv selection.

The change modifies the places to use the API methods
instead.

Resolves: #72590
Releases: master
Change-Id: Ibf8ed5e810d37c301db2b7e3f6e94b76a1061101
Reviewed-on: https://review.typo3.org/45685
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
typo3/sysext/fluid/Classes/ViewHelpers/Format/CaseViewHelper.php
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php
typo3/sysext/indexed_search/Classes/Controller/SearchController.php
typo3/sysext/indexed_search/Classes/Controller/SearchFormController.php
typo3/sysext/indexed_search/Classes/Indexer.php
typo3/sysext/indexed_search/Classes/Lexer.php

index fa52a89..1df9348 100644 (file)
@@ -145,10 +145,10 @@ class CaseViewHelper extends AbstractViewHelper implements CompilableInterface
                 $output = $charsetConverter->conv_case('utf-8', $value, 'toUpper');
                 break;
             case self::CASE_CAPITAL:
-                $output = $charsetConverter->utf8_substr($charsetConverter->convCaseFirst('utf-8', $value, 'toUpper'), 0, 1) . $charsetConverter->utf8_substr($value, 1);
+                $output = $charsetConverter->substr('utf-8', $charsetConverter->convCaseFirst('utf-8', $value, 'toUpper'), 0, 1) . $charsetConverter->substr('utf-8', $value, 1);
                 break;
             case self::CASE_UNCAPITAL:
-                $output = $charsetConverter->utf8_substr($charsetConverter->convCaseFirst('utf-8', $value, 'toLower'), 0, 1) . $charsetConverter->utf8_substr($value, 1);
+                $output = $charsetConverter->substr('utf-8', $charsetConverter->convCaseFirst('utf-8', $value, 'toLower'), 0, 1) . $charsetConverter->substr('utf-8', $value, 1);
                 break;
             case self::CASE_CAPITAL_WORDS:
                 // @todo: Implement method once there is a proper solution with using the CharsetConverter
index 7906830..5d295ec 100644 (file)
@@ -3945,7 +3945,7 @@ class ContentObjectRenderer
         $countSplittedContent = count($splittedContent);
         for ($offset = 0; $offset < $countSplittedContent; $offset++) {
             if ($offset % 2 === 0) {
-                $tempContent = $tsfe->csConvObj->utf8_encode($splittedContent[$offset], $tsfe->renderCharset);
+                $tempContent = $tsfe->csConvObj->conv($splittedContent[$offset], $tsfe->renderCharset, 'utf-8');
                 $thisStrLen = $tsfe->csConvObj->strlen('utf-8', html_entity_decode($tempContent, ENT_COMPAT, 'UTF-8'));
                 if ($strLen + $thisStrLen > $absChars) {
                     $croppedOffset = $offset;
@@ -3968,7 +3968,7 @@ class ContentObjectRenderer
                             }
                         }
                     }
-                    $splittedContent[$offset] = $tsfe->csConvObj->utf8_decode($tempContent, $tsfe->renderCharset);
+                    $splittedContent[$offset] = $tsfe->csConvObj->conv($tempContent, 'utf-8', $tsfe->renderCharset);
                     break;
                 } else {
                     $strLen += $thisStrLen;
index 8a08219..1397099 100644 (file)
@@ -3014,7 +3014,7 @@ class TypoScriptFrontendController
             $message = $this->config['config']['message_page_is_being_generated'];
             if ((string)$message !== '') {
                 // This page is always encoded as UTF-8
-                $message = $this->csConvObj->utf8_encode($message, $this->renderCharset);
+                $message = $this->csConvObj->conv($message, $this->renderCharset, 'utf-8');
                 $message = str_replace('###TITLE###', $title, $message);
                 $message = str_replace('###REQUEST_URI###', $request_uri, $message);
             } else {
index cff454f..5a98a11 100644 (file)
@@ -805,7 +805,7 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
         // 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 = $GLOBALS['TSFE']->csConvObj->utf8_encode($searchWords, $GLOBALS['TSFE']->metaCharset);
+        $searchWords = $GLOBALS['TSFE']->csConvObj->conv($searchWords, $GLOBALS['TSFE']->metaCharset, 'utf-8');
         $searchWords = $GLOBALS['TSFE']->csConvObj->entities_to_utf8($searchWords, true);
         $sWordArray = false;
         if ($hookObj = $this->hookRequest('getSearchWords')) {
@@ -828,9 +828,9 @@ class SearchController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
                     array('-', 'AND NOT'),
                     // Add operators for various languages
                     // Converts the operators to UTF-8 and lowercase
-                    array($GLOBALS['TSFE']->csConvObj->conv_case('utf-8', $GLOBALS['TSFE']->csConvObj->utf8_encode(LocalizationUtility::translate('localizedOperandAnd', 'IndexedSearch'), $GLOBALS['TSFE']->renderCharset), 'toLower'), 'AND'),
-                    array($GLOBALS['TSFE']->csConvObj->conv_case('utf-8', $GLOBALS['TSFE']->csConvObj->utf8_encode(LocalizationUtility::translate('localizedOperandOr', 'IndexedSearch'), $GLOBALS['TSFE']->renderCharset), 'toLower'), 'OR'),
-                    array($GLOBALS['TSFE']->csConvObj->conv_case('utf-8', $GLOBALS['TSFE']->csConvObj->utf8_encode(LocalizationUtility::translate('localizedOperandNot', 'IndexedSearch'), $GLOBALS['TSFE']->renderCharset), 'toLower'), 'AND NOT')
+                    array($GLOBALS['TSFE']->csConvObj->conv_case('utf-8', $GLOBALS['TSFE']->csConvObj->conv(LocalizationUtility::translate('localizedOperandAnd', 'IndexedSearch'), $GLOBALS['TSFE']->renderCharset, 'utf-8'), 'toLower'), 'AND'),
+                    array($GLOBALS['TSFE']->csConvObj->conv_case('utf-8', $GLOBALS['TSFE']->csConvObj->conv(LocalizationUtility::translate('localizedOperandOr', 'IndexedSearch'), $GLOBALS['TSFE']->renderCharset, 'utf-8'), 'toLower'), 'OR'),
+                    array($GLOBALS['TSFE']->csConvObj->conv_case('utf-8', $GLOBALS['TSFE']->csConvObj->conv(LocalizationUtility::translate('localizedOperandNot', 'IndexedSearch'), $GLOBALS['TSFE']->renderCharset, 'utf-8'), 'toLower'), 'AND NOT')
                 );
                 $swordArray = \TYPO3\CMS\IndexedSearch\Utility\IndexedSearchUtility::getExplodedSearchString($searchWords, $defaultOperator == 1 ? 'OR' : 'AND', $operatorTranslateTable);
                 if (is_array($swordArray)) {
index 7a656a3..44631ae 100755 (executable)
@@ -326,9 +326,9 @@ class SearchFormController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin
         }
         // Add operators for various languages
         // Converts the operators to UTF-8 and lowercase
-        $this->operator_translate_table[] = array($this->frontendController->csConvObj->conv_case('utf-8', $this->frontendController->csConvObj->utf8_encode($this->pi_getLL('local_operator_AND'), $this->frontendController->renderCharset), 'toLower'), 'AND');
-        $this->operator_translate_table[] = array($this->frontendController->csConvObj->conv_case('utf-8', $this->frontendController->csConvObj->utf8_encode($this->pi_getLL('local_operator_OR'), $this->frontendController->renderCharset), 'toLower'), 'OR');
-        $this->operator_translate_table[] = array($this->frontendController->csConvObj->conv_case('utf-8', $this->frontendController->csConvObj->utf8_encode($this->pi_getLL('local_operator_NOT'), $this->frontendController->renderCharset), 'toLower'), 'AND NOT');
+        $this->operator_translate_table[] = array($this->frontendController->csConvObj->conv_case('utf-8', $this->frontendController->csConvObj->conv($this->pi_getLL('local_operator_AND'), $this->frontendController->renderCharset, 'utf-8'), 'toLower'), 'AND');
+        $this->operator_translate_table[] = array($this->frontendController->csConvObj->conv_case('utf-8', $this->frontendController->csConvObj->conv($this->pi_getLL('local_operator_OR'), $this->frontendController->renderCharset, 'utf-8'), 'toLower'), 'OR');
+        $this->operator_translate_table[] = array($this->frontendController->csConvObj->conv_case('utf-8', $this->frontendController->csConvObj->conv($this->pi_getLL('local_operator_NOT'), $this->frontendController->renderCharset, 'utf-8'), 'toLower'), 'AND NOT');
         // This is the id of the site root. This value may be a commalist of integer (prepared for this)
         $this->wholeSiteIdList = (int)$this->frontendController->config['rootLine'][0]['uid'];
         // Creating levels for section menu:
@@ -419,7 +419,7 @@ class SearchFormController extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin
         // 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->frontendController->csConvObj->utf8_encode($inSW, $this->frontendController->metaCharset);
+        $inSW = $this->frontendController->csConvObj->conv($inSW, $this->frontendController->metaCharset, 'utf-8');
         $inSW = $this->frontendController->csConvObj->entities_to_utf8($inSW, true);
         $sWordArray = false;
         if ($hookObj = $this->hookRequest('getSearchWords')) {
index 08bf720..69b0a7e 100644 (file)
@@ -670,7 +670,7 @@ class Indexer
         $charset = $this->csObj->parse_charset($charset);
         // Convert charset:
         if ($charset && $charset !== 'utf-8') {
-            $content = $this->csObj->utf8_encode($content, $charset);
+            $content = $this->csObj->conv($content, $charset, 'utf-8');
         }
         // Convert entities, assuming document is now UTF-8:
         return $this->csObj->entities_to_utf8($content, true);
@@ -1272,7 +1272,7 @@ class Indexer
         foreach ($contentArr as $key => $value) {
             if ((string)$contentArr[$key] !== '') {
                 if ($charset !== 'utf-8') {
-                    $contentArr[$key] = $this->csObj->utf8_encode($contentArr[$key], $charset);
+                    $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], true);
index 345d76d..97260b9 100644 (file)
@@ -136,11 +136,11 @@ class Lexer
          */
         if ($cType == 'cjk') {
             // Find total string length:
-            $strlen = $this->csObj->utf8_strlen($theWord);
+            $strlen = $this->csObj->strlen('utf-8', $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);
+                    $words[] = $this->csObj->substr('utf-8', $theWord, $a, 2);
                 }
             }
         } else {