Index: t3lib/class.t3lib_div.php
===================================================================
--- t3lib/class.t3lib_div.php	(revision 9354)
+++ t3lib/class.t3lib_div.php	(revision )
@@ -1,29 +1,29 @@
 <?php
 /***************************************************************
-*  Copyright notice
-*
-*  (c) 1999-2010 Kasper Skårhøj (kasperYYYY@typo3.com)
-*  All rights reserved
-*
-*  This script is part of the TYPO3 project. The TYPO3 project is
-*  free software; you can redistribute it and/or modify
-*  it under the terms of the GNU General Public License as published by
-*  the Free Software Foundation; either version 2 of the License, or
-*  (at your option) any later version.
-*
-*  The GNU General Public License can be found at
-*  http://www.gnu.org/copyleft/gpl.html.
-*  A copy is found in the textfile GPL.txt and important notices to the license
-*  from the author is found in LICENSE.txt distributed with these scripts.
-*
-*
-*  This script is distributed in the hope that it will be useful,
-*  but WITHOUT ANY WARRANTY; without even the implied warranty of
-*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-*  GNU General Public License for more details.
-*
-*  This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
+ *  Copyright notice
+ *
+ *  (c) 1999-2010 Kasper Skårhøj (kasperYYYY@typo3.com)
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *  A copy is found in the textfile GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
 /**
  * Contains the reknown class "t3lib_div" with general purpose functions
  *
@@ -41,161 +41,161 @@
  *
  *  232: class t3lib_div
  *
- *              SECTION: GET/POST Variables
+ *			  SECTION: GET/POST Variables
- *  262:     function _GP($var)
+ *  262:	 function _GP($var)
- *  280:     function _GET($var=NULL)
+ *  280:	 function _GET($var=NULL)
- *  297:     function _POST($var=NULL)
+ *  297:	 function _POST($var=NULL)
- *  313:     function _GETset($inputGet,$key='')
+ *  313:	 function _GETset($inputGet,$key='')
- *  336:     function GPvar($var,$strip=0)
+ *  336:	 function GPvar($var,$strip=0)
- *  353:     function GParrayMerged($var)
+ *  353:	 function GParrayMerged($var)
  *
- *              SECTION: IMAGE FUNCTIONS
+ *			  SECTION: IMAGE FUNCTIONS
- *  397:     function gif_compress($theFile, $type)
+ *  397:	 function gif_compress($theFile, $type)
- *  425:     function png_to_gif_by_imagemagick($theFile)
+ *  425:	 function png_to_gif_by_imagemagick($theFile)
- *  450:     function read_png_gif($theFile,$output_png=0)
+ *  450:	 function read_png_gif($theFile,$output_png=0)
  *
- *              SECTION: STRING FUNCTIONS
+ *			  SECTION: STRING FUNCTIONS
- *  499:     function fixed_lgd($string,$origChars,$preStr='...')
+ *  499:	 function fixed_lgd($string,$origChars,$preStr='...')
- *  524:     function fixed_lgd_pre($string,$chars)
+ *  524:	 function fixed_lgd_pre($string,$chars)
- *  538:     function fixed_lgd_cs($string,$chars)
+ *  538:	 function fixed_lgd_cs($string,$chars)
- *  555:     function breakTextForEmail($str,$implChar=LF,$charWidth=76)
+ *  555:	 function breakTextForEmail($str,$implChar=LF,$charWidth=76)
- *  574:     function breakLinesForEmail($str,$implChar=LF,$charWidth=76)
+ *  574:	 function breakLinesForEmail($str,$implChar=LF,$charWidth=76)
- *  610:     function cmpIP($baseIP, $list)
+ *  610:	 function cmpIP($baseIP, $list)
- *  626:     function cmpIPv4($baseIP, $list)
+ *  626:	 function cmpIPv4($baseIP, $list)
- *  668:     function cmpIPv6($baseIP, $list)
+ *  668:	 function cmpIPv6($baseIP, $list)
- *  711:     function IPv6Hex2Bin ($hex)
+ *  711:	 function IPv6Hex2Bin ($hex)
- *  726:     function normalizeIPv6($address)
+ *  726:	 function normalizeIPv6($address)
- *  782:     function validIPv6($ip)
+ *  782:	 function validIPv6($ip)
- *  805:     function cmpFQDN($baseIP, $list)
+ *  805:	 function cmpFQDN($baseIP, $list)
- *  835:     function inList($list,$item)
+ *  835:	 function inList($list,$item)
- *  847:     function rmFromList($element,$list)
+ *  847:	 function rmFromList($element,$list)
- *  863:     function expandList($list)
+ *  863:	 function expandList($list)
- *  894:     function intInRange($theInt,$min,$max=2000000000,$zeroValue=0)
+ *  894:	 function intInRange($theInt,$min,$max=2000000000,$zeroValue=0)
- *  910:     function intval_positive($theInt)
+ *  910:	 function intval_positive($theInt)
- *  923:     function int_from_ver($verNumberStr)
+ *  923:	 function int_from_ver($verNumberStr)
- *  934:     function compat_version($verNumberStr)
+ *  934:	 function compat_version($verNumberStr)
- *  952:     function md5int($str)
+ *  952:	 function md5int($str)
- *  965:     function shortMD5($input, $len=10)
+ *  965:	 function shortMD5($input, $len=10)
- *  978:     function uniqueList($in_list, $secondParameter=NULL)
+ *  978:	 function uniqueList($in_list, $secondParameter=NULL)
- *  992:     function split_fileref($fileref)
+ *  992:	 function split_fileref($fileref)
- * 1030:     function dirname($path)
+ * 1030:	 function dirname($path)
- * 1046:     function modifyHTMLColor($color,$R,$G,$B)
+ * 1046:	 function modifyHTMLColor($color,$R,$G,$B)
- * 1066:     function modifyHTMLColorAll($color,$all)
+ * 1066:	 function modifyHTMLColorAll($color,$all)
- * 1077:     function rm_endcomma($string)
+ * 1077:	 function rm_endcomma($string)
- * 1090:     function danish_strtoupper($string)
+ * 1090:	 function danish_strtoupper($string)
- * 1105:     function convUmlauts($str)
+ * 1105:	 function convUmlauts($str)
- * 1118:     function testInt($var)
+ * 1118:	 function testInt($var)
- * 1130:     function isFirstPartOfStr($str,$partStr)
+ * 1130:	 function isFirstPartOfStr($str,$partStr)
- * 1146:     function formatSize($sizeInBytes,$labels='')
+ * 1146:	 function formatSize($sizeInBytes,$labels='')
- * 1181:     function convertMicrotime($microtime)
+ * 1181:	 function convertMicrotime($microtime)
- * 1195:     function splitCalc($string,$operators)
+ * 1195:	 function splitCalc($string,$operators)
- * 1217:     function calcPriority($string)
+ * 1217:	 function calcPriority($string)
- * 1258:     function calcParenthesis($string)
+ * 1258:	 function calcParenthesis($string)
- * 1284:     function htmlspecialchars_decode($value)
+ * 1284:	 function htmlspecialchars_decode($value)
- * 1299:     function deHSCentities($str)
+ * 1299:	 function deHSCentities($str)
- * 1312:     function slashJS($string,$extended=0,$char="'")
+ * 1312:	 function slashJS($string,$extended=0,$char="'")
- * 1325:     function rawUrlEncodeJS($str)
+ * 1325:	 function rawUrlEncodeJS($str)
- * 1337:     function rawUrlEncodeFP($str)
+ * 1337:	 function rawUrlEncodeFP($str)
- * 1348:     function validEmail($email)
+ * 1348:	 function validEmail($email)
- * 1363:     function formatForTextarea($content)
+ * 1363:	 function formatForTextarea($content)
  *
- *              SECTION: ARRAY FUNCTIONS
+ *			  SECTION: ARRAY FUNCTIONS
- * 1394:     function inArray($in_array,$item)
+ * 1394:	 function inArray($in_array,$item)
- * 1411:     function intExplode($delim, $string)
+ * 1411:	 function intExplode($delim, $string)
- * 1430:     function revExplode($delim, $string, $count=0)
+ * 1430:	 function revExplode($delim, $string, $count=0)
- * 1450:     function trimExplode($delim, $string, $onlyNonEmptyValues=0)
+ * 1450:	 function trimExplode($delim, $string, $onlyNonEmptyValues=0)
- * 1472:     function uniqueArray($valueArray)
+ * 1472:	 function uniqueArray($valueArray)
- * 1484:     function removeArrayEntryByValue($array,$cmpValue)
+ * 1484:	 function removeArrayEntryByValue($array,$cmpValue)
- * 1513:     function implodeArrayForUrl($name,$theArray,$str='',$skipBlank=0,$rawurlencodeParamName=0)
+ * 1513:	 function implodeArrayForUrl($name,$theArray,$str='',$skipBlank=0,$rawurlencodeParamName=0)
- * 1538:     function explodeUrl2Array($string,$multidim=FALSE)
+ * 1538:	 function explodeUrl2Array($string,$multidim=FALSE)
- * 1564:     function compileSelectedGetVarsFromArray($varList,$getArray,$GPvarAlt=1)
+ * 1564:	 function compileSelectedGetVarsFromArray($varList,$getArray,$GPvarAlt=1)
- * 1587:     function addSlashesOnArray(&$theArray)
+ * 1587:	 function addSlashesOnArray(&$theArray)
- * 1611:     function stripSlashesOnArray(&$theArray)
+ * 1611:	 function stripSlashesOnArray(&$theArray)
- * 1633:     function slashArray($arr,$cmd)
+ * 1633:	 function slashArray($arr,$cmd)
- * 1650:     function array_merge_recursive_overrule($arr0,$arr1,$notAddKeys=0,$includeEmtpyValues=true)
+ * 1650:	 function array_merge_recursive_overrule($arr0,$arr1,$notAddKeys=0,$includeEmtpyValues=true)
- * 1683:     function array_merge($arr1,$arr2)
+ * 1683:	 function array_merge($arr1,$arr2)
- * 1696:     function csvValues($row,$delim=',',$quote='"')
+ * 1696:	 function csvValues($row,$delim=',',$quote='"')
  *
- *              SECTION: HTML/XML PROCESSING
+ *			  SECTION: HTML/XML PROCESSING
- * 1738:     function get_tag_attributes($tag)
+ * 1738:	 function get_tag_attributes($tag)
- * 1775:     function split_tag_attributes($tag)
+ * 1775:	 function split_tag_attributes($tag)
- * 1809:     function implodeAttributes($arr,$xhtmlSafe=FALSE,$dontOmitBlankAttribs=FALSE)
+ * 1809:	 function implodeAttributes($arr,$xhtmlSafe=FALSE,$dontOmitBlankAttribs=FALSE)
- * 1836:     function implodeParams($arr,$xhtmlSafe=FALSE,$dontOmitBlankAttribs=FALSE)
+ * 1836:	 function implodeParams($arr,$xhtmlSafe=FALSE,$dontOmitBlankAttribs=FALSE)
- * 1851:     function wrapJS($string, $linebreak=TRUE)
+ * 1851:	 function wrapJS($string, $linebreak=TRUE)
- * 1882:     function xml2tree($string,$depth=999)
+ * 1882:	 function xml2tree($string,$depth=999)
- * 1969:     function array2xml($array,$NSprefix='',$level=0,$docTag='phparray',$spaceInd=0, $options=array(),$stackData=array())
+ * 1969:	 function array2xml($array,$NSprefix='',$level=0,$docTag='phparray',$spaceInd=0, $options=array(),$stackData=array())
- * 2088:     function xml2array($string,$NSprefix='',$reportDocTag=FALSE)
+ * 2088:	 function xml2array($string,$NSprefix='',$reportDocTag=FALSE)
- * 2198:     function xmlRecompileFromStructValArray($vals)
+ * 2198:	 function xmlRecompileFromStructValArray($vals)
- * 2242:     function xmlGetHeaderAttribs($xmlData)
+ * 2242:	 function xmlGetHeaderAttribs($xmlData)
  *
- *              SECTION: FILES FUNCTIONS
+ *			  SECTION: FILES FUNCTIONS
- * 2275:     function getURL($url, $includeHeader=0)
+ * 2275:	 function getURL($url, $includeHeader=0)
- * 2342:     function writeFile($file,$content)
+ * 2342:	 function writeFile($file,$content)
- * 2367:     function fixPermissions($file)
+ * 2367:	 function fixPermissions($file)
- * 2384:     function writeFileToTypo3tempDir($filepath,$content)
+ * 2384:	 function writeFileToTypo3tempDir($filepath,$content)
- * 2427:     function mkdir($theNewFolder)
+ * 2427:	 function mkdir($theNewFolder)
- * 2446:     function mkdir_deep($destination,$deepDir)
+ * 2446:	 function mkdir_deep($destination,$deepDir)
- * 2468:     function get_dirs($path)
+ * 2468:	 function get_dirs($path)
- * 2493:     function getFilesInDir($path,$extensionList='',$prependPath=0,$order='')
+ * 2493:	 function getFilesInDir($path,$extensionList='',$prependPath=0,$order='')
- * 2547:     function getAllFilesAndFoldersInPath($fileArr,$path,$extList='',$regDirs=0,$recursivityLevels=99)
+ * 2547:	 function getAllFilesAndFoldersInPath($fileArr,$path,$extList='',$regDirs=0,$recursivityLevels=99)
- * 2570:     function removePrefixPathFromList($fileArr,$prefixToRemove)
+ * 2570:	 function removePrefixPathFromList($fileArr,$prefixToRemove)
- * 2586:     function fixWindowsFilePath($theFile)
+ * 2586:	 function fixWindowsFilePath($theFile)
- * 2598:     function resolveBackPath($pathStr)
+ * 2598:	 function resolveBackPath($pathStr)
- * 2626:     function locationHeaderUrl($path)
+ * 2626:	 function locationHeaderUrl($path)
  *
- *              SECTION: DEBUG helper FUNCTIONS
+ *			  SECTION: DEBUG helper FUNCTIONS
- * 2666:     function debug_ordvalue($string,$characters=100)
+ * 2666:	 function debug_ordvalue($string,$characters=100)
- * 2683:     function view_array($array_in)
+ * 2683:	 function view_array($array_in)
- * 2711:     function print_array($array_in)
+ * 2711:	 function print_array($array_in)
- * 2726:     function debug($var="",$brOrHeader=0)
+ * 2726:	 function debug($var="",$brOrHeader=0)
- * 2757:     function debug_trail()
+ * 2757:	 function debug_trail()
- * 2779:     function debugRows($rows,$header='')
+ * 2779:	 function debugRows($rows,$header='')
  *
- *              SECTION: SYSTEM INFORMATION
+ *			  SECTION: SYSTEM INFORMATION
- * 2857:     function getThisUrl()
+ * 2857:	 function getThisUrl()
- * 2873:     function linkThisScript($getParams=array())
+ * 2873:	 function linkThisScript($getParams=array())
- * 2897:     function linkThisUrl($url,$getParams=array())
+ * 2897:	 function linkThisUrl($url,$getParams=array())
- * 2920:     function getIndpEnv($getEnvName)
+ * 2920:	 function getIndpEnv($getEnvName)
- * 3113:     function milliseconds()
+ * 3113:	 function milliseconds()
- * 3125:     function clientInfo($useragent='')
+ * 3125:	 function clientInfo($useragent='')
  *
- *              SECTION: TYPO3 SPECIFIC FUNCTIONS
+ *			  SECTION: TYPO3 SPECIFIC FUNCTIONS
- * 3212:     function getFileAbsFileName($filename,$onlyRelative=1,$relToTYPO3_mainDir=0)
+ * 3212:	 function getFileAbsFileName($filename,$onlyRelative=1,$relToTYPO3_mainDir=0)
- * 3248:     function validPathStr($theFile)
+ * 3248:	 function validPathStr($theFile)
- * 3259:     function isAbsPath($path)
+ * 3259:	 function isAbsPath($path)
- * 3270:     function isAllowedAbsPath($path)
+ * 3270:	 function isAllowedAbsPath($path)
- * 3287:     function verifyFilenameAgainstDenyPattern($filename)
+ * 3287:	 function verifyFilenameAgainstDenyPattern($filename)
- * 3305:     function upload_copy_move($source,$destination)
+ * 3305:	 function upload_copy_move($source,$destination)
- * 3331:     function upload_to_tempfile($uploadedFileName)
+ * 3331:	 function upload_to_tempfile($uploadedFileName)
- * 3349:     function unlink_tempfile($uploadedTempFileName)
+ * 3349:	 function unlink_tempfile($uploadedTempFileName)
- * 3365:     function tempnam($filePrefix)
+ * 3365:	 function tempnam($filePrefix)
- * 3379:     function stdAuthCode($uid_or_record,$fields='',$codeLength=8)
+ * 3379:	 function stdAuthCode($uid_or_record,$fields='',$codeLength=8)
- * 3410:     function cHashParams($addQueryParams)
+ * 3410:	 function cHashParams($addQueryParams)
- * 3433:     function hideIfNotTranslated($l18n_cfg_fieldValue)
+ * 3433:	 function hideIfNotTranslated($l18n_cfg_fieldValue)
- * 3448:     function readLLfile($fileRef,$langKey)
+ * 3448:	 function readLLfile($fileRef,$langKey)
- * 3472:     function readLLXMLfile($fileRef,$langKey)
+ * 3472:	 function readLLXMLfile($fileRef,$langKey)
- * 3589:     function llXmlAutoFileName($fileRef,$language)
+ * 3589:	 function llXmlAutoFileName($fileRef,$language)
- * 3633:     function loadTCA($table)
+ * 3633:	 function loadTCA($table)
- * 3653:     function resolveSheetDefInDS($dataStructArray,$sheet='sDEF')
+ * 3653:	 function resolveSheetDefInDS($dataStructArray,$sheet='sDEF')
- * 3686:     function resolveAllSheetsInDS($dataStructArray)
+ * 3686:	 function resolveAllSheetsInDS($dataStructArray)
- * 3715:     function callUserFunction($funcName,&$params,&$ref,$checkPrefix='user_',$silent=0)
+ * 3715:	 function callUserFunction($funcName,&$params,&$ref,$checkPrefix='user_',$silent=0)
- * 3813:     function &getUserObj($classRef,$checkPrefix='user_',$silent=0)
+ * 3813:	 function &getUserObj($classRef,$checkPrefix='user_',$silent=0)
- * 3871:     function &makeInstance($className)
+ * 3871:	 function &makeInstance($className)
- * 3883:     function makeInstanceClassName($className)
+ * 3883:	 function makeInstanceClassName($className)
- * 3897:     function &makeInstanceService($serviceType, $serviceSubType='', $excludeServiceKeys=array())
+ * 3897:	 function &makeInstanceService($serviceType, $serviceSubType='', $excludeServiceKeys=array())
- * 3961:     function plainMailEncoded($email,$subject,$message,$headers='',$enc='',$charset='',$dontEncodeHeader=false)
+ * 3961:	 function plainMailEncoded($email,$subject,$message,$headers='',$enc='',$charset='',$dontEncodeHeader=false)
- * 4031:     function quoted_printable($string,$maxlen=76)
+ * 4031:	 function quoted_printable($string,$maxlen=76)
- * 4078:     function encodeHeader($line,$enc='',$charset='ISO-8859-1')
+ * 4078:	 function encodeHeader($line,$enc='',$charset='ISO-8859-1')
- * 4121:     function substUrlsInPlainText($message,$urlmode='76',$index_script_url='')
+ * 4121:	 function substUrlsInPlainText($message,$urlmode='76',$index_script_url='')
- * 4155:     function makeRedirectUrl($inUrl,$l=0,$index_script_url='')
+ * 4155:	 function makeRedirectUrl($inUrl,$l=0,$index_script_url='')
- * 4182:     function freetypeDpiComp($font_size)
+ * 4182:	 function freetypeDpiComp($font_size)
- * 4194:     function initSysLog()
+ * 4194:	 function initSysLog()
- * 4251:     function sysLog($msg, $extKey, $severity=0)
+ * 4251:	 function sysLog($msg, $extKey, $severity=0)
- * 4334:     function devLog($msg, $extKey, $severity=0, $dataVar=FALSE)
+ * 4334:	 function devLog($msg, $extKey, $severity=0, $dataVar=FALSE)
- * 4355:     function arrayToLogString($arr, $valueList=array(), $valueLength=20)
+ * 4355:	 function arrayToLogString($arr, $valueList=array(), $valueLength=20)
- * 4378:     function imageMagickCommand($command, $parameters, $path='')
+ * 4378:	 function imageMagickCommand($command, $parameters, $path='')
- * 4425:     function unQuoteFilenames($parameters,$unQuote=FALSE)
+ * 4425:	 function unQuoteFilenames($parameters,$unQuote=FALSE)
- * 4459:     function quoteJSvalue($value, $inScriptTags = false)
+ * 4459:	 function quoteJSvalue($value, $inScriptTags = false)
  *
  * TOTAL FUNCTIONS: 138
  * (This index is automatically created/updated by the extension "extdeveval")
@@ -260,12 +260,18 @@
 	 * @param	string		GET/POST var to return
 	 * @return	mixed		POST var named $var and if not set, the GET var of the same name.
 	 */
-	public static function _GP($var)	{
+	public static function _GP($var) {
-		if(empty($var)) return;
+		if (empty($var)) {
+			return;
+		}
 		$value = isset($_POST[$var]) ? $_POST[$var] : $_GET[$var];
-		if (isset($value))	{
+		if (isset($value)) {
-			if (is_array($value))	{ self::stripSlashesOnArray($value); } else { $value = stripslashes($value); }
+			if (is_array($value)) {
+				self::stripSlashesOnArray($value);
+			} else {
+				$value = stripslashes($value);
-		}
+			}
+		}
 		return $value;
 	}
 
@@ -277,7 +283,7 @@
 	 */
 	public static function _GPmerged($parameter) {
 		$postParameter = (isset($_POST[$parameter]) && is_array($_POST[$parameter])) ? $_POST[$parameter] : array();
-		$getParameter  = (isset($_GET[$parameter]) && is_array($_GET[$parameter])) ? $_GET[$parameter] : array();
+		$getParameter = (isset($_GET[$parameter]) && is_array($_GET[$parameter])) ? $_GET[$parameter] : array();
 
 		$mergedParameters = self::array_merge_recursive_overrule($getParameter, $postParameter);
 		self::stripSlashesOnArray($mergedParameters);
@@ -294,11 +300,15 @@
 	 * @return	mixed		If $var is set it returns the value of $_GET[$var]. If $var is NULL (default), returns $_GET itself. In any case *slashes are stipped from the output!*
 	 * @see _POST(), _GP(), _GETset()
 	 */
-	public static function _GET($var=NULL)	{
+	public static function _GET($var = NULL) {
 		$value = ($var === NULL) ? $_GET : (empty($var) ? NULL : $_GET[$var]);
-		if (isset($value))	{	// Removes slashes since TYPO3 has added them regardless of magic_quotes setting.
+		if (isset($value)) { // Removes slashes since TYPO3 has added them regardless of magic_quotes setting.
-			if (is_array($value))	{ self::stripSlashesOnArray($value); } else { $value = stripslashes($value); }
+			if (is_array($value)) {
+				self::stripSlashesOnArray($value);
+			} else {
+				$value = stripslashes($value);
-		}
+			}
+		}
 		return $value;
 	}
 
@@ -311,11 +321,15 @@
 	 * @return	mixed		If $var is set it returns the value of $_POST[$var]. If $var is NULL (default), returns $_POST itself. In any case *slashes are stipped from the output!*
 	 * @see _GET(), _GP()
 	 */
-	public static function _POST($var=NULL)	{
+	public static function _POST($var = NULL) {
 		$value = ($var === NULL) ? $_POST : (empty($var) ? NULL : $_POST[$var]);
-		if (isset($value))	{	// Removes slashes since TYPO3 has added them regardless of magic_quotes setting.
+		if (isset($value)) { // Removes slashes since TYPO3 has added them regardless of magic_quotes setting.
-			if (is_array($value))	{ self::stripSlashesOnArray($value); } else { $value = stripslashes($value); }
+			if (is_array($value)) {
+				self::stripSlashesOnArray($value);
+			} else {
+				$value = stripslashes($value);
-		}
+			}
+		}
 		return $value;
 	}
 
@@ -324,16 +338,16 @@
 	 * Usage: 2
 	 *
 	 * @param mixed $inputGet
-	 *        array or single value to write to $_GET. Values should NOT be
+	 *		array or single value to write to $_GET. Values should NOT be
-	 *        escaped at input time (but will be escaped before writing
+	 *		escaped at input time (but will be escaped before writing
-	 *        according to TYPO3 standards).
+	 *		according to TYPO3 standards).
 	 * @param string $key
-	 *        alternative key; If set, this will not set the WHOLE GET array,
+	 *		alternative key; If set, this will not set the WHOLE GET array,
-	 *        but only the key in it specified by this value!
+	 *		but only the key in it specified by this value!
-	 *        You can specify to replace keys on deeper array levels by
+	 *		You can specify to replace keys on deeper array levels by
-	 *        separating the keys with a pipe.
+	 *		separating the keys with a pipe.
-	 *        Example: 'parentKey|childKey' will result in
+	 *		Example: 'parentKey|childKey' will result in
-	 *        array('parentKey' => array('childKey' => $inputGet))
+	 *		array('parentKey' => array('childKey' => $inputGet))
 	 *
 	 * @return	void
 	 */
@@ -382,13 +396,19 @@
 	 * @deprecated since TYPO3 3.6, will be removed in TYPO3 4.6 - Use t3lib_div::_GP instead (ALWAYS delivers a value with un-escaped values!)
 	 * @see _GP()
 	 */
-	public static function GPvar($var,$strip=0)	{
+	public static function GPvar($var, $strip = 0) {
 		self::logDeprecatedFunction();
 
-		if(empty($var)) return;
+		if (empty($var)) {
+			return;
+		}
 		$value = isset($_POST[$var]) ? $_POST[$var] : $_GET[$var];
-		if (isset($value) && is_string($value))	{ $value = stripslashes($value); }	// Originally check '&& get_magic_quotes_gpc() ' but the values of $_GET are always slashed regardless of get_magic_quotes_gpc() because HTTP_POST/GET_VARS are run through addSlashesOnArray in the very beginning of index_ts.php eg.
-		if ($strip && isset($value) && is_array($value)) { self::stripSlashesOnArray($value); }
+		if (isset($value) && is_string($value)) {
+			$value = stripslashes($value);
+		} // Originally check '&& get_magic_quotes_gpc() ' but the values of $_GET are always slashed regardless of get_magic_quotes_gpc() because HTTP_POST/GET_VARS are run through addSlashesOnArray in the very beginning of index_ts.php eg.
+		if ($strip && isset($value) && is_array($value)) {
+			self::stripSlashesOnArray($value);
+		}
 		return $value;
 	}
 
@@ -401,7 +421,7 @@
 	 * @deprecated since TYPO3 3.7, will be removed in TYPO3 4.6 - Use t3lib_div::_GPmerged instead
 	 * @see _GP()
 	 */
-	public static function GParrayMerged($var)	{
+	public static function GParrayMerged($var) {
 		self::logDeprecatedFunction();
 
 		return self::_GPmerged($var);
@@ -416,21 +436,13 @@
 	 * @param	string		Input string
 	 * @return	string		Input string with potential XSS code removed
 	 */
-	public static function removeXSS($string)	{
+	public static function removeXSS($string) {
-		require_once(PATH_typo3.'contrib/RemoveXSS/RemoveXSS.php');
+		require_once(PATH_typo3 . 'contrib/RemoveXSS/RemoveXSS.php');
 		$string = RemoveXSS::process($string);
 		return $string;
 	}
 
 
-
-
-
-
-
-
-
-
 	/*************************
 	 *
 	 * IMAGE FUNCTIONS
@@ -442,35 +454,35 @@
 	 * Compressing a GIF file if not already LZW compressed.
 	 * This function is a workaround for the fact that ImageMagick and/or GD does not compress GIF-files to their minimun size (that is RLE or no compression used)
 	 *
-	 * 		The function takes a file-reference, $theFile, and saves it again through GD or ImageMagick in order to compress the file
+	 *		 The function takes a file-reference, $theFile, and saves it again through GD or ImageMagick in order to compress the file
-	 * 		GIF:
+	 *		 GIF:
-	 * 		If $type is not set, the compression is done with ImageMagick (provided that $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path_lzw'] is pointing to the path of a lzw-enabled version of 'convert') else with GD (should be RLE-enabled!)
+	 *		 If $type is not set, the compression is done with ImageMagick (provided that $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path_lzw'] is pointing to the path of a lzw-enabled version of 'convert') else with GD (should be RLE-enabled!)
-	 * 		If $type is set to either 'IM' or 'GD' the compression is done with ImageMagick and GD respectively
+	 *		 If $type is set to either 'IM' or 'GD' the compression is done with ImageMagick and GD respectively
-	 * 		PNG:
+	 *		 PNG:
-	 * 		No changes.
+	 *		 No changes.
 	 *
-	 * 		$theFile is expected to be a valid GIF-file!
+	 *		 $theFile is expected to be a valid GIF-file!
-	 * 		The function returns a code for the operation.
+	 *		 The function returns a code for the operation.
 	 * Usage: 9
 	 *
 	 * @param	string		Filepath
 	 * @param	string		See description of function
 	 * @return	string		Returns "GD" if GD was used, otherwise "IM" if ImageMagick was used. If nothing done at all, it returns empty string.
 	 */
-	public static function gif_compress($theFile, $type)	{
+	public static function gif_compress($theFile, $type) {
 		$gfxConf = $GLOBALS['TYPO3_CONF_VARS']['GFX'];
-		$returnCode='';
+		$returnCode = '';
-		if ($gfxConf['gif_compress'] && strtolower(substr($theFile,-4,4))=='.gif')	{	// GIF...
+		if ($gfxConf['gif_compress'] && strtolower(substr($theFile, -4, 4)) == '.gif') { // GIF...
-			if (($type=='IM' || !$type) && $gfxConf['im'] && $gfxConf['im_path_lzw'])	{	// IM
+			if (($type == 'IM' || !$type) && $gfxConf['im'] && $gfxConf['im_path_lzw']) { // IM
-				$cmd = self::imageMagickCommand('convert', '"'.$theFile.'" "'.$theFile.'"', $gfxConf['im_path_lzw']);
+				$cmd = self::imageMagickCommand('convert', '"' . $theFile . '" "' . $theFile . '"', $gfxConf['im_path_lzw']);
 				exec($cmd);
 
-				$returnCode='IM';
+				$returnCode = 'IM';
-			} elseif (($type=='GD' || !$type) && $gfxConf['gdlib'] && !$gfxConf['gdlib_png'])	{	// GD
+			} elseif (($type == 'GD' || !$type) && $gfxConf['gdlib'] && !$gfxConf['gdlib_png']) { // GD
 				$tempImage = imageCreateFromGif($theFile);
 				imageGif($tempImage, $theFile);
 				imageDestroy($tempImage);
-				$returnCode='GD';
+				$returnCode = 'GD';
 			}
 		}
 		return $returnCode;
@@ -484,17 +496,17 @@
 	 * @param	string		$theFile	the filename with path
 	 * @return	string		new filename
 	 */
-	public static function png_to_gif_by_imagemagick($theFile)	{
+	public static function png_to_gif_by_imagemagick($theFile) {
 		if ($GLOBALS['TYPO3_CONF_VARS']['FE']['png_to_gif']
-			&& $GLOBALS['TYPO3_CONF_VARS']['GFX']['im']
-			&& $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path_lzw']
+				&& $GLOBALS['TYPO3_CONF_VARS']['GFX']['im']
+				&& $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path_lzw']
-			&& strtolower(substr($theFile,-4,4))=='.png'
+				&& strtolower(substr($theFile, -4, 4)) == '.png'
-			&& @is_file($theFile))	{	// IM
+				&& @is_file($theFile)) { // IM
-				$newFile = substr($theFile,0,-4).'.gif';
+			$newFile = substr($theFile, 0, -4) . '.gif';
-				$cmd = self::imageMagickCommand('convert', '"'.$theFile.'" "'.$newFile.'"', $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path_lzw']);
+			$cmd = self::imageMagickCommand('convert', '"' . $theFile . '" "' . $newFile . '"', $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path_lzw']);
-				exec($cmd);
-				$theFile = $newFile;
-					// unlink old file?? May be bad idea bacause TYPO3 would then recreate the file every time as TYPO3 thinks the file is not generated because it's missing!! So do not unlink $theFile here!!
+			exec($cmd);
+			$theFile = $newFile;
+				// unlink old file?? May be bad idea bacause TYPO3 would then recreate the file every time as TYPO3 thinks the file is not generated because it's missing!! So do not unlink $theFile here!!
 		}
 		return $theFile;
 	}
@@ -508,37 +520,26 @@
 	 * @param	boolean		If set, then input file is converted to PNG, otherwise to GIF
 	 * @return	string		If the new image file exists, it's filepath is returned
 	 */
-	public static function read_png_gif($theFile,$output_png=0)	{
+	public static function read_png_gif($theFile, $output_png = 0) {
-		if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im'] && @is_file($theFile))	{
+		if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im'] && @is_file($theFile)) {
-			$ext = strtolower(substr($theFile,-4,4));
+			$ext = strtolower(substr($theFile, -4, 4));
 			if (
-					((string)$ext=='.png' && $output_png)	||
+				((string) $ext == '.png' && $output_png) ||
-					((string)$ext=='.gif' && !$output_png)
+				((string) $ext == '.gif' && !$output_png)
-				)	{
+			) {
 				return $theFile;
 			} else {
-				$newFile = PATH_site.'typo3temp/readPG_'.md5($theFile.'|'.filemtime($theFile)).($output_png?'.png':'.gif');
+				$newFile = PATH_site . 'typo3temp/readPG_' . md5($theFile . '|' . filemtime($theFile)) . ($output_png ? '.png' : '.gif');
-				$cmd = self::imageMagickCommand('convert', '"'.$theFile.'" "'.$newFile.'"', $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path']);
+				$cmd = self::imageMagickCommand('convert', '"' . $theFile . '" "' . $newFile . '"', $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path']);
 				exec($cmd);
-				if (@is_file($newFile))	return $newFile;
+				if (@is_file($newFile)) {
+					return $newFile;
-			}
-		}
-	}
+				}
+			}
+		}
+	}
 
 
-
-
-
-
-
-
-
-
-
-
-
-
-
 	/*************************
 	 *
 	 * STRING FUNCTIONS
@@ -558,15 +559,15 @@
 	 * @deprecated since TYPO3 4.1, will be removed in TYPO3 4.6 - Works ONLY for single-byte charsets! Use t3lib_div::fixed_lgd_cs() instead
 	 * @see fixed_lgd_pre()
 	 */
-	public static function fixed_lgd($string,$origChars,$preStr='...')	{
+	public static function fixed_lgd($string, $origChars, $preStr = '...') {
 		self::logDeprecatedFunction();
 
 		$chars = abs($origChars);
-		if ($chars >= 4)	{
+		if ($chars >= 4) {
-			if(strlen($string)>$chars)  {
+			if (strlen($string) > $chars) {
 				return $origChars < 0 ?
-					$preStr.trim(substr($string, -($chars-3))) :
+						$preStr . trim(substr($string, -($chars - 3))) :
-					trim(substr($string, 0, $chars-3)).$preStr;
+						trim(substr($string, 0, $chars - 3)) . $preStr;
 			}
 		}
 		return $string;
@@ -585,10 +586,10 @@
 	 * @deprecated since TYPO3 4.1, will be removed in TYPO3 4.6 - Use t3lib_div::fixed_lgd_cs() instead (with negative input value for $chars)
 	 * @see fixed_lgd()
 	 */
-	public static function fixed_lgd_pre($string,$chars)	{
+	public static function fixed_lgd_pre($string, $chars) {
 		self::logDeprecatedFunction();
 
-		return strrev(self::fixed_lgd(strrev($string),$chars));
+		return strrev(self::fixed_lgd(strrev($string), $chars));
 	}
 
 	/**
@@ -600,7 +601,7 @@
 	 * @param	string		appendix to the truncated string
 	 * @return	string		cropped string
 	 */
-	public static function fixed_lgd_cs($string, $chars, $appendString='...') {
+	public static function fixed_lgd_cs($string, $chars, $appendString = '...') {
 		if (is_object($GLOBALS['LANG'])) {
 			return $GLOBALS['LANG']->csConvObj->crop($GLOBALS['LANG']->charSet, $string, $chars, $appendString);
 		} elseif (is_object($GLOBALS['TSFE'])) {
@@ -623,15 +624,15 @@
 	 * @deprecated since TYPO3 4.1, will be removed in TYPO3 4.6 - Use PHP function wordwrap()
 	 * @return	string
 	 */
-	public static function breakTextForEmail($str,$implChar=LF,$charWidth=76)	{
+	public static function breakTextForEmail($str, $implChar = LF, $charWidth = 76) {
 		self::logDeprecatedFunction();
 
-		$lines = explode(LF,$str);
+		$lines = explode(LF, $str);
-		$outArr=array();
+		$outArr = array();
 		foreach ($lines as $lStr) {
-			$outArr[] = self::breakLinesForEmail($lStr,$implChar,$charWidth);
+			$outArr[] = self::breakLinesForEmail($lStr, $implChar, $charWidth);
 		}
-		return implode(LF,$outArr);
+		return implode(LF, $outArr);
 	}
 
 	/**
@@ -644,31 +645,35 @@
 	 * @return	string
 	 * @see breakTextForEmail()
 	 */
-	public static function breakLinesForEmail($str,$implChar=LF,$charWidth=76)	{
+	public static function breakLinesForEmail($str, $implChar = LF, $charWidth = 76) {
-		$lines=array();
+		$lines = array();
-		$l=$charWidth;
+		$l = $charWidth;
-		$p=0;
+		$p = 0;
-		while(strlen($str)>$p)	{
+		while (strlen($str) > $p) {
-			$substr=substr($str,$p,$l);
+			$substr = substr($str, $p, $l);
-			if (strlen($substr)==$l)	{
+			if (strlen($substr) == $l) {
-				$count = count(explode(' ',trim(strrev($substr))));
+				$count = count(explode(' ', trim(strrev($substr))));
-				if ($count>1)	{	// OK...
+				if ($count > 1) { // OK...
-					$parts = explode(' ',strrev($substr),2);
+					$parts = explode(' ', strrev($substr), 2);
 					$theLine = strrev($parts[1]);
 				} else {
-					$afterParts = explode(' ',substr($str,$l+$p),2);
+					$afterParts = explode(' ', substr($str, $l + $p), 2);
-					$theLine = $substr.$afterParts[0];
+					$theLine = $substr . $afterParts[0];
 				}
-				if (!strlen($theLine))	{break; }	// Error, because this would keep us in an endless loop.
+				if (!strlen($theLine)) {
+					break;
+				} // Error, because this would keep us in an endless loop.
 			} else {
-				$theLine=$substr;
+				$theLine = $substr;
 			}
 
-			$lines[]=trim($theLine);
+			$lines[] = trim($theLine);
-			$p+=strlen($theLine);
+			$p += strlen($theLine);
-			if (!trim(substr($str,$p,$l)))	break;	// added...
+			if (!trim(substr($str, $p, $l))) {
+				break;
+			} // added...
 		}
-		return implode($implChar,$lines);
+		return implode($implChar, $lines);
 	}
 
 	/**
@@ -680,14 +685,14 @@
 	 * @param	string		$list is a comma-list of IP-addresses to match with. *-wildcard allowed instead of number, plus leaving out parts in the IP number is accepted as wildcard (eg. 192.168.*.* equals 192.168). If list is "*" no check is done and the function returns TRUE immediately. An empty list always returns FALSE.
 	 * @return	boolean		True if an IP-mask from $list matches $baseIP
 	 */
-	public static function cmpIP($baseIP, $list)	{
+	public static function cmpIP($baseIP, $list) {
 		$list = trim($list);
-		if ($list === '')	{
+		if ($list === '') {
-			return false;
+			return FALSE;
-		} elseif ($list === '*')	{
+		} elseif ($list === '*') {
-			return true;
+			return TRUE;
 		}
-		if (strpos($baseIP, ':') !== false && self::validIPv6($baseIP))	{
+		if (strpos($baseIP, ':') !== FALSE && self::validIPv6($baseIP)) {
 			return self::cmpIPv6($baseIP, $list);
 		} else {
 			return self::cmpIPv4($baseIP, $list);
@@ -701,39 +706,41 @@
 	 * @param	string		$list is a comma-list of IP-addresses to match with. *-wildcard allowed instead of number, plus leaving out parts in the IP number is accepted as wildcard (eg. 192.168.*.* equals 192.168)
 	 * @return	boolean		True if an IP-mask from $list matches $baseIP
 	 */
-	public static function cmpIPv4($baseIP, $list)	{
+	public static function cmpIPv4($baseIP, $list) {
-		$IPpartsReq = explode('.',$baseIP);
+		$IPpartsReq = explode('.', $baseIP);
-		if (count($IPpartsReq)==4)	{
+		if (count($IPpartsReq) == 4) {
-			$values = self::trimExplode(',',$list,1);
+			$values = self::trimExplode(',', $list, 1);
 
-			foreach($values as $test)	{
+			foreach ($values as $test) {
-				list($test,$mask) = explode('/',$test);
+				list($test, $mask) = explode('/', $test);
 
-				if(intval($mask)) {
+				if (intval($mask)) {
 						// "192.168.3.0/24"
 					$lnet = ip2long($test);
 					$lip = ip2long($baseIP);
 					$binnet = str_pad(decbin($lnet), 32, '0', STR_PAD_LEFT);
-					$firstpart = substr($binnet,0,$mask);
+					$firstpart = substr($binnet, 0, $mask);
 					$binip = str_pad(decbin($lip), 32, '0', STR_PAD_LEFT);
-					$firstip = substr($binip,0,$mask);
+					$firstip = substr($binip, 0, $mask);
-					$yes = (strcmp($firstpart,$firstip)==0);
+					$yes = (strcmp($firstpart, $firstip) == 0);
 				} else {
 						// "192.168.*.*"
-					$IPparts = explode('.',$test);
+					$IPparts = explode('.', $test);
 					$yes = 1;
 					foreach ($IPparts as $index => $val) {
 						$val = trim($val);
-						if (strcmp($val,'*') && strcmp($IPpartsReq[$index],$val))	{
+						if (strcmp($val, '*') && strcmp($IPpartsReq[$index], $val)) {
-							$yes=0;
+							$yes = 0;
 						}
 					}
 				}
-				if ($yes) return true;
+				if ($yes) {
+					return TRUE;
-			}
-		}
+				}
+			}
-		return false;
-	}
+		}
+		return FALSE;
+	}
 
 	/**
 	 * Match IPv6 address with a list of IPv6 prefixes
@@ -742,42 +749,44 @@
 	 * @param	string		$list is a comma-list of IPv6 prefixes, could also contain IPv4 addresses
 	 * @return	boolean		True if an baseIP matches any prefix
 	 */
-	public static function cmpIPv6($baseIP, $list)	{
+	public static function cmpIPv6($baseIP, $list) {
-		$success = false;	// Policy default: Deny connection
+		$success = FALSE; // Policy default: Deny connection
 		$baseIP = self::normalizeIPv6($baseIP);
 
-		$values = self::trimExplode(',',$list,1);
+		$values = self::trimExplode(',', $list, 1);
-		foreach ($values as $test)	{
+		foreach ($values as $test) {
-			list($test,$mask) = explode('/',$test);
+			list($test, $mask) = explode('/', $test);
-			if (self::validIPv6($test))	{
+			if (self::validIPv6($test)) {
 				$test = self::normalizeIPv6($test);
-				if (intval($mask))	{
+				if (intval($mask)) {
-					switch ($mask) {	// test on /48 /64
+					switch ($mask) { // test on /48 /64
 						case '48':
 							$testBin = substr(self::IPv6Hex2Bin($test), 0, 48);
 							$baseIPBin = substr(self::IPv6Hex2Bin($baseIP), 0, 48);
-							$success = strcmp($testBin, $baseIPBin)==0 ? true : false;
+							$success = strcmp($testBin, $baseIPBin) == 0 ? TRUE : FALSE;
-						break;
+							break;
 						case '64':
 							$testBin = substr(self::IPv6Hex2Bin($test), 0, 64);
 							$baseIPBin = substr(self::IPv6Hex2Bin($baseIP), 0, 64);
-							$success = strcmp($testBin, $baseIPBin)==0 ? true : false;
+							$success = strcmp($testBin, $baseIPBin) == 0 ? TRUE : FALSE;
-						break;
+							break;
 						default:
-							$success = false;
+							$success = FALSE;
 					}
 				} else {
-					if (self::validIPv6($test))	{	// test on full ip address 128 bits
+					if (self::validIPv6($test)) { // test on full ip address 128 bits
 						$testBin = self::IPv6Hex2Bin($test);
 						$baseIPBin = self::IPv6Hex2Bin($baseIP);
-						$success = strcmp($testBin, $baseIPBin)==0 ? true : false;
+						$success = strcmp($testBin, $baseIPBin) == 0 ? TRUE : FALSE;
 					}
 				}
 			}
-			if ($success) return true;
+			if ($success) {
+				return TRUE;
-		}
+			}
-		return false;
-	}
+		}
+		return FALSE;
+	}
 
 	/**
 	 * [Describe function...]
@@ -785,11 +794,11 @@
 	 * @param	[type]		$hex: ...
 	 * @return	[type]		...
 	 */
-	public static function IPv6Hex2Bin ($hex)	{
+	public static function IPv6Hex2Bin($hex) {
 		$bin = '';
-		$hex = str_replace(':', '', $hex);	// Replace colon to nothing
+		$hex = str_replace(':', '', $hex); // Replace colon to nothing
-		for ($i=0; $i<strlen($hex); $i=$i+2)	{
+		for ($i = 0; $i < strlen($hex); $i = $i + 2) {
-			$bin.= chr(hexdec(substr($hex, $i, 2)));
+			$bin .= chr(hexdec(substr($hex, $i, 2)));
 		}
 		return $bin;
 	}
@@ -800,23 +809,26 @@
 	 * @param	string		Given IPv6 address
 	 * @return	string		Normalized address
 	 */
-	public static function normalizeIPv6($address)	{
+	public static function normalizeIPv6($address) {
 		$normalizedAddress = '';
 		$stageOneAddress = '';
 
-		$chunks = explode('::', $address);	// Count 2 if if address has hidden zero blocks
+		$chunks = explode('::', $address); // Count 2 if if address has hidden zero blocks
-		if (count($chunks)==2)	{
+		if (count($chunks) == 2) {
 			$chunksLeft = explode(':', $chunks[0]);
 			$chunksRight = explode(':', $chunks[1]);
 			$left = count($chunksLeft);
 			$right = count($chunksRight);
 
 				// Special case: leading zero-only blocks count to 1, should be 0
-			if ($left==1 && strlen($chunksLeft[0])==0)	$left=0;
+			if ($left == 1 && strlen($chunksLeft[0]) == 0) {
+				$left = 0;
+			}
 
 			$hiddenBlocks = 8 - ($left + $right);
 			$hiddenPart = '';
+			$h = 0;
-			while ($h<$hiddenBlocks)	{
+			while ($h < $hiddenBlocks) {
 				$hiddenPart .= '0000:';
 				$h++;
 			}
@@ -826,21 +838,23 @@
 			} else {
 				$stageOneAddress = $chunks[0] . ':' . $hiddenPart . $chunks[1];
 			}
-		} else $stageOneAddress = $address;
+		} else {
+			$stageOneAddress = $address;
+		}
 
 			// normalize the blocks:
 		$blocks = explode(':', $stageOneAddress);
 		$divCounter = 0;
-		foreach ($blocks as $block)	{
+		foreach ($blocks as $block) {
 			$tmpBlock = '';
 			$i = 0;
 			$hiddenZeros = 4 - strlen($block);
-			while ($i < $hiddenZeros)	{
+			while ($i < $hiddenZeros) {
 				$tmpBlock .= '0';
 				$i++;
 			}
 			$normalizedAddress .= $tmpBlock . $block;
-			if ($divCounter < 7)	{
+			if ($divCounter < 7) {
 				$normalizedAddress .= ':';
 				$divCounter++;
 			}
@@ -857,7 +871,7 @@
 	 * @return	boolean		True if $ip is either of IPv4 or IPv6 format.
 	 */
 	public static function validIP($ip) {
-		return (filter_var($ip, FILTER_VALIDATE_IP) !== false);
+		return (filter_var($ip, FILTER_VALIDATE_IP) !== FALSE);
 	}
 
 	/**
@@ -869,7 +883,7 @@
 	 * @return	boolean		True if $ip is of IPv4 format.
 	 */
 	public static function validIPv4($ip) {
-		return (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== false);
+		return (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== FALSE);
 	}
 
 	/**
@@ -880,8 +894,8 @@
 	 * @param	string		IP address to be tested
 	 * @return	boolean		True if $ip is of IPv6 format.
 	 */
-	public static function validIPv6($ip)	{
+	public static function validIPv6($ip) {
-		return (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== false);
+		return (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) !== FALSE);
 	}
 
 	/**
@@ -891,26 +905,28 @@
 	 * @param	string		A comma-list of domain names to match with. *-wildcard allowed but cannot be part of a string, so it must match the full host name (eg. myhost.*.com => correct, myhost.*domain.com => wrong)
 	 * @return	boolean		True if a domain name mask from $list matches $baseIP
 	 */
-	public static function cmpFQDN($baseIP, $list)        {
+	public static function cmpFQDN($baseIP, $list) {
-		if (count(explode('.',$baseIP))==4)     {
+		if (count(explode('.', $baseIP)) == 4) {
 			$resolvedHostName = explode('.', gethostbyaddr($baseIP));
-			$values = self::trimExplode(',',$list,1);
+			$values = self::trimExplode(',', $list, 1);
 
-			foreach($values as $test)	{
+			foreach ($values as $test) {
-				$hostNameParts = explode('.',$test);
+				$hostNameParts = explode('.', $test);
 				$yes = 1;
 
-				foreach($hostNameParts as $index => $val)	{
+				foreach ($hostNameParts as $index => $val) {
 					$val = trim($val);
-					if (strcmp($val,'*') && strcmp($resolvedHostName[$index],$val)) {
+					if (strcmp($val, '*') && strcmp($resolvedHostName[$index], $val)) {
-						$yes=0;
+						$yes = 0;
 					}
 				}
-				if ($yes) return true;
+				if ($yes) {
+					return TRUE;
-			}
-		}
+				}
+			}
-		return false;
-	}
+		}
+		return FALSE;
+	}
 
 	/**
 	 * Checks if a given URL matches the host that currently handles this HTTP request.
@@ -932,8 +948,8 @@
 	 * @param	string		item to check for
 	 * @return	boolean		true if $item is in $list
 	 */
-	public static function inList($list, $item)	{
+	public static function inList($list, $item) {
-		return (strpos(','.$list.',', ','.$item.',')!==false ? true : false);
+		return (strpos(',' . $list . ',', ',' . $item . ',') !== FALSE ? TRUE : FALSE);
 	}
 
 	/**
@@ -944,14 +960,14 @@
 	 * @param	string		comma-separated list of items (string)
 	 * @return	string		new comma-separated list of items
 	 */
-	public static function rmFromList($element,$list)	{
+	public static function rmFromList($element, $list) {
-		$items = explode(',',$list);
+		$items = explode(',', $list);
 		foreach ($items as $k => $v) {
-			if ($v==$element) {
+			if ($v == $element) {
 				unset($items[$k]);
 			}
 		}
-		return implode(',',$items);
+		return implode(',', $items);
 	}
 
 	/**
@@ -962,24 +978,26 @@
 	 * @return	string		new comma-separated list of items
 	 * @author	Martin Kutschker <martin.kutschker@activesolution.at>
 	 */
-	public static function expandList($list)      {
+	public static function expandList($list) {
-		$items = explode(',',$list);
+		$items = explode(',', $list);
 		$list = array();
 		foreach ($items as $item) {
-			$range = explode('-',$item);
+			$range = explode('-', $item);
-			if (isset($range[1]))	{
+			if (isset($range[1])) {
 				$runAwayBrake = 1000;
-				for ($n=$range[0]; $n<=$range[1]; $n++)	{
+				for ($n = $range[0]; $n <= $range[1]; $n++) {
 					$list[] = $n;
 
 					$runAwayBrake--;
-					if ($runAwayBrake<=0)	break;
+					if ($runAwayBrake <= 0) {
+						break;
-				}
+					}
+				}
 			} else {
 				$list[] = $item;
 			}
 		}
-		return implode(',',$list);
+		return implode(',', $list);
 	}
 
 	/**
@@ -992,12 +1010,18 @@
 	 * @param	integer		Default value if input is false.
 	 * @return	integer		The input value forced into the boundaries of $min and $max
 	 */
-	public static function intInRange($theInt,$min,$max=2000000000,$zeroValue=0)	{
+	public static function intInRange($theInt, $min, $max = 2000000000, $zeroValue = 0) {
-		// Returns $theInt as an integer in the integerspace from $min to $max
+			// Returns $theInt as an integer in the integerspace from $min to $max
 		$theInt = intval($theInt);
-		if ($zeroValue && !$theInt)	{$theInt=$zeroValue;}	// If the input value is zero after being converted to integer, zeroValue may set another default value for it.
-		if ($theInt<$min){$theInt=$min;}
-		if ($theInt>$max){$theInt=$max;}
+		if ($zeroValue && !$theInt) {
+			$theInt = $zeroValue;
+		} // If the input value is zero after being converted to integer, zeroValue may set another default value for it.
+		if ($theInt < $min) {
+			$theInt = $min;
+		}
+		if ($theInt > $max) {
+			$theInt = $max;
+		}
 		return $theInt;
 	}
 
@@ -1008,9 +1032,11 @@
 	 * @param	integer		Integer string to process
 	 * @return	integer
 	 */
-	public static function intval_positive($theInt)	{
+	public static function intval_positive($theInt) {
 		$theInt = intval($theInt);
-		if ($theInt<0){$theInt=0;}
+		if ($theInt < 0) {
+			$theInt = 0;
+		}
 		return $theInt;
 	}
 
@@ -1021,9 +1047,9 @@
 	 * @param	string		Version number on format x.x.x
 	 * @return	integer		Integer version of version number (where each part can count to 999)
 	 */
-	public static function int_from_ver($verNumberStr)	{
+	public static function int_from_ver($verNumberStr) {
-		$verParts = explode('.',$verNumberStr);
+		$verParts = explode('.', $verNumberStr);
-		return intval((int)$verParts[0].str_pad((int)$verParts[1],3,'0',STR_PAD_LEFT).str_pad((int)$verParts[2],3,'0',STR_PAD_LEFT));
+		return intval((int) $verParts[0] . str_pad((int) $verParts[1], 3, '0', STR_PAD_LEFT) . str_pad((int) $verParts[2], 3, '0', STR_PAD_LEFT));
 	}
 
 	/**
@@ -1034,11 +1060,11 @@
 	 * @return	boolean		Returns true if this setup is compatible with the provided version number
 	 * @todo	Still needs a function to convert versions to branches
 	 */
-	public static function compat_version($verNumberStr)	{
+	public static function compat_version($verNumberStr) {
 		global $TYPO3_CONF_VARS;
 		$currVersionStr = $TYPO3_CONF_VARS['SYS']['compat_version'] ? $TYPO3_CONF_VARS['SYS']['compat_version'] : TYPO3_branch;
 
-		if (self::int_from_ver($currVersionStr) < self::int_from_ver($verNumberStr))	{
+		if (self::int_from_ver($currVersionStr) < self::int_from_ver($verNumberStr)) {
 			return FALSE;
 		} else {
 			return TRUE;
@@ -1052,8 +1078,8 @@
 	 * @param	string		String to md5-hash
 	 * @return	integer		Returns 28bit integer-hash
 	 */
-	public static function md5int($str)	{
+	public static function md5int($str) {
-		return hexdec(substr(md5($str),0,7));
+		return hexdec(substr(md5($str), 0, 7));
 	}
 
 	/**
@@ -1065,15 +1091,15 @@
 	 * @param	integer		The string-length of the output
 	 * @return	string		Substring of the resulting md5-hash, being $len chars long (from beginning)
 	 */
-	public static function shortMD5($input, $len=10)	{
+	public static function shortMD5($input, $len = 10) {
-		return substr(md5($input),0,$len);
+		return substr(md5($input), 0, $len);
 	}
 
 	/**
 	 * Returns a proper HMAC on a given input string and secret TYPO3 encryption key.
 	 *
-	 * @param 	string		Input string to create HMAC from
+	 * @param	 string		Input string to create HMAC from
-	 * @return 	string		resulting (hexadecimal) HMAC currently with a length of 40 (HMAC-SHA-1)
+	 * @return	 string		resulting (hexadecimal) HMAC currently with a length of 40 (HMAC-SHA-1)
 	 */
 	public static function hmac($input) {
 		$hashAlgorithm = 'sha1';
@@ -1094,7 +1120,7 @@
 					// keys shorter than blocksize are zero-padded
 				$key = str_pad($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'], $hashBlocksize, chr(0x00));
 			}
-			$hmac = call_user_func($hashAlgorithm, ($key^$opad) . pack('H*', call_user_func($hashAlgorithm, ($key^$ipad) . $input)));
+			$hmac = call_user_func($hashAlgorithm, ($key ^ $opad) . pack('H*', call_user_func($hashAlgorithm, ($key ^ $ipad) . $input)));
 		}
 		return $hmac;
 	}
@@ -1108,7 +1134,7 @@
 	 * @param	mixed		$secondParameter: Dummy field, which if set will show a warning!
 	 * @return	string		Returns the list without any duplicates of values, space around values are trimmed
 	 */
-	public static function uniqueList($in_list, $secondParameter=NULL)	{
+	public static function uniqueList($in_list, $secondParameter = NULL) {
 		if (is_array($in_list)) {
 			throw new InvalidArgumentException(
 				'TYPO3 Fatal Error: t3lib_div::uniqueList() does NOT support array arguments anymore! Only string comma lists!',
@@ -1122,7 +1148,7 @@
 			);
 		}
 
-		return implode(',',array_unique(self::trimExplode(',',$in_list,1)));
+		return implode(',', array_unique(self::trimExplode(',', $in_list, 1)));
 	}
 
 	/**
@@ -1132,7 +1158,7 @@
 	 * @param	string		Filename/filepath to be analysed
 	 * @return	array		Contains keys [path], [file], [filebody], [fileext], [realFileext]
 	 */
-	public static function split_fileref($fileref)	{
+	public static function split_fileref($fileref) {
 		$reg = array();
 		if (preg_match('/(.*\/)(.*)$/', $fileref, $reg)) {
 			$info['path'] = $reg[1];
@@ -1171,9 +1197,9 @@
 	 * @param	string		Directory name / path
 	 * @return	string		Processed input value. See function description.
 	 */
-	public static function dirname($path)	{
+	public static function dirname($path) {
-		$p = self::revExplode('/',$path,2);
+		$p = self::revExplode('/', $path, 2);
-		return count($p)==2 ? $p[0] : '';
+		return count($p) == 2 ? $p[0] : '';
 	}
 
 	/**
@@ -1187,15 +1213,15 @@
 	 * @return	string		A hexadecimal color code, #xxxxxx, modified according to input vars
 	 * @see modifyHTMLColorAll()
 	 */
-	public static function modifyHTMLColor($color,$R,$G,$B)	{
+	public static function modifyHTMLColor($color, $R, $G, $B) {
-		// This takes a hex-color (# included!) and adds $R, $G and $B to the HTML-color (format: #xxxxxx) and returns the new color
+			// This takes a hex-color (# included!) and adds $R, $G and $B to the HTML-color (format: #xxxxxx) and returns the new color
-		$nR = self::intInRange(hexdec(substr($color,1,2))+$R,0,255);
+		$nR = self::intInRange(hexdec(substr($color, 1, 2)) + $R, 0, 255);
-		$nG = self::intInRange(hexdec(substr($color,3,2))+$G,0,255);
+		$nG = self::intInRange(hexdec(substr($color, 3, 2)) + $G, 0, 255);
-		$nB = self::intInRange(hexdec(substr($color,5,2))+$B,0,255);
+		$nB = self::intInRange(hexdec(substr($color, 5, 2)) + $B, 0, 255);
-		return '#'.
+		return '#' .
-			substr('0'.dechex($nR),-2).
+				substr('0' . dechex($nR), -2) .
-			substr('0'.dechex($nG),-2).
+				substr('0' . dechex($nG), -2) .
-			substr('0'.dechex($nB),-2);
+				substr('0' . dechex($nB), -2);
 	}
 
 	/**
@@ -1207,8 +1233,8 @@
 	 * @return	string		A hexadecimal color code, #xxxxxx, modified according to input vars
 	 * @see modifyHTMLColor()
 	 */
-	public static function modifyHTMLColorAll($color,$all)	{
+	public static function modifyHTMLColorAll($color, $all) {
-		return self::modifyHTMLColor($color,$all,$all,$all);
+		return self::modifyHTMLColor($color, $all, $all, $all);
 	}
 
 	/**
@@ -1219,7 +1245,7 @@
 	 * @return	string
 	 * @deprecated since TYPO3 4.5, will be removed in TYPO3 4.7 - Use rtrim() directly
 	 */
-	public static function rm_endcomma($string)	{
+	public static function rm_endcomma($string) {
 		self::logDeprecatedFunction();
 
 		return rtrim($string, ',');
@@ -1234,7 +1260,7 @@
 	 * @deprecated since TYPO3 3.5, will be removed in TYPO3 4.6 - Use t3lib_cs::conv_case() instead or for HTML output, wrap your content in <span class="uppercase">...</span>)
 	 * @ignore
 	 */
-	public static function danish_strtoupper($string)	{
+	public static function danish_strtoupper($string) {
 		self::logDeprecatedFunction();
 
 		$value = strtoupper($string);
@@ -1267,11 +1293,11 @@
 	 * @deprecated since TYPO3 4.1, will be removed in TYPO3 4.6 - Works only for western europe single-byte charsets! Use t3lib_cs::specCharsToASCII() instead!
 	 * @return	string
 	 */
-	public static function convUmlauts($str)	{
+	public static function convUmlauts($str) {
 		self::logDeprecatedFunction();
 
-		$pattern  = array (chr(228), chr(196), chr(246), chr(214), chr(252), chr(220), chr(223), chr(229), chr(197), chr(248), chr(216), chr(230), chr(198));
+		$pattern = array(chr(228), chr(196), chr(246), chr(214), chr(252), chr(220), chr(223), chr(229), chr(197), chr(248), chr(216), chr(230), chr(198));
-		$replace = array ('ae', 'Ae', 'oe', 'Oe', 'ue', 'Ue', 'ss', 'aa', 'AA', 'oe', 'OE', 'ae', 'AE');
+		$replace = array('ae', 'Ae', 'oe', 'Oe', 'ue', 'Ue', 'ss', 'aa', 'AA', 'oe', 'OE', 'ae', 'AE');
 		return str_replace($pattern, $replace, $str);
 	}
 
@@ -1285,7 +1311,7 @@
 		if ($var === '') {
 			return FALSE;
 		}
-		return (string)intval($var) === (string)$var;
+		return (string) intval($var) === (string) $var;
 	}
 
 	/**
@@ -1296,7 +1322,7 @@
 	 * @param	string		Reference string which must be found as the "first part" of the full string
 	 * @return	boolean		True if $partStr was found to be equal to the first part of $str
 	 */
-	public static function isFirstPartOfStr($str,$partStr) {
+	public static function isFirstPartOfStr($str, $partStr) {
 		return $partStr != '' && strpos((string) $str, (string) $partStr, 0) === 0;
 	}
 
@@ -1308,31 +1334,31 @@
 	 * @param	string		Labels for bytes, kilo, mega and giga separated by vertical bar (|) and possibly encapsulated in "". Eg: " | K| M| G" (which is the default value)
 	 * @return	string		Formatted representation of the byte number, for output.
 	 */
-	public static function formatSize($sizeInBytes,$labels='')	{
+	public static function formatSize($sizeInBytes, $labels = '') {
 
 			// Set labels:
 		if (strlen($labels) == 0) {
 			$labels = ' | K| M| G';
 		} else {
-			$labels = str_replace('"','',$labels);
+			$labels = str_replace('"', '', $labels);
 		}
-		$labelArr = explode('|',$labels);
+		$labelArr = explode('|', $labels);
 
 			// Find size:
-		if ($sizeInBytes>900)	{
+		if ($sizeInBytes > 900) {
-			if ($sizeInBytes>900000000)	{	// GB
+			if ($sizeInBytes > 900000000) { // GB
-				$val = $sizeInBytes/(1024*1024*1024);
+				$val = $sizeInBytes / (1024 * 1024 * 1024);
-				return number_format($val, (($val<20)?1:0), '.', '').$labelArr[3];
+				return number_format($val, (($val < 20) ? 1 : 0), '.', '') . $labelArr[3];
 			}
-			elseif ($sizeInBytes>900000)	{	// MB
+			elseif ($sizeInBytes > 900000) { // MB
-				$val = $sizeInBytes/(1024*1024);
+				$val = $sizeInBytes / (1024 * 1024);
-				return number_format($val, (($val<20)?1:0), '.', '').$labelArr[2];
+				return number_format($val, (($val < 20) ? 1 : 0), '.', '') . $labelArr[2];
-			} else {	// KB
+			} else { // KB
-				$val = $sizeInBytes/(1024);
+				$val = $sizeInBytes / (1024);
-				return number_format($val, (($val<20)?1:0), '.', '').$labelArr[1];
+				return number_format($val, (($val < 20) ? 1 : 0), '.', '') . $labelArr[1];
 			}
-		} else {	// Bytes
+		} else { // Bytes
-			return $sizeInBytes.$labelArr[0];
+			return $sizeInBytes . $labelArr[0];
 		}
 	}
 
@@ -1343,9 +1369,9 @@
 	 * @param	string		Microtime
 	 * @return	integer		Microtime input string converted to an integer (milliseconds)
 	 */
-	public static function convertMicrotime($microtime)	{
+	public static function convertMicrotime($microtime) {
-		$parts = explode(' ',$microtime);
+		$parts = explode(' ', $microtime);
-		return round(($parts[0]+$parts[1])*1000);
+		return round(($parts[0] + $parts[1]) * 1000);
 	}
 
 	/**
@@ -1357,15 +1383,15 @@
 	 * @return	array		Array with operators and operands separated.
 	 * @see tslib_cObj::calc(), tslib_gifBuilder::calcOffset()
 	 */
-	public static function splitCalc($string,$operators)	{
+	public static function splitCalc($string, $operators) {
 		$res = Array();
-		$sign='+';
+		$sign = '+';
-		while($string)	{
+		while ($string) {
-			$valueLen=strcspn($string,$operators);
+			$valueLen = strcspn($string, $operators);
-			$value=substr($string,0,$valueLen);
+			$value = substr($string, 0, $valueLen);
-			$res[] = Array($sign,trim($value));
+			$res[] = Array($sign, trim($value));
-			$sign=substr($string,$valueLen,1);
+			$sign = substr($string, $valueLen, 1);
-			$string=substr($string,$valueLen+1);
+			$string = substr($string, $valueLen + 1);
 		}
 		reset($res);
 		return $res;
@@ -1379,38 +1405,54 @@
 	 * @return	integer		Calculated value. Or error string.
 	 * @see calcParenthesis()
 	 */
-	public static function calcPriority($string)	{
+	public static function calcPriority($string) {
-		$string=preg_replace('/[[:space:]]*/','',$string);	// removing all whitespace
+		$string = preg_replace('/[[:space:]]*/', '', $string); // removing all whitespace
-		$string='+'.$string;	// Ensuring an operator for the first entrance
+		$string = '+' . $string; // Ensuring an operator for the first entrance
-		$qm='\*\/\+-^%';
+		$qm = '\*\/\+-^%';
-		$regex = '(['.$qm.'])(['.$qm.']?[0-9\.]*)';
+		$regex = '([' . $qm . '])([' . $qm . ']?[0-9\.]*)';
 			// split the expression here:
 		$reg = array();
-		preg_match_all('/'.$regex.'/',$string,$reg);
+		preg_match_all('/' . $regex . '/', $string, $reg);
 
 		reset($reg[2]);
-		$number=0;
+		$number = 0;
-		$Msign='+';
+		$Msign = '+';
-		$err='';
+		$err = '';
-		$buffer=doubleval(current($reg[2]));
+		$buffer = doubleval(current($reg[2]));
-		next($reg[2]);  // Advance pointer
+		next($reg[2]); // Advance pointer
 
-		while(list($k,$v)=each($reg[2])) {
+		while (list($k, $v) = each($reg[2])) {
-			$v=doubleval($v);
+			$v = doubleval($v);
 			$sign = $reg[1][$k];
-			if ($sign=='+' || $sign=='-')	{
+			if ($sign == '+' || $sign == '-') {
-				$number = $Msign=='-' ? $number-=$buffer : $number+=$buffer;
+				$number = $Msign == '-' ? $number -= $buffer : $number += $buffer;
 				$Msign = $sign;
-				$buffer=$v;
+				$buffer = $v;
 			} else {
-				if ($sign=='/')	{if ($v) $buffer/=$v; else $err='dividing by zero';}
-				if ($sign=='%')	{if ($v) $buffer%=$v; else $err='dividing by zero';}
-				if ($sign=='*')	{$buffer*=$v;}
-				if ($sign=='^')	{$buffer=pow($buffer,$v);}
+				if ($sign == '/') {
+					if ($v) {
+						$buffer /= $v;
+					} else {
+						$err = 'dividing by zero';
-			}
-		}
+					}
+				}
+				if ($sign == '%') {
+					if ($v) {
+						$buffer %= $v;
+					} else {
+						$err = 'dividing by zero';
+					}
+				}
+				if ($sign == '*') {
+					$buffer *= $v;
+				}
+				if ($sign == '^') {
+					$buffer = pow($buffer, $v);
+				}
+			}
+		}
-		$number = $Msign=='-' ? $number-=$buffer : $number+=$buffer;
+		$number = $Msign == '-' ? $number -= $buffer : $number += $buffer;
-		return $err ? 'ERROR: '.$err : $number;
+		return $err ? 'ERROR: ' . $err : $number;
 	}
 
 	/**
@@ -1421,22 +1463,24 @@
 	 * @return	integer		Calculated value. Or error string.
 	 * @see calcPriority(), tslib_cObj::stdWrap()
 	 */
-	public static function calcParenthesis($string)	{
+	public static function calcParenthesis($string) {
-		$securC=100;
+		$securC = 100;
 		do {
-			$valueLenO=strcspn($string,'(');
+			$valueLenO = strcspn($string, '(');
-			$valueLenC=strcspn($string,')');
+			$valueLenC = strcspn($string, ')');
-			if ($valueLenC==strlen($string) || $valueLenC < $valueLenO)	{
+			if ($valueLenC == strlen($string) || $valueLenC < $valueLenO) {
-				$value = self::calcPriority(substr($string,0,$valueLenC));
+				$value = self::calcPriority(substr($string, 0, $valueLenC));
-				$string = $value.substr($string,$valueLenC+1);
+				$string = $value . substr($string, $valueLenC + 1);
 				return $string;
 			} else {
-				$string = substr($string,0,$valueLenO).self::calcParenthesis(substr($string,$valueLenO+1));
+				$string = substr($string, 0, $valueLenO) . self::calcParenthesis(substr($string, $valueLenO + 1));
 			}
 				// Security:
 			$securC--;
-			if ($securC<=0)	break;
+			if ($securC <= 0) {
+				break;
+			}
-		} while($valueLenO<strlen($string));
+		} while ($valueLenO < strlen($string));
 		return $string;
 	}
 
@@ -1447,11 +1491,11 @@
 	 * @param	string		Value where &gt;, &lt;, &quot; and &amp; should be converted to regular chars.
 	 * @return	string		Converted result.
 	 */
-	public static function htmlspecialchars_decode($value)	{
+	public static function htmlspecialchars_decode($value) {
-		$value = str_replace('&gt;','>',$value);
+		$value = str_replace('&gt;', '>', $value);
-		$value = str_replace('&lt;','<',$value);
+		$value = str_replace('&lt;', '<', $value);
-		$value = str_replace('&quot;','"',$value);
+		$value = str_replace('&quot;', '"', $value);
-		$value = str_replace('&amp;','&',$value);
+		$value = str_replace('&amp;', '&', $value);
 		return $value;
 	}
 
@@ -1462,8 +1506,8 @@
 	 * @param	string		String which contains eg. "&amp;amp;" which should stay "&amp;". Or "&amp;#1234;" to "&#1234;". Or "&amp;#x1b;" to "&#x1b;"
 	 * @return	string		Converted result.
 	 */
-	public static function deHSCentities($str)	{
+	public static function deHSCentities($str) {
-		return preg_replace('/&amp;([#[:alnum:]]*;)/','&\1',$str);
+		return preg_replace('/&amp;([#[:alnum:]]*;)/', '&\1', $str);
 	}
 
 	/**
@@ -1475,9 +1519,11 @@
 	 * @param	string		The character to escape, default is ' (single-quote)
 	 * @return	string		Processed input string
 	 */
-	public static function slashJS($string,$extended=0,$char="'")	{
+	public static function slashJS($string, $extended = 0, $char = "'") {
-		if ($extended)	{$string = str_replace ("\\", "\\\\", $string);}
+		if ($extended) {
+			$string = str_replace("\\", "\\\\", $string);
+		}
-		return str_replace ($char, "\\".$char, $string);
+		return str_replace($char, "\\" . $char, $string);
 	}
 
 	/**
@@ -1488,8 +1534,8 @@
 	 * @param	string		String to raw-url-encode with spaces preserved
 	 * @return	string		Rawurlencoded result of input string, but with all %20 (space chars) converted to real spaces.
 	 */
-	public static function rawUrlEncodeJS($str)	{
+	public static function rawUrlEncodeJS($str) {
-		return str_replace('%20',' ',rawurlencode($str));
+		return str_replace('%20', ' ', rawurlencode($str));
 	}
 
 	/**
@@ -1500,8 +1546,8 @@
 	 * @param	string		Input string
 	 * @return	string		Output string
 	 */
-	public static function rawUrlEncodeFP($str)	{
+	public static function rawUrlEncodeFP($str) {
-		return str_replace('%2F','/',rawurlencode($str));
+		return str_replace('%2F', '/', rawurlencode($str));
 	}
 
 	/**
@@ -1511,7 +1557,7 @@
 	 * @param	string		Input string to evaluate
 	 * @return	boolean		Returns true if the $email address (input string) is valid
 	 */
-	public static function validEmail($email)	{
+	public static function validEmail($email) {
 			// enforce maximum length to prevent libpcre recursion crash bug #52929 in PHP
 			// fixed in PHP 5.2+ later than Sept 2010; length restriction per SMTP RFC 2821
 		if (strlen($email) > 320) {
@@ -1533,7 +1579,7 @@
 	 * @return	boolean	true if mail() does not accept recipient name
 	 */
 	public static function isBrokenEmailEnvironment() {
-		return TYPO3_OS == 'WIN' || (false !== strpos(ini_get('sendmail_path'), 'mini_sendmail'));
+		return TYPO3_OS == 'WIN' || (FALSE !== strpos(ini_get('sendmail_path'), 'mini_sendmail'));
 	}
 
 	/**
@@ -1544,7 +1590,7 @@
 	 * @see	t3lib_::isBrokenEmailEnvironment()
 	 */
 	public static function normalizeMailAddress($address) {
-		if (self::isBrokenEmailEnvironment() && false !== ($pos1 = strrpos($address, '<'))) {
+		if (self::isBrokenEmailEnvironment() && FALSE !== ($pos1 = strrpos($address, '<'))) {
 			$pos2 = strpos($address, '>', $pos1);
 			$address = substr($address, $pos1 + 1, ($pos2 ? $pos2 : strlen($address)) - $pos1 - 1);
 		}
@@ -1560,8 +1606,8 @@
 	 * @param	string		Input string to be formatted.
 	 * @return	string		Formatted for <textarea>-tags
 	 */
-	public static function formatForTextarea($content)	{
+	public static function formatForTextarea($content) {
-		return LF.htmlspecialchars($content);
+		return LF . htmlspecialchars($content);
 	}
 
 	/**
@@ -1570,11 +1616,11 @@
 	 * uppercase. It is safe for all supported character sets (incl. utf-8).
 	 * Unlike strtoupper() it does not honour the locale.
 	 *
-	 * @param   string      Input string
+	 * @param   string	  Input string
-	 * @return  string      Uppercase String
+	 * @return  string	  Uppercase String
 	 */
 	public static function strtoupper($str) {
-		return strtr((string)$str, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ');
+		return strtr((string) $str, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ');
 	}
 
 	/**
@@ -1586,8 +1632,8 @@
 	 * @param	string		Input string
 	 * @return	string		Lowercase String
 	 */
-	public static function strtolower($str)	{
+	public static function strtolower($str) {
-		return strtr((string)$str, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz');
+		return strtr((string) $str, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz');
 	}
 
 	/**
@@ -1610,7 +1656,7 @@
 				try {
 					$com = new COM('CAPICOM.Utilities.1');
 					$output = base64_decode($com->GetRandom($count, 0));
-				} catch(Exception $e) {
+				} catch (Exception $e) {
 					// CAPICOM not installed
 				}
 			}
@@ -1618,7 +1664,7 @@
 				if (function_exists('mcrypt_create_iv')) {
 					$output = mcrypt_create_iv($count, MCRYPT_DEV_URANDOM);
 				} elseif (function_exists('openssl_random_pseudo_bytes')) {
-					$isStrong = null;
+					$isStrong = NULL;
 					$output = openssl_random_pseudo_bytes($count, $isStrong);
 						// skip ssl since it wasn't using the strong algo
 					if ($isStrong !== TRUE) {
@@ -1632,11 +1678,11 @@
 		if (!isset($output{$count - 1})) {
 				// We initialize with the somewhat random.
 			$randomState = $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']
-							. base_convert(memory_get_usage() % pow(10, 6), 10, 2)
-							. microtime() . uniqid('') . getmypid();
+					. base_convert(memory_get_usage() % pow(10, 6), 10, 2)
+					. microtime() . uniqid('') . getmypid();
 			while (!isset($output{$count - 1})) {
 				$randomState = sha1(microtime() . mt_rand() . $randomState);
-				$output .= sha1(mt_rand() . $randomState, true);
+				$output .= sha1(mt_rand() . $randomState, TRUE);
 			}
 			$output = substr($output, strlen($output) - $count, $count);
 		}
@@ -1707,18 +1753,10 @@
 	 * @return	boolean		Whether the given URL is valid
 	 */
 	public static function isValidUrl($url) {
-		return (filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED) !== false);
+		return (filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED) !== FALSE);
 	}
 
 
-
-
-
-
-
-
-
-
 	/*************************
 	 *
 	 * ARRAY FUNCTIONS
@@ -1737,10 +1775,10 @@
 	 * +---------+-----------+-----------+-----------+
 	 * | $needle | variant_a | variant_b | variant_c |
 	 * +---------+-----------+-----------+-----------+
-	 * | '1a'    | false     | true      | false     |
+	 * | '1a'	| false	 | true	  | false	 |
-	 * | ''      | false     | true      | false     |
+	 * | ''	  | false	 | true	  | false	 |
-	 * | '0'     | true      | true      | false     |
+	 * | '0'	 | true	  | true	  | false	 |
-	 * | 0       | true      | true      | true      |
+	 * | 0	   | true	  | true	  | true	  |
 	 * +---------+-----------+-----------+-----------+
 	 * Usage: 3
 	 *
@@ -1751,10 +1789,10 @@
 	public static function inArray(array $in_array, $item) {
 		foreach ($in_array as $val) {
 			if (!is_array($val) && !strcmp($val, $item)) {
-				return true;
+				return TRUE;
 			}
 		}
-		return false;
+		return FALSE;
 	}
 
 	/**
@@ -1766,8 +1804,8 @@
 	 * @param	string		The string to explode
 	 * @param	boolean		If set, all empty values (='') will NOT be set in output
 	 * @param	integer		If positive, the result will contain a maximum of limit elements,
-	 * 						if negative, all components except the last -limit are returned,
+	 *						 if negative, all components except the last -limit are returned,
-	 * 						if zero (default), the result is not limited at all
+	 *						 if zero (default), the result is not limited at all
 	 * @return	array		Exploded values, all converted to integers
 	 */
 	public static function intExplode($delimiter, $string, $onlyNonEmptyValues = FALSE, $limit = 0) {
@@ -1785,7 +1823,7 @@
 	 * @param	integer		Number of array entries
 	 * @return	array		Exploded values
 	 */
-	public static function revExplode($delimiter, $string, $count=0) {
+	public static function revExplode($delimiter, $string, $count = 0) {
 		$explodedValues = explode($delimiter, strrev($string), $count);
 		$explodedValues = array_map('strrev', $explodedValues);
 		return array_reverse($explodedValues);
@@ -1800,21 +1838,21 @@
 	 * @param	string		The string to explode
 	 * @param	boolean		If set, all empty values will be removed in output
 	 * @param	integer		If positive, the result will contain a maximum of
-	 * 						$limit elements, if negative, all components except
+	 *						 $limit elements, if negative, all components except
-	 * 						the last -$limit are returned, if zero (default),
+	 *						 the last -$limit are returned, if zero (default),
-	 * 						the result is not limited at all. Attention though
+	 *						 the result is not limited at all. Attention though
-	 * 						that the use of this parameter can slow down this
+	 *						 that the use of this parameter can slow down this
-	 * 						function.
+	 *						 function.
 	 * @return	array		Exploded values
 	 */
-	public static function trimExplode($delim, $string, $removeEmptyValues = false, $limit = 0) {
+	public static function trimExplode($delim, $string, $removeEmptyValues = FALSE, $limit = 0) {
 		$explodedValues = explode($delim, $string);
 
 		$result = array_map('trim', $explodedValues);
 
 		if ($removeEmptyValues) {
 			$temp = array();
-			foreach($result as $value) {
+			foreach ($result as $value) {
 				if ($value !== '') {
 					$temp[] = $value;
 				}
@@ -1844,7 +1882,7 @@
 	 * @ignore
 	 * @deprecated since TYPO3 3.5, will be removed in TYPO3 4.6 - Use the PHP function array_unique instead
 	 */
-	public static function uniqueArray(array $valueArray)	{
+	public static function uniqueArray(array $valueArray) {
 		self::logDeprecatedFunction();
 
 		return array_unique($valueArray);
@@ -1858,7 +1896,7 @@
 	 * @param	string		Value to search for and if found remove array entry where found.
 	 * @return	array		Output array with entries removed if search string is found
 	 */
-	public static function removeArrayEntryByValue(array $array, $cmpValue)	{
+	public static function removeArrayEntryByValue(array $array, $cmpValue) {
 		foreach ($array as $k => $v) {
 			if (is_array($v)) {
 				$array[$k] = self::removeArrayEntryByValue($v, $cmpValue);
@@ -1875,16 +1913,16 @@
 	 *
 	 * Example (arguments used to call this function):
 	 * $array = array(
-	 * 		array('aa' => array('first', 'second'),
+	 *		 array('aa' => array('first', 'second'),
-	 * 		array('bb' => array('third', 'fourth'),
+	 *		 array('bb' => array('third', 'fourth'),
-	 * 		array('cc' => array('fifth', 'sixth'),
+	 *		 array('cc' => array('fifth', 'sixth'),
 	 * );
 	 * $keepItems = array('third');
 	 * $getValueFunc = create_function('$value', 'return $value[0];');
 	 *
 	 * Returns:
 	 * array(
-	 * 		array('bb' => array('third', 'fourth'),
+	 *		 array('bb' => array('third', 'fourth'),
 	 * )
 	 *
 	 * @param	array		$array: The initial array to be filtered/reduced
@@ -1892,7 +1930,7 @@
 	 * @param	string		$getValueFunc: (optional) Unique function name set by create_function() used to get the value to keep
 	 * @return	array		The filtered/reduced array with the kept items
 	 */
-	public static function keepItemsInArray(array $array, $keepItems, $getValueFunc=null) {
+	public static function keepItemsInArray(array $array, $keepItems, $getValueFunc = NULL) {
 		if ($array) {
 				// Convert strings to arrays:
 			if (is_string($keepItems)) {
@@ -1900,7 +1938,7 @@
 			}
 				// create_function() returns a string:
 			if (!is_string($getValueFunc)) {
-				$getValueFunc = null;
+				$getValueFunc = NULL;
 			}
 				// Do the filtering:
 			if (is_array($keepItems) && count($keepItems)) {
@@ -1928,15 +1966,15 @@
 	 * @return	string		Imploded result, fx. &param[key][key2]=value2&param[key][key3]=value3
 	 * @see explodeUrl2Array()
 	 */
-	public static function implodeArrayForUrl($name, array $theArray, $str = '', $skipBlank = false, $rawurlencodeParamName = false) {
+	public static function implodeArrayForUrl($name, array $theArray, $str = '', $skipBlank = FALSE, $rawurlencodeParamName = FALSE) {
-		foreach($theArray as $Akey => $AVal)	{
+		foreach ($theArray as $Akey => $AVal) {
-			$thisKeyName = $name ? $name.'['.$Akey.']' : $Akey;
+			$thisKeyName = $name ? $name . '[' . $Akey . ']' : $Akey;
-			if (is_array($AVal))	{
+			if (is_array($AVal)) {
-				$str = self::implodeArrayForUrl($thisKeyName,$AVal,$str,$skipBlank,$rawurlencodeParamName);
+				$str = self::implodeArrayForUrl($thisKeyName, $AVal, $str, $skipBlank, $rawurlencodeParamName);
 			} else {
-				if (!$skipBlank || strcmp($AVal,''))	{
+				if (!$skipBlank || strcmp($AVal, '')) {
-					$str.='&'.($rawurlencodeParamName ? rawurlencode($thisKeyName) : $thisKeyName).
+					$str .= '&' . ($rawurlencodeParamName ? rawurlencode($thisKeyName) : $thisKeyName) .
-						'='.rawurlencode($AVal);
+							'=' . rawurlencode($AVal);
 				}
 			}
 		}
@@ -1951,15 +1989,15 @@
 	 * @return	array		Array of values. All values AND keys are rawurldecoded() as they properly should be. But this means that any implosion of the array again must rawurlencode it!
 	 * @see implodeArrayForUrl()
 	 */
-	public static function explodeUrl2Array($string,$multidim=FALSE)	{
+	public static function explodeUrl2Array($string, $multidim = FALSE) {
 		$output = array();
-		if ($multidim)	{
+		if ($multidim) {
-			parse_str($string,$output);
+			parse_str($string, $output);
 		} else {
-			$p = explode('&',$string);
+			$p = explode('&', $string);
-			foreach($p as $v)	{
+			foreach ($p as $v) {
-				if (strlen($v))	{
+				if (strlen($v)) {
-					list($pK,$pV) = explode('=',$v,2);
+					list($pK, $pV) = explode('=', $v, 2);
 					$output[rawurldecode($pK)] = rawurldecode($pV);
 				}
 			}
@@ -1977,11 +2015,11 @@
 	 * @param	boolean		If set, then t3lib_div::_GP() is used to fetch the value if not found (isset) in the $getArray
 	 * @return	array		Output array with selected variables.
 	 */
-	public static function compileSelectedGetVarsFromArray($varList,array $getArray,$GPvarAlt=1)	{
+	public static function compileSelectedGetVarsFromArray($varList, array $getArray, $GPvarAlt = 1) {
-		$keys = self::trimExplode(',',$varList,1);
+		$keys = self::trimExplode(',', $varList, 1);
 		$outArr = array();
-		foreach($keys as $v)	{
+		foreach ($keys as $v) {
-			if (isset($getArray[$v]))	{
+			if (isset($getArray[$v])) {
 				$outArr[$v] = $getArray[$v];
 			} elseif ($GPvarAlt) {
 				$outArr[$v] = self::_GP($v);
@@ -2000,7 +2038,7 @@
 	 * @param	array		Multidimensional input array, (REFERENCE!)
 	 * @return	array
 	 */
-	public static function addSlashesOnArray(array &$theArray)	{
+	public static function addSlashesOnArray(array &$theArray) {
 		foreach ($theArray as &$value) {
 			if (is_array($value)) {
 				self::addSlashesOnArray($value);
@@ -2022,7 +2060,7 @@
 	 * @param	array		Multidimensional input array, (REFERENCE!)
 	 * @return	array
 	 */
-	public static function stripSlashesOnArray(array &$theArray)	{
+	public static function stripSlashesOnArray(array &$theArray) {
 		foreach ($theArray as &$value) {
 			if (is_array($value)) {
 				self::stripSlashesOnArray($value);
@@ -2042,17 +2080,21 @@
 	 * @param	string		"add" or "strip", depending on usage you wish.
 	 * @return	array
 	 */
-	public static function slashArray(array $arr,$cmd)	{
+	public static function slashArray(array $arr, $cmd) {
-		if ($cmd=='strip')	self::stripSlashesOnArray($arr);
-		if ($cmd=='add')	self::addSlashesOnArray($arr);
+		if ($cmd == 'strip') {
+			self::stripSlashesOnArray($arr);
+		}
+		if ($cmd == 'add') {
+			self::addSlashesOnArray($arr);
+		}
 		return $arr;
 	}
 
 	/**
-	* Rename Array keys with a given mapping table
-	* @param	array	Array by reference which should be remapped
-	* @param	array	Array with remap information, array/$oldKey => $newKey)
-	*/
+	 * Rename Array keys with a given mapping table
+	 * @param	array	Array by reference which should be remapped
+	 * @param	array	Array with remap information, array/$oldKey => $newKey)
+	 */
 	function remapArrayKeys(&$array, $mappingTable) {
 		if (is_array($mappingTable)) {
 			foreach ($mappingTable as $old => $new) {
@@ -2078,11 +2120,11 @@
 	 * @param	boolean		If set, values from $arr1 will overrule if they are empty or zero. Default: true
 	 * @return	array		Resulting array where $arr1 values has overruled $arr0 values
 	 */
-	public static function array_merge_recursive_overrule(array $arr0,array $arr1,$notAddKeys=0,$includeEmtpyValues=true) {
+	public static function array_merge_recursive_overrule(array $arr0, array $arr1, $notAddKeys = 0, $includeEmtpyValues = TRUE) {
 		foreach ($arr1 as $key => $val) {
-			if(is_array($arr0[$key])) {
+			if (is_array($arr0[$key])) {
-				if (is_array($arr1[$key]))	{
+				if (is_array($arr1[$key])) {
-					$arr0[$key] = self::array_merge_recursive_overrule($arr0[$key],$arr1[$key],$notAddKeys,$includeEmtpyValues);
+					$arr0[$key] = self::array_merge_recursive_overrule($arr0[$key], $arr1[$key], $notAddKeys, $includeEmtpyValues);
 				}
 			} else {
 				if ($notAddKeys) {
@@ -2110,8 +2152,8 @@
 	 * @param	array		Second array
 	 * @return	array		Merged result.
 	 */
-	public static function array_merge(array $arr1,array $arr2)	{
+	public static function array_merge(array $arr1, array $arr2) {
-		return $arr2+$arr1;
+		return $arr2 + $arr1;
 	}
 
 	/**
@@ -2146,13 +2188,13 @@
 	 * @param	string		Quote-character to wrap around the values.
 	 * @return	string		A single line of CSV
 	 */
-	public static function csvValues(array $row,$delim=',',$quote='"')	{
+	public static function csvValues(array $row, $delim = ',', $quote = '"') {
 		reset($row);
-		$out=array();
+		$out = array();
 		foreach ($row as $value) {
-			$out[] = str_replace($quote, $quote.$quote, $value);
+			$out[] = str_replace($quote, $quote . $quote, $value);
 		}
-		$str = $quote.implode($quote.$delim.$quote,$out).$quote;
+		$str = $quote . implode($quote . $delim . $quote, $out) . $quote;
 		return $str;
 	}
 
@@ -2208,11 +2250,6 @@
 	}
 
 
-
-
-
-
-
 	/*************************
 	 *
 	 * HTML/XML PROCESSING
@@ -2228,27 +2265,27 @@
 	 * @param	string		HTML-tag string (or attributes only)
 	 * @return	array		Array with the attribute values.
 	 */
-	public static function get_tag_attributes($tag)	{
+	public static function get_tag_attributes($tag) {
 		$components = self::split_tag_attributes($tag);
-		$name = '';	 // attribute name is stored here
+		$name = ''; // attribute name is stored here
-		$valuemode = false;
+		$valuemode = FALSE;
 		$attributes = array();
-		foreach ($components as $key => $val)	{
+		foreach ($components as $key => $val) {
-			if ($val != '=')	{	// Only if $name is set (if there is an attribute, that waits for a value), that valuemode is enabled. This ensures that the attribute is assigned it's value
+			if ($val != '=') { // Only if $name is set (if there is an attribute, that waits for a value), that valuemode is enabled. This ensures that the attribute is assigned it's value
-				if ($valuemode)	{
+				if ($valuemode) {
-					if ($name)	{
+					if ($name) {
 						$attributes[$name] = $val;
 						$name = '';
 					}
 				} else {
-					if ($key = strtolower(preg_replace('/[^a-zA-Z0-9]/','',$val)))	{
+					if ($key = strtolower(preg_replace('/[^a-zA-Z0-9]/', '', $val))) {
 						$attributes[$key] = '';
 						$name = $key;
 					}
 				}
-				$valuemode = false;
+				$valuemode = FALSE;
 			} else {
-				$valuemode = true;
+				$valuemode = TRUE;
 			}
 		}
 		return $attributes;
@@ -2262,26 +2299,26 @@
 	 * @param	string		HTML-tag string (or attributes only)
 	 * @return	array		Array with the attribute values.
 	 */
-	public static function split_tag_attributes($tag)	{
+	public static function split_tag_attributes($tag) {
-		$tag_tmp = trim(preg_replace('/^<[^[:space:]]*/','',trim($tag)));
+		$tag_tmp = trim(preg_replace('/^<[^[:space:]]*/', '', trim($tag)));
 			// Removes any > in the end of the string
 		$tag_tmp = trim(rtrim($tag_tmp, '>'));
 
 		$value = array();
-		while (strcmp($tag_tmp,''))	{	// Compared with empty string instead , 030102
+		while (strcmp($tag_tmp, '')) { // Compared with empty string instead , 030102
-			$firstChar=substr($tag_tmp,0,1);
+			$firstChar = substr($tag_tmp, 0, 1);
-			if (!strcmp($firstChar,'"') || !strcmp($firstChar,"'"))	{
+			if (!strcmp($firstChar, '"') || !strcmp($firstChar, "'")) {
-				$reg=explode($firstChar,$tag_tmp,3);
+				$reg = explode($firstChar, $tag_tmp, 3);
-				$value[]=$reg[1];
+				$value[] = $reg[1];
-				$tag_tmp=trim($reg[2]);
+				$tag_tmp = trim($reg[2]);
-			} elseif (!strcmp($firstChar,'=')) {
+			} elseif (!strcmp($firstChar, '=')) {
 				$value[] = '=';
-				$tag_tmp = trim(substr($tag_tmp,1));		// Removes = chars.
+				$tag_tmp = trim(substr($tag_tmp, 1)); // Removes = chars.
 			} else {
 					// There are '' around the value. We look for the next ' ' or '>'
 				$reg = preg_split('/[[:space:]=]/', $tag_tmp, 2);
 				$value[] = trim($reg[0]);
-				$tag_tmp = trim(substr($tag_tmp,strlen($reg[0]),1).$reg[1]);
+				$tag_tmp = trim(substr($tag_tmp, strlen($reg[0]), 1) . $reg[1]);
 			}
 		}
 		reset($value);
@@ -2297,19 +2334,23 @@
 	 * @param	boolean		If true, don't check if values are blank. Default is to omit attributes with blank values.
 	 * @return	string		Imploded attributes, eg. 'bgcolor="red" border="0"'
 	 */
-	public static function implodeAttributes(array $arr,$xhtmlSafe=FALSE,$dontOmitBlankAttribs=FALSE)	{
+	public static function implodeAttributes(array $arr, $xhtmlSafe = FALSE, $dontOmitBlankAttribs = FALSE) {
-		if ($xhtmlSafe)	{
+		if ($xhtmlSafe) {
-			$newArr=array();
+			$newArr = array();
-			foreach($arr as $p => $v)	{
+			foreach ($arr as $p => $v) {
-				if (!isset($newArr[strtolower($p)])) $newArr[strtolower($p)] = htmlspecialchars($v);
+				if (!isset($newArr[strtolower($p)])) {
+					$newArr[strtolower($p)] = htmlspecialchars($v);
-			}
+				}
+			}
 			$arr = $newArr;
 		}
 		$list = array();
-		foreach($arr as $p => $v)	{
+		foreach ($arr as $p => $v) {
-			if (strcmp($v,'') || $dontOmitBlankAttribs)	{$list[]=$p.'="'.$v.'"';}
+			if (strcmp($v, '') || $dontOmitBlankAttribs) {
+				$list[] = $p . '="' . $v . '"';
-		}
+			}
+		}
-		return implode(' ',$list);
+		return implode(' ', $list);
 	}
 
 	/**
@@ -2322,10 +2363,10 @@
 	 * @deprecated since TYPO3 3.7, will be removed in TYPO3 4.6 - Name was changed into implodeAttributes
 	 * @see implodeAttributes()
 	 */
-	public static function implodeParams(array $arr,$xhtmlSafe=FALSE,$dontOmitBlankAttribs=FALSE)	{
+	public static function implodeParams(array $arr, $xhtmlSafe = FALSE, $dontOmitBlankAttribs = FALSE) {
 		self::logDeprecatedFunction();
 
-		return self::implodeAttributes($arr,$xhtmlSafe,$dontOmitBlankAttribs);
+		return self::implodeAttributes($arr, $xhtmlSafe, $dontOmitBlankAttribs);
 	}
 
 	/**
@@ -2339,23 +2380,23 @@
 	 * @author	Ingmar Schlecht <ingmars@web.de>
 	 * @author	René Fritz <r.fritz@colorcube.de>
 	 */
-	public static function wrapJS($string, $linebreak=TRUE) {
+	public static function wrapJS($string, $linebreak = TRUE) {
-		if(trim($string)) {
+		if (trim($string)) {
 				// <script wrapped in nl?
-			$cr = $linebreak? LF : '';
+			$cr = $linebreak ? LF : '';
 
 				// remove nl from the beginning
-			$string = preg_replace ('/^\n+/', '', $string);
+			$string = preg_replace('/^\n+/', '', $string);
 				// re-ident to one tab using the first line as reference
 			$match = array();
-			if(preg_match('/^(\t+)/',$string,$match)) {
+			if (preg_match('/^(\t+)/', $string, $match)) {
-				$string = str_replace($match[1],TAB, $string);
+				$string = str_replace($match[1], TAB, $string);
 			}
-			$string = $cr.'<script type="text/javascript">
+			$string = $cr . '<script type="text/javascript">
 /*<![CDATA[*/
-'.$string.'
+' . $string . '
 /*]]>*/
-</script>'.$cr;
+</script>' . $cr;
 		}
 		return trim($string);
 	}
@@ -2370,7 +2411,7 @@
 	 * @return	mixed		The array with the parsed structure unless the XML parser returns with an error in which case the error message string is returned.
 	 * @author bisqwit at iki dot fi dot not dot for dot ads dot invalid / http://dk.php.net/xml_parse_into_struct + kasperYYYY@typo3.com
 	 */
-	public static function xml2tree($string,$depth=999) {
+	public static function xml2tree($string, $depth = 999) {
 		$parser = xml_parser_create();
 		$vals = array();
 		$index = array();
@@ -2379,49 +2420,54 @@
 		xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 0);
 		xml_parse_into_struct($parser, $string, $vals, $index);
 
-		if (xml_get_error_code($parser))	return 'Line '.xml_get_current_line_number($parser).': '.xml_error_string(xml_get_error_code($parser));
+		if (xml_get_error_code($parser)) {
+			return 'Line ' . xml_get_current_line_number($parser) . ': ' . xml_error_string(xml_get_error_code($parser));
+		}
 		xml_parser_free($parser);
 
-		$stack = array( array() );
+		$stack = array(array());
 		$stacktop = 0;
-		$startPoint=0;
+		$startPoint = 0;
 
-// FIXME don't use unset() - what does that mean? Use NULL or similar.
-		unset($tagi);
+		$tagi = array();
-		foreach($vals as $key => $val) {
+		foreach ($vals as $key => $val) {
 			$type = $val['type'];
 
 				// open tag:
-			if ($type=='open' || $type=='complete') {
+			if ($type == 'open' || $type == 'complete') {
 				$stack[$stacktop++] = $tagi;
 
-				if ($depth==$stacktop)	{
+				if ($depth == $stacktop) {
-					$startPoint=$key;
+					$startPoint = $key;
 				}
 
 				$tagi = array('tag' => $val['tag']);
 
-				if(isset($val['attributes']))  $tagi['attrs'] = $val['attributes'];
-				if(isset($val['value']))	$tagi['values'][] = $val['value'];
+				if (isset($val['attributes'])) {
+					$tagi['attrs'] = $val['attributes'];
-			}
+				}
+				if (isset($val['value'])) {
+					$tagi['values'][] = $val['value'];
+				}
+			}
 				// finish tag:
-			if ($type=='complete' || $type=='close')	{
+			if ($type == 'complete' || $type == 'close') {
 				$oldtagi = $tagi;
 				$tagi = $stack[--$stacktop];
 				$oldtag = $oldtagi['tag'];
 				unset($oldtagi['tag']);
 
-				if ($depth==($stacktop+1))	{
+				if ($depth == ($stacktop + 1)) {
-					if ($key-$startPoint > 0)	{
+					if ($key - $startPoint > 0) {
 						$partArray = array_slice(
 							$vals,
-							$startPoint+1,
+								$startPoint + 1,
-							$key-$startPoint-1
+								$key - $startPoint - 1
 						);
 						#$oldtagi=array('XMLvalue'=>self::xmlRecompileFromStructValArray($partArray));
-						$oldtagi['XMLvalue']=self::xmlRecompileFromStructValArray($partArray);
+						$oldtagi['XMLvalue'] = self::xmlRecompileFromStructValArray($partArray);
 					} else {
-						$oldtagi['XMLvalue']=$oldtagi['values'][0];
+						$oldtagi['XMLvalue'] = $oldtagi['values'][0];
 					}
 				}
 
@@ -2429,7 +2475,7 @@
 				unset($oldtagi);
 			}
 				// cdata
-			if($type=='cdata') {
+			if ($type == 'cdata') {
 				$tagi['values'][] = $val['value'];
 			}
 		}
@@ -2446,22 +2492,22 @@
 	 * @return	string		An XML string made from the input content in the array.
 	 * @see xml2array(),array2xml()
 	 */
-	public static function array2xml_cs(array $array,$docTag='phparray',array $options=array(),$charset='')	{
+	public static function array2xml_cs(array $array, $docTag = 'phparray', array $options = array(), $charset = '') {
 
 			// Figure out charset if not given explicitly:
-		if (!$charset)	{
+		if (!$charset) {
-			if ($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'])	{	// First priority: forceCharset! If set, this will be authoritative!
+			if ($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset']) { // First priority: forceCharset! If set, this will be authoritative!
 				$charset = $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'];
-			} elseif (is_object($GLOBALS['LANG']))	{
+			} elseif (is_object($GLOBALS['LANG'])) {
-				$charset = $GLOBALS['LANG']->charSet;	// If "LANG" is around, that will hold the current charset
+				$charset = $GLOBALS['LANG']->charSet; // If "LANG" is around, that will hold the current charset
 			} else {
-				$charset = 'iso-8859-1';	// THIS is just a hopeful guess!
+				$charset = 'iso-8859-1'; // THIS is just a hopeful guess!
 			}
 		}
 
 			// Return XML:
-		return '<?xml version="1.0" encoding="'.htmlspecialchars($charset).'" standalone="yes" ?>'.LF.
+		return '<?xml version="1.0" encoding="' . htmlspecialchars($charset) . '" standalone="yes" ?>' . LF .
-				self::array2xml($array,'',0,$docTag,0, $options);
+				self::array2xml($array, '', 0, $docTag, 0, $options);
 	}
 
 	/**
@@ -2487,59 +2533,59 @@
 	 * @return	string		An XML string made from the input content in the array.
 	 * @see xml2array()
 	 */
-	public static function array2xml(array $array,$NSprefix='',$level=0,$docTag='phparray',$spaceInd=0,array $options=array(),array $stackData=array())	{
+	public static function array2xml(array $array, $NSprefix = '', $level = 0, $docTag = 'phparray', $spaceInd = 0, array $options = array(), array $stackData = array()) {
 			// The list of byte values which will trigger binary-safe storage. If any value has one of these char values in it, it will be encoded in base64
-		$binaryChars = chr(0).chr(1).chr(2).chr(3).chr(4).chr(5).chr(6).chr(7).chr(8).
+		$binaryChars = chr(0) . chr(1) . chr(2) . chr(3) . chr(4) . chr(5) . chr(6) . chr(7) . chr(8) .
-						chr(11).chr(12).chr(14).chr(15).chr(16).chr(17).chr(18).chr(19).
+				chr(11) . chr(12) . chr(14) . chr(15) . chr(16) . chr(17) . chr(18) . chr(19) .
-						chr(20).chr(21).chr(22).chr(23).chr(24).chr(25).chr(26).chr(27).chr(28).chr(29).
+				chr(20) . chr(21) . chr(22) . chr(23) . chr(24) . chr(25) . chr(26) . chr(27) . chr(28) . chr(29) .
-						chr(30).chr(31);
+				chr(30) . chr(31);
 			// Set indenting mode:
 		$indentChar = $spaceInd ? ' ' : TAB;
-		$indentN = $spaceInd>0 ? $spaceInd : 1;
+		$indentN = $spaceInd > 0 ? $spaceInd : 1;
 		$nl = ($spaceInd >= 0 ? LF : '');
 
 			// Init output variable:
-		$output='';
+		$output = '';
 
 			// Traverse the input array
-		foreach($array as $k=>$v)	{
+		foreach ($array as $k => $v) {
 			$attr = '';
 			$tagName = $k;
 
 				// Construct the tag name.
-			if(isset($options['grandParentTagMap'][$stackData['grandParentTagName'].'/'.$stackData['parentTagName']])) {		// Use tag based on grand-parent + parent tag name
+			if (isset($options['grandParentTagMap'][$stackData['grandParentTagName'] . '/' . $stackData['parentTagName']])) { // Use tag based on grand-parent + parent tag name
-				$attr.=' index="'.htmlspecialchars($tagName).'"';
+				$attr .= ' index="' . htmlspecialchars($tagName) . '"';
-				$tagName = (string)$options['grandParentTagMap'][$stackData['grandParentTagName'].'/'.$stackData['parentTagName']];
+				$tagName = (string) $options['grandParentTagMap'][$stackData['grandParentTagName'] . '/' . $stackData['parentTagName']];
-			}elseif(isset($options['parentTagMap'][$stackData['parentTagName'].':_IS_NUM']) && self::testInt($tagName)) {		// Use tag based on parent tag name + if current tag is numeric
+			} elseif (isset($options['parentTagMap'][$stackData['parentTagName'] . ':_IS_NUM']) && self::testInt($tagName)) { // Use tag based on parent tag name + if current tag is numeric
-				$attr.=' index="'.htmlspecialchars($tagName).'"';
+				$attr .= ' index="' . htmlspecialchars($tagName) . '"';
-				$tagName = (string)$options['parentTagMap'][$stackData['parentTagName'].':_IS_NUM'];
+				$tagName = (string) $options['parentTagMap'][$stackData['parentTagName'] . ':_IS_NUM'];
-			}elseif(isset($options['parentTagMap'][$stackData['parentTagName'].':'.$tagName])) {		// Use tag based on parent tag name + current tag
+			} elseif (isset($options['parentTagMap'][$stackData['parentTagName'] . ':' . $tagName])) { // Use tag based on parent tag name + current tag
-				$attr.=' index="'.htmlspecialchars($tagName).'"';
+				$attr .= ' index="' . htmlspecialchars($tagName) . '"';
-				$tagName = (string)$options['parentTagMap'][$stackData['parentTagName'].':'.$tagName];
+				$tagName = (string) $options['parentTagMap'][$stackData['parentTagName'] . ':' . $tagName];
-			} elseif(isset($options['parentTagMap'][$stackData['parentTagName']])) {		// Use tag based on parent tag name:
+			} elseif (isset($options['parentTagMap'][$stackData['parentTagName']])) { // Use tag based on parent tag name:
-				$attr.=' index="'.htmlspecialchars($tagName).'"';
+				$attr .= ' index="' . htmlspecialchars($tagName) . '"';
-				$tagName = (string)$options['parentTagMap'][$stackData['parentTagName']];
+				$tagName = (string) $options['parentTagMap'][$stackData['parentTagName']];
-			} elseif (!strcmp(intval($tagName),$tagName))	{	// If integer...;
+			} elseif (!strcmp(intval($tagName), $tagName)) { // If integer...;
-				if ($options['useNindex']) {	// If numeric key, prefix "n"
+				if ($options['useNindex']) { // If numeric key, prefix "n"
-					$tagName = 'n'.$tagName;
+					$tagName = 'n' . $tagName;
-				} else {	// Use special tag for num. keys:
+				} else { // Use special tag for num. keys:
-					$attr.=' index="'.$tagName.'"';
+					$attr .= ' index="' . $tagName . '"';
 					$tagName = $options['useIndexTagForNum'] ? $options['useIndexTagForNum'] : 'numIndex';
 				}
-			} elseif($options['useIndexTagForAssoc']) {		// Use tag for all associative keys:
+			} elseif ($options['useIndexTagForAssoc']) { // Use tag for all associative keys:
-				$attr.=' index="'.htmlspecialchars($tagName).'"';
+				$attr .= ' index="' . htmlspecialchars($tagName) . '"';
 				$tagName = $options['useIndexTagForAssoc'];
 			}
 
 				// The tag name is cleaned up so only alphanumeric chars (plus - and _) are in there and not longer than 100 chars either.
-			$tagName = substr(preg_replace('/[^[:alnum:]_-]/','',$tagName),0,100);
+			$tagName = substr(preg_replace('/[^[:alnum:]_-]/', '', $tagName), 0, 100);
 
 				// If the value is an array then we will call this function recursively:
-			if (is_array($v))	{
+			if (is_array($v)) {
 
 					// Sub elements:
-				if ($options['alt_options'][$stackData['path'].'/'.$tagName])	{
+				if ($options['alt_options'][$stackData['path'] . '/' . $tagName]) {
-					$subOptions = $options['alt_options'][$stackData['path'].'/'.$tagName];
+					$subOptions = $options['alt_options'][$stackData['path'] . '/' . $tagName];
 					$clearStackPath = $subOptions['clearStackPath'];
 				} else {
 					$subOptions = $options;
@@ -2547,31 +2593,31 @@
 				}
 
 				$content = $nl .
-							self::array2xml(
-								$v,
-								$NSprefix,
+						self::array2xml(
+							$v,
+							$NSprefix,
-								$level+1,
+								$level + 1,
-								'',
-								$spaceInd,
-								$subOptions,
-								array(
-									'parentTagName' => $tagName,
-									'grandParentTagName' => $stackData['parentTagName'],
+							'',
+							$spaceInd,
+							$subOptions,
+							array(
+								'parentTagName' => $tagName,
+								'grandParentTagName' => $stackData['parentTagName'],
-									'path' => $clearStackPath ? '' : $stackData['path'].'/'.$tagName,
+								'path' => $clearStackPath ? '' : $stackData['path'] . '/' . $tagName,
-								)
+							)
-							).
+						) .
-							($spaceInd >= 0 ? str_pad('',($level+1)*$indentN,$indentChar) : '');
+						($spaceInd >= 0 ? str_pad('', ($level + 1) * $indentN, $indentChar) : '');
-				if ((int)$options['disableTypeAttrib']!=2)	{	// Do not set "type = array". Makes prettier XML but means that empty arrays are not restored with xml2array
+				if ((int) $options['disableTypeAttrib'] != 2) { // Do not set "type = array". Makes prettier XML but means that empty arrays are not restored with xml2array
-					$attr.=' type="array"';
+					$attr .= ' type="array"';
 				}
-			} else {	// Just a value:
+			} else { // Just a value:
 
 					// Look for binary chars:
-				$vLen = strlen($v);	// check for length, because PHP 5.2.0 may crash when first argument of strcspn is empty
+				$vLen = strlen($v); // check for length, because PHP 5.2.0 may crash when first argument of strcspn is empty
-				if ($vLen && strcspn($v,$binaryChars) != $vLen)	{	// Go for base64 encoding if the initial segment NOT matching any binary char has the same length as the whole string!
+				if ($vLen && strcspn($v, $binaryChars) != $vLen) { // Go for base64 encoding if the initial segment NOT matching any binary char has the same length as the whole string!
 						// If the value contained binary chars then we base64-encode it an set an attribute to notify this situation:
-					$content = $nl.chunk_split(base64_encode($v));
+					$content = $nl . chunk_split(base64_encode($v));
-					$attr.=' base64="1"';
+					$attr .= ' base64="1"';
 				} else {
 						// Otherwise, just htmlspecialchar the stuff:
 					$content = htmlspecialchars($v);
@@ -2581,21 +2627,21 @@
 							$content = '<![CDATA[' . $v . ']]>';
 						}
 					} elseif (!$options['disableTypeAttrib']) {
-						$attr.= ' type="'.$dType.'"';
+						$attr .= ' type="' . $dType . '"';
 					}
 				}
 			}
 
 				// Add the element to the output string:
-			$output.=($spaceInd >= 0 ? str_pad('',($level+1)*$indentN,$indentChar) : '').'<'.$NSprefix.$tagName.$attr.'>'.$content.'</'.$NSprefix.$tagName.'>'.$nl;
+			$output .= ($spaceInd >= 0 ? str_pad('', ($level + 1) * $indentN, $indentChar) : '') . '<' . $NSprefix . $tagName . $attr . '>' . $content . '</' . $NSprefix . $tagName . '>' . $nl;
 		}
 
-		// If we are at the outer-most level, then we finally wrap it all in the document tags and return that as the value:
+			// If we are at the outer-most level, then we finally wrap it all in the document tags and return that as the value:
-		if (!$level)	{
+		if (!$level) {
 			$output =
-				'<'.$docTag.'>'.$nl.
+					'<' . $docTag . '>' . $nl .
-				$output.
+							$output .
-				'</'.$docTag.'>';
+							'</' . $docTag . '>';
 		}
 
 		return $output;
@@ -2614,7 +2660,7 @@
 	 * @see array2xml(),xml2arrayProcess()
 	 * @author	Fabrizio Branca <typo3@fabrizio-branca.de> (added caching)
 	 */
-	public static function xml2array($string,$NSprefix='',$reportDocTag=FALSE) {
+	public static function xml2array($string, $NSprefix = '', $reportDocTag = FALSE) {
 		static $firstLevelCache = array();
 
 		$identifier = md5($string . $NSprefix . ($reportDocTag ? '1' : '0'));
@@ -2627,7 +2673,7 @@
 			$cacheContent = t3lib_pageSelect::getHash($identifier, 0);
 			$array = unserialize($cacheContent);
 
-			if ($array === false) {
+			if ($array === FALSE) {
 				$array = self::xml2arrayProcess($string, $NSprefix, $reportDocTag);
 				t3lib_pageSelect::storeHash($identifier, serialize($array), 'ident_xml2array');
 			}
@@ -2648,7 +2694,7 @@
 	 * @return	mixed		If the parsing had errors, a string with the error message is returned. Otherwise an array with the content.
 	 * @see array2xml()
 	 */
-	protected function xml2arrayProcess($string,$NSprefix='',$reportDocTag=FALSE) {
+	protected function xml2arrayProcess($string, $NSprefix = '', $reportDocTag = FALSE) {
 		global $TYPO3_CONF_VARS;
 
 			// Create parser:
@@ -2661,16 +2707,16 @@
 
 			// default output charset is UTF-8, only ASCII, ISO-8859-1 and UTF-8 are supported!!!
 		$match = array();
-		preg_match('/^[[:space:]]*<\?xml[^>]*encoding[[:space:]]*=[[:space:]]*"([^"]*)"/',substr($string,0,200),$match);
+		preg_match('/^[[:space:]]*<\?xml[^>]*encoding[[:space:]]*=[[:space:]]*"([^"]*)"/', substr($string, 0, 200), $match);
 		$theCharset = $match[1] ? $match[1] : ($TYPO3_CONF_VARS['BE']['forceCharset'] ? $TYPO3_CONF_VARS['BE']['forceCharset'] : 'iso-8859-1');
-		xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $theCharset);  // us-ascii / utf-8 / iso-8859-1
+		xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $theCharset); // us-ascii / utf-8 / iso-8859-1
 
 			// Parse content:
 		xml_parse_into_struct($parser, $string, $vals, $index);
 
 			// If error, return error message:
-		if (xml_get_error_code($parser))	{
+		if (xml_get_error_code($parser)) {
-			return 'Line '.xml_get_current_line_number($parser).': '.xml_error_string(xml_get_error_code($parser));
+			return 'Line ' . xml_get_current_line_number($parser) . ': ' . xml_error_string(xml_get_error_code($parser));
 		}
 		xml_parser_free($parser);
 
@@ -2682,63 +2728,67 @@
 		$documentTag = '';
 
 			// Traverse the parsed XML structure:
-		foreach($vals as $key => $val) {
+		foreach ($vals as $key => $val) {
 
 				// First, process the tag-name (which is used in both cases, whether "complete" or "close")
 			$tagName = $val['tag'];
-			if (!$documentTag)	$documentTag = $tagName;
+			if (!$documentTag) {
+				$documentTag = $tagName;
+			}
 
 				// Test for name space:
-			$tagName = ($NSprefix && substr($tagName,0,strlen($NSprefix))==$NSprefix) ? substr($tagName,strlen($NSprefix)) : $tagName;
+			$tagName = ($NSprefix && substr($tagName, 0, strlen($NSprefix)) == $NSprefix) ? substr($tagName, strlen($NSprefix)) : $tagName;
 
 				// Test for numeric tag, encoded on the form "nXXX":
-			$testNtag = substr($tagName,1);	// Closing tag.
+			$testNtag = substr($tagName, 1); // Closing tag.
-			$tagName = (substr($tagName,0,1)=='n' && !strcmp(intval($testNtag),$testNtag)) ? intval($testNtag) : $tagName;
+			$tagName = (substr($tagName, 0, 1) == 'n' && !strcmp(intval($testNtag), $testNtag)) ? intval($testNtag) : $tagName;
 
 				// Test for alternative index value:
-			if (strlen($val['attributes']['index']))	{ $tagName = $val['attributes']['index']; }
+			if (strlen($val['attributes']['index'])) {
+				$tagName = $val['attributes']['index'];
+			}
 
 				// Setting tag-values, manage stack:
-			switch($val['type'])	{
+			switch ($val['type']) {
-				case 'open':		// If open tag it means there is an array stored in sub-elements. Therefore increase the stackpointer and reset the accumulation array:
+				case 'open': // If open tag it means there is an array stored in sub-elements. Therefore increase the stackpointer and reset the accumulation array:
-					$current[$tagName] = array();	// Setting blank place holder
+					$current[$tagName] = array(); // Setting blank place holder
 					$stack[$stacktop++] = $current;
 					$current = array();
-				break;
+					break;
-				case 'close':	// If the tag is "close" then it is an array which is closing and we decrease the stack pointer.
+				case 'close': // If the tag is "close" then it is an array which is closing and we decrease the stack pointer.
 					$oldCurrent = $current;
 					$current = $stack[--$stacktop];
-					end($current);	// Going to the end of array to get placeholder key, key($current), and fill in array next:
+					end($current); // Going to the end of array to get placeholder key, key($current), and fill in array next:
 					$current[key($current)] = $oldCurrent;
 					unset($oldCurrent);
-				break;
+					break;
-				case 'complete':	// If "complete", then it's a value. If the attribute "base64" is set, then decode the value, otherwise just set it.
+				case 'complete': // If "complete", then it's a value. If the attribute "base64" is set, then decode the value, otherwise just set it.
-					if ($val['attributes']['base64'])	{
+					if ($val['attributes']['base64']) {
 						$current[$tagName] = base64_decode($val['value']);
 					} else {
-						$current[$tagName] = (string)$val['value']; // Had to cast it as a string - otherwise it would be evaluate false if tested with isset()!!
+						$current[$tagName] = (string) $val['value']; // Had to cast it as a string - otherwise it would be evaluate false if tested with isset()!!
 
 							// Cast type:
-						switch((string)$val['attributes']['type'])	{
+						switch ((string) $val['attributes']['type']) {
 							case 'integer':
-								$current[$tagName] = (integer)$current[$tagName];
+								$current[$tagName] = (integer) $current[$tagName];
-							break;
+								break;
 							case 'double':
-								$current[$tagName] = (double)$current[$tagName];
+								$current[$tagName] = (double) $current[$tagName];
-							break;
+								break;
 							case 'boolean':
-								$current[$tagName] = (bool)$current[$tagName];
+								$current[$tagName] = (bool) $current[$tagName];
-							break;
+								break;
 							case 'array':
-								$current[$tagName] = array();	// MUST be an empty array since it is processed as a value; Empty arrays would end up here because they would have no tags inside...
+								$current[$tagName] = array(); // MUST be an empty array since it is processed as a value; Empty arrays would end up here because they would have no tags inside...
-							break;
+								break;
 						}
 					}
-				break;
+					break;
 			}
 		}
 
-		if ($reportDocTag)	{
+		if ($reportDocTag) {
 			$current[$tagName]['_DOCUMENT_TAG'] = $documentTag;
 		}
 
@@ -2753,37 +2803,41 @@
 	 * @param	array		A array of XML parts, see xml2tree
 	 * @return	string		Re-compiled XML data.
 	 */
-	public static function xmlRecompileFromStructValArray(array $vals)	{
+	public static function xmlRecompileFromStructValArray(array $vals) {
-		$XMLcontent='';
+		$XMLcontent = '';
 
-		foreach($vals as $val) {
+		foreach ($vals as $val) {
 			$type = $val['type'];
 
 				// open tag:
-			if ($type=='open' || $type=='complete') {
+			if ($type == 'open' || $type == 'complete') {
-				$XMLcontent.='<'.$val['tag'];
+				$XMLcontent .= '<' . $val['tag'];
-				if(isset($val['attributes']))  {
+				if (isset($val['attributes'])) {
-					foreach($val['attributes'] as $k => $v)	{
+					foreach ($val['attributes'] as $k => $v) {
-						$XMLcontent.=' '.$k.'="'.htmlspecialchars($v).'"';
+						$XMLcontent .= ' ' . $k . '="' . htmlspecialchars($v) . '"';
 					}
 				}
-				if ($type=='complete')	{
+				if ($type == 'complete') {
-					if(isset($val['value']))	{
+					if (isset($val['value'])) {
-						$XMLcontent.='>'.htmlspecialchars($val['value']).'</'.$val['tag'].'>';
+						$XMLcontent .= '>' . htmlspecialchars($val['value']) . '</' . $val['tag'] . '>';
-					} else $XMLcontent.='/>';
-				} else $XMLcontent.='>';
+					} else {
+						$XMLcontent .= '/>';
+					}
+				} else {
+					$XMLcontent .= '>';
+				}
 
-				if ($type=='open' && isset($val['value']))	{
+				if ($type == 'open' && isset($val['value'])) {
-					$XMLcontent.=htmlspecialchars($val['value']);
+					$XMLcontent .= htmlspecialchars($val['value']);
 				}
 			}
 				// finish tag:
-			if ($type=='close')	{
+			if ($type == 'close') {
-				$XMLcontent.='</'.$val['tag'].'>';
+				$XMLcontent .= '</' . $val['tag'] . '>';
 			}
 				// cdata
-			if($type=='cdata') {
+			if ($type == 'cdata') {
-				$XMLcontent.=htmlspecialchars($val['value']);
+				$XMLcontent .= htmlspecialchars($val['value']);
 			}
 		}
 
@@ -2797,9 +2851,9 @@
 	 * @param	string		XML data
 	 * @return	array		Attributes of the xml prologue (header)
 	 */
-	public static function xmlGetHeaderAttribs($xmlData)	{
+	public static function xmlGetHeaderAttribs($xmlData) {
 		$match = array();
-		if (preg_match('/^\s*<\?xml([^>]*)\?\>/', $xmlData, $match))	{
+		if (preg_match('/^\s*<\?xml([^>]*)\?\>/', $xmlData, $match)) {
 			return self::get_tag_attributes($match[1]);
 		}
 	}
@@ -2817,7 +2871,7 @@
 			$error = '';
 			$script = trim(JSMin::minify(str_replace(CR, '', $script)));
 		}
-		catch(JSMinException $e) {
+		catch (JSMinException $e) {
 			$error = 'Error while minifying JavaScript: ' . $e->getMessage();
 			self::devLog($error, 't3lib_div', 2,
 				array('JavaScript' => $script, 'Stack trace' => $e->getTrace()));
@@ -2826,12 +2880,6 @@
 	}
 
 
-
-
-
-
-
-
 	/*************************
 	 *
 	 * FILES FUNCTIONS
@@ -2849,28 +2897,28 @@
 	 * @param	array			Error code/message and, if $includeHeader is 1, response meta data (HTTP status and content type)
 	 * @return	string	The content from the resource given as input. FALSE if an error has occured.
 	 */
-	public static function getURL($url, $includeHeader = 0, $requestHeaders = false, &$report = NULL)	{
-		$content = false;
+	public static function getURL($url, $includeHeader = 0, $requestHeaders = FALSE, &$report = NULL) {
+		$content = FALSE;
 
-		if (isset($report))	{
+		if (isset($report)) {
 			$report['error'] = 0;
 			$report['message'] = '';
 		}
 
 			// use cURL for: http, https, ftp, ftps, sftp and scp
-		if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlUse'] == '1' && preg_match('/^(?:http|ftp)s?|s(?:ftp|cp):/', $url))	{
+		if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlUse'] == '1' && preg_match('/^(?:http|ftp)s?|s(?:ftp|cp):/', $url)) {
-			if (isset($report))	{
+			if (isset($report)) {
 				$report['lib'] = 'cURL';
 			}
 
 				// External URL without error checking.
 			$ch = curl_init();
-			if (!$ch)	{
+			if (!$ch) {
-				if (isset($report))	{
+				if (isset($report)) {
 					$report['error'] = -1;
 					$report['message'] = 'Couldn\'t initialize cURL.';
 				}
-				return false;
+				return FALSE;
 			}
 
 			curl_setopt($ch, CURLOPT_URL, $url);
@@ -2884,33 +2932,33 @@
 				// may fail (PHP 5.2.0+ and 5.1.5+) when open_basedir or safe_mode are enabled
 			$followLocation = @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
 
-			if (is_array($requestHeaders))	{
+			if (is_array($requestHeaders)) {
 				curl_setopt($ch, CURLOPT_HTTPHEADER, $requestHeaders);
 			}
 
 				// (Proxy support implemented by Arco <arco@appeltaart.mine.nu>)
-			if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyServer'])	{
+			if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyServer']) {
 				curl_setopt($ch, CURLOPT_PROXY, $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyServer']);
 
-				if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyTunnel'])	{
+				if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyTunnel']) {
 					curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyTunnel']);
 				}
-				if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyUserPass'])	{
+				if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyUserPass']) {
 					curl_setopt($ch, CURLOPT_PROXYUSERPWD, $GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyUserPass']);
 				}
 			}
 			$content = curl_exec($ch);
-			if (isset($report))	{
+			if (isset($report)) {
-				if ($content===FALSE)	{
+				if ($content === FALSE) {
 					$report['error'] = curl_errno($ch);
 					$report['message'] = curl_error($ch);
 				} else {
 					$curlInfo = curl_getinfo($ch);
 						// We hit a redirection but we couldn't follow it
-					if (!$followLocation && $curlInfo['status'] >= 300 && $curlInfo['status'] < 400)	 {
+					if (!$followLocation && $curlInfo['status'] >= 300 && $curlInfo['status'] < 400) {
 						$report['error'] = -1;
 						$report['message'] = 'Couldn\'t follow location redirect (either PHP configuration option safe_mode or open_basedir is in effect).';
-					} elseif($includeHeader) {
+					} elseif ($includeHeader) {
 							// Set only for $includeHeader to work exactly like PHP variant
 						$report['http_code'] = $curlInfo['http_code'];
 						$report['content_type'] = $curlInfo['content_type'];
@@ -2919,99 +2967,99 @@
 			}
 			curl_close($ch);
 
-		} elseif ($includeHeader)	{
+		} elseif ($includeHeader) {
-			if (isset($report))	{
+			if (isset($report)) {
 				$report['lib'] = 'socket';
 			}
 			$parsedURL = parse_url($url);
-			if (!preg_match('/^https?/', $parsedURL['scheme']))	{
+			if (!preg_match('/^https?/', $parsedURL['scheme'])) {
-				if (isset($report))	{
+				if (isset($report)) {
 					$report['error'] = -1;
 					$report['message'] = 'Reading headers is not allowed for this protocol.';
 				}
-				return false;
+				return FALSE;
 			}
 			$port = intval($parsedURL['port']);
-			if ($port < 1)	{
+			if ($port < 1) {
-				if ($parsedURL['scheme'] == 'http')	{
+				if ($parsedURL['scheme'] == 'http') {
-					$port = ($port>0 ? $port : 80);
+					$port = ($port > 0 ? $port : 80);
 					$scheme = '';
 				} else {
-					$port = ($port>0 ? $port : 443);
+					$port = ($port > 0 ? $port : 443);
 					$scheme = 'ssl://';
 				}
 			}
 			$errno = 0;
-			// $errstr = '';
+				// $errstr = '';
-			$fp = @fsockopen($scheme.$parsedURL['host'], $port, $errno, $errstr, 2.0);
+			$fp = @fsockopen($scheme . $parsedURL['host'], $port, $errno, $errstr, 2.0);
-			if (!$fp || $errno > 0)	{
+			if (!$fp || $errno > 0) {
-				if (isset($report))	{
+				if (isset($report)) {
 					$report['error'] = $errno ? $errno : -1;
 					$report['message'] = $errno ? ($errstr ? $errstr : 'Socket error.') : 'Socket initialization error.';
 				}
-				return false;
+				return FALSE;
 			}
 			$method = ($includeHeader == 2) ? 'HEAD' : 'GET';
 			$msg = $method . ' ' . $parsedURL['path'] .
 					($parsedURL['query'] ? '?' . $parsedURL['query'] : '') .
 					' HTTP/1.0' . CRLF . 'Host: ' .
 					$parsedURL['host'] . "\r\nConnection: close\r\n";
-			if (is_array($requestHeaders))	{
+			if (is_array($requestHeaders)) {
 				$msg .= implode(CRLF, $requestHeaders) . CRLF;
 			}
 			$msg .= CRLF;
 
 			fputs($fp, $msg);
-			while (!feof($fp))	{
+			while (!feof($fp)) {
 				$line = fgets($fp, 2048);
-				if (isset($report))	{
+				if (isset($report)) {
-					if (preg_match('|^HTTP/\d\.\d +(\d+)|', $line, $status))	{
+					if (preg_match('|^HTTP/\d\.\d +(\d+)|', $line, $status)) {
 						$report['http_code'] = $status[1];
 					}
-					elseif (preg_match('/^Content-Type: *(.*)/i', $line, $type))	{
+					elseif (preg_match('/^Content-Type: *(.*)/i', $line, $type)) {
 						$report['content_type'] = $type[1];
 					}
 				}
 				$content .= $line;
-				if (!strlen(trim($line)))	{
+				if (!strlen(trim($line))) {
-					break;	// Stop at the first empty line (= end of header)
+					break; // Stop at the first empty line (= end of header)
 				}
 			}
-			if ($includeHeader != 2)	{
+			if ($includeHeader != 2) {
 				$content .= stream_get_contents($fp);
 			}
 			fclose($fp);
 
-		} elseif (is_array($requestHeaders))	{
+		} elseif (is_array($requestHeaders)) {
-			if (isset($report))	{
+			if (isset($report)) {
 				$report['lib'] = 'file/context';
 			}
 			$parsedURL = parse_url($url);
-			if (!preg_match('/^https?/', $parsedURL['scheme']))	{
+			if (!preg_match('/^https?/', $parsedURL['scheme'])) {
-				if (isset($report))	{
+				if (isset($report)) {
 					$report['error'] = -1;
 					$report['message'] = 'Sending request headers is not allowed for this protocol.';
 				}
-				return false;
+				return FALSE;
 			}
 			$ctx = stream_context_create(array(
-						'http' => array(
-							'header' => implode(CRLF, $requestHeaders)
-						)
-					)
-				);
+				'http' => array(
+					'header' => implode(CRLF, $requestHeaders)
+				)
+			)
+			);
-			$content = @file_get_contents($url, false, $ctx);
-			if ($content === false && isset($report)) {
+			$content = @file_get_contents($url, FALSE, $ctx);
+			if ($content === FALSE && isset($report)) {
 				$phpError = error_get_last();
 				$report['error'] = $phpError['type'];
 				$report['message'] = $phpError['message'];
 			}
-		} else	{
+		} else {
-			if (isset($report))	{
+			if (isset($report)) {
 				$report['lib'] = 'file';
 			}
 			$content = @file_get_contents($url);
-			if ($content === false && isset($report))	{
+			if ($content === FALSE && isset($report)) {
 				if (function_exists('error_get_last')) {
 					$phpError = error_get_last();
 					$report['error'] = $phpError['type'];
@@ -3034,23 +3082,27 @@
 	 * @param	string		Content to write
 	 * @return	boolean		True if the file was successfully opened and written to.
 	 */
-	public static function writeFile($file,$content)	{
+	public static function writeFile($file, $content) {
-		if (!@is_file($file))	$changePermissions = true;
+		if (!@is_file($file)) {
+			$changePermissions = TRUE;
+		}
 
-		if ($fd = fopen($file,'wb'))	{
+		if ($fd = fopen($file, 'wb')) {
-			$res = fwrite($fd,$content);
+			$res = fwrite($fd, $content);
 			fclose($fd);
 
-			if ($res===false)	return false;
+			if ($res === FALSE) {
+				return FALSE;
+			}
 
-			if ($changePermissions)	{	// Change the permissions only if the file has just been created
+			if ($changePermissions) { // Change the permissions only if the file has just been created
 				self::fixPermissions($file);
 			}
 
-			return true;
+			return TRUE;
 		}
 
-		return false;
+		return FALSE;
 	}
 
 	/**
@@ -3058,7 +3110,7 @@
 	 *
 	 * @param   string   Absolute filepath of file or folder, must not be escaped.
 	 * @param   boolean  If set, also fixes permissions of files and folders in the folder (if $path is a folder)
-	 * @return  mixed    TRUE on success, FALSE on error, always TRUE on Windows OS
+	 * @return  mixed	TRUE on success, FALSE on error, always TRUE on Windows OS
 	 */
 	public static function fixPermissions($path, $recursive = FALSE) {
 		if (TYPO3_OS != 'WIN') {
@@ -3074,7 +3126,7 @@
 				}
 
 					// Set createGroup if not empty
-				if($GLOBALS['TYPO3_CONF_VARS']['BE']['createGroup']) {
+				if ($GLOBALS['TYPO3_CONF_VARS']['BE']['createGroup']) {
 						// "@" is there because file is not necessarily OWNED by the user
 					$changeGroupResult = @chgrp($path, $GLOBALS['TYPO3_CONF_VARS']['BE']['createGroup']);
 					$result = $changeGroupResult ? $result : FALSE;
@@ -3084,7 +3136,7 @@
 				if ($recursive && @is_dir($path)) {
 					$handle = opendir($path);
 					while (($file = readdir($handle)) !== FALSE) {
-						unset($recursionResult);
+						$recursionResult = NULL;
 						if ($file !== '.' && $file !== '..') {
 							if (@is_file($path . '/' . $file)) {
 								$recursionResult = self::fixPermissions($path . '/' . $file);
@@ -3113,41 +3165,57 @@
 	 * @param	string		Content string to write
 	 * @return	string		Returns false on success, otherwise an error string telling about the problem.
 	 */
-	public static function writeFileToTypo3tempDir($filepath,$content)	{
+	public static function writeFileToTypo3tempDir($filepath, $content) {
 
 			// Parse filepath into directory and basename:
 		$fI = pathinfo($filepath);
-		$fI['dirname'].= '/';
+		$fI['dirname'] .= '/';
 
 			// Check parts:
-		if (self::validPathStr($filepath) && $fI['basename'] && strlen($fI['basename'])<60)	{
+		if (self::validPathStr($filepath) && $fI['basename'] && strlen($fI['basename']) < 60) {
-			if (defined('PATH_site'))	{
+			if (defined('PATH_site')) {
-				$dirName = PATH_site.'typo3temp/';	// Setting main temporary directory name (standard)
+				$dirName = PATH_site . 'typo3temp/'; // Setting main temporary directory name (standard)
-				if (@is_dir($dirName))	{
+				if (@is_dir($dirName)) {
-					if (self::isFirstPartOfStr($fI['dirname'],$dirName))	{
+					if (self::isFirstPartOfStr($fI['dirname'], $dirName)) {
 
 							// Checking if the "subdir" is found:
-						$subdir = substr($fI['dirname'],strlen($dirName));
+						$subdir = substr($fI['dirname'], strlen($dirName));
-						if ($subdir)	{
+						if ($subdir) {
-							if (preg_match('/^[[:alnum:]_]+\/$/',$subdir) || preg_match('/^[[:alnum:]_]+\/[[:alnum:]_]+\/$/',$subdir))	{
+							if (preg_match('/^[[:alnum:]_]+\/$/', $subdir) || preg_match('/^[[:alnum:]_]+\/[[:alnum:]_]+\/$/', $subdir)) {
-								$dirName.= $subdir;
+								$dirName .= $subdir;
-								if (!@is_dir($dirName))	{
+								if (!@is_dir($dirName)) {
-									self::mkdir_deep(PATH_site.'typo3temp/', $subdir);
+									self::mkdir_deep(PATH_site . 'typo3temp/', $subdir);
 								}
-							} else return 'Subdir, "'.$subdir.'", was NOT on the form "[[:alnum:]_]/" or  "[[:alnum:]_]/[[:alnum:]_]/"';
+							} else {
+								return 'Subdir, "' . $subdir . '", was NOT on the form "[[:alnum:]_]/" or  "[[:alnum:]_]/[[:alnum:]_]/"';
-						}
+							}
+						}
 							// Checking dir-name again (sub-dir might have been created):
-						if (@is_dir($dirName))	{
+						if (@is_dir($dirName)) {
-							if ($filepath == $dirName.$fI['basename'])	{
+							if ($filepath == $dirName . $fI['basename']) {
 								self::writeFile($filepath, $content);
-								if (!@is_file($filepath))	return 'File not written to disk! Write permission error in filesystem?';
-							} else return 'Calculated filelocation didn\'t match input $filepath!';
-						} else return '"'.$dirName.'" is not a directory!';
-					} else return '"'.$fI['dirname'].'" was not within directory PATH_site + "typo3temp/"';
-				} else return 'PATH_site + "typo3temp/" was not a directory!';
-			} else return 'PATH_site constant was NOT defined!';
-		} else return 'Input filepath "'.$filepath.'" was generally invalid!';
+								if (!@is_file($filepath)) {
+									return 'File not written to disk! Write permission error in filesystem?';
-	}
+								}
+							} else {
+								return 'Calculated filelocation didn\'t match input $filepath!';
+							}
+						} else {
+							return '"' . $dirName . '" is not a directory!';
+						}
+					} else {
+						return '"' . $fI['dirname'] . '" was not within directory PATH_site + "typo3temp/"';
+					}
+				} else {
+					return 'PATH_site + "typo3temp/" was not a directory!';
+				}
+			} else {
+				return 'PATH_site constant was NOT defined!';
+			}
+		} else {
+			return 'Input filepath "' . $filepath . '" was generally invalid!';
+		}
+	}
 
 	/**
 	 * Wrapper function for mkdir.
@@ -3173,15 +3241,15 @@
 	 * @param	string		Deep directory to create, eg. "xx/yy/" which creates "/root/typo3site/xx/yy/" if $destination is "/root/typo3site/"
 	 * @return	string		If error, returns error string.
 	 */
-	public static function mkdir_deep($destination,$deepDir)	{
+	public static function mkdir_deep($destination, $deepDir) {
-		$allParts = self::trimExplode('/',$deepDir,1);
+		$allParts = self::trimExplode('/', $deepDir, 1);
 		$root = '';
-		foreach($allParts as $part)	{
+		foreach ($allParts as $part) {
-			$root.= $part.'/';
+			$root .= $part . '/';
-			if (!is_dir($destination.$root))	{
+			if (!is_dir($destination . $root)) {
-				self::mkdir($destination.$root);
+				self::mkdir($destination . $root);
-				if (!@is_dir($destination.$root))	{
+				if (!@is_dir($destination . $root)) {
-					return 'Error: The directory "'.$destination.$root.'" could not be created...';
+					return 'Error: The directory "' . $destination . $root . '" could not be created...';
 				}
 			}
 		}
@@ -3194,24 +3262,28 @@
 	 * @param	boolean		Allow deletion of non-empty directories
 	 * @return	boolean		true if @rmdir went well!
 	 */
-	public static function rmdir($path,$removeNonEmpty=false)	{
-		$OK = false;
+	public static function rmdir($path, $removeNonEmpty = FALSE) {
+		$OK = FALSE;
-		$path = preg_replace('|/$|','',$path);	// Remove trailing slash
+		$path = preg_replace('|/$|', '', $path); // Remove trailing slash
 
-		if (file_exists($path))	{
+		if (file_exists($path)) {
-			$OK = true;
+			$OK = TRUE;
 
-			if (is_dir($path))	{
+			if (is_dir($path)) {
-				if ($removeNonEmpty==true && $handle = opendir($path))	{
-					while ($OK && false !== ($file = readdir($handle)))	{
-						if ($file=='.' || $file=='..') continue;
+				if ($removeNonEmpty == TRUE && $handle = opendir($path)) {
+					while ($OK && FALSE !== ($file = readdir($handle))) {
+						if ($file == '.' || $file == '..') {
+							continue;
+						}
-						$OK = self::rmdir($path.'/'.$file,$removeNonEmpty);
+						$OK = self::rmdir($path . '/' . $file, $removeNonEmpty);
 					}
 					closedir($handle);
 				}
-				if ($OK)	{ $OK = rmdir($path); }
+				if ($OK) {
+					$OK = rmdir($path);
+				}
 
-			} else {	// If $dirname is a file, simply remove it
+			} else { // If $dirname is a file, simply remove it
 				$OK = unlink($path);
 			}
 
@@ -3229,7 +3301,7 @@
 	 * @param	string		Path to list directories from
 	 * @return	array		Returns an array with the directory entries as values. If no path, the return value is nothing.
 	 */
-	public static function get_dirs($path)	{
+	public static function get_dirs($path) {
 		if ($path) {
 			if (is_dir($path)) {
 				$dir = scandir($path);
@@ -3257,7 +3329,7 @@
 	 * @param	string		A comma seperated list of filenames to exclude, no wildcards
 	 * @return	array		Array of the files found
 	 */
-	public static function getFilesInDir($path,$extensionList='',$prependPath=0,$order='',$excludePattern='')	{
+	public static function getFilesInDir($path, $extensionList = '', $prependPath = 0, $order = '', $excludePattern = '') {
 
 			// Initialize variabels:
 		$filearray = array();
@@ -3265,33 +3337,39 @@
 		$path = rtrim($path, '/');
 
 			// Find files+directories:
-		if (@is_dir($path))	{
+		if (@is_dir($path)) {
 			$extensionList = strtolower($extensionList);
 			$d = dir($path);
-			if (is_object($d))	{
+			if (is_object($d)) {
-				while($entry=$d->read()) {
+				while ($entry = $d->read()) {
-					if (@is_file($path.'/'.$entry))	{
+					if (@is_file($path . '/' . $entry)) {
 						$fI = pathinfo($entry);
-						$key = md5($path.'/'.$entry);	// Don't change this ever - extensions may depend on the fact that the hash is an md5 of the path! (import/export extension)
+						$key = md5($path . '/' . $entry); // Don't change this ever - extensions may depend on the fact that the hash is an md5 of the path! (import/export extension)
-						if ((!strlen($extensionList) || self::inList($extensionList,strtolower($fI['extension']))) && (!strlen($excludePattern) || !preg_match('/^'.$excludePattern.'$/',$entry)))	{
+						if ((!strlen($extensionList) || self::inList($extensionList, strtolower($fI['extension']))) && (!strlen($excludePattern) || !preg_match('/^' . $excludePattern . '$/', $entry))) {
-							$filearray[$key]=($prependPath?$path.'/':'').$entry;
+							$filearray[$key] = ($prependPath ? $path . '/' : '') . $entry;
-								if ($order=='mtime') {$sortarray[$key]=filemtime($path.'/'.$entry);}
-								elseif ($order)	{$sortarray[$key]=$entry;}
+							if ($order == 'mtime') {
+								$sortarray[$key] = filemtime($path . '/' . $entry);
-						}
+							}
+							elseif ($order) {
+								$sortarray[$key] = $entry;
-					}
-				}
+							}
+						}
+					}
+				}
 				$d->close();
-			} else return 'error opening path: "'.$path.'"';
+			} else {
+				return 'error opening path: "' . $path . '"';
-		}
+			}
+		}
 
 			// Sort them:
 		if ($order) {
 			asort($sortarray);
-			$newArr=array();
+			$newArr = array();
 			foreach ($sortarray as $k => $v) {
-				$newArr[$k]=$filearray[$k];
+				$newArr[$k] = $filearray[$k];
 			}
-			$filearray=$newArr;
+			$filearray = $newArr;
 		}
 
 			// Return result
@@ -3311,15 +3389,17 @@
 	 * @param string		$excludePattern: regex pattern of files/directories to exclude
 	 * @return	array		An array with the found files/directories.
 	 */
-	public static function getAllFilesAndFoldersInPath(array $fileArr,$path,$extList='',$regDirs=0,$recursivityLevels=99,$excludePattern='')	{
+	public static function getAllFilesAndFoldersInPath(array $fileArr, $path, $extList = '', $regDirs = 0, $recursivityLevels = 99, $excludePattern = '') {
-		if ($regDirs)	$fileArr[] = $path;
+		if ($regDirs) {
+			$fileArr[] = $path;
+		}
-		$fileArr = array_merge($fileArr, self::getFilesInDir($path,$extList,1,1,$excludePattern));
+		$fileArr = array_merge($fileArr, self::getFilesInDir($path, $extList, 1, 1, $excludePattern));
 
 		$dirs = self::get_dirs($path);
-		if (is_array($dirs) && $recursivityLevels>0)	{
+		if (is_array($dirs) && $recursivityLevels > 0) {
-			foreach ($dirs as $subdirs)	{
+			foreach ($dirs as $subdirs) {
-				if ((string)$subdirs!='' && (!strlen($excludePattern) || !preg_match('/^'.$excludePattern.'$/',$subdirs)))	{
+				if ((string) $subdirs != '' && (!strlen($excludePattern) || !preg_match('/^' . $excludePattern . '$/', $subdirs))) {
-					$fileArr = self::getAllFilesAndFoldersInPath($fileArr,$path.$subdirs.'/',$extList,$regDirs,$recursivityLevels-1,$excludePattern);
+					$fileArr = self::getAllFilesAndFoldersInPath($fileArr, $path . $subdirs . '/', $extList, $regDirs, $recursivityLevels - 1, $excludePattern);
 				}
 			}
 		}
@@ -3334,7 +3414,7 @@
 	 * @param	string		$prefixToRemove: The prefix path to remove (if found as first part of string!)
 	 * @return	array		The input $fileArr processed.
 	 */
-	public static function removePrefixPathFromList(array $fileArr,$prefixToRemove)	{
+	public static function removePrefixPathFromList(array $fileArr, $prefixToRemove) {
 		foreach ($fileArr as $k => &$absFileRef) {
 			if (self::isFirstPartOfStr($absFileRef, $prefixToRemove)) {
 				$absFileRef = substr($absFileRef, strlen($prefixToRemove));
@@ -3352,8 +3432,8 @@
 	 * @param	string		File path to process
 	 * @return	string
 	 */
-	public static function fixWindowsFilePath($theFile)	{
+	public static function fixWindowsFilePath($theFile) {
-		return str_replace('//','/', str_replace('\\','/', $theFile));
+		return str_replace('//', '/', str_replace('\\', '/', $theFile));
 	}
 
 	/**
@@ -3364,22 +3444,24 @@
 	 * @param	string		File path in which "/../" is resolved
 	 * @return	string
 	 */
-	public static function resolveBackPath($pathStr)	{
+	public static function resolveBackPath($pathStr) {
-		$parts = explode('/',$pathStr);
+		$parts = explode('/', $pathStr);
-		$output=array();
+		$output = array();
 		$c = 0;
-		foreach($parts as $pV)	{
+		foreach ($parts as $pV) {
-			if ($pV=='..')	{
+			if ($pV == '..') {
-				if ($c)	{
+				if ($c) {
 					array_pop($output);
 					$c--;
-				} else $output[]=$pV;
-			} else {
+				} else {
+					$output[] = $pV;
+				}
+			} else {
 				$c++;
-				$output[]=$pV;
+				$output[] = $pV;
 			}
 		}
-		return implode('/',$output);
+		return implode('/', $output);
 	}
 
 	/**
@@ -3392,12 +3474,12 @@
 	 * @param	string		URL / path to prepend full URL addressing to.
 	 * @return	string
 	 */
-	public static function locationHeaderUrl($path)	{
+	public static function locationHeaderUrl($path) {
 		$uI = parse_url($path);
-		if (substr($path,0,1)=='/')	{ // relative to HOST
+		if (substr($path, 0, 1) == '/') { // relative to HOST
-			$path = self::getIndpEnv('TYPO3_REQUEST_HOST').$path;
+			$path = self::getIndpEnv('TYPO3_REQUEST_HOST') . $path;
-		} elseif (!$uI['scheme'])	{ // No scheme either
+		} elseif (!$uI['scheme']) { // No scheme either
-			$path = self::getIndpEnv('TYPO3_REQUEST_DIR').$path;
+			$path = self::getIndpEnv('TYPO3_REQUEST_DIR') . $path;
 		}
 		return $path;
 	}
@@ -3439,13 +3521,17 @@
 	public static function getBytesFromSizeMeasurement($measurement) {
 		if (stripos($measurement, 'G')) {
 			$bytes = doubleval($measurement) * 1024 * 1024 * 1024;
-		} else if (stripos($measurement, 'M')) {
+		} else {
+			if (stripos($measurement, 'M')) {
-			$bytes = doubleval($measurement) * 1024 * 1024;
+				$bytes = doubleval($measurement) * 1024 * 1024;
-		} else if (stripos($measurement, 'K')) {
+			} else {
+				if (stripos($measurement, 'K')) {
-			$bytes = doubleval($measurement) * 1024;
-		} else {
-			$bytes = doubleval($measurement);
-		}
+					$bytes = doubleval($measurement) * 1024;
+				} else {
+					$bytes = doubleval($measurement);
+				}
+			}
+		}
 		return $bytes;
 	}
 
@@ -3495,57 +3581,54 @@
 	 */
 	public static function createVersionNumberedFilename($file, $forceQueryString = FALSE) {
 		$lookupFile = explode('?', $file);
-		$path = self::resolveBackPath(self::dirname(PATH_thisScript) .'/'. $lookupFile[0]);
+		$path = self::resolveBackPath(self::dirname(PATH_thisScript) . '/' . $lookupFile[0]);
 
 		if (TYPO3_MODE == 'FE') {
 			$mode = strtolower($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['versionNumberInFilename']);
 			if ($mode === 'embed') {
 				$mode = TRUE;
-			} else if ($mode === 'querystring') {
+			} else {
+				if ($mode === 'querystring') {
-				$mode = FALSE;
-			} else {
-				$doNothing = TRUE;
-			}
+					$mode = FALSE;
+				} else {
+					$doNothing = TRUE;
+				}
+			}
 		} else {
 			$mode = $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['versionNumberInFilename'];
 		}
 
-		if (! file_exists($path) || $doNothing) {
+		if (!file_exists($path) || $doNothing) {
 				// File not found, return filename unaltered
 			$fullName = $file;
 
-		} else if (! $mode || $forceQueryString) {
+		} else {
+			if (!$mode || $forceQueryString) {
-				// If use of .htaccess rule is not configured,
-				// we use the default query-string method
-			if ($lookupFile[1]) {
-				$separator = '&';
-			} else {
-				$separator = '?';
-			}
-			$fullName = $file . $separator . filemtime($path);
+					// If use of .htaccess rule is not configured,
+					// we use the default query-string method
+				if ($lookupFile[1]) {
+					$separator = '&';
+				} else {
+					$separator = '?';
+				}
+				$fullName = $file . $separator . filemtime($path);
 
-		} else {
-				// Change the filename
-			$name = explode('.', $lookupFile[0]);
-			$extension = array_pop($name);
+			} else {
+					// Change the filename
+				$name = explode('.', $lookupFile[0]);
+				$extension = array_pop($name);
 
-			array_push($name, filemtime($path), $extension);
-			$fullName = implode('.', $name);
-				// append potential query string
-			$fullName .= $lookupFile[1] ? '?' . $lookupFile[1] : '';
-		}
+				array_push($name, filemtime($path), $extension);
+				$fullName = implode('.', $name);
+					// append potential query string
+				$fullName .= $lookupFile[1] ? '?' . $lookupFile[1] : '';
+			}
+		}
 
 		return $fullName;
 	}
 
 
-
-
-
-
-
-
-
 	/*************************
 	 *
 	 * DEBUG helper FUNCTIONS
@@ -3560,10 +3643,12 @@
 	 * @param	integer		Number of characters to show
 	 * @return	string		The string with ASCII values in separated by a space char.
 	 */
-	public static function debug_ordvalue($string,$characters=100)	{
+	public static function debug_ordvalue($string, $characters = 100) {
-		if(strlen($string) < $characters)	$characters = strlen($string);
+		if (strlen($string) < $characters) {
+			$characters = strlen($string);
+		}
-		for ($i=0; $i<$characters; $i++)	{
+		for ($i = 0; $i < $characters; $i++) {
-			$valuestring.=' '.ord(substr($string,$i,1));
+			$valuestring .= ' ' . ord(substr($string, $i, 1));
 		}
 		return trim($valuestring);
 	}
@@ -3577,19 +3662,19 @@
 	 * @param	mixed		Array to view
 	 * @return	string		HTML output
 	 */
-	public static function view_array($array_in)	{
+	public static function view_array($array_in) {
-		if (is_array($array_in))	{
+		if (is_array($array_in)) {
-			$result='
+			$result = '
 			<table border="1" cellpadding="1" cellspacing="0" bgcolor="white">';
-			if (count($array_in) == 0)	{
+			if (count($array_in) == 0) {
-				$result.= '<tr><td><font face="Verdana,Arial" size="1"><strong>EMPTY!</strong></font></td></tr>';
+				$result .= '<tr><td><font face="Verdana,Arial" size="1"><strong>EMPTY!</strong></font></td></tr>';
-			} else	{
+			} else {
-				foreach ($array_in as $key => $val)	{
+				foreach ($array_in as $key => $val) {
-					$result.= '<tr>
+					$result .= '<tr>
-						<td valign="top"><font face="Verdana,Arial" size="1">'.htmlspecialchars((string)$key).'</font></td>
+						<td valign="top"><font face="Verdana,Arial" size="1">' . htmlspecialchars((string) $key) . '</font></td>
 						<td>';
-					if (is_array($val))	{
+					if (is_array($val)) {
-						$result.=self::view_array($val);
+						$result .= self::view_array($val);
 					} elseif (is_object($val)) {
 						$string = '';
 						if (method_exists($val, '__toString')) {
@@ -3597,26 +3682,26 @@
 						} else {
 							$string .= print_r($val, TRUE);
 						}
-						$result .= '<font face="Verdana,Arial" size="1" color="red">'.nl2br(htmlspecialchars($string)).'<br /></font>';
+						$result .= '<font face="Verdana,Arial" size="1" color="red">' . nl2br(htmlspecialchars($string)) . '<br /></font>';
-					} else	{
+					} else {
-						if (gettype($val) == 'object')	{
+						if (gettype($val) == 'object') {
 							$string = 'Unknown object';
-						} else	{
+						} else {
-							$string = (string)$val;
+							$string = (string) $val;
 						}
-						$result.= '<font face="Verdana,Arial" size="1" color="red">'.nl2br(htmlspecialchars($string)).'<br /></font>';
+						$result .= '<font face="Verdana,Arial" size="1" color="red">' . nl2br(htmlspecialchars($string)) . '<br /></font>';
 					}
-					$result.= '</td>
+					$result .= '</td>
 					</tr>';
 				}
 			}
-			$result.= '</table>';
+			$result .= '</table>';
 		} else {
-			$result  = '<table border="1" cellpadding="1" cellspacing="0" bgcolor="white">
+			$result = '<table border="1" cellpadding="1" cellspacing="0" bgcolor="white">
 				<tr>
-					<td><font face="Verdana,Arial" size="1" color="red">'.nl2br(htmlspecialchars((string)$array_in)).'<br /></font></td>
+					<td><font face="Verdana,Arial" size="1" color="red">' . nl2br(htmlspecialchars((string) $array_in)) . '<br /></font></td>
 				</tr>
-			</table>';	// Output it as a string.
+			</table>'; // Output it as a string.
 		}
 		return $result;
 	}
@@ -3629,7 +3714,7 @@
 	 * @return	void
 	 * @see view_array()
 	 */
-	public static function print_array($array_in)	{
+	public static function print_array($array_in) {
 		echo self::view_array($array_in);
 	}
 
@@ -3645,9 +3730,9 @@
 	 * @param	string		Group for the debug console
 	 * @return	void
 	 */
-	public static function debug($var = '', $header = '', $group = 'Debug')	{
+	public static function debug($var = '', $header = '', $group = 'Debug') {
 			// buffer the output of debug if no buffering started before
-		if (ob_get_level()==0) {
+		if (ob_get_level() == 0) {
 			ob_start();
 		}
 		$debug = '';
@@ -3657,27 +3742,27 @@
 			<table class="typo3-debug" border="0" cellpadding="0" cellspacing="0" bgcolor="white" style="border:0px; margin-top:3px; margin-bottom:3px;">
 				<tr>
 					<td style="background-color:#bbbbbb; font-family: verdana,arial; font-weight: bold; font-size: 10px;">' .
-						htmlspecialchars((string) $header) .
+					htmlspecialchars((string) $header) .
 					'</td>
 				</tr>
 				<tr>
 					<td>';
 		}
 
-		if (is_array($var))	{
+		if (is_array($var)) {
 			$debug .= self::view_array($var);
 		} elseif (is_object($var)) {
-			$debug .=  '<strong>|Object:<pre>';
+			$debug .= '<strong>|Object:<pre>';
 			$debug .= print_r($var, TRUE);
-			$debug .=  '</pre>|</strong>';
+			$debug .= '</pre>|</strong>';
-		} elseif ((string) $var !== '')	{
+		} elseif ((string) $var !== '') {
-			$debug .= '<strong>|' . htmlspecialchars((string)$var) . '|</strong>';
+			$debug .= '<strong>|' . htmlspecialchars((string) $var) . '|</strong>';
 		} else {
 			$debug .= '<strong>| debug |</strong>';
 		}
 
 		if ($header) {
-			$debug .=  '
+			$debug .= '
 					</td>
 				</tr>
 			</table>';
@@ -3749,17 +3834,17 @@
 	 *
 	 * @return	string
 	 */
-	public static function debug_trail()	{
+	public static function debug_trail() {
 		$trail = debug_backtrace();
 		$trail = array_reverse($trail);
 		array_pop($trail);
 
 		$path = array();
-		foreach($trail as $dat)	{
+		foreach ($trail as $dat) {
-			$path[] = $dat['class'].$dat['type'].$dat['function'].'#'.$dat['line'];
+			$path[] = $dat['class'] . $dat['type'] . $dat['function'] . '#' . $dat['line'];
 		}
 
-		return implode(' // ',$path);
+		return implode(' // ', $path);
 	}
 
 	/**
@@ -3770,74 +3855,54 @@
 	 * @param	boolean		If TRUE, will return content instead of echo'ing out.
 	 * @return	void		Outputs to browser.
 	 */
-	public static function debugRows($rows,$header='',$returnHTML=FALSE)	{
+	public static function debugRows($rows, $header = '', $returnHTML = FALSE) {
-		if (is_array($rows))	{
+		if (is_array($rows)) {
 			reset($rows);
 			$firstEl = current($rows);
-			if (is_array($firstEl))	{
+			if (is_array($firstEl)) {
 				$headerColumns = array_keys($firstEl);
 				$tRows = array();
 
 					// Header:
-				$tRows[] = '<tr><td colspan="'.count($headerColumns).'" style="background-color:#bbbbbb; font-family: verdana,arial; font-weight: bold; font-size: 10px;"><strong>'.htmlspecialchars($header).'</strong></td></tr>';
+				$tRows[] = '<tr><td colspan="' . count($headerColumns) . '" style="background-color:#bbbbbb; font-family: verdana,arial; font-weight: bold; font-size: 10px;"><strong>' . htmlspecialchars($header) . '</strong></td></tr>';
 				$tCells = array();
-				foreach($headerColumns as $key)	{
+				foreach ($headerColumns as $key) {
 					$tCells[] = '
-							<td><font face="Verdana,Arial" size="1"><strong>'.htmlspecialchars($key).'</strong></font></td>';
+							<td><font face="Verdana,Arial" size="1"><strong>' . htmlspecialchars($key) . '</strong></font></td>';
 				}
 				$tRows[] = '
-						<tr>'.implode('',$tCells).'
+						<tr>' . implode('', $tCells) . '
 						</tr>';
 
 					// Rows:
-				foreach($rows as $singleRow)	{
+				foreach ($rows as $singleRow) {
 					$tCells = array();
-					foreach($headerColumns as $key)	{
+					foreach ($headerColumns as $key) {
 						$tCells[] = '
-							<td><font face="Verdana,Arial" size="1">'.(is_array($singleRow[$key]) ? self::debugRows($singleRow[$key],'',TRUE) : htmlspecialchars($singleRow[$key])).'</font></td>';
+							<td><font face="Verdana,Arial" size="1">' . (is_array($singleRow[$key]) ? self::debugRows($singleRow[$key], '', TRUE) : htmlspecialchars($singleRow[$key])) . '</font></td>';
 					}
 					$tRows[] = '
-						<tr>'.implode('',$tCells).'
+						<tr>' . implode('', $tCells) . '
 						</tr>';
 				}
 
 				$table = '
-					<table border="1" cellpadding="1" cellspacing="0" bgcolor="white">'.implode('',$tRows).'
+					<table border="1" cellpadding="1" cellspacing="0" bgcolor="white">' . implode('', $tRows) . '
 					</table>';
-				if ($returnHTML)	return $table; else echo $table;
-			} else debug('Empty array of rows',$header);
+				if ($returnHTML) {
+					return $table;
-		} else {
+				} else {
+					echo $table;
+				}
+			} else {
+				debug('Empty array of rows', $header);
+			}
+		} else {
-			debug('No array of rows',$header);
+			debug('No array of rows', $header);
 		}
 	}
 
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
 	/*************************
 	 *
 	 * SYSTEM INFORMATION
@@ -3850,10 +3915,10 @@
 	 *
 	 * @return	string
 	 */
-	public static function getThisUrl()	{
+	public static function getThisUrl() {
-		$p=parse_url(self::getIndpEnv('TYPO3_REQUEST_SCRIPT'));		// Url of this script
+		$p = parse_url(self::getIndpEnv('TYPO3_REQUEST_SCRIPT')); // Url of this script
-		$dir=self::dirname($p['path']).'/';	// Strip file
+		$dir = self::dirname($p['path']) . '/'; // Strip file
-		$url = str_replace('//','/',$p['host'].($p['port']?':'.$p['port']:'').$dir);
+		$url = str_replace('//', '/', $p['host'] . ($p['port'] ? ':' . $p['port'] : '') . $dir);
 		return $url;
 	}
 
@@ -3892,17 +3957,17 @@
 	 * @param	array		Array of key/value pairs for get parameters to add/overrule with. Can be multidimensional.
 	 * @return	string		Output URL with added getParams.
 	 */
-	public static function linkThisUrl($url,array $getParams=array())	{
+	public static function linkThisUrl($url, array $getParams = array()) {
 		$parts = parse_url($url);
 		$getP = array();
-		if ($parts['query'])	{
+		if ($parts['query']) {
-			parse_str($parts['query'],$getP);
+			parse_str($parts['query'], $getP);
 		}
-		$getP = self::array_merge_recursive_overrule($getP,$getParams);
+		$getP = self::array_merge_recursive_overrule($getP, $getParams);
-		$uP = explode('?',$url);
+		$uP = explode('?', $url);
 
-		$params = self::implodeArrayForUrl('',$getP);
+		$params = self::implodeArrayForUrl('', $getP);
-		$outurl = $uP[0].($params ? '?'.substr($params, 1) : '');
+		$outurl = $uP[0] . ($params ? '?' . substr($params, 1) : '');
 
 		return $outurl;
 	}
@@ -3915,7 +3980,7 @@
 	 * @param	string		Name of the "environment variable"/"server variable" you wish to use. Valid values are SCRIPT_NAME, SCRIPT_FILENAME, REQUEST_URI, PATH_INFO, REMOTE_ADDR, REMOTE_HOST, HTTP_REFERER, HTTP_HOST, HTTP_USER_AGENT, HTTP_ACCEPT_LANGUAGE, QUERY_STRING, TYPO3_DOCUMENT_ROOT, TYPO3_HOST_ONLY, TYPO3_HOST_ONLY, TYPO3_REQUEST_HOST, TYPO3_REQUEST_URL, TYPO3_REQUEST_SCRIPT, TYPO3_REQUEST_DIR, TYPO3_SITE_URL, _ARRAY
 	 * @return	string		Value based on the input key, independent of server/os environment.
 	 */
-	public static function getIndpEnv($getEnvName)	{
+	public static function getIndpEnv($getEnvName) {
 		/*
 			Conventions:
 			output from parse_url():
@@ -3979,65 +4044,65 @@
 
 		*/
 
-#		if ($getEnvName=='HTTP_REFERER')	return '';
+		#		if ($getEnvName=='HTTP_REFERER')	return '';
 
 		$retVal = '';
 
-		switch ((string)$getEnvName)	{
+		switch ((string) $getEnvName) {
 			case 'SCRIPT_NAME':
 				$retVal = (PHP_SAPI == 'fpm-fcgi' || PHP_SAPI == 'cgi' || PHP_SAPI == 'cgi-fcgi') &&
-					($_SERVER['ORIG_PATH_INFO'] ? $_SERVER['ORIG_PATH_INFO'] : $_SERVER['PATH_INFO']) ?
-					($_SERVER['ORIG_PATH_INFO'] ? $_SERVER['ORIG_PATH_INFO'] : $_SERVER['PATH_INFO']) :
-					($_SERVER['ORIG_SCRIPT_NAME'] ? $_SERVER['ORIG_SCRIPT_NAME'] : $_SERVER['SCRIPT_NAME']);
+						($_SERVER['ORIG_PATH_INFO'] ? $_SERVER['ORIG_PATH_INFO'] : $_SERVER['PATH_INFO']) ?
+						($_SERVER['ORIG_PATH_INFO'] ? $_SERVER['ORIG_PATH_INFO'] : $_SERVER['PATH_INFO']) :
+						($_SERVER['ORIG_SCRIPT_NAME'] ? $_SERVER['ORIG_SCRIPT_NAME'] : $_SERVER['SCRIPT_NAME']);
 					// add a prefix if TYPO3 is behind a proxy: ext-domain.com => int-server.com/prefix
 				if (self::cmpIP($_SERVER['REMOTE_ADDR'], $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyIP'])) {
 					if (self::getIndpEnv('TYPO3_SSL') && $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefixSSL']) {
-						$retVal = $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefixSSL'].$retVal;
+						$retVal = $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefixSSL'] . $retVal;
 					} elseif ($GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefix']) {
-						$retVal = $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefix'].$retVal;
+						$retVal = $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefix'] . $retVal;
 					}
 				}
-			break;
+				break;
 			case 'SCRIPT_FILENAME':
 				$retVal = str_replace('//', '/', str_replace('\\', '/',
 					(PHP_SAPI == 'fpm-fcgi' || PHP_SAPI == 'cgi' || PHP_SAPI == 'isapi' || PHP_SAPI == 'cgi-fcgi') &&
-					($_SERVER['ORIG_PATH_TRANSLATED'] ? $_SERVER['ORIG_PATH_TRANSLATED'] : $_SERVER['PATH_TRANSLATED']) ?
-					($_SERVER['ORIG_PATH_TRANSLATED'] ? $_SERVER['ORIG_PATH_TRANSLATED'] : $_SERVER['PATH_TRANSLATED']) :
-					($_SERVER['ORIG_SCRIPT_FILENAME'] ? $_SERVER['ORIG_SCRIPT_FILENAME'] : $_SERVER['SCRIPT_FILENAME'])));
+							($_SERVER['ORIG_PATH_TRANSLATED'] ? $_SERVER['ORIG_PATH_TRANSLATED'] : $_SERVER['PATH_TRANSLATED']) ?
+							($_SERVER['ORIG_PATH_TRANSLATED'] ? $_SERVER['ORIG_PATH_TRANSLATED'] : $_SERVER['PATH_TRANSLATED']) :
+							($_SERVER['ORIG_SCRIPT_FILENAME'] ? $_SERVER['ORIG_SCRIPT_FILENAME'] : $_SERVER['SCRIPT_FILENAME'])));
 
 				break;
 			case 'REQUEST_URI':
 					// Typical application of REQUEST_URI is return urls, forms submitting to itself etc. Example: returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))
-				if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['requestURIvar'])	{	// This is for URL rewriters that store the original URI in a server variable (eg ISAPI_Rewriter for IIS: HTTP_X_REWRITE_URL)
+				if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['requestURIvar']) { // This is for URL rewriters that store the original URI in a server variable (eg ISAPI_Rewriter for IIS: HTTP_X_REWRITE_URL)
-					list($v,$n) = explode('|',$GLOBALS['TYPO3_CONF_VARS']['SYS']['requestURIvar']);
+					list($v, $n) = explode('|', $GLOBALS['TYPO3_CONF_VARS']['SYS']['requestURIvar']);
 					$retVal = $GLOBALS[$v][$n];
-				} elseif (!$_SERVER['REQUEST_URI'])	{	// This is for ISS/CGI which does not have the REQUEST_URI available.
+				} elseif (!$_SERVER['REQUEST_URI']) { // This is for ISS/CGI which does not have the REQUEST_URI available.
-					$retVal = '/'.ltrim(self::getIndpEnv('SCRIPT_NAME'), '/').
+					$retVal = '/' . ltrim(self::getIndpEnv('SCRIPT_NAME'), '/') .
-						($_SERVER['QUERY_STRING']?'?'.$_SERVER['QUERY_STRING']:'');
+							($_SERVER['QUERY_STRING'] ? '?' . $_SERVER['QUERY_STRING'] : '');
 				} else {
 					$retVal = $_SERVER['REQUEST_URI'];
 				}
 					// add a prefix if TYPO3 is behind a proxy: ext-domain.com => int-server.com/prefix
 				if (self::cmpIP($_SERVER['REMOTE_ADDR'], $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyIP'])) {
 					if (self::getIndpEnv('TYPO3_SSL') && $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefixSSL']) {
-						$retVal = $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefixSSL'].$retVal;
+						$retVal = $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefixSSL'] . $retVal;
 					} elseif ($GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefix']) {
-						$retVal = $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefix'].$retVal;
+						$retVal = $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyPrefix'] . $retVal;
 					}
 				}
-			break;
+				break;
 			case 'PATH_INFO':
 					// $_SERVER['PATH_INFO']!=$_SERVER['SCRIPT_NAME'] is necessary because some servers (Windows/CGI) are seen to set PATH_INFO equal to script_name
 					// Further, there must be at least one '/' in the path - else the PATH_INFO value does not make sense.
 					// IF 'PATH_INFO' never works for our purpose in TYPO3 with CGI-servers, then 'PHP_SAPI=='cgi'' might be a better check. Right now strcmp($_SERVER['PATH_INFO'],t3lib_div::getIndpEnv('SCRIPT_NAME')) will always return false for CGI-versions, but that is only as long as SCRIPT_NAME is set equal to PATH_INFO because of PHP_SAPI=='cgi' (see above)
-//				if (strcmp($_SERVER['PATH_INFO'],self::getIndpEnv('SCRIPT_NAME')) && count(explode('/',$_SERVER['PATH_INFO']))>1)	{
+					//				if (strcmp($_SERVER['PATH_INFO'],self::getIndpEnv('SCRIPT_NAME')) && count(explode('/',$_SERVER['PATH_INFO']))>1)	{
 				if (PHP_SAPI != 'cgi' && PHP_SAPI != 'cgi-fcgi' && PHP_SAPI != 'fpm-fcgi') {
 					$retVal = $_SERVER['PATH_INFO'];
 				}
-			break;
+				break;
 			case 'TYPO3_REV_PROXY':
 				$retVal = self::cmpIP($_SERVER['REMOTE_ADDR'], $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyIP']);
-			break;
+				break;
 			case 'REMOTE_ADDR':
 				$retVal = $_SERVER['REMOTE_ADDR'];
 				if (self::cmpIP($_SERVER['REMOTE_ADDR'], $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyIP'])) {
@@ -4047,21 +4112,21 @@
 						switch ($GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyHeaderMultiValue']) {
 							case 'last':
 								$ip = array_pop($ip);
-							break;
+								break;
 							case 'first':
 								$ip = array_shift($ip);
-							break;
+								break;
 							case 'none':
 							default:
 								$ip = '';
-							break;
+								break;
 						}
 					}
 					if (self::validIP($ip)) {
 						$retVal = $ip;
 					}
 				}
-			break;
+				break;
 			case 'HTTP_HOST':
 				$retVal = $_SERVER['HTTP_HOST'];
 				if (self::cmpIP($_SERVER['REMOTE_ADDR'], $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyIP'])) {
@@ -4071,21 +4136,21 @@
 						switch ($GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyHeaderMultiValue']) {
 							case 'last':
 								$host = array_pop($host);
-							break;
+								break;
 							case 'first':
 								$host = array_shift($host);
-							break;
+								break;
 							case 'none':
 							default:
 								$host = '';
-							break;
+								break;
 						}
 					}
-					if ($host)	{
+					if ($host) {
 						$retVal = $host;
 					}
 				}
-			break;
+				break;
 				// These are let through without modification
 			case 'HTTP_REFERER':
 			case 'HTTP_USER_AGENT':
@@ -4094,76 +4159,82 @@
 			case 'REMOTE_HOST':
 			case 'QUERY_STRING':
 				$retVal = $_SERVER[$getEnvName];
-			break;
+				break;
 			case 'TYPO3_DOCUMENT_ROOT':
-				// Get the web root (it is not the root of the TYPO3 installation)
-				// The absolute path of the script can be calculated with TYPO3_DOCUMENT_ROOT + SCRIPT_FILENAME
-				// Some CGI-versions (LA13CGI) and mod-rewrite rules on MODULE versions will deliver a 'wrong' DOCUMENT_ROOT (according to our description). Further various aliases/mod_rewrite rules can disturb this as well.
-				// Therefore the DOCUMENT_ROOT is now always calculated as the SCRIPT_FILENAME minus the end part shared with SCRIPT_NAME.
+					// Get the web root (it is not the root of the TYPO3 installation)
+					// The absolute path of the script can be calculated with TYPO3_DOCUMENT_ROOT + SCRIPT_FILENAME
+					// Some CGI-versions (LA13CGI) and mod-rewrite rules on MODULE versions will deliver a 'wrong' DOCUMENT_ROOT (according to our description). Further various aliases/mod_rewrite rules can disturb this as well.
+					// Therefore the DOCUMENT_ROOT is now always calculated as the SCRIPT_FILENAME minus the end part shared with SCRIPT_NAME.
 				$SFN = self::getIndpEnv('SCRIPT_FILENAME');
-				$SN_A = explode('/',strrev(self::getIndpEnv('SCRIPT_NAME')));
+				$SN_A = explode('/', strrev(self::getIndpEnv('SCRIPT_NAME')));
-				$SFN_A = explode('/',strrev($SFN));
+				$SFN_A = explode('/', strrev($SFN));
 				$acc = array();
 				foreach ($SN_A as $kk => $vv) {
-					if (!strcmp($SFN_A[$kk],$vv))	{
+					if (!strcmp($SFN_A[$kk], $vv)) {
 						$acc[] = $vv;
-					} else break;
+					} else {
+						break;
-				}
+					}
+				}
-				$commonEnd=strrev(implode('/',$acc));
+				$commonEnd = strrev(implode('/', $acc));
-				if (strcmp($commonEnd,''))	{ $DR = substr($SFN,0,-(strlen($commonEnd)+1)); }
+				if (strcmp($commonEnd, '')) {
+					$DR = substr($SFN, 0, -(strlen($commonEnd) + 1));
+				}
 				$retVal = $DR;
-			break;
+				break;
 			case 'TYPO3_HOST_ONLY':
-				$p = explode(':',self::getIndpEnv('HTTP_HOST'));
+				$p = explode(':', self::getIndpEnv('HTTP_HOST'));
 				$retVal = $p[0];
-			break;
+				break;
 			case 'TYPO3_PORT':
-				$p = explode(':',self::getIndpEnv('HTTP_HOST'));
+				$p = explode(':', self::getIndpEnv('HTTP_HOST'));
 				$retVal = $p[1];
-			break;
+				break;
 			case 'TYPO3_REQUEST_HOST':
-				$retVal = (self::getIndpEnv('TYPO3_SSL') ? 'https://' : 'http://').
+				$retVal = (self::getIndpEnv('TYPO3_SSL') ? 'https://' : 'http://') .
-					self::getIndpEnv('HTTP_HOST');
-			break;
+						self::getIndpEnv('HTTP_HOST');
+				break;
 			case 'TYPO3_REQUEST_URL':
-				$retVal = self::getIndpEnv('TYPO3_REQUEST_HOST').self::getIndpEnv('REQUEST_URI');
+				$retVal = self::getIndpEnv('TYPO3_REQUEST_HOST') . self::getIndpEnv('REQUEST_URI');
-			break;
+				break;
 			case 'TYPO3_REQUEST_SCRIPT':
-				$retVal = self::getIndpEnv('TYPO3_REQUEST_HOST').self::getIndpEnv('SCRIPT_NAME');
+				$retVal = self::getIndpEnv('TYPO3_REQUEST_HOST') . self::getIndpEnv('SCRIPT_NAME');
-			break;
+				break;
 			case 'TYPO3_REQUEST_DIR':
-				$retVal = self::getIndpEnv('TYPO3_REQUEST_HOST').self::dirname(self::getIndpEnv('SCRIPT_NAME')).'/';
+				$retVal = self::getIndpEnv('TYPO3_REQUEST_HOST') . self::dirname(self::getIndpEnv('SCRIPT_NAME')) . '/';
-			break;
+				break;
 			case 'TYPO3_SITE_URL':
-				if (defined('PATH_thisScript') && defined('PATH_site'))	{
+				if (defined('PATH_thisScript') && defined('PATH_site')) {
-					$lPath = substr(dirname(PATH_thisScript),strlen(PATH_site)).'/';
+					$lPath = substr(dirname(PATH_thisScript), strlen(PATH_site)) . '/';
 					$url = self::getIndpEnv('TYPO3_REQUEST_DIR');
-					$siteUrl = substr($url,0,-strlen($lPath));
+					$siteUrl = substr($url, 0, -strlen($lPath));
-					if (substr($siteUrl,-1)!='/')	$siteUrl.='/';
+					if (substr($siteUrl, -1) != '/') {
+						$siteUrl .= '/';
+					}
 					$retVal = $siteUrl;
 				}
-			break;
+				break;
 			case 'TYPO3_SITE_PATH':
 				$retVal = substr(self::getIndpEnv('TYPO3_SITE_URL'), strlen(self::getIndpEnv('TYPO3_REQUEST_HOST')));
-			break;
+				break;
 			case 'TYPO3_SITE_SCRIPT':
-				$retVal = substr(self::getIndpEnv('TYPO3_REQUEST_URL'),strlen(self::getIndpEnv('TYPO3_SITE_URL')));
+				$retVal = substr(self::getIndpEnv('TYPO3_REQUEST_URL'), strlen(self::getIndpEnv('TYPO3_SITE_URL')));
-			break;
+				break;
 			case 'TYPO3_SSL':
 				$proxySSL = trim($GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxySSL']);
 				if ($proxySSL == '*') {
 					$proxySSL = $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyIP'];
 				}
-				if (self::cmpIP($_SERVER['REMOTE_ADDR'], $proxySSL))	{
+				if (self::cmpIP($_SERVER['REMOTE_ADDR'], $proxySSL)) {
-					$retVal = true;
+					$retVal = TRUE;
 				} else {
-					$retVal = $_SERVER['SSL_SESSION_ID'] || !strcasecmp($_SERVER['HTTPS'], 'on') || !strcmp($_SERVER['HTTPS'], '1') ? true : false;	// see http://bugs.typo3.org/view.php?id=3909
+					$retVal = $_SERVER['SSL_SESSION_ID'] || !strcasecmp($_SERVER['HTTPS'], 'on') || !strcmp($_SERVER['HTTPS'], '1') ? TRUE : FALSE; // see http://bugs.typo3.org/view.php?id=3909
 				}
-			break;
+				break;
 			case '_ARRAY':
 				$out = array();
 					// Here, list ALL possible keys to this function for debug display.
-				$envTestVars = self::trimExplode(',','
+				$envTestVars = self::trimExplode(',', '
 					HTTP_HOST,
 					TYPO3_HOST_ONLY,
 					TYPO3_PORT,
@@ -4185,13 +4256,13 @@
 					REMOTE_ADDR,
 					REMOTE_HOST,
 					HTTP_USER_AGENT,
-					HTTP_ACCEPT_LANGUAGE',1);
+					HTTP_ACCEPT_LANGUAGE', 1);
 				foreach ($envTestVars as $v) {
-					$out[$v]=self::getIndpEnv($v);
+					$out[$v] = self::getIndpEnv($v);
 				}
 				reset($out);
 				$retVal = $out;
-			break;
+				break;
 		}
 		return $retVal;
 	}
@@ -4202,7 +4273,7 @@
 	 * @return	integer		The unixtime as milliseconds
 	 */
 	public static function milliseconds() {
-		return round(microtime(true) * 1000);
+		return round(microtime(TRUE) * 1000);
 	}
 
 	/**
@@ -4212,55 +4283,63 @@
 	 * @param	string		Alternative User Agent string (if empty, t3lib_div::getIndpEnv('HTTP_USER_AGENT') is used)
 	 * @return	array		Parsed information about the HTTP_USER_AGENT in categories BROWSER, VERSION, SYSTEM and FORMSTYLE
 	 */
-	public static function clientInfo($useragent='')	{
+	public static function clientInfo($useragent = '') {
-		if (!$useragent) $useragent=self::getIndpEnv('HTTP_USER_AGENT');
+		if (!$useragent) {
+			$useragent = self::getIndpEnv('HTTP_USER_AGENT');
+		}
 
-		$bInfo=array();
+		$bInfo = array();
 			// Which browser?
-		if (strpos($useragent,'Konqueror') !== false)	{
+		if (strpos($useragent, 'Konqueror') !== FALSE) {
-			$bInfo['BROWSER']= 'konqu';
+			$bInfo['BROWSER'] = 'konqu';
-		} elseif (strpos($useragent,'Opera') !== false)	{
+		} elseif (strpos($useragent, 'Opera') !== FALSE) {
-			$bInfo['BROWSER']= 'opera';
+			$bInfo['BROWSER'] = 'opera';
-		} elseif (strpos($useragent, 'MSIE') !== false) {
+		} elseif (strpos($useragent, 'MSIE') !== FALSE) {
-			$bInfo['BROWSER']= 'msie';
+			$bInfo['BROWSER'] = 'msie';
-		} elseif (strpos($useragent, 'Mozilla') !== false) {
+		} elseif (strpos($useragent, 'Mozilla') !== FALSE) {
-			$bInfo['BROWSER']='net';
+			$bInfo['BROWSER'] = 'net';
-		} elseif (strpos($useragent, 'Flash') !== false) {
+		} elseif (strpos($useragent, 'Flash') !== FALSE) {
 			$bInfo['BROWSER'] = 'flash';
 		}
-		if ($bInfo['BROWSER'])	{
+		if ($bInfo['BROWSER']) {
 				// Browser version
-			switch($bInfo['BROWSER'])	{
+			switch ($bInfo['BROWSER']) {
 				case 'net':
-					$bInfo['VERSION']= doubleval(substr($useragent,8));
+					$bInfo['VERSION'] = doubleval(substr($useragent, 8));
-					if (strpos($useragent,'Netscape6/') !== false) { $bInfo['VERSION'] = doubleval(substr(strstr($useragent,'Netscape6/'),10)); }	// Will we ever know if this was a typo or intention...?! :-(
-					if (strpos($useragent,'Netscape/6') !== false) { $bInfo['VERSION'] = doubleval(substr(strstr($useragent,'Netscape/6'),10)); }
-					if (strpos($useragent,'Netscape/7') !== false) { $bInfo['VERSION'] = doubleval(substr(strstr($useragent,'Netscape/7'),9)); }
+					if (strpos($useragent, 'Netscape6/') !== FALSE) {
+						$bInfo['VERSION'] = doubleval(substr(strstr($useragent, 'Netscape6/'), 10));
+					} // Will we ever know if this was a typo or intention...?! :-(
+					if (strpos($useragent, 'Netscape/6') !== FALSE) {
+						$bInfo['VERSION'] = doubleval(substr(strstr($useragent, 'Netscape/6'), 10));
+					}
+					if (strpos($useragent, 'Netscape/7') !== FALSE) {
+						$bInfo['VERSION'] = doubleval(substr(strstr($useragent, 'Netscape/7'), 9));
+					}
-				break;
+					break;
 				case 'msie':
-					$tmp = strstr($useragent,'MSIE');
+					$tmp = strstr($useragent, 'MSIE');
-					$bInfo['VERSION'] = doubleval(preg_replace('/^[^0-9]*/','',substr($tmp,4)));
+					$bInfo['VERSION'] = doubleval(preg_replace('/^[^0-9]*/', '', substr($tmp, 4)));
-				break;
+					break;
 				case 'opera':
-					$tmp = strstr($useragent,'Opera');
+					$tmp = strstr($useragent, 'Opera');
-					$bInfo['VERSION'] = doubleval(preg_replace('/^[^0-9]*/','',substr($tmp,5)));
+					$bInfo['VERSION'] = doubleval(preg_replace('/^[^0-9]*/', '', substr($tmp, 5)));
-				break;
+					break;
 				case 'konqu':
-					$tmp = strstr($useragent,'Konqueror/');
+					$tmp = strstr($useragent, 'Konqueror/');
-					$bInfo['VERSION'] = doubleval(substr($tmp,10));
+					$bInfo['VERSION'] = doubleval(substr($tmp, 10));
-				break;
+					break;
 			}
-				// Client system
+			// Client system
-			if (strpos($useragent,'Win') !== false)	{
+			if (strpos($useragent, 'Win') !== FALSE) {
 				$bInfo['SYSTEM'] = 'win';
-			} elseif (strpos($useragent,'Mac') !== false)	{
+			} elseif (strpos($useragent, 'Mac') !== FALSE) {
 				$bInfo['SYSTEM'] = 'mac';
-			} elseif (strpos($useragent,'Linux') !== false || strpos($useragent,'X11') !== false || strpos($useragent,'SGI') !== false || strpos($useragent,' SunOS ') !== false || strpos($useragent,' HP-UX ') !== false)	{
+			} elseif (strpos($useragent, 'Linux') !== FALSE || strpos($useragent, 'X11') !== FALSE || strpos($useragent, 'SGI') !== FALSE || strpos($useragent, ' SunOS ') !== FALSE || strpos($useragent, ' HP-UX ') !== FALSE) {
 				$bInfo['SYSTEM'] = 'unix';
 			}
 		}
-			// Is true if the browser supports css to format forms, especially the width
+		// Is true if the browser supports css to format forms, especially the width
-		$bInfo['FORMSTYLE']=($bInfo['BROWSER']=='msie' || ($bInfo['BROWSER']=='net' && $bInfo['VERSION']>=5) || $bInfo['BROWSER']=='opera' || $bInfo['BROWSER']=='konqu');
+		$bInfo['FORMSTYLE'] = ($bInfo['BROWSER'] == 'msie' || ($bInfo['BROWSER'] == 'net' && $bInfo['VERSION'] >= 5) || $bInfo['BROWSER'] == 'opera' || $bInfo['BROWSER'] == 'konqu');
 
 		return $bInfo;
 	}
@@ -4272,54 +4351,40 @@
 	 * @param	boolean		Use request host (when not in CLI mode).
 	 * @return	string		The fully-qualified host name.
 	 */
-	public static function getHostname($requestHost=TRUE)	{
+	public static function getHostname($requestHost = TRUE) {
 		$host = '';
 			// If not called from the command-line, resolve on getIndpEnv()
 			// Note that TYPO3_REQUESTTYPE is not used here as it may not yet be defined
-		if ($requestHost && (!defined('TYPO3_cliMode') || !TYPO3_cliMode))	{
+		if ($requestHost && (!defined('TYPO3_cliMode') || !TYPO3_cliMode)) {
 			$host = self::getIndpEnv('HTTP_HOST');
 		}
-		if (!$host)	{
+		if (!$host) {
 				// will fail for PHP 4.1 and 4.2
 			$host = @php_uname('n');
 				// 'n' is ignored in broken installations
-			if (strpos($host, ' '))	$host = '';
+			if (strpos($host, ' ')) {
+				$host = '';
-		}
+			}
+		}
 			// we have not found a FQDN yet
-		if ($host && strpos($host, '.') === false) {
+		if ($host && strpos($host, '.') === FALSE) {
 			$ip = gethostbyname($host);
 				// we got an IP address
-			if ($ip != $host)	{
+			if ($ip != $host) {
 				$fqdn = gethostbyaddr($ip);
-				if ($ip != $fqdn)	$host = $fqdn;
+				if ($ip != $fqdn) {
+					$host = $fqdn;
-			}
-		}
+				}
+			}
-		if (!$host)	$host = 'localhost.localdomain';
+		}
+		if (!$host) {
+			$host = 'localhost.localdomain';
+		}
 
 		return $host;
 	}
 
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
 	/*************************
 	 *
 	 * TYPO3 SPECIFIC FUNCTIONS
@@ -4335,27 +4400,31 @@
 	 * @param	boolean		If $relToTYPO3_mainDir is set, then relative paths are relative to PATH_typo3 constant - otherwise (default) they are relative to PATH_site
 	 * @return	string		Returns the absolute filename of $filename IF valid, otherwise blank string.
 	 */
-	public static function getFileAbsFileName($filename,$onlyRelative=TRUE,$relToTYPO3_mainDir=FALSE)	{
+	public static function getFileAbsFileName($filename, $onlyRelative = TRUE, $relToTYPO3_mainDir = FALSE) {
-		if (!strcmp($filename,''))		return '';
+		if (!strcmp($filename, '')) {
+			return '';
+		}
 
-		if ($relToTYPO3_mainDir)	{
+		if ($relToTYPO3_mainDir) {
-			if (!defined('PATH_typo3'))	return '';
+			if (!defined('PATH_typo3')) {
+				return '';
+			}
 			$relPathPrefix = PATH_typo3;
 		} else {
 			$relPathPrefix = PATH_site;
 		}
-		if (substr($filename,0,4)=='EXT:')	{	// extension
+		if (substr($filename, 0, 4) == 'EXT:') { // extension
-			list($extKey,$local) = explode('/',substr($filename,4),2);
+			list($extKey, $local) = explode('/', substr($filename, 4), 2);
-			$filename='';
+			$filename = '';
-			if (strcmp($extKey,'') && t3lib_extMgm::isLoaded($extKey) && strcmp($local,''))	{
+			if (strcmp($extKey, '') && t3lib_extMgm::isLoaded($extKey) && strcmp($local, '')) {
-				$filename = t3lib_extMgm::extPath($extKey).$local;
+				$filename = t3lib_extMgm::extPath($extKey) . $local;
 			}
-		} elseif (!self::isAbsPath($filename))	{	// relative. Prepended with $relPathPrefix
+		} elseif (!self::isAbsPath($filename)) { // relative. Prepended with $relPathPrefix
-			$filename=$relPathPrefix.$filename;
+			$filename = $relPathPrefix . $filename;
-		} elseif ($onlyRelative && !self::isFirstPartOfStr($filename,$relPathPrefix)) {	// absolute, but set to blank if not allowed
+		} elseif ($onlyRelative && !self::isFirstPartOfStr($filename, $relPathPrefix)) { // absolute, but set to blank if not allowed
-			$filename='';
+			$filename = '';
 		}
-		if (strcmp($filename,'') && self::validPathStr($filename))	{	// checks backpath.
+		if (strcmp($filename, '') && self::validPathStr($filename)) { // checks backpath.
 			return $filename;
 		}
 	}
@@ -4371,9 +4440,9 @@
 	 * @return	boolean		True, if no '//', '\', '/../' is in the $theFile and $theFile doesn't begin with '../'
 	 * @todo	Possible improvement: Should it rawurldecode the string first to check if any of these characters is encoded ?
 	 */
-	public static function validPathStr($theFile)	{
+	public static function validPathStr($theFile) {
-		if (strpos($theFile, '//')===false && strpos($theFile, '\\')===false && !preg_match('#(?:^\.\.|/\.\./)#', $theFile)) {
-			return true;
+		if (strpos($theFile, '//') === FALSE && strpos($theFile, '\\') === FALSE && !preg_match('#(?:^\.\.|/\.\./)#', $theFile)) {
+			return TRUE;
 		}
 	}
 
@@ -4384,8 +4453,8 @@
 	 * @param	string		Filepath to evaluate
 	 * @return	boolean
 	 */
-	public static function isAbsPath($path)	{
+	public static function isAbsPath($path) {
-		return TYPO3_OS=='WIN' ? substr($path,1,2)==':/' :  substr($path,0,1)=='/';
+		return TYPO3_OS == 'WIN' ? substr($path, 1, 2) == ':/' : substr($path, 0, 1) == '/';
 	}
 
 	/**
@@ -4395,15 +4464,17 @@
 	 * @param	string		Filepath to evaluate
 	 * @return	boolean
 	 */
-	public static function isAllowedAbsPath($path)	{
+	public static function isAllowedAbsPath($path) {
 		if (self::isAbsPath($path) &&
-			self::validPathStr($path) &&
+				self::validPathStr($path) &&
-				(	self::isFirstPartOfStr($path,PATH_site)
+				(self::isFirstPartOfStr($path, PATH_site)
-					||
+						||
-					($GLOBALS['TYPO3_CONF_VARS']['BE']['lockRootPath'] && self::isFirstPartOfStr($path,$GLOBALS['TYPO3_CONF_VARS']['BE']['lockRootPath']))
+						($GLOBALS['TYPO3_CONF_VARS']['BE']['lockRootPath'] && self::isFirstPartOfStr($path, $GLOBALS['TYPO3_CONF_VARS']['BE']['lockRootPath']))
 				)
-			)	return true;
+		) {
+			return TRUE;
-	}
+		}
+	}
 
 	/**
 	 * Verifies the input filename againts the 'fileDenyPattern'. Returns true if OK.
@@ -4412,12 +4483,14 @@
 	 * @param	string		Filepath to evaluate
 	 * @return	boolean
 	 */
-	public static function verifyFilenameAgainstDenyPattern($filename)	{
+	public static function verifyFilenameAgainstDenyPattern($filename) {
-		if (strcmp($filename,'') && strcmp($GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern'],''))	{
+		if (strcmp($filename, '') && strcmp($GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern'], '')) {
-			$result = preg_match('/'.$GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern'].'/i',$filename);
+			$result = preg_match('/' . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern'] . '/i', $filename);
-			if ($result)	return false;	// so if a matching filename is found, return false;
+			if ($result) {
+				return FALSE;
+			} // so if a matching filename is found, return FALSE;
 		}
-		return true;
+		return TRUE;
 	}
 
 	/**
@@ -4427,7 +4500,7 @@
 	 * @param string $url potential URL to check
 	 *
 	 * @return string either $url if $url is considered to be harmless, or an
-	 *                empty string otherwise
+	 *				empty string otherwise
 	 */
 	public static function sanitizeLocalUrl($url = '') {
 		$sanitizedUrl = '';
@@ -4473,17 +4546,17 @@
 	 * @coauthor	Dennis Petersen <fessor@software.dk>
 	 * @see upload_to_tempfile()
 	 */
-	public static function upload_copy_move($source,$destination)	{
+	public static function upload_copy_move($source, $destination) {
-		if (is_uploaded_file($source))	{
+		if (is_uploaded_file($source)) {
 			$uploaded = TRUE;
-			// Return the value of move_uploaded_file, and if false the temporary $source is still around so the user can use unlink to delete it:
+				// Return the value of move_uploaded_file, and if false the temporary $source is still around so the user can use unlink to delete it:
 			$uploadedResult = move_uploaded_file($source, $destination);
 		} else {
 			$uploaded = FALSE;
-			@copy($source,$destination);
+			@copy($source, $destination);
 		}
 
-		self::fixPermissions($destination);	// Change the permissions of the file
+		self::fixPermissions($destination); // Change the permissions of the file
 
 			// If here the file is copied and the temporary $source is still around, so when returning false the user can try unlink to delete the $source
 		return $uploaded ? $uploadedResult : FALSE;
@@ -4499,8 +4572,8 @@
 	 * @return	string		If a new file was successfully created, return its filename, otherwise blank string.
 	 * @see unlink_tempfile(), upload_copy_move()
 	 */
-	public static function upload_to_tempfile($uploadedFileName)	{
+	public static function upload_to_tempfile($uploadedFileName) {
-		if (is_uploaded_file($uploadedFileName))	{
+		if (is_uploaded_file($uploadedFileName)) {
 			$tempFile = self::tempnam('upload_temp_');
 			move_uploaded_file($uploadedFileName, $tempFile);
 			return @is_file($tempFile) ? $tempFile : '';
@@ -4517,11 +4590,13 @@
 	 * @return	boolean		Returns true if the file was unlink()'ed
 	 * @see upload_to_tempfile(), tempnam()
 	 */
-	public static function unlink_tempfile($uploadedTempFileName)	{
+	public static function unlink_tempfile($uploadedTempFileName) {
-		if ($uploadedTempFileName && self::validPathStr($uploadedTempFileName) && self::isFirstPartOfStr($uploadedTempFileName,PATH_site.'typo3temp/') && @is_file($uploadedTempFileName))	{
+		if ($uploadedTempFileName && self::validPathStr($uploadedTempFileName) && self::isFirstPartOfStr($uploadedTempFileName, PATH_site . 'typo3temp/') && @is_file($uploadedTempFileName)) {
-			if (unlink($uploadedTempFileName))	return TRUE;
+			if (unlink($uploadedTempFileName)) {
+				return TRUE;
-		}
-	}
+			}
+		}
+	}
 
 	/**
 	 * Create temporary filename (Create file with unique file name)
@@ -4533,8 +4608,8 @@
 	 * @return	string		result from PHP function tempnam() with PATH_site.'typo3temp/' set for temp path.
 	 * @see unlink_tempfile(), upload_to_tempfile()
 	 */
-	public static function tempnam($filePrefix)	{
+	public static function tempnam($filePrefix) {
-		return tempnam(PATH_site.'typo3temp/',$filePrefix);
+		return tempnam(PATH_site . 'typo3temp/', $filePrefix);
 	}
 
 	/**
@@ -4546,25 +4621,25 @@
 	 * @param	integer		Length of returned authentication code.
 	 * @return	string		MD5 hash of 8 chars.
 	 */
-	public static function stdAuthCode($uid_or_record,$fields='',$codeLength=8)	{
+	public static function stdAuthCode($uid_or_record, $fields = '', $codeLength = 8) {
 
-		if (is_array($uid_or_record))	{
+		if (is_array($uid_or_record)) {
-			$recCopy_temp=array();
+			$recCopy_temp = array();
-			if ($fields)	{
+			if ($fields) {
-				$fieldArr = self::trimExplode(',',$fields,1);
+				$fieldArr = self::trimExplode(',', $fields, 1);
 				foreach ($fieldArr as $k => $v) {
-					$recCopy_temp[$k]=$uid_or_record[$v];
+					$recCopy_temp[$k] = $uid_or_record[$v];
 				}
 			} else {
-				$recCopy_temp=$uid_or_record;
+				$recCopy_temp = $uid_or_record;
 			}
-			$preKey = implode('|',$recCopy_temp);
+			$preKey = implode('|', $recCopy_temp);
 		} else {
 			$preKey = $uid_or_record;
 		}
 
-		$authCode = $preKey.'||'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'];
+		$authCode = $preKey . '||' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'];
-		$authCode = substr(md5($authCode),0,$codeLength);
+		$authCode = substr(md5($authCode), 0, $codeLength);
 		return $authCode;
 	}
 
@@ -4577,18 +4652,18 @@
 	 * @see tslib_fe::makeCacheHash(), tslib_cObj::typoLink(), t3lib_div::calculateCHash()
 	 */
 	public static function cHashParams($addQueryParams) {
-		$params = explode('&',substr($addQueryParams,1));	// Splitting parameters up
+		$params = explode('&', substr($addQueryParams, 1)); // Splitting parameters up
 
 			// Make array:
 		$pA = array();
-		foreach($params as $theP)	{
+		foreach ($params as $theP) {
-			$pKV = explode('=', $theP);	// Splitting single param by '=' sign
+			$pKV = explode('=', $theP); // Splitting single param by '=' sign
-			if (!self::inList('id,type,no_cache,cHash,MP,ftu',$pKV[0]) && !preg_match('/TSFE_ADMIN_PANEL\[.*?\]/',$pKV[0]))	{
+			if (!self::inList('id,type,no_cache,cHash,MP,ftu', $pKV[0]) && !preg_match('/TSFE_ADMIN_PANEL\[.*?\]/', $pKV[0])) {
-				$pA[rawurldecode($pKV[0])] = (string)rawurldecode($pKV[1]);
+				$pA[rawurldecode($pKV[0])] = (string) rawurldecode($pKV[1]);
 			}
 		}
 			// Hook: Allows to manipulate the parameters which are taken to build the chash:
-		if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['cHashParamsHook']))	{
+		if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['cHashParamsHook'])) {
 			$cHashParamsHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['cHashParamsHook'];
 			if (is_array($cHashParamsHook)) {
 				$hookParameters = array(
@@ -4596,8 +4671,8 @@
 					'params' => &$params,
 					'pA' => &$pA,
 				);
-				$hookReference = null;
+				$hookReference = NULL;
-				foreach ($cHashParamsHook as $hookFunction)	{
+				foreach ($cHashParamsHook as $hookFunction) {
 					self::callUserFunction($hookFunction, $hookParameters, $hookReference);
 				}
 			}
@@ -4639,11 +4714,11 @@
 	 * @param	integer		Value from "l18n_cfg" field of a page record
 	 * @return	boolean		True if the page should be hidden
 	 */
-	public static function hideIfNotTranslated($l18n_cfg_fieldValue)	{
+	public static function hideIfNotTranslated($l18n_cfg_fieldValue) {
-		if ($GLOBALS['TYPO3_CONF_VARS']['FE']['hidePagesIfNotTranslatedByDefault'])	{
+		if ($GLOBALS['TYPO3_CONF_VARS']['FE']['hidePagesIfNotTranslatedByDefault']) {
-			return $l18n_cfg_fieldValue&2 ? FALSE : TRUE;
+			return $l18n_cfg_fieldValue & 2 ? FALSE : TRUE;
 		} else {
-			return $l18n_cfg_fieldValue&2 ? TRUE : FALSE;
+			return $l18n_cfg_fieldValue & 2 ? TRUE : FALSE;
 		}
 	}
 
@@ -4655,30 +4730,31 @@
 	 * @param	string		Character set (option); if not set, determined by the language key
 	 * @param	integer		Error mode (when file could not be found): 0 - syslog entry, 1 - do nothing, 2 - throw an exception
 	 * @return	array		Value of $LOCAL_LANG found in the included file. If that array is found it  will returned.
-	 * 						Otherwise an empty array and it is FALSE in error case.
+	 *						 Otherwise an empty array and it is FALSE in error case.
 	 */
-	public static function readLLfile($fileRef, $langKey, $charset = '', $errorMode = 0)	{
+	public static function readLLfile($fileRef, $langKey, $charset = '', $errorMode = 0) {
 
 		$result = FALSE;
 		$file = self::getFileAbsFileName($fileRef);
-		if ($file)	{
+		if ($file) {
 			$baseFile = preg_replace('/\.(php|xml)$/', '', $file);
 
-			if (@is_file($baseFile.'.xml')) {
+			if (@is_file($baseFile . '.xml')) {
-				$LOCAL_LANG = self::readLLXMLfile($baseFile.'.xml', $langKey, $charset);
+				$LOCAL_LANG = self::readLLXMLfile($baseFile . '.xml', $langKey, $charset);
-			} elseif (@is_file($baseFile.'.php'))   {
+			} elseif (@is_file($baseFile . '.php')) {
-				if ($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] || $charset)  {
+				if ($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] || $charset) {
-					$LOCAL_LANG = self::readLLPHPfile($baseFile.'.php', $langKey, $charset);
+					$LOCAL_LANG = self::readLLPHPfile($baseFile . '.php', $langKey, $charset);
 				} else {
-					include($baseFile.'.php');
+					include($baseFile . '.php');
-					if (is_array($LOCAL_LANG))      {
+					if (is_array($LOCAL_LANG)) {
-						$LOCAL_LANG = array('default'=>$LOCAL_LANG['default'], $langKey=>$LOCAL_LANG[$langKey]); }
+						$LOCAL_LANG = array('default' => $LOCAL_LANG['default'], $langKey => $LOCAL_LANG[$langKey]);
-				}
+					}
+				}
 			} else {
-				$errorMsg = 'File "' . $fileRef. '" not found!';
+				$errorMsg = 'File "' . $fileRef . '" not found!';
 				if ($errorMode == 2) {
 					throw new t3lib_exception($errorMsg);
-				} elseif(!$errorMode) {
+				} elseif (!$errorMode) {
 					self::sysLog($errorMsg, 'Core', self::SYSLOG_SEVERITY_ERROR);
 				}
 				$fileNotFound = TRUE;
@@ -4705,7 +4781,7 @@
 				}
 			}
 		}
-		if ($fileNotFound !== TRUE)	{
+		if ($fileNotFound !== TRUE) {
 			$result = is_array($LOCAL_LANG) ? $LOCAL_LANG : array();
 		}
 		return $result;
@@ -4720,23 +4796,23 @@
 	 * @param	string		Character set (optional)
 	 * @return	array		LOCAL_LANG array in return.
 	 */
-	public static function readLLPHPfile($fileRef, $langKey, $charset='')	{
+	public static function readLLPHPfile($fileRef, $langKey, $charset = '') {
 
-		if (is_object($GLOBALS['LANG']))	{
+		if (is_object($GLOBALS['LANG'])) {
 			$csConvObj = $GLOBALS['LANG']->csConvObj;
-		} elseif (is_object($GLOBALS['TSFE']))	{
+		} elseif (is_object($GLOBALS['TSFE'])) {
 			$csConvObj = $GLOBALS['TSFE']->csConvObj;
 		} else {
 			$csConvObj = self::makeInstance('t3lib_cs');
 		}
 
-		if (@is_file($fileRef) && $langKey)	{
+		if (@is_file($fileRef) && $langKey) {
 
 				// Set charsets:
 			$sourceCharset = $csConvObj->parse_charset($csConvObj->charSetArray[$langKey] ? $csConvObj->charSetArray[$langKey] : 'iso-8859-1');
-			if ($charset)	{
+			if ($charset) {
 				$targetCharset = $csConvObj->parse_charset($charset);
-			} elseif ($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'])  {
+			} elseif ($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset']) {
 					// when forceCharset is set, we store ALL labels in this charset!!!
 				$targetCharset = $csConvObj->parse_charset($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset']);
 			} else {
@@ -4744,16 +4820,16 @@
 			}
 
 				// Cache file name:
-			$hashSource = substr($fileRef,strlen(PATH_site)).'|'.date('d-m-Y H:i:s',filemtime($fileRef)).'|version=2.3';
+			$hashSource = substr($fileRef, strlen(PATH_site)) . '|' . date('d-m-Y H:i:s', filemtime($fileRef)) . '|version=2.3';
-			$cacheFileName = PATH_site.'typo3temp/llxml/'.
+			$cacheFileName = PATH_site . 'typo3temp/llxml/' .
-							substr(basename($fileRef),10,15).
+					substr(basename($fileRef), 10, 15) .
-							'_'.self::shortMD5($hashSource).'.'.$langKey.'.'.$targetCharset.'.cache';
+					'_' . self::shortMD5($hashSource) . '.' . $langKey . '.' . $targetCharset . '.cache';
 				// Check if cache file exists...
-			if (!@is_file($cacheFileName))	{	// ... if it doesn't, create content and write it:
+			if (!@is_file($cacheFileName)) { // ... if it doesn't, create content and write it:
-
+				$LOCAL_LANG = NULL;
 					// Get PHP data
 				include($fileRef);
-				if (!is_array($LOCAL_LANG))	{
+				if (!is_array($LOCAL_LANG)) {
 					$fileName = substr($fileRef, strlen(PATH_site));
 					throw new RuntimeException(
 						'TYPO3 Fatal Error: "' . $fileName . '" is no TYPO3 language file!',
@@ -4764,19 +4840,19 @@
 					// converting the default language (English)
 					// this needs to be done for a few accented loan words and extension names
 				if (is_array($LOCAL_LANG['default']) && $targetCharset != 'iso-8859-1') {
-					foreach ($LOCAL_LANG['default'] as &$labelValue)	{
+					foreach ($LOCAL_LANG['default'] as &$labelValue) {
 						$labelValue = $csConvObj->conv($labelValue, 'iso-8859-1', $targetCharset);
 					}
 				}
 
-				if ($langKey!='default' && is_array($LOCAL_LANG[$langKey]) && $sourceCharset!=$targetCharset)	{
+				if ($langKey != 'default' && is_array($LOCAL_LANG[$langKey]) && $sourceCharset != $targetCharset) {
-					foreach ($LOCAL_LANG[$langKey] as &$labelValue)	{
+					foreach ($LOCAL_LANG[$langKey] as &$labelValue) {
 						$labelValue = $csConvObj->conv($labelValue, $sourceCharset, $targetCharset);
 					}
 				}
 
 					// Cache the content now:
-				$serContent = array('origFile'=>$hashSource, 'LOCAL_LANG'=>array('default'=>$LOCAL_LANG['default'], $langKey=>$LOCAL_LANG[$langKey]));
+				$serContent = array('origFile' => $hashSource, 'LOCAL_LANG' => array('default' => $LOCAL_LANG['default'], $langKey => $LOCAL_LANG[$langKey]));
 				$res = self::writeFileToTypo3tempDir($cacheFileName, serialize($serContent));
 				if ($res) {
 					throw new RuntimeException(
@@ -4803,23 +4879,23 @@
 	 * @param	string		Character set (optional)
 	 * @return	array		LOCAL_LANG array in return.
 	 */
-	public static function readLLXMLfile($fileRef, $langKey, $charset='')	{
+	public static function readLLXMLfile($fileRef, $langKey, $charset = '') {
 
-		if (is_object($GLOBALS['LANG']))	{
+		if (is_object($GLOBALS['LANG'])) {
 			$csConvObj = $GLOBALS['LANG']->csConvObj;
-		} elseif (is_object($GLOBALS['TSFE']))	{
+		} elseif (is_object($GLOBALS['TSFE'])) {
 			$csConvObj = $GLOBALS['TSFE']->csConvObj;
 		} else {
 			$csConvObj = self::makeInstance('t3lib_cs');
 		}
 
 		$LOCAL_LANG = NULL;
-		if (@is_file($fileRef) && $langKey)	{
+		if (@is_file($fileRef) && $langKey) {
 
 				// Set charset:
-			if ($charset)	{
+			if ($charset) {
 				$targetCharset = $csConvObj->parse_charset($charset);
-			} elseif ($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'])  {
+			} elseif ($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset']) {
 					// when forceCharset is set, we store ALL labels in this charset!!!
 				$targetCharset = $csConvObj->parse_charset($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset']);
 			} else {
@@ -4827,13 +4903,13 @@
 			}
 
 				// Cache file name:
-			$hashSource = substr($fileRef,strlen(PATH_site)).'|'.date('d-m-Y H:i:s',filemtime($fileRef)).'|version=2.3';
+			$hashSource = substr($fileRef, strlen(PATH_site)) . '|' . date('d-m-Y H:i:s', filemtime($fileRef)) . '|version=2.3';
-			$cacheFileName = PATH_site.'typo3temp/llxml/'.
+			$cacheFileName = PATH_site . 'typo3temp/llxml/' .
-						substr(basename($fileRef),10,15).
+					substr(basename($fileRef), 10, 15) .
-						'_'.self::shortMD5($hashSource).'.'.$langKey.'.'.$targetCharset.'.cache';
+					'_' . self::shortMD5($hashSource) . '.' . $langKey . '.' . $targetCharset . '.cache';
 
 				// Check if cache file exists...
-			if (!@is_file($cacheFileName))	{	// ... if it doesn't, create content and write it:
+			if (!@is_file($cacheFileName)) { // ... if it doesn't, create content and write it:
 
 					// Read XML, parse it.
 				$xmlString = self::getUrl($fileRef);
@@ -4854,7 +4930,7 @@
 					// this needs to be done for a few accented loan words and extension names
 					// NOTE: no conversion is done when in UTF-8 mode!
 				if (is_array($LOCAL_LANG['default']) && $targetCharset != 'utf-8') {
-					foreach ($LOCAL_LANG['default'] as &$labelValue)	{
+					foreach ($LOCAL_LANG['default'] as &$labelValue) {
 						$labelValue = $csConvObj->utf8_decode($labelValue, $targetCharset);
 					}
 					unset($labelValue);
@@ -4862,25 +4938,25 @@
 
 					// converting other languages to their "native" charsets
 					// NOTE: no conversion is done when in UTF-8 mode!
-				if ($langKey!='default')	{
+				if ($langKey != 'default') {
 
 						// If no entry is found for the language key, then force a value depending on meta-data setting. By default an automated filename will be used:
 					$LOCAL_LANG[$langKey] = self::llXmlAutoFileName($fileRef, $langKey);
 					$localized_file = self::getFileAbsFileName($LOCAL_LANG[$langKey]);
-					if (!@is_file($localized_file) && isset($xmlContent['data'][$langKey]))	{
+					if (!@is_file($localized_file) && isset($xmlContent['data'][$langKey])) {
 						$LOCAL_LANG[$langKey] = $xmlContent['data'][$langKey];
 					}
 
 						// Checking if charset should be converted.
-					if (is_array($LOCAL_LANG[$langKey]) && $targetCharset!='utf-8')	{
+					if (is_array($LOCAL_LANG[$langKey]) && $targetCharset != 'utf-8') {
-						foreach($LOCAL_LANG[$langKey] as $labelKey => $labelValue)	{
+						foreach ($LOCAL_LANG[$langKey] as $labelKey => $labelValue) {
-							$LOCAL_LANG[$langKey][$labelKey] = $csConvObj->utf8_decode($labelValue,$targetCharset);
+							$LOCAL_LANG[$langKey][$labelKey] = $csConvObj->utf8_decode($labelValue, $targetCharset);
 						}
 					}
 				}
 
 					// Cache the content now:
-				$serContent = array('origFile'=>$hashSource, 'LOCAL_LANG'=>array('default'=>$LOCAL_LANG['default'], $langKey=>$LOCAL_LANG[$langKey]));
+				$serContent = array('origFile' => $hashSource, 'LOCAL_LANG' => array('default' => $LOCAL_LANG['default'], $langKey => $LOCAL_LANG[$langKey]));
 				$res = self::writeFileToTypo3tempDir($cacheFileName, serialize($serContent));
 				if ($res) {
 					throw new RuntimeException(
@@ -4895,20 +4971,20 @@
 			}
 
 				// Checking for EXTERNAL file for non-default language:
-			if ($langKey!='default' && is_string($LOCAL_LANG[$langKey]) && strlen($LOCAL_LANG[$langKey]))	{
+			if ($langKey != 'default' && is_string($LOCAL_LANG[$langKey]) && strlen($LOCAL_LANG[$langKey])) {
 
 					// Look for localized file:
 				$localized_file = self::getFileAbsFileName($LOCAL_LANG[$langKey]);
-				if ($localized_file && @is_file($localized_file))	{
+				if ($localized_file && @is_file($localized_file)) {
 
 						// Cache file name:
-					$hashSource = substr($localized_file,strlen(PATH_site)).'|'.date('d-m-Y H:i:s',filemtime($localized_file)).'|version=2.3';
+					$hashSource = substr($localized_file, strlen(PATH_site)) . '|' . date('d-m-Y H:i:s', filemtime($localized_file)) . '|version=2.3';
-					$cacheFileName = PATH_site.'typo3temp/llxml/EXT_'.
+					$cacheFileName = PATH_site . 'typo3temp/llxml/EXT_' .
-									substr(basename($localized_file),10,15).
+							substr(basename($localized_file), 10, 15) .
-									'_'.self::shortMD5($hashSource).'.'.$langKey.'.'.$targetCharset.'.cache';
+							'_' . self::shortMD5($hashSource) . '.' . $langKey . '.' . $targetCharset . '.cache';
 
 						// Check if cache file exists...
-					if (!@is_file($cacheFileName))	{	// ... if it doesn't, create content and write it:
+					if (!@is_file($cacheFileName)) { // ... if it doesn't, create content and write it:
 
 							// Read and parse XML content:
 						$local_xmlString = self::getUrl($localized_file);
@@ -4923,14 +4999,14 @@
 						$LOCAL_LANG[$langKey] = is_array($local_xmlContent['data'][$langKey]) ? $local_xmlContent['data'][$langKey] : array();
 
 							// Checking if charset should be converted.
-						if (is_array($LOCAL_LANG[$langKey]) && $targetCharset!='utf-8')	{
+						if (is_array($LOCAL_LANG[$langKey]) && $targetCharset != 'utf-8') {
-							foreach($LOCAL_LANG[$langKey] as $labelKey => $labelValue)	{
+							foreach ($LOCAL_LANG[$langKey] as $labelKey => $labelValue) {
-								$LOCAL_LANG[$langKey][$labelKey] = $csConvObj->utf8_decode($labelValue,$targetCharset);
+								$LOCAL_LANG[$langKey][$labelKey] = $csConvObj->utf8_decode($labelValue, $targetCharset);
 							}
 						}
 
 							// Cache the content now:
-						$serContent = array('extlang'=>$langKey, 'origFile'=>$hashSource, 'EXT_DATA'=>$LOCAL_LANG[$langKey]);
+						$serContent = array('extlang' => $langKey, 'origFile' => $hashSource, 'EXT_DATA' => $LOCAL_LANG[$langKey]);
 						$res = self::writeFileToTypo3tempDir($cacheFileName, serialize($serContent));
 						if ($res) {
 							throw new RuntimeException(
@@ -4959,33 +5035,35 @@
 	 * @param	string		Language key
 	 * @return	string		Returns the filename reference for the language unless error occured (or local mode is used) in which case it will be NULL
 	 */
-	public static function llXmlAutoFileName($fileRef,$language)	{
+	public static function llXmlAutoFileName($fileRef, $language) {
 			// Analyse file reference:
-		$location = 'typo3conf/l10n/'.$language.'/';	// Default location of translations
+		$location = 'typo3conf/l10n/' . $language . '/'; // Default location of translations
-		if (self::isFirstPartOfStr($fileRef,PATH_typo3.'sysext/'))	{	// Is system:
+		if (self::isFirstPartOfStr($fileRef, PATH_typo3 . 'sysext/')) { // Is system:
-			$validatedPrefix = PATH_typo3.'sysext/';
+			$validatedPrefix = PATH_typo3 . 'sysext/';
 			#$location = 'EXT:csh_'.$language.'/';	// For system extensions translations are found in "csh_*" extensions (language packs)
-		} elseif (self::isFirstPartOfStr($fileRef,PATH_typo3.'ext/'))	{	// Is global:
+		} elseif (self::isFirstPartOfStr($fileRef, PATH_typo3 . 'ext/')) { // Is global:
-			$validatedPrefix = PATH_typo3.'ext/';
+			$validatedPrefix = PATH_typo3 . 'ext/';
-		} elseif (self::isFirstPartOfStr($fileRef,PATH_typo3conf.'ext/'))	{	// Is local:
+		} elseif (self::isFirstPartOfStr($fileRef, PATH_typo3conf . 'ext/')) { // Is local:
-			$validatedPrefix = PATH_typo3conf.'ext/';
+			$validatedPrefix = PATH_typo3conf . 'ext/';
 		} else {
 			$validatedPrefix = '';
 		}
 
-		if ($validatedPrefix)	{
+		if ($validatedPrefix) {
 
 				// Divide file reference into extension key, directory (if any) and base name:
-			list($file_extKey,$file_extPath) = explode('/',substr($fileRef,strlen($validatedPrefix)),2);
+			list($file_extKey, $file_extPath) = explode('/', substr($fileRef, strlen($validatedPrefix)), 2);
-			$temp = self::revExplode('/',$file_extPath,2);
+			$temp = self::revExplode('/', $file_extPath, 2);
-			if (count($temp)==1)	array_unshift($temp,'');	// Add empty first-entry if not there.
+			if (count($temp) == 1) {
+				array_unshift($temp, '');
+			} // Add empty first-entry if not there.
-			list($file_extPath,$file_fileName) = $temp;
+			list($file_extPath, $file_fileName) = $temp;
 
 				// The filename is prefixed with "[language key]." because it prevents the llxmltranslate tool from detecting it.
-			return $location.
+			return $location .
-				$file_extKey.'/'.
+					$file_extKey . '/' .
-				($file_extPath?$file_extPath.'/':'').
+					($file_extPath ? $file_extPath . '/' : '') .
-				$language.'.'.$file_fileName;
+					$language . '.' . $file_fileName;
 		} else {
 			return NULL;
 		}
@@ -5008,7 +5086,7 @@
 	 * @param	string		Table name for which to load the full TCA array part into the global $TCA
 	 * @return	void
 	 */
-	public static function loadTCA($table)	{
+	public static function loadTCA($table) {
 		global $TCA;
 
 		if (isset($TCA[$table])) {
@@ -5016,15 +5094,17 @@
 			if (!$tca['columns']) {
 				$dcf = $tca['ctrl']['dynamicConfigFile'];
 				if ($dcf) {
-					if (!strcmp(substr($dcf,0,6),'T3LIB:'))	{
+					if (!strcmp(substr($dcf, 0, 6), 'T3LIB:')) {
-						include(PATH_t3lib.'stddb/'.substr($dcf,6));
+						include(PATH_t3lib . 'stddb/' . substr($dcf, 6));
-					} elseif (self::isAbsPath($dcf) && @is_file($dcf))	{	// Absolute path...
+					} elseif (self::isAbsPath($dcf) && @is_file($dcf)) { // Absolute path...
 						include($dcf);
-					} else include(PATH_typo3conf.$dcf);
+					} else {
+						include(PATH_typo3conf . $dcf);
-				}
-			}
-		}
-	}
+					}
+				}
+			}
+		}
+	}
 
 	/**
 	 * Looks for a sheet-definition in the input data structure array. If found it will return the data structure for the sheet given as $sheet (if found).
@@ -5035,30 +5115,34 @@
 	 * @param	string		The sheet to return, preferably.
 	 * @return	array		An array with two num. keys: key0: The data structure is returned in this key (array) UNLESS an error happend in which case an error string is returned (string). key1: The used sheet key value!
 	 */
-	public static function resolveSheetDefInDS($dataStructArray,$sheet='sDEF')	{
+	public static function resolveSheetDefInDS($dataStructArray, $sheet = 'sDEF') {
-		if (!is_array ($dataStructArray)) return 'Data structure must be an array';
+		if (!is_array($dataStructArray)) {
+			return 'Data structure must be an array';
+		}
 
-		if (is_array($dataStructArray['sheets']))	{
+		if (is_array($dataStructArray['sheets'])) {
 			$singleSheet = FALSE;
-			if (!isset($dataStructArray['sheets'][$sheet]))	{
+			if (!isset($dataStructArray['sheets'][$sheet])) {
-				$sheet='sDEF';
+				$sheet = 'sDEF';
 			}
-			$dataStruct =  $dataStructArray['sheets'][$sheet];
+			$dataStruct = $dataStructArray['sheets'][$sheet];
 
 				// If not an array, but still set, then regard it as a relative reference to a file:
-			if ($dataStruct && !is_array($dataStruct))	{
+			if ($dataStruct && !is_array($dataStruct)) {
 				$file = self::getFileAbsFileName($dataStruct);
-				if ($file && @is_file($file))	{
+				if ($file && @is_file($file)) {
 					$dataStruct = self::xml2array(self::getUrl($file));
 				}
 			}
 		} else {
 			$singleSheet = TRUE;
 			$dataStruct = $dataStructArray;
-			if (isset($dataStruct['meta'])) unset($dataStruct['meta']);	// Meta data should not appear there.
+			if (isset($dataStruct['meta'])) {
+				unset($dataStruct['meta']);
+			} // Meta data should not appear there.
-			$sheet = 'sDEF';	// Default sheet
+			$sheet = 'sDEF'; // Default sheet
 		}
-		return array($dataStruct,$sheet,$singleSheet);
+		return array($dataStruct, $sheet, $singleSheet);
 	}
 
 	/**
@@ -5068,13 +5152,13 @@
 	 * @param	array		Input data structure, possibly with a sheet-definition and references to external data source files.
 	 * @return	array		Output data structure with all sheets resolved as arrays.
 	 */
-	public static function resolveAllSheetsInDS(array $dataStructArray)	{
+	public static function resolveAllSheetsInDS(array $dataStructArray) {
-		if (is_array($dataStructArray['sheets']))	{
+		if (is_array($dataStructArray['sheets'])) {
-			$out=array('sheets'=>array());
+			$out = array('sheets' => array());
-			foreach($dataStructArray['sheets'] as $sheetId => $sDat)	{
+			foreach ($dataStructArray['sheets'] as $sheetId => $sDat) {
-				list($ds,$aS) = self::resolveSheetDefInDS($dataStructArray,$sheetId);
+				list($ds, $aS) = self::resolveSheetDefInDS($dataStructArray, $sheetId);
-				if ($sheetId==$aS)	{
+				if ($sheetId == $aS) {
-					$out['sheets'][$aS]=$ds;
+					$out['sheets'][$aS] = $ds;
 				}
 			}
 		} else {
@@ -5097,72 +5181,74 @@
 	 * @return	mixed		Content from method/function call or false if the class/method/function was not found
 	 * @see getUserObj()
 	 */
-	public static function callUserFunction($funcName,&$params,&$ref,$checkPrefix='user_',$errorMode=0)	{
+	public static function callUserFunction($funcName, &$params, &$ref, $checkPrefix = 'user_', $errorMode = 0) {
 		global $TYPO3_CONF_VARS;
-		$content = false;
+		$content = FALSE;
 
 			// Check persistent object and if found, call directly and exit.
-		if (is_array($GLOBALS['T3_VAR']['callUserFunction'][$funcName]))	{
+		if (is_array($GLOBALS['T3_VAR']['callUserFunction'][$funcName])) {
 			return call_user_func_array(
-						array(&$GLOBALS['T3_VAR']['callUserFunction'][$funcName]['obj'],
-							$GLOBALS['T3_VAR']['callUserFunction'][$funcName]['method']),
-						array(&$params, &$ref)
-					);
+				array(&$GLOBALS['T3_VAR']['callUserFunction'][$funcName]['obj'],
+					$GLOBALS['T3_VAR']['callUserFunction'][$funcName]['method']),
+				array(&$params, &$ref)
+			);
 		}
 
 			// Check file-reference prefix; if found, require_once() the file (should be library of code)
-		if (strpos($funcName,':') !== false)	{
+		if (strpos($funcName, ':') !== FALSE) {
-			list($file,$funcRef) = self::revExplode(':',$funcName,2);
+			list($file, $funcRef) = self::revExplode(':', $funcName, 2);
 			$requireFile = self::getFileAbsFileName($file);
-			if ($requireFile) self::requireOnce($requireFile);
+			if ($requireFile) {
+				self::requireOnce($requireFile);
+			}
 		} else {
 			$funcRef = $funcName;
 		}
 
 			// Check for persistent object token, "&"
-		if (substr($funcRef,0,1)=='&')	{
+		if (substr($funcRef, 0, 1) == '&') {
-			$funcRef = substr($funcRef,1);
+			$funcRef = substr($funcRef, 1);
-			$storePersistentObject = true;
+			$storePersistentObject = TRUE;
 		} else {
-			$storePersistentObject = false;
+			$storePersistentObject = FALSE;
 		}
 
 			// Check prefix is valid:
 		if ($checkPrefix &&
-			!self::isFirstPartOfStr(trim($funcRef),$checkPrefix) &&
+				!self::isFirstPartOfStr(trim($funcRef), $checkPrefix) &&
-			!self::isFirstPartOfStr(trim($funcRef),'tx_')
+				!self::isFirstPartOfStr(trim($funcRef), 'tx_')
-			)	{
+		) {
 			$errorMsg = "Function/class '$funcRef' was not prepended with '$checkPrefix'";
 			if ($errorMode == 2) {
 				throw new Exception($errorMsg);
-			} elseif(!$errorMode)	{
+			} elseif (!$errorMode) {
 				debug($errorMsg, 't3lib_div::callUserFunction');
 			}
-			return false;
+			return FALSE;
 		}
 
 			// Call function or method:
-		$parts = explode('->',$funcRef);
+		$parts = explode('->', $funcRef);
-		if (count($parts)==2)	{	// Class
+		if (count($parts) == 2) { // Class
 
 				// Check if class/method exists:
-			if (class_exists($parts[0]))	{
+			if (class_exists($parts[0])) {
 
 					// Get/Create object of class:
-				if ($storePersistentObject)	{	// Get reference to current instance of class:
+				if ($storePersistentObject) { // Get reference to current instance of class:
-					if (!is_object($GLOBALS['T3_VAR']['callUserFunction_classPool'][$parts[0]]))	{
+					if (!is_object($GLOBALS['T3_VAR']['callUserFunction_classPool'][$parts[0]])) {
 						$GLOBALS['T3_VAR']['callUserFunction_classPool'][$parts[0]] = self::makeInstance($parts[0]);
 					}
 					$classObj = $GLOBALS['T3_VAR']['callUserFunction_classPool'][$parts[0]];
-				} else {	// Create new object:
+				} else { // Create new object:
 					$classObj = self::makeInstance($parts[0]);
 				}
 
-				if (method_exists($classObj, $parts[1]))	{
+				if (method_exists($classObj, $parts[1])) {
 
 						// If persistent object should be created, set reference:
-					if ($storePersistentObject)	{
+					if ($storePersistentObject) {
-						$GLOBALS['T3_VAR']['callUserFunction'][$funcName] = array (
+						$GLOBALS['T3_VAR']['callUserFunction'][$funcName] = array(
 							'method' => $parts[1],
 							'obj' => &$classObj
 						);
@@ -5173,29 +5259,29 @@
 						array(&$params, &$ref)
 					);
 				} else {
-					$errorMsg = "<strong>ERROR:</strong> No method name '".$parts[1]."' in class ".$parts[0];
+					$errorMsg = "<strong>ERROR:</strong> No method name '" . $parts[1] . "' in class " . $parts[0];
 					if ($errorMode == 2) {
 						throw new Exception($errorMsg);
-					} elseif(!$errorMode)   {
+					} elseif (!$errorMode) {
 						debug($errorMsg, 't3lib_div::callUserFunction');
 					}
 				}
 			} else {
-				$errorMsg = "<strong>ERROR:</strong> No class named: ".$parts[0];
+				$errorMsg = "<strong>ERROR:</strong> No class named: " . $parts[0];
 				if ($errorMode == 2) {
 					throw new Exception($errorMsg);
-				} elseif(!$errorMode)   {
+				} elseif (!$errorMode) {
 					debug($errorMsg, 't3lib_div::callUserFunction');
 				}
 			}
-		} else {	// Function
+		} else { // Function
-			if (function_exists($funcRef))	{
+			if (function_exists($funcRef)) {
 				$content = call_user_func_array($funcRef, array(&$params, &$ref));
 			} else {
-				$errorMsg = "<strong>ERROR:</strong> No function named: ".$funcRef;
+				$errorMsg = "<strong>ERROR:</strong> No function named: " . $funcRef;
 				if ($errorMode == 2) {
 					throw new Exception($errorMsg);
-				} elseif(!$errorMode)   {
+				} elseif (!$errorMode) {
 					debug($errorMsg, 't3lib_div::callUserFunction');
 				}
 			}
@@ -5214,25 +5300,27 @@
 	 * @return	object		The instance of the class asked for. Instance is created with t3lib_div::makeInstance
 	 * @see callUserFunction()
 	 */
-	public static function getUserObj($classRef, $checkPrefix='user_', $silent=false) {
+	public static function getUserObj($classRef, $checkPrefix = 'user_', $silent = FALSE) {
 		global $TYPO3_CONF_VARS;
 			// Check persistent object and if found, call directly and exit.
-		if (is_object($GLOBALS['T3_VAR']['getUserObj'][$classRef]))	{
+		if (is_object($GLOBALS['T3_VAR']['getUserObj'][$classRef])) {
 			return $GLOBALS['T3_VAR']['getUserObj'][$classRef];
 		} else {
 
 				// Check file-reference prefix; if found, require_once() the file (should be library of code)
-			if (strpos($classRef,':') !== false)	{
+			if (strpos($classRef, ':') !== FALSE) {
-				list($file,$class) = self::revExplode(':',$classRef,2);
+				list($file, $class) = self::revExplode(':', $classRef, 2);
 				$requireFile = self::getFileAbsFileName($file);
-				if ($requireFile)	self::requireOnce($requireFile);
+				if ($requireFile) {
+					self::requireOnce($requireFile);
+				}
 			} else {
 				$class = $classRef;
 			}
 
 				// Check for persistent object token, "&"
-			if (substr($class,0,1)=='&')	{
+			if (substr($class, 0, 1) == '&') {
-				$class = substr($class,1);
+				$class = substr($class, 1);
 				$storePersistentObject = TRUE;
 			} else {
 				$storePersistentObject = FALSE;
@@ -5240,35 +5328,39 @@
 
 				// Check prefix is valid:
 			if ($checkPrefix &&
-				!self::isFirstPartOfStr(trim($class),$checkPrefix) &&
+					!self::isFirstPartOfStr(trim($class), $checkPrefix) &&
-				!self::isFirstPartOfStr(trim($class),'tx_')
+					!self::isFirstPartOfStr(trim($class), 'tx_')
-				)	{
+			) {
-				if (!$silent)	debug("Class '".$class."' was not prepended with '".$checkPrefix."'", 't3lib_div::getUserObj');
+				if (!$silent) {
+					debug("Class '" . $class . "' was not prepended with '" . $checkPrefix . "'", 't3lib_div::getUserObj');
+				}
 				return FALSE;
 			}
 
 				// Check if class exists:
-			if (class_exists($class))	{
+			if (class_exists($class)) {
 				$classObj = self::makeInstance($class);
 
 					// If persistent object should be created, set reference:
-				if ($storePersistentObject)	{
+				if ($storePersistentObject) {
 					$GLOBALS['T3_VAR']['getUserObj'][$classRef] = $classObj;
 				}
 
 				return $classObj;
 			} else {
-				if (!$silent)	debug("<strong>ERROR:</strong> No class named: ".$class, 't3lib_div::getUserObj');
+				if (!$silent) {
+					debug("<strong>ERROR:</strong> No class named: " . $class, 't3lib_div::getUserObj');
-			}
-		}
-	}
+				}
+			}
+		}
+	}
 
 	/**
 	 * Creates an instance of a class taking into account the class-extensions
 	 * API of TYPO3. USE THIS method instead of the PHP "new" keyword.
 	 * Eg. "$obj = new myclass;" should be "$obj = t3lib_div::makeInstance("myclass")" instead!
 	 * You can also pass arguments for a constructor:
-	 * 	t3lib_div::makeInstance('myClass', $arg1, $arg2,  ..., $argN)
+	 *	 t3lib_div::makeInstance('myClass', $arg1, $arg2,  ..., $argN)
 	 *
 	 * @param	string		Class name to instantiate
 	 * @return	object		A reference to the object
@@ -5314,10 +5406,10 @@
 	 * @return	string		Final class name to instantiate with "new [classname]"
 	 * @deprecated since TYPO3 4.3, will be removed in TYPO3 4.6 - Use t3lib_div::makeInstance('myClass', $arg1, $arg2,  ..., $argN)
 	 */
-	public static function makeInstanceClassName($className)	{
+	public static function makeInstanceClassName($className) {
 		self::logDeprecatedFunction();
 
-		return (class_exists($className) && class_exists('ux_'.$className, false) ? self::makeInstanceClassName('ux_' . $className) : $className);
+		return (class_exists($className) && class_exists('ux_' . $className, FALSE) ? self::makeInstanceClassName('ux_' . $className) : $className);
 	}
 
 	/**
@@ -5328,7 +5420,7 @@
 	 * @return	string		Final class name to instantiate with "new [classname]"
 	 */
 	protected function getClassName($className) {
-		return (class_exists($className) && class_exists('ux_' . $className, false) ? self::getClassName('ux_' . $className) : $className);
+		return (class_exists($className) && class_exists('ux_' . $className, FALSE) ? self::getClassName('ux_' . $className) : $className);
 	}
 
 	/**
@@ -5341,18 +5433,18 @@
 	 * @return	object		The service object or an array with error info's.
 	 * @author	René Fritz <r.fritz@colorcube.de>
 	 */
-	public static function makeInstanceService($serviceType, $serviceSubType='', $excludeServiceKeys=array()) {
+	public static function makeInstanceService($serviceType, $serviceSubType = '', $excludeServiceKeys = array()) {
 		global $T3_SERVICES, $T3_VAR, $TYPO3_CONF_VARS;
 
 		$error = FALSE;
 
-		if (!is_array($excludeServiceKeys) ) {
+		if (!is_array($excludeServiceKeys)) {
 			$excludeServiceKeys = self::trimExplode(',', $excludeServiceKeys, 1);
 		}
-		while ($info = t3lib_extMgm::findService($serviceType, $serviceSubType, $excludeServiceKeys))	{
+		while ($info = t3lib_extMgm::findService($serviceType, $serviceSubType, $excludeServiceKeys)) {
 
 				// Check persistent object and if found, call directly and exit.
-			if (is_object($GLOBALS['T3_VAR']['makeInstanceService'][$info['className']]))	{
+			if (is_object($GLOBALS['T3_VAR']['makeInstanceService'][$info['className']])) {
 					// reset service and return object
 				$T3_VAR['makeInstanceService'][$info['className']]->reset();
 				return $GLOBALS['T3_VAR']['makeInstanceService'][$info['className']];
@@ -5361,12 +5453,12 @@
 			} else {
 				$requireFile = self::getFileAbsFileName($info['classFile']);
 				if (@is_file($requireFile)) {
-					self::requireOnce ($requireFile);
+					self::requireOnce($requireFile);
 					$obj = self::makeInstance($info['className']);
 					if (is_object($obj)) {
-						if(!@is_callable(array($obj,'init')))	{
+						if (!@is_callable(array($obj, 'init'))) {
 								// use silent logging??? I don't think so.
-							die ('Broken service:'.self::view_array($info));
+							die ('Broken service:' . self::view_array($info));
 						}
 						$obj->info = $info;
 						if ($obj->init()) { // service available?
@@ -5385,7 +5477,7 @@
 				}
 			}
 				// deactivate the service
-			t3lib_extMgm::deactivateService($info['serviceType'],$info['serviceKey']);
+			t3lib_extMgm::deactivateService($info['serviceType'], $info['serviceKey']);
 		}
 		return $error;
 	}
@@ -5394,7 +5486,7 @@
 	 * Require a class for TYPO3
 	 * Useful to require classes from inside other classes (not global scope). A limited set of global variables are available (see function)
 	 */
-	public static function requireOnce($requireFile)	{
+	public static function requireOnce($requireFile) {
 		global $T3_SERVICES, $T3_VAR, $TYPO3_CONF_VARS;
 
 		require_once ($requireFile);
@@ -5428,68 +5520,68 @@
 	 * @param	boolean		If set, the header content will not be encoded.
 	 * @return	boolean		True if mail was accepted for delivery, false otherwise
 	 */
-	public static function plainMailEncoded($email,$subject,$message,$headers='',$encoding='quoted-printable',$charset='',$dontEncodeHeader=false)	{
+	public static function plainMailEncoded($email, $subject, $message, $headers = '', $encoding = 'quoted-printable', $charset = '', $dontEncodeHeader = FALSE) {
-		if (!$charset)	{
+		if (!$charset) {
 			$charset = $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] ? $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] : 'ISO-8859-1';
 		}
 
 		$email = self::normalizeMailAddress($email);
-		if (!$dontEncodeHeader)	{
+		if (!$dontEncodeHeader) {
 				// Mail headers must be ASCII, therefore we convert the whole header to either base64 or quoted_printable
-			$newHeaders=array();
+			$newHeaders = array();
-			foreach (explode(LF,$headers) as $line)	{	// Split the header in lines and convert each line separately
+			foreach (explode(LF, $headers) as $line) { // Split the header in lines and convert each line separately
-				$parts = explode(': ',$line,2);	// Field tags must not be encoded
+				$parts = explode(': ', $line, 2); // Field tags must not be encoded
-				if (count($parts)==2)	{
+				if (count($parts) == 2) {
 					if (0 == strcasecmp($parts[0], 'from')) {
 						$parts[1] = self::normalizeMailAddress($parts[1]);
 					}
-					$parts[1] = self::encodeHeader($parts[1],$encoding,$charset);
+					$parts[1] = self::encodeHeader($parts[1], $encoding, $charset);
-					$newHeaders[] = implode(': ',$parts);
+					$newHeaders[] = implode(': ', $parts);
 				} else {
-					$newHeaders[] = $line;	// Should never happen - is such a mail header valid? Anyway, just add the unchanged line...
+					$newHeaders[] = $line; // Should never happen - is such a mail header valid? Anyway, just add the unchanged line...
 				}
 			}
-			$headers = implode(LF,$newHeaders);
+			$headers = implode(LF, $newHeaders);
 			unset($newHeaders);
 
-			$email = self::encodeHeader($email,$encoding,$charset);		// Email address must not be encoded, but it could be appended by a name which should be so (e.g. "Kasper Skårhøj <kasperYYYY@typo3.com>")
+			$email = self::encodeHeader($email, $encoding, $charset); // Email address must not be encoded, but it could be appended by a name which should be so (e.g. "Kasper Skårhøj <kasperYYYY@typo3.com>")
-			$subject = self::encodeHeader($subject,$encoding,$charset);
+			$subject = self::encodeHeader($subject, $encoding, $charset);
 		}
 
-		switch ((string)$encoding)	{
+		switch ((string) $encoding) {
 			case 'base64':
-				$headers=trim($headers).LF.
+				$headers = trim($headers) . LF .
-				'Mime-Version: 1.0'.LF.
+						'Mime-Version: 1.0' . LF .
-				'Content-Type: text/plain; charset="'.$charset.'"'.LF.
+						'Content-Type: text/plain; charset="' . $charset . '"' . LF .
-				'Content-Transfer-Encoding: base64';
+						'Content-Transfer-Encoding: base64';
 
-				$message=trim(chunk_split(base64_encode($message.LF))).LF;	// Adding LF because I think MS outlook 2002 wants it... may be removed later again.
+				$message = trim(chunk_split(base64_encode($message . LF))) . LF; // Adding LF because I think MS outlook 2002 wants it... may be removed later again.
-			break;
+				break;
 			case '8bit':
-				$headers=trim($headers).LF.
+				$headers = trim($headers) . LF .
-				'Mime-Version: 1.0'.LF.
+						'Mime-Version: 1.0' . LF .
-				'Content-Type: text/plain; charset='.$charset.LF.
+						'Content-Type: text/plain; charset=' . $charset . LF .
-				'Content-Transfer-Encoding: 8bit';
-			break;
+						'Content-Transfer-Encoding: 8bit';
+				break;
 			case 'quoted-printable':
 			default:
-				$headers=trim($headers).LF.
+				$headers = trim($headers) . LF .
-				'Mime-Version: 1.0'.LF.
+						'Mime-Version: 1.0' . LF .
-				'Content-Type: text/plain; charset='.$charset.LF.
+						'Content-Type: text/plain; charset=' . $charset . LF .
-				'Content-Transfer-Encoding: quoted-printable';
+						'Content-Transfer-Encoding: quoted-printable';
 
-				$message=self::quoted_printable($message);
+				$message = self::quoted_printable($message);
-			break;
+				break;
 		}
 
-		// Headers must be separated by CRLF according to RFC 2822, not just LF.
-		// But many servers (Gmail, for example) behave incorectly and want only LF.
-		// So we stick to LF in all cases.
+			// Headers must be separated by CRLF according to RFC 2822, not just LF.
+			// But many servers (Gmail, for example) behave incorectly and want only LF.
+			// So we stick to LF in all cases.
-		$headers = trim(implode(LF, self::trimExplode(LF, $headers, true)));	// Make sure no empty lines are there.
+		$headers = trim(implode(LF, self::trimExplode(LF, $headers, TRUE))); // Make sure no empty lines are there.
 
 
 		return t3lib_utility_Mail::mail($email, $subject, $message, $headers);
-		}
+	}
 
 	/**
 	 * Implementation of quoted-printable encode.
@@ -5501,42 +5593,42 @@
 	 * @param	integer		Length of the lines, default is 76
 	 * @return	string		The QP encoded string
 	 */
-	public static function quoted_printable($string,$maxlen=76)	{
+	public static function quoted_printable($string, $maxlen = 76) {
 			// Make sure the string contains only Unix linebreaks
-		$string = str_replace(CRLF, LF, $string);	// Replace Windows breaks (\r\n)
+		$string = str_replace(CRLF, LF, $string); // Replace Windows breaks (\r\n)
-		$string = str_replace(CR, LF, $string);		// Replace Mac breaks (\r)
+		$string = str_replace(CR, LF, $string); // Replace Mac breaks (\r)
 
-		$linebreak = LF;			// Default line break for Unix systems.
+		$linebreak = LF; // Default line break for Unix systems.
-		if (TYPO3_OS=='WIN')	{
+		if (TYPO3_OS == 'WIN') {
-			$linebreak = CRLF;	// Line break for Windows. This is needed because PHP on Windows systems send mails via SMTP instead of using sendmail, and thus the linebreak needs to be \r\n.
+			$linebreak = CRLF; // Line break for Windows. This is needed because PHP on Windows systems send mails via SMTP instead of using sendmail, and thus the linebreak needs to be \r\n.
 		}
 
 		$newString = '';
-		$theLines = explode(LF,$string);	// Split lines
+		$theLines = explode(LF, $string); // Split lines
-		foreach ($theLines as $val)	{
+		foreach ($theLines as $val) {
 			$newVal = '';
 			$theValLen = strlen($val);
 			$len = 0;
-			for ($index=0; $index < $theValLen; $index++)	{	// Walk through each character of this line
+			for ($index = 0; $index < $theValLen; $index++) { // Walk through each character of this line
-				$char = substr($val,$index,1);
+				$char = substr($val, $index, 1);
 				$ordVal = ord($char);
-				if ($len>($maxlen-4) || ($len>($maxlen-14) && $ordVal==32))	{
+				if ($len > ($maxlen - 4) || ($len > ($maxlen - 14) && $ordVal == 32)) {
-					$newVal.='='.$linebreak;	// Add a line break
+					$newVal .= '=' . $linebreak; // Add a line break
-					$len=0;			// Reset the length counter
+					$len = 0; // Reset the length counter
 				}
-				if (($ordVal>=33 && $ordVal<=60) || ($ordVal>=62 && $ordVal<=126) || $ordVal==9 || $ordVal==32)	{
+				if (($ordVal >= 33 && $ordVal <= 60) || ($ordVal >= 62 && $ordVal <= 126) || $ordVal == 9 || $ordVal == 32) {
-					$newVal.=$char;		// This character is ok, add it to the message
+					$newVal .= $char; // This character is ok, add it to the message
 					$len++;
 				} else {
-					$newVal.=sprintf('=%02X',$ordVal);	// Special character, needs to be encoded
+					$newVal .= sprintf('=%02X', $ordVal); // Special character, needs to be encoded
-					$len+=3;
+					$len += 3;
 				}
 			}
-			$newVal = preg_replace('/'.chr(32).'$/','=20',$newVal);		// Replaces a possible SPACE-character at the end of a line
+			$newVal = preg_replace('/' . chr(32) . '$/', '=20', $newVal); // Replaces a possible SPACE-character at the end of a line
-			$newVal = preg_replace('/'.TAB.'$/','=09',$newVal);		// Replaces a possible TAB-character at the end of a line
+			$newVal = preg_replace('/' . TAB . '$/', '=09', $newVal); // Replaces a possible TAB-character at the end of a line
-			$newString.=$newVal.$linebreak;
+			$newString .= $newVal . $linebreak;
 		}
-		return preg_replace('/'.$linebreak.'$/','',$newString);		// Remove last newline
+		return preg_replace('/' . $linebreak . '$/', '', $newString); // Remove last newline
 	}
 
 	/**
@@ -5548,42 +5640,42 @@
 	 * @param	string		Charset used for encoding
 	 * @return	string		The encoded string
 	 */
-	public static function encodeHeader($line,$enc='quoted-printable',$charset='iso-8859-1')	{
+	public static function encodeHeader($line, $enc = 'quoted-printable', $charset = 'iso-8859-1') {
 			// Avoid problems if "###" is found in $line (would conflict with the placeholder which is used below)
-		if (strpos($line,'###') !== false) {
+		if (strpos($line, '###') !== FALSE) {
 			return $line;
 		}
 			// Check if any non-ASCII characters are found - otherwise encoding is not needed
-		if (!preg_match('/[^'.chr(32).'-'.chr(127).']/',$line))	{
+		if (!preg_match('/[^' . chr(32) . '-' . chr(127) . ']/', $line)) {
 			return $line;
 		}
 			// Wrap email addresses in a special marker
 		$line = preg_replace('/([^ ]+@[^ ]+)/', '###$1###', $line);
 
 		$matches = preg_split('/(.?###.+###.?|\(|\))/', $line, -1, PREG_SPLIT_NO_EMPTY);
-		foreach ($matches as $part)	{
+		foreach ($matches as $part) {
 			$oldPart = $part;
-			switch ((string)$enc)	{
+			switch ((string) $enc) {
 				case 'base64':
-					$part = '=?'.$charset.'?B?'.base64_encode($part).'?=';
+					$part = '=?' . $charset . '?B?' . base64_encode($part) . '?=';
-				break;
+					break;
 				case 'quoted-printable':
 				default:
-					$qpValue = self::quoted_printable($part,1000);
+					$qpValue = self::quoted_printable($part, 1000);
-					if ($part!=$qpValue)	{
+					if ($part != $qpValue) {
-						// Encoded words in the header should not contain non-encoded:
-						// * spaces. "_" is a shortcut for "=20". See RFC 2047 for details.
-						// * question mark. See RFC 1342 (http://tools.ietf.org/html/rfc1342)
+							// Encoded words in the header should not contain non-encoded:
+							// * spaces. "_" is a shortcut for "=20". See RFC 2047 for details.
+							// * question mark. See RFC 1342 (http://tools.ietf.org/html/rfc1342)
 						$search = array(' ', '?');
 						$replace = array('_', '=3F');
 						$qpValue = str_replace($search, $replace, $qpValue);
-						$part = '=?'.$charset.'?Q?'.$qpValue.'?=';
+						$part = '=?' . $charset . '?Q?' . $qpValue . '?=';
 					}
-				break;
+					break;
 			}
 			$line = str_replace($oldPart, $part, $line);
 		}
-		$line = preg_replace('/###(.+?)###/', '$1', $line);	// Remove the wrappers
+		$line = preg_replace('/###(.+?)###/', '$1', $line); // Remove the wrappers
 
 		return $line;
 	}
@@ -5599,27 +5691,27 @@
 	 * @return	string		Processed message content
 	 * @see makeRedirectUrl()
 	 */
-	public static function substUrlsInPlainText($message,$urlmode='76',$index_script_url='')	{
+	public static function substUrlsInPlainText($message, $urlmode = '76', $index_script_url = '') {
 			// Substitute URLs with shorter links:
-		foreach (array('http','https') as $protocol)	{
+		foreach (array('http', 'https') as $protocol) {
-			$urlSplit = explode($protocol.'://',$message);
+			$urlSplit = explode($protocol . '://', $message);
 			foreach ($urlSplit as $c => &$v) {
-				if ($c)	{
+				if ($c) {
 					$newParts = preg_split('/\s|[<>"{}|\\\^`()\']/', $v, 2);
-					$newURL = $protocol.'://'.$newParts[0];
+					$newURL = $protocol . '://' . $newParts[0];
 
-					switch ((string)$urlmode)	{
+					switch ((string) $urlmode) {
 						case 'all':
-							$newURL = self::makeRedirectUrl($newURL,0,$index_script_url);
+							$newURL = self::makeRedirectUrl($newURL, 0, $index_script_url);
-						break;
+							break;
 						case '76':
-							$newURL = self::makeRedirectUrl($newURL,76,$index_script_url);
+							$newURL = self::makeRedirectUrl($newURL, 76, $index_script_url);
-						break;
+							break;
 					}
-					$v = $newURL . substr($v,strlen($newParts[0]));
+					$v = $newURL . substr($v, strlen($newParts[0]));
 				}
 			}
-			$message = implode('',$urlSplit);
+			$message = implode('', $urlSplit);
 		}
 
 		return $message;
@@ -5634,13 +5726,13 @@
 	 * @param	string		URL of "index script" - the prefix of the "?RDCT=..." parameter. If not supplyed it will default to t3lib_div::getIndpEnv('TYPO3_REQUEST_DIR').'index.php'
 	 * @return	string		Processed URL
 	 */
-	public static function makeRedirectUrl($inUrl,$l=0,$index_script_url='')	{
+	public static function makeRedirectUrl($inUrl, $l = 0, $index_script_url = '') {
-		if (strlen($inUrl)>$l)	{
+		if (strlen($inUrl) > $l) {
-			$md5 = substr(md5($inUrl),0,20);
+			$md5 = substr(md5($inUrl), 0, 20);
 			$count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
 				'*',
 				'cache_md5params',
-				'md5hash=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($md5, 'cache_md5params')
+					'md5hash=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($md5, 'cache_md5params')
 			);
 			if (!$count) {
 				$insertFields = array(
@@ -5652,8 +5744,8 @@
 
 				$GLOBALS['TYPO3_DB']->exec_INSERTquery('cache_md5params', $insertFields);
 			}
-			$inUrl=($index_script_url ? $index_script_url : self::getIndpEnv('TYPO3_REQUEST_DIR').'index.php').
+			$inUrl = ($index_script_url ? $index_script_url : self::getIndpEnv('TYPO3_REQUEST_DIR') . 'index.php') .
-				'?RDCT='.$md5;
+					'?RDCT=' . $md5;
 		}
 
 		return $inUrl;
@@ -5666,9 +5758,11 @@
 	 * @param	integer		Fontsize for freetype function call
 	 * @return	integer		Compensated fontsize based on $GLOBALS['TYPO3_CONF_VARS']['GFX']['TTFdpi']
 	 */
-	public static function freetypeDpiComp($font_size)	{
+	public static function freetypeDpiComp($font_size) {
 		$dpi = intval($GLOBALS['TYPO3_CONF_VARS']['GFX']['TTFdpi']);
-		if ($dpi!=72)	$font_size = $font_size/$dpi*72;
+		if ($dpi != 72) {
+			$font_size = $font_size / $dpi * 72;
+		}
 		return $font_size;
 	}
 
@@ -5678,13 +5772,13 @@
 	 * @return	void
 	 * @see sysLog()
 	 */
-	public static function initSysLog()	{
+	public static function initSysLog() {
 		global $TYPO3_CONF_VARS;
 
 			// for CLI logging name is <fqdn-hostname>:<TYPO3-path>
 			// Note that TYPO3_REQUESTTYPE is not used here as it may not yet be defined
-		if (defined('TYPO3_cliMode') && TYPO3_cliMode)	{
+		if (defined('TYPO3_cliMode') && TYPO3_cliMode) {
-			$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'] = self::getHostname($requestHost=FALSE).':'.PATH_site;
+			$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'] = self::getHostname($requestHost = FALSE) . ':' . PATH_site;
 		}
 			// for Web logging name is <protocol>://<request-hostame>/<site-path>
 		else {
@@ -5692,29 +5786,29 @@
 		}
 
 			// init custom logging
-		if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLog']))	{
+		if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLog'])) {
-			$params = array('initLog'=>TRUE);
+			$params = array('initLog' => TRUE);
 			$fakeThis = FALSE;
-			foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLog'] as $hookMethod)	{
+			foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLog'] as $hookMethod) {
-				self::callUserFunction($hookMethod,$params,$fakeThis);
+				self::callUserFunction($hookMethod, $params, $fakeThis);
 			}
 		}
 
 			// init TYPO3 logging
-		foreach (explode(';',$TYPO3_CONF_VARS['SYS']['systemLog'],2) as $log)	{
+		foreach (explode(';', $TYPO3_CONF_VARS['SYS']['systemLog'], 2) as $log) {
-			list($type,$destination) = explode(',',$log,3);
+			list($type, $destination) = explode(',', $log, 3);
 
-			if ($type == 'syslog')	{
+			if ($type == 'syslog') {
-				if (TYPO3_OS == 'WIN')	{
+				if (TYPO3_OS == 'WIN') {
 					$facility = LOG_USER;
 				} else {
-					$facility = constant('LOG_'.strtoupper($destination));
+					$facility = constant('LOG_' . strtoupper($destination));
 				}
 				openlog($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'], LOG_ODELAY, $facility);
 			}
 		}
 
-		$TYPO3_CONF_VARS['SYS']['systemLogLevel'] = self::intInRange($TYPO3_CONF_VARS['SYS']['systemLogLevel'],0,4);
+		$TYPO3_CONF_VARS['SYS']['systemLogLevel'] = self::intInRange($TYPO3_CONF_VARS['SYS']['systemLogLevel'], 0, 4);
 		$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogInit'] = TRUE;
 	}
 
@@ -5722,80 +5816,86 @@
 	 * Logs message to the system log.
 	 * This should be implemented around the source code, including the Core and both frontend and backend, logging serious errors.
 	 * If you want to implement the sysLog in your applications, simply add lines like:
-	 * 		t3lib_div::sysLog('[write message in English here]', 'extension_key', 'severity');
+	 *		 t3lib_div::sysLog('[write message in English here]', 'extension_key', 'severity');
 	 *
 	 * @param	string		Message (in English).
 	 * @param	string		Extension key (from which extension you are calling the log) or "Core"
 	 * @param	integer		Severity: 0 is info, 1 is notice, 2 is warning, 3 is error, 4 is fatal error
 	 * @return	void
 	 */
-	public static function sysLog($msg, $extKey, $severity=0) {
+	public static function sysLog($msg, $extKey, $severity = 0) {
 		global $TYPO3_CONF_VARS;
 
-		$severity = self::intInRange($severity,0,4);
+		$severity = self::intInRange($severity, 0, 4);
 
 			// is message worth logging?
-		if (intval($TYPO3_CONF_VARS['SYS']['systemLogLevel']) > $severity)	return;
+		if (intval($TYPO3_CONF_VARS['SYS']['systemLogLevel']) > $severity) {
+			return;
+		}
 
 			// initialize logging
-		if (!$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogInit'])	{
+		if (!$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogInit']) {
 			self::initSysLog();
 		}
 
 			// do custom logging
 		if (isset($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLog']) &&
 				is_array($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLog'])) {
-			$params = array('msg'=>$msg, 'extKey'=>$extKey, 'backTrace'=>debug_backtrace(), 'severity'=>$severity);
+			$params = array('msg' => $msg, 'extKey' => $extKey, 'backTrace' => debug_backtrace(), 'severity' => $severity);
 			$fakeThis = FALSE;
-			foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLog'] as $hookMethod)	{
+			foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLog'] as $hookMethod) {
-				self::callUserFunction($hookMethod,$params,$fakeThis);
+				self::callUserFunction($hookMethod, $params, $fakeThis);
 			}
 		}
 
 			// TYPO3 logging enabled?
-		if (!$TYPO3_CONF_VARS['SYS']['systemLog'])	return;
+		if (!$TYPO3_CONF_VARS['SYS']['systemLog']) {
+			return;
+		}
 
 		$dateFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'];
 		$timeFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'];
 
 			// use all configured logging options
-		foreach (explode(';',$TYPO3_CONF_VARS['SYS']['systemLog'],2) as $log)	{
+		foreach (explode(';', $TYPO3_CONF_VARS['SYS']['systemLog'], 2) as $log) {
-			list($type,$destination,$level) = explode(',',$log,4);
+			list($type, $destination, $level) = explode(',', $log, 4);
 
 				// is message worth logging for this log type?
-			if (intval($level) > $severity)	continue;
+			if (intval($level) > $severity) {
+				continue;
+			}
 
-			$msgLine = ' - '.$extKey.': '.$msg;
+			$msgLine = ' - ' . $extKey . ': ' . $msg;
 
 				// write message to a file
-			if ($type == 'file')	{
+			if ($type == 'file') {
 				$file = fopen($destination, 'a');
-				if ($file)     {
+				if ($file) {
-					flock($file, LOCK_EX);  // try locking, but ignore if not available (eg. on NFS and FAT)
+					flock($file, LOCK_EX); // try locking, but ignore if not available (eg. on NFS and FAT)
-					fwrite($file, date($dateFormat.' '.$timeFormat).$msgLine.LF);
+					fwrite($file, date($dateFormat . ' ' . $timeFormat) . $msgLine . LF);
-					flock($file, LOCK_UN);    // release the lock
+					flock($file, LOCK_UN); // release the lock
 					fclose($file);
 				}
 			}
 				// send message per mail
-			elseif ($type == 'mail')	{
+			elseif ($type == 'mail') {
-				list($to,$from) = explode('/',$destination);
+				list($to, $from) = explode('/', $destination);
 				t3lib_utility_Mail::mail($to, 'Warning - error in TYPO3 installation',
-					'Host: '.$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'].LF.
+						'Host: ' . $TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'] . LF .
-					'Extension: '.$extKey.LF.
+								'Extension: ' . $extKey . LF .
-					'Severity: '.$severity.LF.
+								'Severity: ' . $severity . LF .
-					LF.$msg,
+								LF . $msg,
-					($from ? 'From: '.$from : '')
+					($from ? 'From: ' . $from : '')
 				);
 			}
 				// use the PHP error log
-			elseif ($type == 'error_log')	{
+			elseif ($type == 'error_log') {
-				error_log($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'].$msgLine, 0);
+				error_log($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'] . $msgLine, 0);
 			}
 				// use the system log
-			elseif ($type == 'syslog')	{
+			elseif ($type == 'syslog') {
-				$priority = array(LOG_INFO,LOG_NOTICE,LOG_WARNING,LOG_ERR,LOG_CRIT);
+				$priority = array(LOG_INFO, LOG_NOTICE, LOG_WARNING, LOG_ERR, LOG_CRIT);
-				syslog($priority[(int)$severity], $msgLine);
+				syslog($priority[(int) $severity], $msgLine);
 			}
 		}
 	}
@@ -5806,7 +5906,7 @@
 	 * The result is meant to make sense to developers during development or debugging of a site.
 	 * The idea is that this function is only a wrapper for external extensions which can set a hook which will be allowed to handle the logging of the information to any format they might wish and with any kind of filter they would like.
 	 * If you want to implement the devLog in your applications, simply add lines like:
-	 * 		if (TYPO3_DLOG)	t3lib_div::devLog('[write message in english here]', 'extension key');
+	 *		 if (TYPO3_DLOG)	t3lib_div::devLog('[write message in english here]', 'extension key');
 	 *
 	 * @param	string		Message (in english).
 	 * @param	string		Extension key (from which extension you are calling the log)
@@ -5814,14 +5914,14 @@
 	 * @param	array		Additional data you want to pass to the logger.
 	 * @return	void
 	 */
-	public static function devLog($msg, $extKey, $severity=0, $dataVar=FALSE)	{
+	public static function devLog($msg, $extKey, $severity = 0, $dataVar = FALSE) {
 		global $TYPO3_CONF_VARS;
 
-		if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['devLog']))	{
+		if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['devLog'])) {
-			$params = array('msg'=>$msg, 'extKey'=>$extKey, 'severity'=>$severity, 'dataVar'=>$dataVar);
+			$params = array('msg' => $msg, 'extKey' => $extKey, 'severity' => $severity, 'dataVar' => $dataVar);
 			$fakeThis = FALSE;
-			foreach($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['devLog'] as $hookMethod)	{
+			foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_div.php']['devLog'] as $hookMethod) {
-				self::callUserFunction($hookMethod,$params,$fakeThis);
+				self::callUserFunction($hookMethod, $params, $fakeThis);
 			}
 		}
 	}
@@ -5850,9 +5950,9 @@
 			$destination = self::getDeprecationLogFileName();
 			$file = @fopen($destination, 'a');
 			if ($file) {
-				flock($file, LOCK_EX);  // try locking, but ignore if not available (eg. on NFS and FAT)
+				flock($file, LOCK_EX); // try locking, but ignore if not available (eg. on NFS and FAT)
 				@fwrite($file, $date . $msg . LF);
-				flock($file, LOCK_UN);    // release the lock
+				flock($file, LOCK_UN); // release the lock
 				@fclose($file);
 			}
 		}
@@ -5875,11 +5975,11 @@
 	 */
 	public static function getDeprecationLogFileName() {
 		return PATH_typo3conf .
-			'deprecation_' .
-			self::shortMD5(
-				PATH_site . $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']
-			) .
-			'.log';
+				'deprecation_' .
+				self::shortMD5(
+					PATH_site . $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']
+				) .
+				'.log';
 	}
 
 	/**
@@ -5910,11 +6010,11 @@
 		if ($trail[1]['class']) {
 			$errorMsg .= ' of class ' . $trail[1]['class'];
 		}
-		$errorMsg .= ' is deprecated (called from '.$trail[1]['file'] . '#' . $trail[1]['line'] . ', defined in ' . $function->getFileName() . '#' . $function->getStartLine() . ')';
+		$errorMsg .= ' is deprecated (called from ' . $trail[1]['file'] . '#' . $trail[1]['line'] . ', defined in ' . $function->getFileName() . '#' . $function->getStartLine() . ')';
 
 			// write a longer message to the deprecation log: <function> <annotion> - <trace> (<source>)
 		$logMsg = $trail[1]['class'] . $trail[1]['type'] . $trail[1]['function'];
-		$logMsg .= '() - ' . $msg.' - ' . self::debug_trail();
+		$logMsg .= '() - ' . $msg . ' - ' . self::debug_trail();
 		$logMsg .= ' (' . substr($function->getFileName(), strlen(PATH_site)) . '#' . $function->getStartLine() . ')';
 		self::deprecationLog($logMsg);
 	}
@@ -5928,15 +6028,15 @@
 	 * @param	integer		Long string values are shortened to this length. Default: 20
 	 * @return	string		Output string with key names and their value as string
 	 */
-	public static function arrayToLogString(array $arr, $valueList=array(), $valueLength=20) {
+	public static function arrayToLogString(array $arr, $valueList = array(), $valueLength = 20) {
 		$str = '';
-		if (!is_array($valueList))	{
+		if (!is_array($valueList)) {
 			$valueList = self::trimExplode(',', $valueList, 1);
 		}
 		$valListCnt = count($valueList);
-		foreach ($arr as $key => $value)	{
+		foreach ($arr as $key => $value) {
-			if (!$valListCnt || in_array($key, $valueList))	{
+			if (!$valListCnt || in_array($key, $valueList)) {
-				$str .= (string)$key.trim(': '.self::fixed_lgd_cs(str_replace(LF,'|',(string)$value), $valueLength)).'; ';
+				$str .= (string) $key . trim(': ' . self::fixed_lgd_cs(str_replace(LF, '|', (string) $value), $valueLength)) . '; ';
 			}
 		}
 		return $str;
@@ -5950,35 +6050,39 @@
 	 * @param	string		Override the default path (e.g. used by the install tool)
 	 * @return	string		Compiled command that deals with IM6 & GraphicsMagick
 	 */
-	public static function imageMagickCommand($command, $parameters, $path='')	{
+	public static function imageMagickCommand($command, $parameters, $path = '') {
 		$gfxConf = $GLOBALS['TYPO3_CONF_VARS']['GFX'];
-		$isExt = (TYPO3_OS=='WIN' ? '.exe' : '');
+		$isExt = (TYPO3_OS == 'WIN' ? '.exe' : '');
-		$switchCompositeParameters=false;
+		$switchCompositeParameters = FALSE;
 
-		if(!$path)	{ $path = $gfxConf['im_path']; }
+		if (!$path) {
+			$path = $gfxConf['im_path'];
+		}
 		$path = self::fixWindowsFilePath($path);
 
 		$im_version = strtolower($gfxConf['im_version_5']);
 		$combineScript = $gfxConf['im_combine_filename'] ? trim($gfxConf['im_combine_filename']) : 'combine';
 
-		if($command==='combine')	{	// This is only used internally, has no effect outside
+		if ($command === 'combine') { // This is only used internally, has no effect outside
 			$command = 'composite';
 		}
 
 			// Compile the path & command
-		if($im_version==='gm')	{
+		if ($im_version === 'gm') {
-			$switchCompositeParameters=true;
+			$switchCompositeParameters = TRUE;
 			$path = escapeshellarg($path . 'gm' . $isExt) . ' ' . $command;
-		} else	{
+		} else {
-			if($im_version==='im6')	{ $switchCompositeParameters=true; }
+			if ($im_version === 'im6') {
+				$switchCompositeParameters = TRUE;
+			}
 			$path = escapeshellarg($path . (($command == 'composite') ? $combineScript : $command) . $isExt);
 		}
 
 			// strip profile information for thumbnails and reduce their size
 		if ($parameters && $command != 'identify' && $gfxConf['im_useStripProfileByDefault'] && $gfxConf['im_stripProfileCommand'] != '') {
-			if (strpos($parameters, $gfxConf['im_stripProfileCommand']) === false) {
+			if (strpos($parameters, $gfxConf['im_stripProfileCommand']) === FALSE) {
 					// Determine whether the strip profile action has be disabled by TypoScript:
-				if ($parameters !== '-version' && strpos($parameters, '###SkipStripProfile###') === false) {
+				if ($parameters !== '-version' && strpos($parameters, '###SkipStripProfile###') === FALSE) {
 					$parameters = $gfxConf['im_stripProfileCommand'] . ' ' . $parameters;
 				} else {
 					$parameters = str_replace('###SkipStripProfile###', '', $parameters);
@@ -5986,18 +6090,18 @@
 			}
 		}
 
-		$cmdLine = $path.' '.$parameters;
+		$cmdLine = $path . ' ' . $parameters;
 
-		if($command=='composite' && $switchCompositeParameters)	{	// Because of some weird incompatibilities between ImageMagick 4 and 6 (plus GraphicsMagick), it is needed to change the parameters order under some preconditions
+		if ($command == 'composite' && $switchCompositeParameters) { // Because of some weird incompatibilities between ImageMagick 4 and 6 (plus GraphicsMagick), it is needed to change the parameters order under some preconditions
 			$paramsArr = self::unQuoteFilenames($parameters);
 
-			if(count($paramsArr)>5)	{	// The mask image has been specified => swap the parameters
+			if (count($paramsArr) > 5) { // The mask image has been specified => swap the parameters
-				$tmp = $paramsArr[count($paramsArr)-3];
+				$tmp = $paramsArr[count($paramsArr) - 3];
-				$paramsArr[count($paramsArr)-3] = $paramsArr[count($paramsArr)-4];
+				$paramsArr[count($paramsArr) - 3] = $paramsArr[count($paramsArr) - 4];
-				$paramsArr[count($paramsArr)-4] = $tmp;
+				$paramsArr[count($paramsArr) - 4] = $tmp;
 			}
 
-			$cmdLine = $path.' '.implode(' ', $paramsArr);
+			$cmdLine = $path . ' ' . implode(' ', $paramsArr);
 		}
 
 		return $cmdLine;
@@ -6010,30 +6114,32 @@
 	 * @param	boolean		If set, the elements of the resulting array are unquoted.
 	 * @return	array		Exploded parameters
 	 */
-	public static function unQuoteFilenames($parameters,$unQuote=FALSE)	{
+	public static function unQuoteFilenames($parameters, $unQuote = FALSE) {
 		$paramsArr = explode(' ', trim($parameters));
 
-		$quoteActive = -1;	// Whenever a quote character (") is found, $quoteActive is set to the element number inside of $params. A value of -1 means that there are not open quotes at the current position.
+		$quoteActive = -1; // Whenever a quote character (") is found, $quoteActive is set to the element number inside of $params. A value of -1 means that there are not open quotes at the current position.
 		foreach ($paramsArr as $k => $v) {
-			if($quoteActive > -1)	{
+			if ($quoteActive > -1) {
-				$paramsArr[$quoteActive] .= ' '.$v;
+				$paramsArr[$quoteActive] .= ' ' . $v;
 				unset($paramsArr[$k]);
-				if(preg_match('/"$/', $v))	{ $quoteActive = -1; }
+				if (preg_match('/"$/', $v)) {
+					$quoteActive = -1;
+				}
 
-			} elseif(!trim($v))	{
+			} elseif (!trim($v)) {
-				unset($paramsArr[$k]);	// Remove empty elements
+				unset($paramsArr[$k]); // Remove empty elements
 
-			} elseif(preg_match('/^"/', $v))	{
+			} elseif (preg_match('/^"/', $v)) {
 				$quoteActive = $k;
 			}
 		}
 
-		if($unQuote) {
+		if ($unQuote) {
 			foreach ($paramsArr as $key => &$val) {
-				$val = preg_replace('/(^"|"$)/','',$val);
+				$val = preg_replace('/(^"|"$)/', '', $val);
 			}
 		}
-		// return reindexed array
+			// return reindexed array
 		return array_values($paramsArr);
 	}
 
@@ -6045,13 +6151,13 @@
 	 *
 	 * @param string $value the string to encode, may be empty
 	 * @param boolean $withinCData
-	 *        whether the escaped data is expected to be used as CDATA and thus
+	 *		whether the escaped data is expected to be used as CDATA and thus
-	 *        does not need to be htmlspecialchared
+	 *		does not need to be htmlspecialchared
 	 *
 	 * @return string the encoded value already quoted (with single quotes),
-	 *                will not be empty
+	 *				will not be empty
 	 */
-	static public function quoteJSvalue($value, $withinCData = false)	{
+	static public function quoteJSvalue($value, $withinCData = FALSE) {
 		$escapedValue = addcslashes(
 			$value, '\'' . '"' . '\\' . TAB . LF . CR
 		);
@@ -6068,7 +6174,9 @@
 	 * @return	void
 	 */
 	public static function cleanOutputBuffers() {
-		while (ob_end_clean());
+		while (ob_end_clean()) {
+			;
+		}
 		header('Content-Encoding: None', TRUE);
 	}
 
@@ -6081,7 +6189,9 @@
 	public static function flushOutputBuffers() {
 		$obContent = '';
 
-		while ($obContent .= ob_get_clean());
+		while ($obContent .= ob_get_clean()) {
+			;
+		}
 
 			// if previously a "Content-Encoding: whatever" has been set, we have to unset it
 		if (!headers_sent()) {
