Fixed issue #13670: Performance optimization: change while(list() to foreach() (thank...
authorErnesto Baschny <ernst@cron-it.de>
Thu, 13 May 2010 17:11:55 +0000 (17:11 +0000)
committerErnesto Baschny <ernst@cron-it.de>
Thu, 13 May 2010 17:11:55 +0000 (17:11 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@7592 709f56b5-9817-0410-a4d7-c38de5d9e867

32 files changed:
ChangeLog
t3lib/class.t3lib_admin.php
t3lib/class.t3lib_arraybrowser.php
t3lib/class.t3lib_basicfilefunc.php
t3lib/class.t3lib_bedisplaylog.php
t3lib/class.t3lib_befunc.php
t3lib/class.t3lib_clipboard.php
t3lib/class.t3lib_diff.php
t3lib/class.t3lib_div.php
t3lib/class.t3lib_extmgm.php
t3lib/class.t3lib_formmail.php
t3lib/class.t3lib_fullsearch.php
t3lib/class.t3lib_modsettings.php
t3lib/class.t3lib_parsehtml.php
t3lib/class.t3lib_parsehtml_proc.php
t3lib/class.t3lib_positionmap.php
t3lib/class.t3lib_querygenerator.php
t3lib/class.t3lib_readmail.php
t3lib/class.t3lib_recordlist.php
t3lib/class.t3lib_refindex.php
t3lib/class.t3lib_scbase.php
t3lib/class.t3lib_stdgraphic.php
t3lib/class.t3lib_superadmin.php
t3lib/class.t3lib_timetrack.php
t3lib/class.t3lib_transferdata.php
t3lib/class.t3lib_tsparser_ext.php
t3lib/class.t3lib_tsstyleconfig.php
t3lib/class.t3lib_tstemplate.php
t3lib/class.t3lib_userauthgroup.php
t3lib/class.t3lib_xml.php
t3lib/config_default.php
t3lib/stddb/load_ext_tables.php

index a7ff22c..0eb2217 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-05-13  Ernesto Baschny  <ernst@cron-it.de>
+
+       * Fixed issue #13670: Performance optimization: change while(list() to foreach() (thanks to Georg Ringer)
+
 2010-05-13  Steffen Kamper  <info@sk-typo3.de>
 
        * Fixed bug #12803: Creating or deleting ENABLE_INSTALL_TOOL file saves settings in "User Settings"
index 6ba9d5c..c603452 100644 (file)
@@ -314,10 +314,9 @@ class t3lib_admin {
         */
        function lostRecords($pid_list) {
                global $TCA;
-               reset($TCA);
                $this->lostPagesList='';
                if ($pid_list)  {
-                       while (list($table)=each($TCA)) {
+                       foreach ($TCA as $table => $tableConf) {
                                t3lib_div::loadTCA($table);
 
                                $pid_list_tmp = $pid_list;
@@ -373,11 +372,10 @@ class t3lib_admin {
         */
        function countRecords($pid_list)        {
                global $TCA;
-               reset($TCA);
                $list=Array();
                $list_n=Array();
                if ($pid_list)  {
-                       while (list($table)=each($TCA)) {
+                       foreach ($TCA as $table => $tableConf) {
                                t3lib_div::loadTCA($table);
 
                                $pid_list_tmp = $pid_list;
@@ -408,13 +406,11 @@ class t3lib_admin {
         */
        function getGroupFields($mode)  {
                global $TCA;
-               reset ($TCA);
                $result = Array();
-               while (list($table)=each($TCA)) {
+               foreach ($TCA as $table => $tableConf) {
                        t3lib_div::loadTCA($table);
                        $cols = $TCA[$table]['columns'];
-                       reset ($cols);
-                       while (list($field,$config)=each($cols))        {
+                       foreach ($cols as $field => $config) {
                                if ($config['config']['type']=='group') {
                                        if (
                                                ((!$mode||$mode=='file') && $config['config']['internal_type']=='file') ||
@@ -442,13 +438,11 @@ class t3lib_admin {
         */
        function getFileFields($uploadfolder)   {
                global $TCA;
-               reset ($TCA);
                $result = Array();
-               while (list($table)=each($TCA)) {
+               foreach ($TCA as $table => $tableConf) {
                        t3lib_div::loadTCA($table);
                        $cols = $TCA[$table]['columns'];
-                       reset ($cols);
-                       while (list($field,$config)=each($cols))        {
+                       foreach ($cols as $field => $config) {
                                if ($config['config']['type']=='group' && $config['config']['internal_type']=='file' && $config['config']['uploadfolder']==$uploadfolder)       {
                                        $result[]=Array($table,$field);
                                }
@@ -467,11 +461,10 @@ class t3lib_admin {
                global $TCA;
                $result = Array();
                reset ($TCA);
-               while (list($table)=each($TCA)) {
+               foreach ($TCA as $table => $tableConf) {
                        t3lib_div::loadTCA($table);
                        $cols = $TCA[$table]['columns'];
-                       reset ($cols);
-                       while (list($field,$config)=each($cols))        {
+                       foreach ($cols as $field => $config) {
                                if ($config['config']['type']=='group' && $config['config']['internal_type']=='db')     {
                                        if (trim($config['config']['allowed'])=='*' || strstr($config['config']['allowed'],$theSearchTable))    {
                                                $result[]=Array($table,$field);
@@ -494,8 +487,7 @@ class t3lib_admin {
        function selectNonEmptyRecordsWithFkeys($fkey_arrays)   {
                global $TCA;
                if (is_array($fkey_arrays))     {
-                       reset($fkey_arrays);
-                       while (list($table,$field_list)=each($fkey_arrays))     {
+                       foreach ($fkey_arrays as $table => $field_list) {
                                if ($TCA[$table] && trim($field_list))  {
                                        t3lib_div::loadTCA($table);
                                        $fieldArr = explode(',',$field_list);
@@ -506,7 +498,7 @@ class t3lib_admin {
                                                list(,$field)=each($fieldArr);
                                                $cl_fl = ($GLOBALS['TYPO3_DB']->MetaType($fields[$field]['type'],$table) == 'I' || $GLOBALS['TYPO3_DB']->MetaType($fields[$field]['type'],$table) == 'N' || $GLOBALS['TYPO3_DB']->MetaType($fields[$field]['type'],$table) == 'R') ?
                                                $field.'!=0' : $field.'!=\'\'';
-                                               while (list(,$field)=each($fieldArr))   {
+                                               foreach ($fieldArr as $field) {
                                                        $cl_fl .= ($GLOBALS['TYPO3_DB']->MetaType($fields[$field]['type'],$table) == 'I' || $GLOBALS['TYPO3_DB']->MetaType($fields[$field]['type'],$table) == 'N' || $GLOBALS['TYPO3_DB']->MetaType($fields[$field]['type'],$table) == 'R') ?
                                                        ' OR '.$field.'!=0' : ' OR '.$field.'!=\'\'';
                                                }
@@ -518,8 +510,7 @@ class t3lib_admin {
 
                                        $mres = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,'.$field_list, $table, $cl_fl);
                                        while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($mres))     {
-                                               reset($fieldArr);
-                                               while (list(,$field)=each($fieldArr))   {
+                                               foreach ($fieldArr as $field) {
                                                        if (trim($row[$field]))         {
                                                                $fieldConf = $TCA[$table]['columns'][$field]['config'];
                                                                if ($fieldConf['type']=='group')        {
@@ -529,8 +520,7 @@ class t3lib_admin {
                                                                                        $tempArr=array();
                                                                                        $dbAnalysis = t3lib_div::makeInstance('t3lib_loadDBGroup');
                                                                                        $dbAnalysis->start('','files',$fieldConf['MM'],$row['uid']);
-                                                                                       reset($dbAnalysis->itemArray);
-                                                                                       while (list($somekey,$someval)=each($dbAnalysis->itemArray))    {
+                                                                                       foreach ($dbAnalysis->itemArray as $somekey => $someval) {
                                                                                                if ($someval['id'])     {
                                                                                                        $tempArr[]=$someval['id'];
                                                                                                }
@@ -538,8 +528,7 @@ class t3lib_admin {
                                                                                } else {
                                                                                        $tempArr = explode(',',trim($row[$field]));
                                                                                }
-                                                                               reset($tempArr);
-                                                                               while (list(,$file)=each($tempArr))     {
+                                                                               foreach ($tempArr as $file) {
                                                                                        $file = trim($file);
                                                                                        if ($file)      {
                                                                                                $this->checkFileRefs[$fieldConf['uploadfolder']][$file]+=1;
@@ -550,8 +539,7 @@ class t3lib_admin {
                                                                                // dbs - group
                                                                                $dbAnalysis = t3lib_div::makeInstance('t3lib_loadDBGroup');
                                                                                $dbAnalysis->start($row[$field],$fieldConf['allowed'],$fieldConf['MM'],$row['uid'], $table, $fieldConf);
-                                                                               reset($dbAnalysis->itemArray);
-                                                                               while (list(,$tempArr)=each($dbAnalysis->itemArray))    {
+                                                                               foreach ($dbAnalysis->itemArray as $tempArr) {
                                                                                        $this->checkGroupDBRefs[$tempArr['table']][$tempArr['id']]+=1;
                                                                                }
                                                                        }
@@ -560,8 +548,7 @@ class t3lib_admin {
                                                                        // dbs - select
                                                                        $dbAnalysis = t3lib_div::makeInstance('t3lib_loadDBGroup');
                                                                        $dbAnalysis->start($row[$field],$fieldConf['foreign_table'],$fieldConf['MM'],$row['uid'], $table, $fieldConf);
-                                                                       reset($dbAnalysis->itemArray);
-                                                                       while (list(,$tempArr)=each($dbAnalysis->itemArray))    {
+                                                                       foreach ($dbAnalysis->itemArray as $tempArr) {
                                                                                if ($tempArr['id']>0)   {
                                                                                        $this->checkGroupDBRefs[$fieldConf['foreign_table']][$tempArr['id']]+=1;
                                                                                }
@@ -570,6 +557,7 @@ class t3lib_admin {
                                                        }
                                                }
                                        }
+                                       $GLOBALS['TYPO3_DB']->sql_free_result($mres);
                                }
                        }
                }
@@ -607,8 +595,7 @@ class t3lib_admin {
                }
                $this->checkFileRefs = $newCheckFileRefs;
 
-               reset($this->checkFileRefs);
-               while(list($folder,$fileArr)=each($this->checkFileRefs))        {
+               foreach ($this->checkFileRefs as $folder => $fileArr) {
                        $path = PATH_site.$folder;
                        if (@is_dir($path))     {
                                $d = dir($path);
@@ -618,7 +605,7 @@ class t3lib_admin {
                                                        if ($fileArr[$entry] > 1)       {
                                                                $temp = $this->whereIsFileReferenced($folder,$entry);
                                                                $tempList = '';
-                                                               while(list(,$inf)=each($temp))  {
+                                                               foreach ($temp as $inf) {
                                                                        $tempList.='['.$inf['table'].']['.$inf['uid'].']['.$inf['field'].'] (pid:'.$inf['pid'].') - ';
                                                                }
                                                                $output['moreReferences'][] = Array($path,$entry,$fileArr[$entry],$tempList);
@@ -633,9 +620,8 @@ class t3lib_admin {
                                        }
                                }
                                $d->close();
-                               reset($fileArr);
                                $tempCounter=0;
-                               while(list($file,)=each($fileArr))      {
+                               foreach ($fileArr as $file => $value) {
                                                // workaround for direct file references
                                        if (preg_match('/^' . preg_quote($GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'], '/') . '/', $folder)) {
                                                $file = $folder . '/' . $file;
@@ -644,7 +630,7 @@ class t3lib_admin {
                                        }
                                        $temp = $this->whereIsFileReferenced($folder,$file);
                                        $tempList = '';
-                                       while(list(,$inf)=each($temp))  {
+                                       foreach ($temp as $inf) {
                                                $tempList.='['.$inf['table'].']['.$inf['uid'].']['.$inf['field'].'] (pid:'.$inf['pid'].') - ';
                                        }
                                        $tempCounter++;
@@ -665,13 +651,10 @@ class t3lib_admin {
         */
        function testDBRefs($theArray)  {
                global $TCA;
-               reset($theArray);
-               while(list($table,$dbArr)=each($theArray))      {
+               foreach ($theArray as $table => $dbArr) {
                        if ($TCA[$table])       {
-                               $idlist = Array();
-                               while(list($id,)=each($dbArr))  {
-                                       $idlist[]=$id;
-                               }
+                               $idlist = array_keys($dbArr); 
+
                                $theList = implode(',',$idlist);
                                if ($theList)   {
                                        $mres = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', $table, 'uid IN ('.$theList.')'.t3lib_BEfunc::deleteClause($table));
@@ -682,8 +665,7 @@ class t3lib_admin {
                                                        $result.='Strange Error. ...<br />';
                                                }
                                        }
-                                       reset($dbArr);
-                                       while (list($theId,$theC)=each($dbArr)) {
+                                       foreach ($dbArr as $theId => $theC) {
                                                $result.='There are '.$theC.' records pointing to this missing or deleted record; ['.$table.']['.$theId.']<br />';
                                        }
                                }
@@ -705,7 +687,7 @@ class t3lib_admin {
                global $TCA;
                $fileFields = $this->getDBFields($searchTable); // Gets tables / Fields that reference to files...
                $theRecordList=Array();
-               while (list(,$info)=each($fileFields))  {
+               foreach ($fileFields as $info) {
                        $table=$info[0];        $field=$info[1];
                        t3lib_div::loadTCA($table);
                        $mres = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
@@ -720,13 +702,13 @@ class t3lib_admin {
 
                                $dbAnalysis = t3lib_div::makeInstance('t3lib_loadDBGroup');
                                $dbAnalysis->start($row[$field],$allowedTables,$fieldConf['MM'],$row['uid'], $table, $fieldConf);
-                               reset($dbAnalysis->itemArray);
-                               while (list(,$tempArr)=each($dbAnalysis->itemArray))    {
+                               foreach ($dbAnalysis->itemArray as $tempArr) {
                                        if ($tempArr['table']==$searchTable && $tempArr['id']==$id)     {
                                                $theRecordList[]=Array('table'=>$table,'uid'=>$row['uid'],'field'=>$field,'pid'=>$row['pid']);
                                        }
                                }
                        }
+                       $GLOBALS['TYPO3_DB']->sql_free_result($mres);
                }
                return $theRecordList;
        }
@@ -742,7 +724,7 @@ class t3lib_admin {
                global $TCA;
                $fileFields = $this->getFileFields($uploadfolder);      // Gets tables / Fields that reference to files...
                $theRecordList=Array();
-               while (list(,$info)=each($fileFields))  {
+               foreach ($fileFields as $info) {
                        $table=$info[0];        $field=$info[1];
                        $mres = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
                                                        'uid,pid,'.$TCA[$table]['ctrl']['label'].','.$field,
@@ -752,7 +734,7 @@ class t3lib_admin {
                        while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($mres))     {
                                // Now this is the field, where the reference COULD come from. But we're not garanteed, so we must carefully examine the data.
                                $tempArr = explode(',',trim($row[$field]));
-                               while (list(,$file)=each($tempArr))     {
+                               foreach ($tempArr as $file) {
                                        $file = trim($file);
                                        if ($file==$filename)   {
                                                $theRecordList[]=Array('table'=>$table,'uid'=>$row['uid'],'field'=>$field,'pid'=>$row['pid']);
index 998b5eb..e593c8d 100644 (file)
@@ -101,8 +101,7 @@ class t3lib_arrayBrowser    {
                if ($depth_in)  {$depth_in = $depth_in.'.';}
 
                $c=count($arr);
-               reset($arr);
-               while (list($key,)=each($arr))  {
+               foreach ($arr as $key => $value) {
                        $a++;
                        $depth = $depth_in.$key;
                        $goto = 'a' . substr(md5($depth), 0, 6);
@@ -199,10 +198,9 @@ class t3lib_arrayBrowser   {
         * @return      array
         */
        function getSearchKeys($keyArr, $depth_in, $searchString, $keyArray)            {
-               reset($keyArr);
                $c=count($keyArr);
                if ($depth_in)  {$depth_in = $depth_in.'.';}
-               while (list($key,)=each($keyArr))       {
+               foreach ($keyArr as $key => $value) {
                        $depth=$depth_in.$key;
                        $deeper = is_array($keyArr[$key]);
 
@@ -251,21 +249,19 @@ class t3lib_arrayBrowser  {
         */
        function depthKeys($arr,$settings)      {
                $tsbrArray=array();
-               reset($arr);
-               while(list($theK,$theV)=each($arr))     {
+               foreach ($arr as $theK => $theV) {
                        $theKeyParts = explode('.',$theK);
                        $depth='';
                        $c=count($theKeyParts);
                        $a=0;
-                       while(list(,$p)=each($theKeyParts))     {
+                       foreach ($theKeyParts as $p) {
                                $a++;
                                $depth.=($depth?'.':'').$p;
                                $tsbrArray[$depth]= ($c==$a) ? $theV : 1;
                        }
                }
                        // Modify settings
-               reset($tsbrArray);
-               while(list($theK,$theV)=each($tsbrArray))       {
+               foreach ($tsbrArray as $theK => $theV) {
                        if ($theV)      {
                                $settings[$theK] = 1;
                        } else {
index e3157e0..f9e42c8 100644 (file)
@@ -324,8 +324,7 @@ class t3lib_basicFileFunctions      {
         */
        function checkPathAgainstMounts($thePath)       {
                if ($thePath && $this->isPathValid($thePath) && is_array($this->mounts))        {
-                       reset ($this->mounts);
-                       while(list($k,$val)=each($this->mounts))        {
+                       foreach ($this->mounts as $k => $val) {
                                if (t3lib_div::isFirstPartOfStr($thePath,$val['path'])) {
                                        return $k;
                                }
@@ -342,8 +341,7 @@ class t3lib_basicFileFunctions      {
                global $TYPO3_CONF_VARS;
 
                if (is_array($this->mounts))    {
-                       reset ($this->mounts);
-                       while(list($k,$val)=each($this->mounts))        {
+                       foreach ($this->mounts as $k => $val) {
                                if (t3lib_div::isFirstPartOfStr($val['path'], PATH_site.$TYPO3_CONF_VARS['BE']['fileadminDir']))        {
                                        return $k;
                                }
@@ -376,8 +374,7 @@ class t3lib_basicFileFunctions      {
         */
        function findTempFolder()       {
                if ($this->tempFN && is_array($this->mounts))   {
-                       reset ($this->mounts);
-                       while(list($k,$val)=each($this->mounts))        {
+                       foreach ($this->mounts as $k => $val) {
                                $tDir = $val['path'].$this->tempFN;
                                if (@is_dir($tDir))     {
                                        return $tDir;
index eadd833..3e076cd 100644 (file)
@@ -268,7 +268,7 @@ class t3lib_BEDisplayLog {
         */
        function stripPath($inArr)      {
                if ($this->stripPath && is_array($inArr))       {
-                       while(list($key,$val)=each($inArr))     {
+                       foreach ($inArr as $key => $val) {
                                $inArr[$key]=basename($val);
                        }
                }
index 3013053..9cc2f69 100644 (file)
@@ -392,7 +392,7 @@ final class t3lib_BEfunc {
                $list = Array();
                if ((string)trim($in_list)!='') {
                        $tempItemArray = explode(',', trim($in_list));
-                       while(list($key, $val) = each($tempItemArray)) {
+                       foreach ($tempItemArray as $key => $val) {
                                $val = strrev($val);
                                $parts = explode('_', $val, 2);
                                if ((string)trim($parts[0])!='') {
@@ -1069,8 +1069,7 @@ final class t3lib_BEfunc {
        public static function getSpecConfParametersFromArray($pArr) {
                $out = array();
                if (is_array($pArr)) {
-                       reset($pArr);
-                       while(list($k, $v) = each($pArr)) {
+                       foreach ($pArr as $k => $v) {
                                $parts = explode('=', $v, 2);
                                if (count($parts)==2) {
                                        $out[trim($parts[0])] = trim($parts[1]);
@@ -1390,9 +1389,8 @@ final class t3lib_BEfunc {
                        if (!is_array($impParams)) {
                                $impParams =t3lib_BEfunc::implodeTSParams(t3lib_BEfunc::getPagesTSconfig($id));
                        }
-                       reset($pageTS);
                        $set = array();
-                       while(list($f, $v) = each($pageTS)) {
+                       foreach ($pageTS as $f => $v) {
                                $f = $TSconfPrefix.$f;
                                if ((!isset($impParams[$f])&&trim($v)) || strcmp(trim($impParams[$f]), trim($v))) {
                                        $set[$f] = trim($v);
@@ -1404,11 +1402,9 @@ final class t3lib_BEfunc {
                                $TSlines = explode(LF, $pRec['TSconfig']);
                                $TSlines = array_reverse($TSlines);
                                        // Reset the set of changes.
-                               reset($set);
-                               while(list($f, $v) = each($set)) {
-                                       reset($TSlines);
+                               foreach ($set as $f => $v) {
                                        $inserted = 0;
-                                       while(list($ki, $kv) = each($TSlines)) {
+                                       foreach ($TSlines as $ki => $kv) {
                                                if (substr($kv, 0, strlen($f)+1)==$f.'=') {
                                                        $TSlines[$ki] = $f.'='.$v;
                                                        $inserted = 1;
@@ -1442,8 +1438,7 @@ final class t3lib_BEfunc {
        public static function implodeTSParams($p, $k = '') {
                $implodeParams = array();
                if (is_array($p)) {
-                       reset($p);
-                       while(list($kb, $val) = each($p)) {
+                       foreach ($p as $kb => $val) {
                                if (is_array($val)) {
                                        $implodeParams = array_merge($implodeParams, t3lib_BEfunc::implodeTSParams($val, $k.$kb));
                                } else {
@@ -1537,12 +1532,11 @@ final class t3lib_BEfunc {
         */
        public static function blindUserNames($usernames, $groupArray, $excludeBlindedFlag = 0) {
                if (is_array($usernames) && is_array($groupArray)) {
-                       while(list($uid, $row) = each($usernames)) {
+                       foreach ($usernames as $uid => $row) {
                                $userN = $uid;
                                $set = 0;
                                if ($row['uid']!=$GLOBALS['BE_USER']->user['uid']) {
-                                       reset($groupArray);
-                                       while(list(,$v) = each($groupArray)) {
+                                       foreach ($groupArray as $v) {
                                                if ($v && t3lib_div::inList($row['usergroup_cached_list'], $v)) {
                                                        $userN = $row['username'];
                                                        $set = 1;
@@ -1570,7 +1564,7 @@ final class t3lib_BEfunc {
         */
        public static function blindGroupNames($groups, $groupArray, $excludeBlindedFlag = 0) {
                if (is_array($groups) && is_array($groupArray)) {
-                       while(list($uid, $row) = each($groups)) {
+                       foreach ($groups as $uid => $row) {
                                $groupN = $uid;
                                $set = 0;
                                if (t3lib_div::inArray($groupArray, $uid)) {
@@ -1773,7 +1767,7 @@ final class t3lib_BEfunc {
                        // Traverse files:
                $thumbs = explode(',', $row[$field]);
                $thumbData = '';
-               while(list(,$theFile) = each($thumbs)) {
+               foreach ($thumbs as $theFile) {
                        if (trim($theFile)) {
                                $fI = t3lib_div::split_fileref($theFile);
                                $ext = $fI['fileext'];
@@ -1999,8 +1993,7 @@ final class t3lib_BEfunc {
                        // Check, if there is an "items" array:
                if (is_array($TCA[$table]) && is_array($TCA[$table]['columns'][$col]) && is_array($TCA[$table]['columns'][$col]['config']['items'])) {
                                // Traverse the items-array...
-                       reset($TCA[$table]['columns'][$col]['config']['items']);
-                       while(list($k, $v) = each($TCA[$table]['columns'][$col]['config']['items'])) {
+                       foreach ($TCA[$table]['columns'][$col]['config']['items'] as $k => $v) {
                                        // ... and return the first found label where the value was equal to $key
                                if (!strcmp($v[1], $key))       return $v[0];
                        }
@@ -2218,9 +2211,8 @@ final class t3lib_BEfunc {
                                                                $l = $value;
                                                        } else {
                                                                $rParts = t3lib_div::trimExplode(',', $value, 1);
-                                                               reset($rParts);
                                                                $lA = array();
-                                                               while(list(,$rVal) = each($rParts)) {
+                                                               foreach ($rParts as $rVal) {
                                                                        $rVal = intval($rVal);
                                                                        if ($rVal>0) {
                                                                                $r = t3lib_BEfunc::getRecordWSOL($theColConf['foreign_table'], $rVal);
@@ -2245,9 +2237,8 @@ final class t3lib_BEfunc {
                                        if (!is_array($theColConf['items']) || count($theColConf['items'])==1) {
                                                $l = $value ? $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:yes') : $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:no');
                                        } else {
-                                               reset($theColConf['items']);
                                                $lA = Array();
-                                               while(list($key, $val) = each($theColConf['items'])) {
+                                               foreach ($theColConf['items'] as $key => $val) {
                                                        if ($value & pow(2, $key))      {$lA[] = $GLOBALS['LANG']->sL($val[0]);}
                                                }
                                                $l = implode(', ', $lA);
@@ -2413,9 +2404,8 @@ final class t3lib_BEfunc {
        public static function makeConfigForm($configArray, $defaults, $dataPrefix) {
                $params = $defaults;
                if (is_array($configArray)) {
-                       reset($configArray);
                        $lines = array();
-                       while(list($fname, $config) = each($configArray)) {
+                       foreach ($configArray as $fname => $config) {
                                if (is_array($config)) {
                                        $lines[$fname] = '<strong>'.htmlspecialchars($config[1]).'</strong><br />';
                                        $lines[$fname].=$config[2].'<br />';
@@ -2431,9 +2421,8 @@ final class t3lib_BEfunc {
                                                        $formEl = '';
                                                break;
                                                case 'select':
-                                                       reset($config[3]);
                                                        $opt = array();
-                                                       while(list($k, $v) = each($config[3])) {
+                                                       foreach ($config[3] as $k => $v) {
                                                                $opt[] = '<option value="'.htmlspecialchars($k).'"'.($params[$fname]==$k?' selected="selected"':'').'>'.htmlspecialchars($v).'</option>';
                                                        }
                                                        $formEl = '<select name="'.$dataPrefix.'['.$fname.']">'.implode('', $opt).'</select>';
@@ -2838,8 +2827,7 @@ final class t3lib_BEfunc {
                        // Getting TS-config options for this module for the Backend User:
                $conf = $GLOBALS['BE_USER']->getTSConfig($TSref, $modTSconfig);
                if (is_array($conf['properties'])) {
-                       reset($conf['properties']);
-                       while(list($key, $val) = each($conf['properties'])) {
+                       foreach ($conf['properties'] as $key => $val) {
                                if (!$val) {
                                        unset($itemArray[$key]);
                                }
@@ -3172,7 +3160,7 @@ final class t3lib_BEfunc {
                $fTWHERE = $fieldValue['config'][$prefix.'foreign_table_where'];
                if (strstr($fTWHERE, '###REC_FIELD_')) {
                        $fTWHERE_parts = explode('###REC_FIELD_', $fTWHERE);
-                       while(list($kk, $vv) = each($fTWHERE_parts)) {
+                       foreach ($fTWHERE_parts as $kk => $vv) {
                                if ($kk) {
                                        $fTWHERE_subpart = explode('###', $vv, 2);
                                        $fTWHERE_parts[$kk] = $TSconfig['_THIS_ROW'][$fTWHERE_subpart[0]].$fTWHERE_subpart[1];
@@ -3258,7 +3246,7 @@ final class t3lib_BEfunc {
                if ($TScID>=0) {
                        $tempConf = $GLOBALS['BE_USER']->getTSConfig('TCEFORM.'.$table, t3lib_BEfunc::getPagesTSconfig($TScID, $rootLine));
                        if (is_array($tempConf['properties'])) {
-                               while(list($key, $val) = each($tempConf['properties'])) {
+                               foreach ($tempConf['properties'] as $key => $val) {
                                        if (is_array($val)) {
                                                $fieldN = substr($key, 0, -1);
                                                $res[$fieldN] = $val;
@@ -3275,8 +3263,7 @@ final class t3lib_BEfunc {
                $res['_THIS_CID'] = $row['cid'];
                $res['_THIS_ROW'] = $row;       // So the row will be passed to foreign_table_where_query()
 
-               reset($rootLine);
-               while(list(,$rC) = each($rootLine)) {
+               foreach ($rootLine as $rC) {
                        if (!$res['_STORAGE_PID'])      $res['_STORAGE_PID'] = intval($rC['storage_pid']);
                        if (!$res['_SITEROOT']) $res['_SITEROOT'] = $rC['is_siteroot']?intval($rC['uid']):0;
                }
@@ -3371,8 +3358,7 @@ final class t3lib_BEfunc {
         */
        public static function firstDomainRecord($rootLine) {
                if (t3lib_extMgm::isLoaded('cms')) {
-                       reset($rootLine);
-                       while(list(,$row) = each($rootLine)) {
+                       foreach ($rootLine as $row) {
                                $dRec = t3lib_BEfunc::getRecordsByField('sys_domain', 'pid', $row['uid'], ' AND redirectTo=\'\' AND hidden=0', '', 'sorting');
                                if (is_array($dRec)) {
                                        reset($dRec);
@@ -3546,14 +3532,13 @@ final class t3lib_BEfunc {
         * @return      boolean
         */
        public static function isModuleSetInTBE_MODULES($modName) {
-               reset($GLOBALS['TBE_MODULES']);
                $loaded = array();
 
-               while(list($mkey, $list) = each($GLOBALS['TBE_MODULES'])) {
+               foreach ($GLOBALS['TBE_MODULES'] as $mkey => $list) {
                        $loaded[$mkey] = 1;
                        if (!is_array($list) && trim($list)) {
                                $subList = t3lib_div::trimExplode(',', $list, 1);
-                               while(list(,$skey) = each($subList)) {
+                               foreach ($subList as $skey) {
                                        $loaded[$mkey.'_'.$skey] = 1;
                                }
                        }
@@ -4137,7 +4122,7 @@ final class t3lib_BEfunc {
                        );
                }
                $cNotice = '<a href="http://typo3.com/" target="_blank">' .
-                       '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/loginlogo_transp.gif', 'width="75" height="19" vspace="2" hspace="4"') . ' alt="' . 
+                       '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/loginlogo_transp.gif', 'width="75" height="19" vspace="2" hspace="4"') . ' alt="' .
                        $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_login.xml:typo3.logo') . '" align="left" />' .
                        $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_login.xml:typo3.cms') . ' ' .
                        $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_login.xml:version.short') . ' ' .
@@ -4379,7 +4364,7 @@ final class t3lib_BEfunc {
        public static function processParams($params) {
                $paramArr = array();
                $lines = explode(LF, $params);
-               while(list(,$val) = each($lines)) {
+               foreach ($lines as $val) {
                        $val = trim($val);
                        if ($val) {
                                $pair = explode('=', $val, 2);
index 56e06cf..33c23a4 100644 (file)
@@ -195,8 +195,7 @@ class t3lib_clipboard {
         */
        function setCmd($cmd)   {
                if (is_array($cmd['el']))       {
-                       reset($cmd['el']);
-                       while(list($k,$v)=each($cmd['el']))     {
+                       foreach ($cmd['el'] as $k => $v) {
                                if ($this->current=='normal')   {
                                        unset($this->clipData['normal']);
                                }
@@ -270,8 +269,7 @@ class t3lib_clipboard {
         */
        function cleanUpCBC($CBarr,$table,$removeDeselected=0)  {
                if (is_array($CBarr))   {
-                       reset($CBarr);
-                       while(list($k,$v)=each($CBarr)) {
+                       foreach ($CBarr as $k => $v) {
                                $p=explode('|',$k);
                                if ((string)$p[0]!=(string)$table || ($removeDeselected && !$v))        {
                                        unset($CBarr[$k]);
@@ -424,8 +422,7 @@ class t3lib_clipboard {
 
                $lines=array();
                if (is_array($this->clipData[$pad]['el']))      {
-                       reset($this->clipData[$pad]['el']);
-                       while(list($k,$v)=each($this->clipData[$pad]['el']))    {
+                       foreach ($this->clipData[$pad]['el'] as $k => $v) {
                                if ($v) {
                                        list($table,$uid) = explode('|',$k);
                                        $bgColClass = ($table=='_FILE'&&$this->fileMode)||($table!='_FILE'&&!$this->fileMode) ? 'bgColor4-20' : 'bgColor4';
@@ -664,9 +661,8 @@ class t3lib_clipboard {
         */
        function editUrl()      {
                $elements = $this->elFromTable('');     // all records
-               reset($elements);
                $editCMDArray=array();
-               while(list($tP)=each($elements))        {
+               foreach ($elements as $tP => $value) {
                        list($table,$uid) = explode('|',$tP);
                        $editCMDArray[] = '&edit['.$table.']['.$uid.']=edit';
                }
@@ -762,8 +758,7 @@ class t3lib_clipboard {
 
                        // Traverse items:
                if (is_array($this->clipData[$pad]['el']))      {
-                       reset($this->clipData[$pad]['el']);
-                       while(list($k,$v)=each($this->clipData[$pad]['el']))    {
+                       foreach ($this->clipData[$pad]['el'] as $k => $v) {
                                if ($v) {
                                        list($table,$uid) = explode('|',$k);
 
@@ -837,8 +832,7 @@ class t3lib_clipboard {
         */
        function cleanCurrent() {
                if (is_array($this->clipData[$this->current]['el']))    {
-                       reset($this->clipData[$this->current]['el']);
-                       while(list($k,$v)=each($this->clipData[$this->current]['el']))  {
+                       foreach ($this->clipData[$this->current]['el'] as $k => $v) {
                                list($table,$uid) = explode('|',$k);
                                if ($table!='_FILE')    {
                                        if (!$v || !is_array(t3lib_BEfunc::getRecord($table,$uid,'uid')))       {
@@ -866,8 +860,7 @@ class t3lib_clipboard {
                $pad = $pad ? $pad : $this->current;
                $list=array();
                if (is_array($this->clipData[$pad]['el']))      {
-                       reset($this->clipData[$pad]['el']);
-                       while(list($k,$v)=each($this->clipData[$pad]['el']))    {
+                       foreach ($this->clipData[$pad]['el'] as $k => $v) {
                                if ($v) {
                                        list($table,$uid) = explode('|',$k);
                                        if ($table!='_FILE')    {
@@ -977,8 +970,7 @@ class t3lib_clipboard {
                        $mode = $this->currentMode()=='copy' ? 'copy' : 'move';
 
                                // Traverse elements and make CMD array
-                       reset($elements);
-                       while(list($tP)=each($elements))        {
+                       foreach ($elements as $tP => $value) {
                                list($table,$uid) = explode('|',$tP);
                                if (!is_array($CMD[$table]))    $CMD[$table]=array();
                                $CMD[$table][$uid][$mode]=$pUid;
@@ -997,8 +989,7 @@ class t3lib_clipboard {
         */
        function makeDeleteCmdArray($CMD)       {
                $elements = $this->elFromTable('');     // all records
-               reset($elements);
-               while(list($tP)=each($elements))        {
+               foreach ($elements as $tP => $value) {
                        list($table,$uid) = explode('|',$tP);
                        if (!is_array($CMD[$table]))    $CMD[$table]=array();
                        $CMD[$table][$uid]['delete']=1;
@@ -1044,8 +1035,7 @@ class t3lib_clipboard {
                $mode = $this->currentMode()=='copy' ? 'copy' : 'move';
 
                        // Traverse elements and make CMD array
-               reset($elements);
-               while(list($tP,$path)=each($elements))  {
+               foreach ($elements as $tP => $path) {
                        $FILE[$mode][]=array('data'=>$path,'target'=>$pUid,'altName'=>1);
                        if ($mode=='move')      $this->removeElement($tP);
                }
@@ -1063,8 +1053,7 @@ class t3lib_clipboard {
        function makeDeleteCmdArray_file($FILE) {
                $elements = $this->elFromTable('_FILE');
                        // Traverse elements and make CMD array
-               reset($elements);
-               while(list($tP,$path)=each($elements))  {
+               foreach ($elements as $tP => $path) {
                        $FILE['delete'][]=array('data'=>$path);
                        $this->removeElement($tP);
                }
index 999c5b1..ccc8587 100644 (file)
@@ -97,11 +97,10 @@ class t3lib_diff {
                $diffRes = $this->getDiff(implode(LF,$str1Lines).LF,implode(LF,$str2Lines).LF);
 
                if (is_array($diffRes)) {
-                       reset($diffRes);
                        $c=0;
                        $diffResArray=array();
                        $differenceStr = '';
-                       while(list(,$lValue)=each($diffRes))    {
+                       foreach ($diffRes as $lValue) {
                                if (intval($lValue))    {
                                        $c=intval($lValue);
                                        $diffResArray[$c]['changeInfo']=$lValue;
@@ -205,8 +204,7 @@ class t3lib_diff {
        function explodeStringIntoWords($str)   {
                $strArr = t3lib_div::trimExplode(LF,$str);
                $outArray=array();
-               reset($strArr);
-               while(list(,$lineOfWords)=each($strArr))        {
+               foreach ($strArr as $lineOfWords) {
                        $allWords = t3lib_div::trimExplode(' ',$lineOfWords,1);
                        $outArray = array_merge($outArray,$allWords);
                        $outArray[]='';
index 2638dcd..0e6a13c 100644 (file)
@@ -1370,14 +1370,13 @@ final class t3lib_div {
                $reg = array();
                preg_match_all('/'.$regex.'/',$string,$reg);
 
-               reset($reg[2]);
                $number=0;
                $Msign='+';
                $err='';
                $buffer=doubleval(current($reg[2]));
                next($reg[2]);  // Advance pointer
 
-               while(list($k,$v)=each($reg[2])) {
+               foreach ($reg[2] as $k => $v) {
                        $v=doubleval($v);
                        $sign = $reg[1][$k];
                        if ($sign=='+' || $sign=='-')   {
index ef71f79..3b5a389 100644 (file)
@@ -670,8 +670,7 @@ final class t3lib_extMgm {
                                        case 'after':
                                        case 'before':
                                                $pointer = 0;
-                                               reset($mods);
-                                               while(list($k, $m) = each($mods)) {
+                                               foreach ($mods as $k => $m) {
                                                        if (!strcmp($m, $modRef)) {
                                                                $pointer = strtolower($place)=='after'?$k+1:$k;
                                                        }
@@ -1013,8 +1012,7 @@ final class t3lib_extMgm {
 
                t3lib_div::loadTCA('tt_content');
                if (is_array($TCA['tt_content']['columns']) && is_array($TCA['tt_content']['columns'][$type]['config']['items'])) {
-                       reset($TCA['tt_content']['columns'][$type]['config']['items']);
-                       while(list($k, $v) = each($TCA['tt_content']['columns'][$type]['config']['items'])) {
+                       foreach ($TCA['tt_content']['columns'][$type]['config']['items'] as $k => $v) {
                                if (!strcmp($v[1], $itemArray[1])) {
                                        $TCA['tt_content']['columns'][$type]['config']['items'][$k] = $itemArray;
                                        return;
@@ -1465,8 +1463,7 @@ $TYPO3_LOADED_EXT = unserialize(stripslashes(\''.addslashes(serialize($extension
 
 ?>';
 
-               reset($extensions);
-               while(list($key, $conf) = each($extensions)) {
+               foreach ($extensions as $key => $conf) {
                        if (is_array($conf)) {
                                if ($conf['ext_localconf.php']) {
                                        $cFiles['ext_localconf'].=t3lib_extMgm::_makeIncludeHeader($key, $conf['ext_localconf.php']);
index ff0d144..ac6b8c8 100644 (file)
@@ -141,8 +141,7 @@ class t3lib_formmail extends t3lib_htmlmail {
 
                                // Runs through $V and generates the mail
                        if (is_array($V))       {
-                               reset($V);
-                               while (list($key,$val)=each($V))        {
+                               foreach ($V as $key => $val) {
                                        if (!t3lib_div::inList($this->reserved_names,$key))     {
                                                $space = (strlen($val)>60)?LF:'';
                                                $val = (is_array($val) ? implode($val,LF) : $val);
index 7a2a987..88b8e0a 100644 (file)
@@ -127,8 +127,7 @@ class t3lib_fullsearch {
 
                        // Store Array:
                $opt=array();
-               reset($storeArray);
-               while(list($k,$v)=each($storeArray))    {
+               foreach ($storeArray as $k => $v) {
                        $opt[]='<option value="'.$k.'"'.(!strcmp($cur,$v)?' selected':'').'>'.htmlspecialchars($v).'</option>';
                }
 
@@ -181,8 +180,7 @@ class t3lib_fullsearch {
         */
        function cleanStoreQueryConfigs($storeQueryConfigs,$storeArray) {
                if (is_array($storeQueryConfigs))       {
-                       reset($storeQueryConfigs);
-                       while(list($k,$v)=each($storeQueryConfigs))     {
+                       foreach ($storeQueryConfigs as $k => $v) {
                                if (!isset($storeArray[$k]))    unset($storeQueryConfigs[$k]);
                        }
                }
@@ -198,9 +196,8 @@ class t3lib_fullsearch {
         */
        function addToStoreQueryConfigs($storeQueryConfigs,$index)      {
                $keyArr = explode(',',$this->storeList);
-               reset($keyArr);
                $storeQueryConfigs[$index]=array();
-               while(list(,$k)=each($keyArr))  {
+               foreach ($keyArr as $k) {
                        $storeQueryConfigs[$index][$k]=$GLOBALS['SOBE']->MOD_SETTINGS[$k];
                }
                return $storeQueryConfigs;
@@ -215,9 +212,8 @@ class t3lib_fullsearch {
        function saveQueryInAction($uid)        {
                if (t3lib_extMgm::isLoaded('sys_action'))       {
                        $keyArr = explode(',',$this->storeList);
-                       reset($keyArr);
                        $saveArr=array();
-                       while(list(,$k)=each($keyArr))  {
+                       foreach ($keyArr as $k) {
                                $saveArr[$k]=$GLOBALS['SOBE']->MOD_SETTINGS[$k];
                        }
 
@@ -264,8 +260,7 @@ class t3lib_fullsearch {
        function loadStoreQueryConfigs($storeQueryConfigs,$storeIndex,$writeArray)      {
                if ($storeQueryConfigs[$storeIndex])    {
                        $keyArr = explode(',',$this->storeList);
-                       reset($keyArr);
-                       while(list(,$k)=each($keyArr))  {
+                       foreach ($keyArr => $k) {
                                $writeArray[$k]=$storeQueryConfigs[$storeIndex][$k];
                        }
                }
@@ -599,8 +594,7 @@ class t3lib_fullsearch {
                $limit=200;
                $showAlways=0;
                if ($swords)    {
-                       reset($TCA);
-                       while(list($table)=each($TCA))  {
+                       foreach ($TCA as $table => $value) {
                                        // Get fields list
                                t3lib_div::loadTCA($table);
                                $conf=$TCA[$table];
@@ -610,11 +604,7 @@ class t3lib_fullsearch {
                                        continue;
                                }
 
-                               reset($conf['columns']);
-                               $list=array();
-                               while(list($field,)=each($conf['columns']))     {
-                                       $list[]=$field;
-                               }
+                               $list = array_keys($conf['columns']);
                                        // Get query
                                $qp = $GLOBALS['TYPO3_DB']->searchQuery(array($swords), $list, $table);
 
@@ -657,8 +647,7 @@ class t3lib_fullsearch {
                $SET = $GLOBALS['SOBE']->MOD_SETTINGS;
                $out='<tr class="bgColor' . ($even ? '6' : '4') . '">';
                $even = !$even;
-               reset($row);
-               while(list($fN,$fV)=each($row)) {
+               foreach ($row as $fN => $fV) {
                        if (t3lib_div::inList($SET['queryFields'], $fN) || (!$SET['queryFields'] && $fN!='pid' && $fN!='deleted'))      {
                                if ($SET['search_result_labels'])       {
                                        $fVnew = $this->getProcessedValueExtra($table, $fN, $fV, $conf, '<br />');
index 028aff8..acaef9e 100644 (file)
@@ -247,8 +247,7 @@ class t3lib_modSettings {
 
                $prefix = $prefix ? $prefix : $this->prefix;
 
-               reset($SOBE->MOD_SETTINGS);
-               while(list($key)=each($SOBE->MOD_SETTINGS))     {
+               foreach ($SOBE->MOD_SETTINGS as $key => $value) {
                        if (preg_match('/^'.$prefix.'/',$key)) {
                                $this->storeList[$key]=$key;
                        }
index 17fd2ee..fce5b29 100644 (file)
@@ -794,8 +794,7 @@ class t3lib_parsehtml       {
                                                                if (is_array($tags[$tagName]['fixAttrib']))     {
                                                                        $tagAttrib = $this->get_tag_attributes($tagParts[1]);
                                                                        $tagParts[1]='';
-                                                                       reset($tags[$tagName]['fixAttrib']);
-                                                                       while(list($attr,$params)=each($tags[$tagName]['fixAttrib']))   {
+                                                                       foreach ($tags[$tagName]['fixAttrib'] as $attr => $params) {
                                                                                if (strlen($params['set']))     $tagAttrib[0][$attr] = $params['set'];
                                                                                if (strlen($params['unset']))   unset($tagAttrib[0][$attr]);
                                                                                if (strcmp($params['default'],'') && !isset($tagAttrib[0][$attr]))      $tagAttrib[0][$attr]=$params['default'];
@@ -1262,22 +1261,19 @@ class t3lib_parsehtml   {
 
                        // Set config properties.
                if (is_array($TSconfig['tags.']))       {
-                       reset($TSconfig['tags.']);
-                       while(list($key,$tagC)=each($TSconfig['tags.']))        {
+                       foreach ($TSconfig['tags.'] as $key => $tagC) {
                                if (!is_array($tagC) && $key==strtolower($key)) {
                                        if (!strcmp($tagC,'0')) unset($keepTags[$key]);
                                        if (!strcmp($tagC,'1') && !isset($keepTags[$key]))      $keepTags[$key]=1;
                                }
                        }
 
-                       reset($TSconfig['tags.']);
                        foreach ($TSconfig['tags.'] as $key => $tagC)   {
                                if (is_array($tagC) && $key==strtolower($key))  {
                                        $key=substr($key,0,-1);
                                        if (!is_array($keepTags[$key])) $keepTags[$key]=array();
                                        if (is_array($tagC['fixAttrib.']))      {
-                                               reset($tagC['fixAttrib.']);
-                                               while(list($atName,$atConfig)=each($tagC['fixAttrib.']))        {
+                                               foreach ($tagC['fixAttrib.'] as $atName => $atConfig) {
                                                        if (is_array($atConfig))        {
                                                                $atName=substr($atName,0,-1);
                                                                if (!is_array($keepTags[$key]['fixAttrib'][$atName]))   {
@@ -1298,7 +1294,7 @@ class t3lib_parsehtml     {
                        // localNesting
                if ($TSconfig['localNesting'])  {
                        $lN = t3lib_div::trimExplode(',',strtolower($TSconfig['localNesting']),1);
-                       while(list(,$tn)=each($lN))     {
+                       foreach ($lN as $tn) {
                                if (isset($keepTags[$tn]))      {
                                        $keepTags[$tn]['nesting']=1;
                                }
@@ -1306,7 +1302,7 @@ class t3lib_parsehtml     {
                }
                if ($TSconfig['globalNesting']) {
                        $lN = t3lib_div::trimExplode(',',strtolower($TSconfig['globalNesting']),1);
-                       while(list(,$tn)=each($lN))     {
+                       foreach ($lN as $tn) {
                                if (isset($keepTags[$tn]))      {
                                        if (!is_array($keepTags[$tn]))  $keepTags[$tn]=array();
                                        $keepTags[$tn]['nesting']='global';
@@ -1315,7 +1311,7 @@ class t3lib_parsehtml     {
                }
                if ($TSconfig['rmTagIfNoAttrib'])       {
                        $lN = t3lib_div::trimExplode(',',strtolower($TSconfig['rmTagIfNoAttrib']),1);
-                       while(list(,$tn)=each($lN))     {
+                       foreach ($lN as $tn) {
                                if (isset($keepTags[$tn]))      {
                                        if (!is_array($keepTags[$tn]))  $keepTags[$tn]=array();
                                        $keepTags[$tn]['rmTagIfNoAttrib']=1;
@@ -1324,7 +1320,7 @@ class t3lib_parsehtml     {
                }
                if ($TSconfig['noAttrib'])      {
                        $lN = t3lib_div::trimExplode(',',strtolower($TSconfig['noAttrib']),1);
-                       while(list(,$tn)=each($lN))     {
+                       foreach ($lN as $tn) {
                                if (isset($keepTags[$tn]))      {
                                        if (!is_array($keepTags[$tn]))  $keepTags[$tn]=array();
                                        $keepTags[$tn]['allowedAttribs']=0;
@@ -1333,7 +1329,7 @@ class t3lib_parsehtml     {
                }
                if ($TSconfig['removeTags'])    {
                        $lN = t3lib_div::trimExplode(',',strtolower($TSconfig['removeTags']),1);
-                       while(list(,$tn)=each($lN))     {
+                       foreach ($lN as $tn) {
                                $keepTags[$tn]=array();
                                $keepTags[$tn]['allowedAttribs']=0;
                                $keepTags[$tn]['rmTagIfNoAttrib']=1;
@@ -1419,8 +1415,7 @@ class t3lib_parsehtml     {
                                if (!strcmp($tagName,'img') && !isset($tagAttrib[0]['alt']))            $tagAttrib[0]['alt']='';        // Set alt attribute for all images (not XHTML though...)
                                if (!strcmp($tagName,'script') && !isset($tagAttrib[0]['type']))        $tagAttrib[0]['type']='text/javascript';        // Set type attribute for all script-tags
                                $outA=array();
-                               reset($tagAttrib[0]);
-                               while(list($attrib_name,$attrib_value)=each($tagAttrib[0]))     {
+                               foreach ($tagAttrib[0] as $attrib_name => $attrib_value) {
                                                // Set attributes: lowercase, always in quotes, with htmlspecialchars converted.
                                        $outA[]=$attrib_name.'="'.$this->bidir_htmlspecialchars($attrib_value,2).'"';
                                }
index 1caae12..db9b4e3 100644 (file)
@@ -601,8 +601,7 @@ class t3lib_parsehtml_proc extends t3lib_parsehtml {
                        case 'db':
                                $siteURL = $this->siteUrl();
                                $blockSplit = $this->splitIntoBlock('A',$value);
-                               reset($blockSplit);
-                               while(list($k,$v)=each($blockSplit))    {
+                               foreach ($blockSplit as $k => $v) {
                                        if ($k%2)       {       // block:
                                                $attribArray=$this->get_tag_attributes_classic($this->getFirstTag($v),1);
                                                        // If the url is local, remove url-prefix
@@ -855,7 +854,7 @@ class t3lib_parsehtml_proc extends t3lib_parsehtml {
                                                if (!$css)      {
                                                        if (!isset($this->procOptions['typolist']) || $this->procOptions['typolist'])   {
                                                                $parts = $this->getAllParts($this->splitIntoBlock('LI',$this->removeFirstAndLastTag($blockSplit[$k])),1,0);
-                                                               while(list($k2)=each($parts))   {
+                                                               foreach ($parts as $k2 => $value) {
                                                                        $parts[$k2]=preg_replace('/['.preg_quote(LF.CR).']+/','',$parts[$k2]);  // remove all linesbreaks!
                                                                        $parts[$k2]=$this->defaultTStagMapping($parts[$k2],'db');
                                                                        $parts[$k2]=$this->cleanFontTags($parts[$k2],0,0,0);
@@ -1256,8 +1255,7 @@ class t3lib_parsehtml_proc extends t3lib_parsehtml {
                                        }
 
                                                // Traverse sublines (there is typically one, except if <br/> has been converted to lines as well!)
-                                       reset($subLines);
-                                       while(list($sk)=each($subLines))        {
+                                       foreach ($subLines as $sk => $value) {
 
                                                        // Clear up the subline for DB.
                                                $subLines[$sk]=$this->HTMLcleaner_db($subLines[$sk]);
@@ -1588,8 +1586,7 @@ class t3lib_parsehtml_proc extends t3lib_parsehtml {
         */
        function TS_AtagToAbs($value,$dontSetRTEKEEP=FALSE)     {
                $blockSplit = $this->splitIntoBlock('A',$value);
-               reset($blockSplit);
-               while(list($k,$v)=each($blockSplit))    {
+               foreach ($blockSplit as $k => $v) {
                        if ($k%2)       {       // block:
                                $attribArray = $this->get_tag_attributes_classic($this->getFirstTag($v),1);
 
index f47e19b..6d6f3d5 100644 (file)
@@ -367,7 +367,7 @@ class t3lib_positionMap {
                $codeA = t3lib_div::trimExplode(',',$codes.",line",1);
 
                $lines=array();
-               while(list(,$code)=each($codeA))        {
+               foreach ($codeA as $code) {
                        if ($code=="blank" || $allBlank)        {
                                $lines[]='<img src="clear.gif" width="18" height="8" align="top" alt="" />';
                        } else {
@@ -407,7 +407,7 @@ class t3lib_positionMap {
                $colPosArray = t3lib_div::trimExplode(',',$colPosList,1);
 
                $lines=array();
-               while(list($kk,$vv)=each($colPosArray)) {
+               foreach ($colPosArray as $kk => $vv) {
                        $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
                                                        '*',
                                                        'tt_content',
index 6ad5800..1a22c9f 100644 (file)
@@ -249,8 +249,7 @@ class t3lib_queryGenerator  {
                $fieldListArr = array();
                if (is_array($TCA[$this->table]))       {
                        t3lib_div::loadTCA($this->table);
-                       reset($TCA[$this->table]['columns']);
-                       while(list($fN)=each($TCA[$this->table]['columns']))    {
+                       foreach ($TCA[$this->table]['columns'] as $fN => $value)
                                $fieldListArr[]=$fN;
                        }
                        $fieldListArr[]='uid';
@@ -283,8 +282,7 @@ class t3lib_queryGenerator  {
                        $this->fieldList = $fieldList ? $fieldList : $this->makeFieldList();
 
                        $fieldArr = t3lib_div::trimExplode(',',$this->fieldList,1);
-                       reset($fieldArr);
-                       while(list(,$fN)=each($fieldArr))       {
+                       foreach ($fieldArr as $fN) {
                                $fC = $TCA[$this->table]['columns'][$fN];
                                $this->fields[$fN] = $fC['config'];
                                $this->fields[$fN]['exclude'] = $fC['exclude'];
@@ -411,9 +409,8 @@ class t3lib_queryGenerator  {
         */
        function setAndCleanUpExternalLists($name,$list,$force='')      {
                $fields = array_unique(t3lib_div::trimExplode(',',$list.','.$force,1));
-               reset($fields);
                $reList=array();
-               while(list(,$fN)=each($fields)) {
+               foreach ($fields as $fN) {
                        if ($this->fields[$fN])         $reList[]=$fN;
                }
                $this->extFieldLists[$name]=implode(',',$reList);
@@ -537,10 +534,9 @@ class t3lib_queryGenerator {
                        if(!$queryConfig[0] || !$queryConfig[0]['type']) $queryConfig[0] = array('type'=>'FIELD_');
                }
                        // Traverse:
-               reset($queryConfig);
                $c=0;
                $arrCount=0;
-               while(list($key,$conf)=each($queryConfig))      {
+               foreach ($queryConfig as $key => $conf) {
                        if(substr($conf['type'],0,6)=='FIELD_') {
                                $fName = substr($conf['type'],6);
                                $fType = $this->fields[$fName]['type'];
@@ -589,10 +585,9 @@ class t3lib_queryGenerator {
                $codeArr=array();
                if (!is_array($queryConfig))    $queryConfig=$this->queryConfig;
 
-               reset($queryConfig);
                $c=0;
                $arrCount=0;
-               while(list($key,$conf)=each($queryConfig))      {
+               foreach ($queryConfig as $key => $conf) {
                        $subscript = $parent.'['.$key.']';
                        $lineHTML = '';
                        $lineHTML.=$this->mkOperatorSelect($this->name.$subscript,$conf['operator'],$c,($conf['type']!='FIELD_'));
@@ -953,12 +948,11 @@ class t3lib_queryGenerator        {
  * @return     [type]          ...
  */
        function printCodeArray($codeArr,$l=0)  {
-               reset($codeArr);
                $line='';
                if ($l)         $indent='<td style="vertical-align:top;"><img height="1" width="50"></td>';
                $lf=$l*30;
                $bgColor = t3lib_div::modifyHTMLColor($GLOBALS['TBE_TEMPLATE']->bgColor2,$lf,$lf,$lf);
-               while(list($k,$v)=each($codeArr))       {
+               foreach ($codeArr as $k => $v) {
                        $line.= '<tr>'.$indent.'<td bgcolor="'.$bgColor.'"'.$this->noWrap.'>'.$v['html'].'</td></tr>';
                        if ($this->enableQueryParts)    {$line.= '<tr>'.$indent.'<td>'.$this->formatQ($v['query']).'</td></tr>';}
                        if (is_array($v['sub']))        {
@@ -1013,8 +1007,7 @@ class t3lib_queryGenerator        {
        function mkTypeSelect($name,$fieldName,$prepend='FIELD_')       {
                $out='<select name="'.$name.'" onChange="submit();">';
                $out.='<option value=""></option>';
-               reset($this->fields);
-               while(list($key,)=each($this->fields)) {
+               foreach ($this->fields as $key => $value) {
                        if (!$fieldValue['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields', $this->table.':'.$key)) {
                                $label = $this->fields[$key]['label'];
                                $label_alt = $this->fields[$key]['label_alt'];
@@ -1032,9 +1025,8 @@ class t3lib_queryGenerator        {
         * @return      [type]          ...
         */
        function verifyType($fieldName) {
-               reset($this->fields);
                $first = '';
-               while(list($key,)=each($this->fields)) {
+               foreach ($this->fields as $key => $value) {
                        if (!$first)    $first = $key;
                        if ($key==$fieldName) return $key;
                }
@@ -1071,8 +1063,7 @@ class t3lib_queryGenerator        {
                $out='<input type="Text" value="'.htmlspecialchars($fieldName).'" name="'.$name.'"'.$GLOBALS['TBE_TEMPLATE']->formWidth().'>'.$this->updateIcon();
                $out.='<a href="#" onClick="document.forms[0][\''.$name.'\'].value=\'\';return false;"><img ' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/garbage.gif', 'width="11" height="12"') . ' class="absmiddle" title="Clear list" border="0"></a>';
                $out.='<BR><select name="_fieldListDummy" size="5" onChange="document.forms[0][\''.$name.'\'].value+=\',\'+this.value">';
-               reset($this->fields);
-               while(list($key,)=each($this->fields)) {
+               foreach ($this->fields as $key => $value) {
                        if (!$fieldValue['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields', $this->table.':'.$key)) {
                                $label = $this->fields[$key]['label'];
                                $label_alt = $this->fields[$key]['label_alt'];
@@ -1094,8 +1085,7 @@ class t3lib_queryGenerator        {
                global $TCA;
                $out='<select name="'.$name.'" onChange="submit();">';
                $out.='<option value=""></option>';
-               reset($TCA);
-               while(list($tN)=each($TCA)) {
+               foreach ($TCA as $tN => $value) {
                        if ($GLOBALS['BE_USER']->check('tables_select',$tN))    {
                                $out.='<option value="'.$tN.'"'.($tN==$cur ? ' selected':'').'>'.$GLOBALS['LANG']->sl($TCA[$tN]['ctrl']['title']).'</option>';
                        }
@@ -1178,9 +1168,8 @@ class t3lib_queryGenerator        {
                $qs = '';
                        // Since we don't traverse the array using numeric keys in the upcoming whileloop make sure it's fresh and clean
                ksort($queryConfig);
-               reset($queryConfig);
                $first=1;
-               while(list($key,$conf) = each($queryConfig)) {
+               foreach ($queryConfig as $key => $conf) {
                        switch($conf['type']) {
                                case 'newlevel':
                                        $qs.=LF.$pad.trim($conf['operator']).' ('.$this->getQuery($queryConfig[$key]['nl'],$pad.'   ').LF.$pad.')';
@@ -1333,9 +1322,8 @@ class t3lib_queryGenerator        {
                        if ($this->extFieldLists['queryOrder']) {
                                $descParts = explode(',',$modSettings['queryOrderDesc'].','.$modSettings['queryOrder2Desc']);
                                $orderParts = explode(',',$this->extFieldLists['queryOrder']);
-                               reset($orderParts);
                                $reList=array();
-                               while(list($kk,$vv)=each($orderParts))  {
+                               foreach ($orderParts as $kk => $vv) {
                                        $reList[]=$vv.($descParts[$kk]?' DESC':'');
                                }
                                $this->extFieldLists['queryOrder_SQL'] = implode(',',$reList);
index ca4f867..67a2c0f 100644 (file)
@@ -153,9 +153,8 @@ class t3lib_readmail {
        function getMailBoundaryParts($boundary,$content)       {
                $mParts = explode('--'.$boundary,$content);
                unset($mParts[0]);
-               reset($mParts);
                $new=array();
-               while(list(,$val)=each($mParts))        {
+               foreach ($mParts as $val) {
                        if (trim($val)=='--') break;
                        $new[] = ltrim($val);
                }
@@ -371,7 +370,7 @@ class t3lib_readmail {
                $lines=explode(LF,ltrim($content));
                $headers=array();
                $p='';
-               while(list($k,$str)=each($lines))               {
+               foreach ($lines as $k => $str) {
                        if (!trim($str))        break;  // header finished
                        $parts = explode(' ',$str,2);
                        if ($parts[0] && substr($parts[0],-1)==':')     {
@@ -406,12 +405,12 @@ class t3lib_readmail {
 
                        // Decoding header values which potentially can be encoded by =?...?=
                $list = explode(',','subject,thread-topic,from,to');
-               while(list(,$headerType)=each($list))   {
+               foreach ($list as $headerType) {
                        if (isset($mailParts[$headerType]))     $mailParts[$headerType]=$this->decodeHeaderString($mailParts[$headerType]);
                }
                        // Separating email/names from header fields which can contain email addresses.
                $list = explode(',','from,to,reply-to,sender,return-path');
-               while(list(,$headerType)=each($list))   {
+               foreach ($list as $headerType) {
                        if (isset($mailParts[$headerType]))     {
                                $mailParts['_'.strtoupper($headerType)]=$this->extractNameEmail($mailParts[$headerType]);
                        }
@@ -449,8 +448,7 @@ class t3lib_readmail {
                                        $contentSectionParts = t3lib_div::trimExplode('--'.$mailParts['_CONTENT_TYPE_DAT']['boundary'],$mailParts['CONTENT'],1);
                                        $contentSectionParts_proc=array();
 
-                                       reset($contentSectionParts);
-                                       while(list($k,$v)=each($contentSectionParts))   {
+                                       foreach ($contentSectionParts as $k => $v) {
                                                if (substr($v,0,2)=='--')       break;
                                                $contentSectionParts_proc[$k]=$this->fullParse($v);
                                        }
index df1ab36..fb86cb4 100644 (file)
@@ -170,8 +170,7 @@ class t3lib_recordList {
                $ccount=0;
 
                        // Traverse field array which contains the data to present:
-               reset($this->fieldArray);
-               while(list(,$vKey)=each($this->fieldArray))     {
+               foreach ($this->fieldArray as $vKey) {
                        if (isset($data[$vKey]))        {
                                if ($lastKey)   {
                                        $cssClass = $this->addElement_tdCssClass[$lastKey];
index 15ed193..d10d80f 100644 (file)
@@ -931,8 +931,7 @@ class t3lib_refindex {
                                        unset($wl[$row['baseword']]);
                                }
 
-                               reset($wl);
-                               while(list($key,$val)=each($wl)) {
+                               foreach ($wl as $key => $val) {
                                        $insertFields = array(
                                                'wid' => t3lib_div::md5int($key),
                                                'baseword' => $key
index 8de6f99..4ab41f8 100644 (file)
@@ -292,8 +292,7 @@ class t3lib_SCbase {
        function mergeExternalItems($modName,$menuKey,$menuArr) {
                $mergeArray = $GLOBALS['TBE_MODULES_EXT'][$modName]['MOD_MENU'][$menuKey];
                if (is_array($mergeArray))      {
-                       reset($mergeArray);
-                       while(list($k,$v)=each($mergeArray))    {
+                       foreach ($mergeArray as $k => $v) {
                                if ((string)$v['ws']==='' ||
                                        ($GLOBALS['BE_USER']->workspace===0 && t3lib_div::inList($v['ws'],'online')) ||
                                        ($GLOBALS['BE_USER']->workspace===-1 && t3lib_div::inList($v['ws'],'offline')) ||
index eb248e6..8427c48 100644 (file)
@@ -785,7 +785,7 @@ class t3lib_stdGraphic      {
                        $x=0;
                        if (!$spacing && $wordSpacing)  {
                                $bits = explode(' ',$theText);
-                               while(list(,$word)=each($bits)) {
+                               foreach ($bits as $word) {
                                        $word.=' ';
                                        $wordInf = $this->ImageTTFBBoxWrapper($conf['fontSize'], $conf['angle'], $conf['fontFile'], $word, $conf['splitRendering.'],$sF);
                                        $wordW = ($wordInf[2]-$wordInf[0]);
@@ -908,8 +908,7 @@ class t3lib_stdGraphic      {
 
                if (!$spacing && $wordSpacing)  {
                        $bits = explode(' ',$text);
-                       reset($bits);
-                       while(list(,$word)=each($bits)) {
+                       foreach ($bits as $word) {
                                $word.=' ';
                                $word = $word;
                                $wordInf = $this->ImageTTFBBoxWrapper($fontSize, $angle, $fontFile, $word, $splitRenderingConf ,$sF);
@@ -1653,7 +1652,7 @@ class t3lib_stdGraphic    {
                if (!trim($setup)){return '';}
                $effects = explode('|', $setup);
                $commands = '';
-               while(list(,$val)=each($effects))       {
+               foreach ($effects as $val) {
                        $pairs=explode('=',$val,2);
                        $value = trim($pairs[1]);
                        $effect = strtolower(trim($pairs[0]));
@@ -1736,7 +1735,7 @@ class t3lib_stdGraphic    {
                $setup = $conf['value'];
                if (!trim($setup)){return '';}
                $effects = explode('|', $setup);
-               while(list(,$val)=each($effects))       {
+               foreach ($effects as $val) {
                        $pairs=explode('=',$val,2);
                        $value = trim($pairs[1]);
                        $effect = strtolower(trim($pairs[0]));
@@ -2635,7 +2634,7 @@ class t3lib_stdGraphic    {
                        if ($splitstring)       {
                                preg_match('/([^\.]*)$/',$imagefile,$reg);
                                $splitinfo = explode(' ', $splitstring);
-                               while (list($key,$val) = each($splitinfo))      {
+                               foreach ($splitinfo as $key => $val) {
                                        $temp = '';
                                        if ($val) {$temp = explode('x', $val);}
                                        if (intval($temp[0]) && intval($temp[1]))       {
index 229181e..3637627 100644 (file)
@@ -457,9 +457,8 @@ class t3lib_superadmin {
                        if (@is_dir($dir))      {
                                $in_dirs = t3lib_div::get_dirs($dir);
                                asort($in_dirs);
-                               reset($in_dirs);
                                $dirArr=array();
-                               while(list($k,$v)=each($in_dirs))       {
+                               foreach ($in_dirs as $k => $v) {
                                        if (substr($v,0,9)!='typo3_src')        {
                                                $this->currentUrl = $baseUrl.'/'.$v;
                                                $content.= $this->headerSiteDir($v);
@@ -787,8 +786,7 @@ class t3lib_superadmin {
                                $mtimes = array();
 
                                        // Find most recent mtime of the options:
-                               reset($instances);
-                               while(list($k,$eInfo)=each($instances)) {
+                               foreach ($instances as $k => $eInfo) {
                                        $mtimes[] = $eInfo['mtime'];
                                }
                                        // Max mtime:
@@ -999,8 +997,7 @@ class t3lib_superadmin {
         * @return      array           Modified file array (or error string)
         */
        function removePrefixPathFromList($fileArr,$extPath)    {
-               reset($fileArr);
-               while(list($k,$absFileRef)=each($fileArr))      {
+               foreach ($fileArr as $k => $absFileRef) {
                        if(t3lib_div::isFirstPartOfStr($absFileRef,$extPath))   {
                                $fileArr[$k]=substr($absFileRef,strlen($extPath));
                        } else return 'ERROR: One or more of the files was NOT prefixed with the prefix-path!';
index 1b8612b..142a186 100644 (file)
@@ -398,8 +398,7 @@ class t3lib_timeTrack {
                        $keyLabel = '';
                        if (!$flag_tree && $data['stackPointer']) {
                                $temp = array();
-                               reset($data['tsStack']);
-                               while(list($k,$v)=each($data['tsStack'])) {
+                               foreach ($data['tsStack'] as $k => $v) {
                                        $temp[] = t3lib_div::fixed_lgd_cs(implode($v,$k?'.':'/'),-$keyLgd);
                                }
                                array_pop($temp);
@@ -438,8 +437,7 @@ class t3lib_timeTrack {
                        $msgArr = array();
                        $msg = '';
                        if ($flag_messages && is_array($data['message'])) {
-                               reset($data['message']);
-                               while(list(,$v)=each($data['message'])) {
+                               foreach ($data['message'] as $v) {
                                        $msgArr[] = nl2br($v);
                                }
                        }
@@ -481,16 +479,14 @@ class t3lib_timeTrack {
                $ac=0;
                $c=0;
                        // First, find number of entries
-               reset($arr);
-               while(list($k,$v)=each($arr)) {
+               foreach ($arr as $k => $v) {
                        if (t3lib_div::testInt($k)) {
                                $ac++;
                        }
                }
                        // Traverse through entries
                $subtime=0;
-               reset($arr);
-               while(list($k,$v)=each($arr)) {
+               foreach ($arr as $k => $v) {
                        if (t3lib_div::testInt($k)) {
                                $c++;
 
@@ -522,8 +518,7 @@ class t3lib_timeTrack {
                $content=$this->fixCLen($content, $this->tsStackLog[$vKey]['value']);
 
                        // Traverse array again, this time substitute the unique hash with the red key
-               reset($arr);
-               while(list($k,$v)=each($arr)) {
+               foreach ($arr as $k => $v) {
                        if (t3lib_div::testInt($k)) {
                                if (strlen($this->tsStackLog[$v]['content'])) {
                                        $content = str_replace($v, '<strong style="color:red;">['.$this->tsStackLog[$v]['key'].']</strong>', $content);
index 3cbbf3a..8a666b2 100644 (file)
@@ -197,7 +197,7 @@ class t3lib_transferData {
                                                        if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                                                                        // Gets the list of fields to copy from the previous record.
                                                                $fArr=t3lib_div::trimExplode(',',$TCA[$table]['ctrl']['useColumnsForDefaultValues'],1);
-                                                               while(list(,$theF)=each($fArr)) {
+                                                               foreach ($fArr as $theF) {
                                                                        if (isset($TCA[$table]['columns'][$theF]))      {
                                                                                $newRow[$theF]=$row[$theF];
                                                                        }
index f6c8128..453d1ea 100644 (file)
@@ -191,8 +191,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate   {
        function flattenSetup($setupArray, $prefix, $resourceFlag)      {
                if (is_array($setupArray))      {
                        $this->getFileName_backPath=PATH_site;          // Setting absolute prefixed path for relative resources.
-                       reset($setupArray);
-                       while(list($key,$val)=each($setupArray))        {
+                       foreach ($setupArray as $key => $val) {
                                if ($prefix || substr($key,0,16)!='TSConstantEditor')   {               // We don't want 'TSConstantEditor' in the flattend setup.
                                        if (is_array($val))     {
                                                $this->flattenSetup($val,$prefix.$key, ($key=='file.'));
@@ -298,8 +297,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate   {
 
                $c=0;
                $cc=count($this->constants);
-               reset($this->constants);
-               while (list(,$str)=each($this->constants))      {
+               foreach ($this->constants as $str) {
                        $c++;
                        if ($c==$cc)    {
                                if (strstr($str,$this->edit_divider))   {
@@ -360,13 +358,12 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
                $HTML='';
                $a=0;
 
-               reset($arr);
                if($alphaSort == '1')   {
                        ksort($arr);
                }
                $keyArr_num=array();
                $keyArr_alpha=array();
-               while (list($key,)=each($arr))  {
+               foreach ($arr as $key => $value) {
                        if (substr($key,-2)!='..')      {       // Don't do anything with comments / linenumber registrations...
                                $key=preg_replace('/\.$/','',$key);
                                if (substr($key,-1)!='.')       {
@@ -380,11 +377,10 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
                }
                ksort($keyArr_num);
                $keyArr=$keyArr_num+$keyArr_alpha;
-               reset($keyArr);
                $c=count($keyArr);
                if ($depth_in)  {$depth_in = $depth_in.'.';}
 
-               while (list($key,)=each($keyArr))       {
+               foreach ($keyArr as $key => $value) {
                        $a++;
                        $depth=$depth_in.$key;
                        if ($this->bType!='const' || substr($depth,0,1)!='_')   {               // this excludes all constants starting with '_' from being shown.
@@ -507,18 +503,16 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
         * @return      [type]          ...
         */
        function ext_getSearchKeys($arr, $depth_in, $searchString, $keyArray)           {
-               reset($arr);
                $keyArr=array();
-               while (list($key,)=each($arr))  {
+               foreach ($arr as $key => $value) {
                        $key=preg_replace('/\.$/','',$key);
                        if (substr($key,-1)!='.')       {
                                $keyArr[$key]=1;
                        }
                }
-               reset($keyArr);
                $c=count($keyArr);
                if ($depth_in)  { $depth_in = $depth_in.'.'; }
-               while (list($key,)=each($keyArr))       {
+               foreach ($keyArr as $key => $value) {
                        $depth=$depth_in.$key;
                        $deeper = is_array($arr[$key.'.']);
 
@@ -563,8 +557,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate   {
         */
        function ext_getRootlineNumber($pid)    {
                if ($pid && is_array($GLOBALS['rootLine']))     {
-                       reset($GLOBALS['rootLine']);
-                       while(list($key,$val)=each($GLOBALS['rootLine']))       {
+                       foreach ($GLOBALS['rootLine'] as $key => $val) {
                                if ($val['uid']==$pid)  return $key;
                        }
                }
@@ -580,19 +573,17 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
         * @return      [type]          ...
         */
        function ext_getTemplateHierarchyArr($arr,$depthData, $keyArray,$first=0)       {
-               reset($arr);
                $keyArr=array();
-               while (list($key,)=each($arr))  {
+               foreach ($arr as $key => $value) {
                        $key=preg_replace('/\.$/','',$key);
                        if (substr($key,-1)!='.')       {
                                $keyArr[$key]=1;
                        }
                }
-               reset($keyArr);
                $a=0;
                $c=count($keyArr);
                static $i;
-               while (list($key,)=each($keyArr))       {
+               foreach ($keyArr as $key => $value) {
                        $HTML = '';
                        $a++;
                        $deeper = is_array($arr[$key . '.']);
@@ -679,8 +670,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate   {
         */
        function ext_outputTS($config, $lineNumbers=0, $comments=0, $crop=0, $syntaxHL=0, $syntaxHLBlockmode=0) {
                $all='';
-               reset($config);
-               while (list(,$str)=each($config))       {
+               foreach ($config as $str) {
                        $all .= LF .'[GLOBAL]' . LF . $str;
                }
 
@@ -742,10 +732,9 @@ class t3lib_tsparser_ext extends t3lib_TStemplate  {
                $input = chop($input);
                $cArr = explode(LF,$input);
 
-               reset($cArr);
                $n = ceil(log10(count($cArr)+$this->ext_lineNumberOffset));
                $lineNum='';
-               while(list($k,$v)=each($cArr))  {
+               foreach ($cArr as $k => $v) {
                        $lln=$k+$this->ext_lineNumberOffset+1;
                        if ($ln)        $lineNum = $this->ext_lnBreakPointWrap($lln,str_replace(' ','&nbsp;',sprintf('% '.$n.'d',$lln))).':   ';
                        $v=htmlspecialchars($v);
@@ -820,15 +809,15 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
        function ext_compareFlatSetups($default)        {
                $editableComments=array();
                reset($this->flatSetup);
-               while(list($const,$value)=each($this->flatSetup))       {
+               foreach ($this->flatSetup as $const => $value) {
                        if (substr($const,-2)!='..' && isset($this->flatSetup[$const.'..']))    {
                                $comment = trim($this->flatSetup[$const.'..']);
                                $c_arr = explode(LF,$comment);
-                               while(list($k,$v)=each($c_arr)) {
+                               foreach ($c_arr as $k => $v) {
                                        $line=trim(preg_replace('/^[#\/]*/','',$v));
                                        if ($line)      {
                                                $parts = explode(';', $line);
-                                               while(list(,$par)=each($parts))         {
+                                               foreach ($parts as $par) {
                                                        if (strstr($par,'='))   {
                                                                $keyValPair =explode('=',$par,2);
                                                                switch(trim(strtolower($keyValPair[0])))        {
@@ -893,14 +882,12 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
         */
        function ext_categorizeEditableConstants($editConstArray)       {
                // Runs through the available constants and fills the $this->categories array with pointers and priority-info
-               reset($editConstArray);
-               while(list($constName,$constData)=each($editConstArray))        {
+               foreach ($editConstArray as $constName => $constData) {
                        if (!$constData['type']) {
                                $constData['type']='string';
                        }
                        $cats = explode(',',$constData['cat']);
-                       reset($cats);
-                       while (list(,$theCat)=each($cats))      {               // if = only one category, while allows for many. We have agreed on only one category is the most basic way...
+                       foreach ($cats as $theCat) {            // if = only one category, while allows for many. We have agreed on only one category is the most basic way...
                                $theCat=trim($theCat);
                                if ($theCat)    {
                                        $this->categories[$theCat][$constName]=$constData['subcat'];
@@ -917,7 +904,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate   {
        function ext_getCategoryLabelArray()    {
                // Returns array used for labels in the menu.
                $retArr = array();
-               while(list($k,$v)=each($this->categories))      {
+               foreach ($this->categories as $k => $v) {
                        if (count($v))  {
                                $retArr[$k]=strtoupper($k).' ('.count($v).')';
                        }
@@ -976,8 +963,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate   {
                $catConf=$this->setup['constants']['TSConstantEditor.'][$category.'.'];
                $out=array();
                if (is_array($catConf)) {
-                       reset($catConf);
-                       while(list($key,$val)=each($catConf))   {
+                       foreach ($catConf as $key => $val) {
                                switch($key)    {
                                        case 'image':
                                                $out['imagetag'] = $this->ext_getTSCE_config_image($catConf['image']);
@@ -990,8 +976,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate   {
                                        default:
                                                if (t3lib_div::testInt($key))   {
                                                        $constRefs = explode(',',$val);
-                                                       reset($constRefs);
-                                                       while(list(,$const)=each($constRefs))   {
+                                                       foreach ($constRefs as $const) {
                                                                $const=trim($const);
                                                                if ($const && $const<=20)       {
                                                                        $out['constants'][$const].=$this->ext_getKeyImage($key);
@@ -1048,7 +1033,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
        function ext_resourceDims()     {
                if ($this->setup['resources'])  {
                        $rArr=explode(',',$this->setup['resources']);
-                       while(list($c,$val)=each($rArr))        {
+                       foreach ($rArr as $c => $val) {
                                $val=trim($val);
                                $theFile = PATH_site.'uploads/tf/'.$val;
                                if ($val && @is_file($theFile)) {
@@ -1059,8 +1044,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
                                }
                        }
                }
-               reset($this->dirResources);
-               while(list($c,$val)=each($this->dirResources))  {
+               foreach ($this->dirResources as $c => $val) {
                        $val=trim($val);
                        $imgInfo = @getimagesize(PATH_site.$val);
                        if (is_array($imgInfo)) {
@@ -1144,7 +1128,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
                        $this->rArr=explode(',',$this->setup['resources'].','.implode($this->dirResources,','));
 
                        if (!$this->doNotSortCategoriesBeforeMakingForm) asort($this->categories[$category]);
-                       while(list($name,$type)=each($this->categories[$category]))     {
+                       foreach ($this->categories[$category] as $name => $type) {
                                $params = $theConstants[$name];
                                if (is_array($params))  {
                                        if ($subcat!=$params['subcat_name'])    {
@@ -1190,7 +1174,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
                                                case 'color':
                                                        $colorNames=explode(',',','.$this->HTMLcolorList);
                                                        $p_field='';
-                                                       while(list(,$val)=each($colorNames))    {
+                                                       foreach ($colorNames as $val) {
                                                                $sel='';
                                                                if ($val==strtolower($params['value'])) {
                                                                        $sel = ' selected';
@@ -1224,7 +1208,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
                                                case 'options':
                                                        if (is_array($typeDat['params']))       {
                                                                $p_field='';
-                                                               while(list(,$val)=each($typeDat['params']))     {
+                                                               foreach ($typeDat['params'] as $val) {
                                                                        $vParts = explode('=',$val,2);
                                                                        $label = $vParts[0];
                                                                        $val = isset($vParts[1]) ? $vParts[1] : $vParts[0];
@@ -1273,7 +1257,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
                                                        reset($this->rArr);
                                                        $onlineResourceFlag=$this->ext_defaultOnlineResourceFlag;
 
-                                                       while(list($c,$val)=each($this->rArr))  {
+                                                       foreach ($this->rArr as $c => $val) {
                                                                $val=trim($val);
                                                                $fI=t3lib_div::split_fileref($val);
                                                                if ($val && (!$extList || t3lib_div::inList($extList,$fI['fileext'])))  {
@@ -1526,22 +1510,20 @@ class t3lib_tsparser_ext extends t3lib_TStemplate       {
         * @return      [type]          ...
         */
        function ext_depthKeys($arr,$settings)  {
-               reset($arr);
                $tsbrArray=array();
-               while(list($theK,$theV)=each($arr))     {
+               foreach ($arr as $theK => $theV) {
                        $theKeyParts = explode('.',$theK);
                        $depth='';
                        $c=count($theKeyParts);
                        $a=0;
-                       while(list(,$p)=each($theKeyParts))     {
+                       foreach ($theKeyParts as $p) {
                                $a++;
                                $depth.=($depth?'.':'').$p;
                                $tsbrArray[$depth]= ($c==$a) ? $theV : 1;
                        }
                }
                        // Modify settings
-               reset($tsbrArray);
-               while(list($theK,$theV)=each($tsbrArray))       {
+               foreach ($tsbrArray as $theK => $theV) {
                        if ($theV)      {
                                $settings[$theK] = 1;
                        } else {
@@ -1571,8 +1553,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
                $W5data=$http_post_vars['W5data'];
 
                if (is_array($data))    {
-                       reset($data);
-                       while(list($key,$var)=each($data))      {
+                       foreach ($data as $key => $var) {
                                if (isset($theConstants[$key])) {
                                        if ($this->ext_dontCheckIssetValues || isset($check[$key]))     {               // If checkbox is set, update the value
                                                list($var) = explode(LF,$var);  // exploding with linebreak, just to make sure that no multiline input is given!
@@ -1679,8 +1660,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
                }
                        // Remaining keys in $check indicates fields that are just clicked "on" to be edited. Therefore we get the default value and puts that in the template as a start...
                if (!$this->ext_dontCheckIssetValues && is_array($check))       {
-                       reset($check);
-                       while(list($key,$var)=each($check))     {
+                       foreach ($check as $key => $var) {
                                if (isset($theConstants[$key])) {
                                        $dValue = $theConstants[$key]['default_value'];
                                        $this->ext_putValueInConf($key, $dValue);
@@ -1749,8 +1729,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
         */
        function ext_prevPageWithTemplate($id,$perms_clause)    {
                $rootLine = t3lib_BEfunc::BEgetRootLine($id,$perms_clause?' AND '.$perms_clause:'');
-               reset($rootLine);
-               while(list(,$p)=each($rootLine))        {
+               foreach ($rootLine as $p) {
                        if ($this->ext_getFirstTemplate($p['uid']))     {
                                return $p;
                        }
index 70fd97f..a8b40cc 100644 (file)
@@ -123,8 +123,7 @@ class t3lib_tsStyleConfig extends t3lib_tsparser_ext        {
                $this->flatSetup = $temp;
 
 
-               reset($theConstants);
-               while(list($k,$p)=each($theConstants))  {
+               foreach ($theConstants as $k => $p) {
                        if (isset($this->objReg[$k]))   {
                                $theConstants[$k]["value"] = $this->ext_realValues[$k];
                        }
index 4a65aa0..5db1853 100644 (file)
@@ -1307,8 +1307,7 @@ class t3lib_TStemplate    {
        function checkFile($name,$menuArr)      {
                t3lib_div::logDeprecatedFunction();
 
-               reset ($menuArr);
-               while (list($aKey,)=each($menuArr))     {
+               foreach ($menuArr as $aKey => $value) {
                        $menuArr[$aKey][$name] = $this->getFileName($menuArr[$aKey][$name]);
                }
                return $menuArr;
index 2a57f61..4faef91 100644 (file)
@@ -1347,7 +1347,6 @@ class t3lib_userAuthGroup extends t3lib_userAuth {
 
                        // Traversing records in the correct order
                $include_staticArr = t3lib_div::intExplode(',',$grList);
-               reset($include_staticArr);
                        // traversing list
                foreach ($include_staticArr as $key => $uid) {
 
index 1b289c4..8f7c5d5 100644 (file)
@@ -169,8 +169,7 @@ class t3lib_xml {
                        $pList='';
                        if (count($params))     {
                                $par=array();
-                               reset($params);
-                               while(list($key,$val)=each($params))    {
+                               foreach ($params as $key => $val) {
                                        $par[]=$key.'="'.htmlspecialchars($val).'"';
                                }
                                $pList=' '.implode(' ',$par);
@@ -254,8 +253,7 @@ class t3lib_xml {
         */
        function getRowInXML($table,$row)       {
                $fields = t3lib_div::trimExplode(',',$this->XML_recFields[$table],1);
-               reset($fields);
-               while(list(,$field)=each($fields))      {
+               foreach ($fields as $field) {
                        if ($row[$field] || $this->includeNonEmptyValues)       {
                                $this->lines[]=$this->Icode.$this->fieldWrap($field,$this->substNewline($this->utf8(htmlspecialchars($row[$field]))));
                        }
index a43c79e..3782456 100644 (file)
@@ -590,8 +590,7 @@ if ($TYPO3_LOADED_EXT['_CACHEFILE'])        {
        require(PATH_typo3conf.$TYPO3_LOADED_EXT['_CACHEFILE'].'_ext_localconf.php');
 } else {
        $temp_TYPO3_LOADED_EXT = $TYPO3_LOADED_EXT;
-       reset($temp_TYPO3_LOADED_EXT);
-       while(list($_EXTKEY,$temp_lEDat)=each($temp_TYPO3_LOADED_EXT))  {
+       foreach ($temp_TYPO3_LOADED_EXT as $_EXTKEY => $temp_lEDat) {
                if (is_array($temp_lEDat) && $temp_lEDat['ext_localconf.php'])  {
                        $_EXTCONF = $TYPO3_CONF_VARS['EXT']['extConf'][$_EXTKEY];
                        require($temp_lEDat['ext_localconf.php']);
index ae25568..2ea8497 100644 (file)
@@ -11,8 +11,7 @@ if (!defined ('TYPO3_MODE'))  die ('Access denied.');
  * @see tslib_fe::includeTCA(), typo3/init.php
  */
 $temp_TYPO3_LOADED_EXT = $GLOBALS['TYPO3_LOADED_EXT'];
-reset($temp_TYPO3_LOADED_EXT);
-while(list($_EXTKEY,$temp_lEDat)=each($temp_TYPO3_LOADED_EXT)) {
+foreach ($temp_TYPO3_LOADED_EXT as $_EXTKEY => $temp_lEDat) {
        if (is_array($temp_lEDat) && $temp_lEDat['ext_tables.php'])     {
                $_EXTCONF = $TYPO3_CONF_VARS['EXT']['extConf'][$_EXTKEY];
                require($temp_lEDat['ext_tables.php']);