/**
  * 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
  */
 function charsetEntity2utf8(&$contentArr, $charset)
 {
     // Convert charset if necessary
     foreach ($contentArr as $key => $value) {
         if (strlen($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);
         }
     }
 }
 /**
  * Set the pagename for the logfile entry
  *
  * @return	void
  * @access private
  */
 protected function statistics_init_pagename()
 {
     if (preg_match('/utf-?8/i', $this->config['config']['stat_apache_niceTitle'])) {
         // Make life easier and accept variants for utf-8
         $this->config['config']['stat_apache_niceTitle'] = 'utf-8';
     }
     if ($this->config['config']['stat_apache_niceTitle'] == 'utf-8') {
         $shortTitle = $this->csConvObj->utf8_encode($this->page['title'], $this->renderCharset);
     } elseif ($this->config['config']['stat_apache_niceTitle']) {
         $shortTitle = $this->csConvObj->specCharsToASCII($this->renderCharset, $this->page['title']);
     } else {
         $shortTitle = $this->page['title'];
     }
     $len = t3lib_div::intInRange($this->config['config']['stat_apache_pageLen'], 1, 100, 30);
     if ($this->config['config']['stat_apache_niceTitle'] == 'utf-8') {
         $shortTitle = rawurlencode($this->csConvObj->substr('utf-8', $shortTitle, 0, $len));
     } else {
         $shortTitle = substr(preg_replace('/[^.[:alnum:]_-]/', '_', $shortTitle), 0, $len);
     }
     $pageName = $this->config['config']['stat_apache_pagenames'] ? $this->config['config']['stat_apache_pagenames'] : '[path][title]--[uid].html';
     $pageName = str_replace('[title]', $shortTitle, $pageName);
     $pageName = str_replace('[uid]', $this->page['uid'], $pageName);
     $pageName = str_replace('[alias]', $this->page['alias'], $pageName);
     $pageName = str_replace('[type]', $this->type, $pageName);
     $pageName = str_replace('[request_uri]', t3lib_div::getIndpEnv('REQUEST_URI'), $pageName);
     $temp = $this->config['rootLine'];
     if ($temp) {
         // rootLine does not exist if this function is called at early stage (e.g. if DB connection failed)
         array_pop($temp);
         if ($this->config['config']['stat_apache_noRoot']) {
             array_shift($temp);
         }
         $len = t3lib_div::intInRange($this->config['config']['stat_titleLen'], 1, 100, 20);
         if ($this->config['config']['stat_apache_niceTitle'] == 'utf-8') {
             $path = '';
             $c = count($temp);
             for ($i = 0; $i < $c; $i++) {
                 if ($temp[$i]['uid']) {
                     $p = $this->csConvObj->crop('utf-8', $this->csConvObj->utf8_encode($temp[$i]['title'], $this->renderCharset), $len, "…");
                     // U+2026; HORIZONTAL ELLIPSIS
                     $path .= '/' . rawurlencode($p);
                 }
             }
         } elseif ($this->config['config']['stat_apache_niceTitle']) {
             $path = $this->csConvObj->specCharsToASCII($this->renderCharset, $this->sys_page->getPathFromRootline($temp, $len));
         } else {
             $path = $this->sys_page->getPathFromRootline($temp, $len);
         }
     } else {
         $path = '';
         // If rootLine is missing, we just drop the path...
     }
     if ($this->config['config']['stat_apache_niceTitle'] == 'utf-8') {
         $this->config['stat_vars']['pageName'] = str_replace('[path]', $path . '/', $pageName);
     } else {
         $this->config['stat_vars']['pageName'] = str_replace('[path]', preg_replace('/[^.[:alnum:]\\/_-]/', '_', $path . '/'), $pageName);
     }
 }
 /**
  * Recode string
  * Used with text strings for fonts when languages has other character sets.
  *
  * @param	string		The text to recode
  * @return	string		The recoded string. Should be UTF-8 output. MAY contain entities (eg. &#123; or &#quot; which should render as real chars).
  */
 function recodeString($string)
 {
     // Recode string to UTF-8 from $this->nativeCharset:
     if ($this->nativeCharset && $this->nativeCharset != 'utf-8') {
         $string = $this->csConvObj->utf8_encode($string, $this->nativeCharset);
         // Convert to UTF-8
     }
     // Recode string accoding to TTFLocaleConv. Deprecated.
     if ($this->TTFLocaleConv) {
         t3lib_div::deprecationLog('The option $TYPO3_CONF_VARS[\'GFX\'][\'TTFLocaleConv\'] is in use, but deprecated since TYPO3 3.6, will be removed in TYPO3 4.6. Make sure to unset this variable in your typo3conf/localconf.php and use a different way to encode your string.');
         list($from, $to) = t3lib_div::trimExplode('..', $this->TTFLocaleConv, TRUE);
         $string = $this->csConvObj->conv($string, $from, $to);
     }
     return $string;
 }
Beispiel #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		Input string, encoded with $this->charSet
  * @return	string		Output string, a JavaScript function: "String.fromCharCode(......)"
  * @access	public
  */
 public function JScharCode($str)
 {
     // Convert string to UTF-8:
     if ($this->charSet != 'utf-8') {
         $str = $this->csConvObj->utf8_encode($str, $this->charSet);
     }
     // Convert the UTF-8 string into a array of char numbers:
     $nArr = $this->csConvObj->utf8_to_numberarray($str);
     return 'String.fromCharCode(' . implode(',', $nArr) . ')';
 }