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

17 files changed:
typo3/sysext/cms/layout/class.tx_cms_layout.php
typo3/sysext/cms/layout/db_layout.php
typo3/sysext/cms/tslib/class.tslib_fe.php
typo3/sysext/cms/tslib/class.tslib_fetce.php
typo3/sysext/cms/tslib/class.tslib_feuserauth.php
typo3/sysext/cms/tslib/class.tslib_search.php
typo3/sysext/cms/tslib/index_ts.php
typo3/sysext/cms/tslib/media/scripts/example_itemArrayProcFunc.php
typo3/sysext/cms/tslib/media/scripts/fe_adminLib.inc
typo3/sysext/cms/tslib/media/scripts/gmenu_layers.php
typo3/sysext/cms/tslib/media/scripts/makeMenu_datedirectory.inc
typo3/sysext/cms/tslib/media/scripts/plaintextLib.inc
typo3/sysext/cms/tslib/media/scripts/postit.inc
typo3/sysext/cms/tslib/media/scripts/tmenu_layers.php
typo3/sysext/cms/tslib/media/scripts/wapversionLib.inc
typo3/sysext/cms/tslib/pagegen.php
typo3/sysext/cms/tslib/publish.php

index 2fdd2cc..12f9ea1 100755 (executable)
@@ -649,7 +649,7 @@ class tx_cms_layout extends recordList {
                                        </tr>';
 
                                        // Traverse columns to display top-on-top
-                               while(list($counter,$key)=each($cList)) {
+                               foreach ($cList as $counter => $key) {
 
                                                // Select content elements:
                                        $queryParts = $this->makeQueryArray('tt_content', $id, 'AND colPos='.intval($key).$showHidden.$showLanguage);
@@ -948,8 +948,7 @@ class tx_cms_layout extends recordList {
                                                $out.=$this->tt_board_drawItem('tt_board',$row,count($theRows));
 
                                                if ($GLOBALS['SOBE']->MOD_SETTINGS['tt_board']=='expand')       {
-                                                       reset($theRows);
-                                                       while(list($n,$sRow)=each($theRows))    {
+                                                       foreach ($theRows as $n => $sRow) {
                                                                $out.=$this->tt_board_drawItem('tt_board',$sRow,0);
                                                        }
                                                }
index 6da6e76..471f746 100755 (executable)
@@ -986,8 +986,7 @@ class SC_db_layout {
                $CMcounter = 0;
 
                        // Traverse the list of table names which has records on this page (that array is populated by the $dblist object during the function getTableMenu()):
-               reset($dblist->activeTables);
-               while(list($table)=each($dblist->activeTables)) {
+               foreach ($dblist->activeTables as $table => $value) {
 
                                // Load full table definitions:
                        t3lib_div::loadTCA($table);
index e511ac7..b24b161 100644 (file)
                                        $pO = $randval;
                                }
                                $c = 0;
-                               reset($pageArray);
-                               while(list(,$pV)=each($pageArray))      {
+                               foreach ($pageArray as $pV) {
                                        if ($c==$pO)    {
                                                $page = $pV;
                                                break;
 
                // Checks if the $domain-startpage is in the rootLine. This is necessary so that references to page-id's from other domains are not possible.
                if ($domainStartPage && is_array($this->rootLine)) {
-                       reset ($this->rootLine);
                        $idFound = 0;
-                       while(list($key,$val)=each($this->rootLine)) {
+                       foreach ($this->rootLine as $key => $val) {
                                if ($val['uid']==$domainStartPage)      {
                                        $idFound=1;
                                        break;
 
                        // Updating content of the two rootLines IF the language key is set!
                if ($this->sys_language_uid && is_array($this->tmpl->rootLine)) {
-                       reset($this->tmpl->rootLine);
-                       while(list($rLk)=each($this->tmpl->rootLine))   {
+                       foreach ($this->tmpl->rootLine as $rLk => $value) {
                                $this->tmpl->rootLine[$rLk] = $this->sys_page->getPageOverlay($this->tmpl->rootLine[$rLk]);
                        }
                }
                if ($this->sys_language_uid && is_array($this->rootLine))       {
-                       reset($this->rootLine);
-                       while(list($rLk)=each($this->rootLine)) {
+                       foreach ($this->rootLine as $rLk => $value) {
                                $this->rootLine[$rLk] = $this->sys_page->getPageOverlay($this->rootLine[$rLk]);
                        }
                }
@@ -3407,7 +3403,7 @@ if (version == "n3") {
                        // Set headers, if any
                if (!empty($this->config['config']['additionalHeaders'])) {
                        $headerArray = explode('|', $this->config['config']['additionalHeaders']);
-                       while(list(,$headLine)=each($headerArray))      {
+                       foreach ($headerArray as $headLine) {
                                $headLine = trim($headLine);
                                header($headLine);
                        }
@@ -4445,8 +4441,7 @@ if (version == "n3") {
                        return array();
                }
 
-               reset($this->rootLine);
-               while(list(,$rC)=each($this->rootLine)) {
+               foreach ($this->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;
                }
@@ -4460,10 +4455,9 @@ if (version == "n3") {
         */
        function getPagesTSconfig()     {
                if (!is_array($this->pagesTSconfig))    {
-                       reset($this->rootLine);
                        $TSdataArray = array();
                        $TSdataArray[] = $this->TYPO3_CONF_VARS['BE']['defaultPageTSconfig'];   // Setting default configuration:
-                       while(list($k,$v)=each($this->rootLine))        {
+                       foreach ($this->rootLine as $k => $v) {
                                $TSdataArray[]=$v['TSconfig'];
                        }
                                // Parsing the user TS (or getting from cache)
@@ -4778,7 +4772,7 @@ if (version == "n3") {
                $this->getPageRenderer()->setLanguage($this->lang);
 
                $ls = explode('|',TYPO3_languages);
-               while(list($i,$v)=each($ls))    {
+               foreach ($ls as $i => $v) {
                        if ($v==$this->lang)    {$this->langSplitIndex=$i; break;}
                }
 
index 1794be7..5ed528a 100644 (file)
@@ -98,13 +98,11 @@ class tslib_feTCE   {
         * @see tslib_fe::fe_tce(), includeScripts()
         */
        function start($data,$FEData)   {
-               reset($data);
-               while(list($table,$id_arr)=each($data)) {
+               foreach ($data as $table => $id_arr) {
                        t3lib_div::loadTCA($table);
                        if (is_array($id_arr))  {
                                $sep=$FEData[$table.'.']['separator']?$FEData[$table.'.']['separator']:LF;
-                               reset($id_arr);
-                               while(list($id,$field_arr)=each($id_arr))       {
+                               foreach ($id_arr as $id => $field_arr) {
                                        $this->newData[$table][$id]=Array();
                                        if (strstr($id,'NEW'))  {               // NEW
                                                        // Defaults:
@@ -116,8 +114,7 @@ class tslib_feTCE   {
                                                }
                                                        // Insert external data:
                                                if (is_array($field_arr))       {
-                                                       reset($field_arr);
-                                                       while(list($field,$value)=each($field_arr))     {
+                                                       foreach ($field_arr as $field => $value) {
                                                                if ($FEData[$table.'.']['allowNew.'][$field])   {
                                                                        if (is_array($value)) {
                                                                                $this->newData[$table][$id][$field] = implode($sep,$value);
@@ -142,8 +139,7 @@ class tslib_feTCE   {
                                        } else {                // EDIT
                                                        // Insert external data:
                                                if (is_array($field_arr))       {
-                                                       reset($field_arr);
-                                                       while(list($field,$value)=each($field_arr))     {
+                                                       foreach ($field_arr as $field => $value) {
                                                                if ($FEData[$table.'.']['allowEdit.'][$field])  {
                                                                        if (is_array($value)) {
                                                                                $this->newData[$table][$id][$field] = implode($sep,$value);
@@ -155,8 +151,7 @@ class tslib_feTCE   {
                                                }
                                                        // Internal Override
                                                if (is_array($FEData[$table.'.']['overrideEdit.']))     {
-                                                       reset($FEData[$table.'.']['overrideEdit.']);
-                                                       while(list($field,$value)=each($FEData[$table.'.']['overrideEdit.']))   {
+                                                       foreach ($FEData[$table.'.']['overrideEdit.'] as $field => $value) {
                                                                $this->newData[$table][$id][$field] = $value;
                                                        }
                                                }
@@ -212,8 +207,7 @@ class tslib_feTCE   {
         * @see tslib_fe::fe_tce(), includeScripts()
         */
        function includeScripts()       {
-               reset($this->extScripts);
-               while(list($incFile_table,$incFile)=each($this->extScripts))    {
+               foreach ($this->extScripts as $incFile_table => $incFile) {
                        if (@is_file($incFile) && $GLOBALS['TSFE']->checkFileInclude($incFile)) {
                                include($incFile);      // Always start the incFiles with a check of the object fe_tce.  is_object($this);
                                $GLOBALS['TT']->setTSlogMessage('Included '.$incFile,0);
index c0ec4cf..c732057 100644 (file)
@@ -500,11 +500,9 @@ class tslib_feUserAuth extends t3lib_userAuth {
                        }
                        $change=0;
                        $recs_array=$this->getKey('ses','recs');
-                       reset($recs);
-                       while(list($table,$data)=each($recs))   {
+                       foreach ($recs as $table => $data) {
                                if (is_array($data))    {
-                                       reset($data);
-                                       while(list($rec_id,$value)=each($data)) {
+                                       foreach ($data as $rec_id => $value) {
                                                if ($value != $recs_array[$table][$rec_id])     {
                                                        $recs_array[$table][$rec_id] = $value;
                                                        $change=1;
index 92ff3e2..4ca7396 100644 (file)
@@ -168,12 +168,12 @@ class tslib_search {
        function explodeCols($in)       {
                $theArray = explode(':',$in);
                $out = Array();
-               while(list(,$val)=each($theArray))      {
+               foreach ($theArray as $val) {
                        $val=trim($val);
                        $parts = explode('.',$val);
                        if ($parts[0] && $parts[1])     {
                                $subparts = explode('-',$parts[1]);
-                               while(list(,$piece)=each($subparts))    {
+                               foreach ($subparts as $piece) {
                                        $piece=trim($piece);
                                        if ($piece)             $out[]=$parts[0].'.'.$piece;
                                }
@@ -198,8 +198,7 @@ class tslib_search {
                        if (is_array($components))      {
                                $i=0;
                                $lastoper = '';
-                               reset($components);
-                               while (list($key,$val) = each ($components))    {
+                               foreach ($components as $key => $val) {
                                        $operator=$this->get_operator($val);
                                        if ($operator)  {
                                                $lastoper = $operator;
@@ -412,11 +411,10 @@ class tslib_search {
        function get_operator($operator)        {
                $operator = trim($operator);
                $op_array = $this->operator_translate_table;
-               reset ($op_array);
                if ($this->operator_translate_table_caseinsensitive)    {
                        $operator = strtolower($operator);      // case-conversion is charset insensitive, but it doesn't spoil anything if input string AND operator table is already converted
                }
-               while (list($key,$val) = each($op_array))       {
+               foreach ($op_array as $key => $val) {
                        $item = $op_array[$key][0];
                        if ($this->operator_translate_table_caseinsensitive)    {
                                $item = strtolower($item);      // See note above.
index 0770b00..5ec2a3b 100644 (file)
@@ -471,16 +471,14 @@ if ($TSFE->isOutputting())        {
                        $EXTiS_splitC = explode('<!--EXT_SCRIPT.',$TSFE->content);      // Splits content with the key
 
                                // Special feature: Include libraries
-                       reset($EXTiS_config);
-                       while(list(,$EXTiS_cPart)=each($EXTiS_config))  {
+                       foreach ($EXTiS_config as $EXTiS_cPart) {
                                if (isset($EXTiS_cPart['conf']['includeLibs']) && $EXTiS_cPart['conf']['includeLibs']) {
                                        $EXTiS_resourceList = t3lib_div::trimExplode(',',$EXTiS_cPart['conf']['includeLibs'], true);
                                        $TSFE->includeLibraries($EXTiS_resourceList);
                                }
                        }
 
-                       reset($EXTiS_splitC);
-                       while(list($EXTiS_c,$EXTiS_cPart)=each($EXTiS_splitC))  {
+                       foreach ($EXTiS_splitC as $EXTiS_c => $EXTiS_cPart) {
                                if (substr($EXTiS_cPart,32,3)=='-->')   {       // If the split had a comment-end after 32 characters it's probably a split-string
                                        $EXTiS_key = 'EXT_SCRIPT.'.substr($EXTiS_cPart,0,32);
                                        if (is_array($EXTiS_config[$EXTiS_key]))        {
index 2a89f9f..4574cb9 100755 (executable)
  */
 function user_itemArrayProcFuncTest($menuArr,$conf)    {
        if ($conf['demoItemStates'])    {               // Used in the example of item states
-               reset($menuArr);
                $c=0;
                $teststates=explode(',','NO,ACT,IFSUB,CUR,USR,SPC,USERDEF1,USERDEF2');
-               while(list($k,$v)=each($menuArr))       {
+               foreach ($menuArr as $k => $v) {
                        $menuArr[$k]['ITEM_STATE']=$teststates[$c];
                        $menuArr[$k]['title'].= ($teststates[$c] ? ' ['.$teststates[$c].']' : '');
                        $c++;
index 02797a0..15e4284 100755 (executable)
@@ -398,10 +398,9 @@ class user_feAdmin {
         */
        function parseValues()  {
                if (is_array($this->conf['parseValues.']))      {
-                       reset($this->conf['parseValues.']);
-                       while(list($theField,$theValue)=each($this->conf['parseValues.']))      {
+                       foreach ($this->conf['parseValues.'] as $theField => $theValue) {
                                $listOfCommands = t3lib_div::trimExplode(',',$theValue,1);
-                               while(list(,$cmd)=each($listOfCommands))        {
+                               foreach ($listOfCommands as $cmd) {
                                        $cmdParts = split('\[|\]',$cmd);        // Point is to enable parameters after each command enclosed in brackets [..]. These will be in position 1 in the array.
                                        $theCmd=trim($cmdParts[0]);
                                        switch($theCmd) {
@@ -450,9 +449,8 @@ class user_feAdmin  {
                                                break;
                                                case 'checkArray':
                                                        if (is_array($this->dataArr[$theField]))        {
-                                                               reset($this->dataArr[$theField]);
                                                                $val = 0;
-                                                               while(list($kk,$vv)=each($this->dataArr[$theField]))    {
+                                                               foreach ($this->dataArr[$theField] as $kk => $vv) {
                                                                        $kk = t3lib_div::intInRange($kk,0);
                                                                        if ($kk<=30)    {
                                                                                if ($vv)        {
@@ -466,7 +464,7 @@ class user_feAdmin  {
                                                case 'uniqueHashInt':
                                                        $otherFields = t3lib_div::trimExplode(';',$cmdParts[1],1);
                                                        $hashArray=array();
-                                                       while(list(,$fN)=each($otherFields))    {
+                                                       foreach ($otherFields as $fN) {
                                                                $vv = $this->dataArr[$fN];
                                                                $vv = preg_replace('/[[:space:]]/','',$vv);
                                                                $vv = preg_replace('/[^[:alnum:]]/','',$vv);
@@ -498,8 +496,7 @@ class user_feAdmin  {
 
                if (is_string($this->dataArr[$theField]))       {               // files from preview.
                        $tmpArr = explode(',',$this->dataArr[$theField]);
-                       reset($tmpArr);
-                       while(list(,$val)=each($tmpArr))        {
+                       foreach ($tmpArr as $val) {
                                $valParts = explode('|',$val);
                                $filesArr[] = array (
                                        'name'=>$valParts[1],
@@ -507,8 +504,7 @@ class user_feAdmin  {
                                );
                        }
                } elseif (is_array($_FILES['FE'][$this->theTable][$theField]['name']))  {       // Files from upload
-                       reset($_FILES['FE'][$this->theTable][$theField]['name']);
-                       while(list($kk,$vv)=each($_FILES['FE'][$this->theTable][$theField]['name']))    {
+                       foreach ($_FILES['FE'][$this->theTable][$theField]['name'] as $kk => $vv) {
                                if ($vv)        {
                                        $tmpFile = t3lib_div::upload_to_tempfile($_FILES['FE'][$this->theTable][$theField]['tmp_name'][$kk]);
                                        if ($tmpFile)   {
@@ -521,8 +517,7 @@ class user_feAdmin  {
                                }
                        }
                } elseif (is_array($_FILES['FE']['name'][$this->theTable][$theField]))  {       // Files from upload
-                       reset($_FILES['FE']['name'][$this->theTable][$theField]);
-                       while(list($kk,$vv)=each($_FILES['FE']['name'][$this->theTable][$theField]))    {
+                       foreach ($_FILES['FE']['name'][$this->theTable][$theField] as $kk => $vv) {
                                if ($vv)        {
                                        $tmpFile = t3lib_div::upload_to_tempfile($_FILES['FE']['tmp_name'][$this->theTable][$theField][$kk]);
                                        if ($tmpFile)   {
@@ -542,8 +537,7 @@ class user_feAdmin  {
                if (count($filesArr))   {
                        $extArray = t3lib_div::trimExplode(';',strtolower($cmdParts[1]),1);
                        $maxSize = intval($cmdParts[3]);
-                       reset($filesArr);
-                       while(list(,$infoArr)=each($filesArr))  {
+                       foreach ($filesArr as $infoArr) {
                                $fI = pathinfo($infoArr['name']);
                                if (t3lib_div::verifyFilenameAgainstDenyPattern($fI['name']))   {
                                        if (!count($extArray) || in_array(strtolower($fI['extension']), $extArray))     {
@@ -558,9 +552,8 @@ class user_feAdmin  {
                        }
                }
                        // Copy the files in the resulting array to the proper positions based on preview/non-preview.
-               reset($finalFilesArr);
                $fileNameList=array();
-               while(list(,$infoArr)=each($finalFilesArr))     {
+               foreach ($finalFilesArr as $infoArr) {
                        if ($this->isPreview()) {               // If the form is a preview form (and data is therefore not going into the database...) do this.
                                $this->createFileFuncObj();
                                $fI = pathinfo($infoArr['name']);
@@ -600,8 +593,7 @@ class user_feAdmin  {
        function overrideValues()       {
                // Addition of overriding values
                if (is_array($this->conf[$this->cmdKey.'.']['overrideValues.']))        {
-                       reset($this->conf[$this->cmdKey.'.']['overrideValues.']);
-                       while(list($theField,$theValue)=each($this->conf[$this->cmdKey.'.']['overrideValues.']))        {
+                       foreach ($this->conf[$this->cmdKey.'.']['overrideValues.'] as $theField => $theValue) {
                                $this->dataArr[$theField] = $theValue;
                        }
                }
@@ -616,8 +608,7 @@ class user_feAdmin  {
        function defaultValues()        {
                        // Addition of default values
                if (is_array($this->conf[$this->cmdKey.'.']['defaultValues.'])) {
-                       reset($this->conf[$this->cmdKey.'.']['defaultValues.']);
-                       while(list($theField,$theValue)=each($this->conf[$this->cmdKey.'.']['defaultValues.'])) {
+                       foreach ($this->conf[$this->cmdKey.'.']['defaultValues.'] as $theField => $theValue) {
                                $this->dataArr[$theField] = $theValue;
                        }
                }
@@ -634,9 +625,8 @@ class user_feAdmin  {
         */
        function evalValues()   {
                // Check required, set failure if not ok.
-               reset($this->requiredArr);
                $tempArr=array();
-               while(list(,$theField)=each($this->requiredArr))        {
+               foreach ($this->requiredArr as $theField) {
                        if (!trim($this->dataArr[$theField]))   {
                                $tempArr[]=$theField;
                        }
@@ -660,10 +650,9 @@ class user_feAdmin {
                                break;
                        }
 
-                       reset($this->conf[$this->cmdKey.'.']['evalValues.']);
-                       while(list($theField,$theValue)=each($this->conf[$this->cmdKey.'.']['evalValues.']))    {
+                       foreach ($this->conf[$this->cmdKey.'.']['evalValues.'] as $theField => $theValue) {
                                $listOfCommands = t3lib_div::trimExplode(',',$theValue,1);
-                               while(list(,$cmd)=each($listOfCommands))        {
+                               foreach ($listOfCommands as $cmd) {
                                        $cmdParts = split('\[|\]',$cmd);        // Point is to enable parameters after each command enclosed in brackets [..]. These will be in position 1 in the array.
                                        $theCmd = trim($cmdParts[0]);
                                        switch($theCmd) {
@@ -908,16 +897,14 @@ class user_feAdmin        {
 
                $GLOBALS['TSFE']->includeTCA();
                t3lib_div::loadTCA($table);
-               reset($GLOBALS['TCA'][$table]['columns']);
                $iFields=array();
-               while(list($field,$conf)=each($GLOBALS['TCA'][$table]['columns']))      {
+               foreach ($GLOBALS['TCA'][$table]['columns'] as $field => $conf) {
                        if ($conf['config']['type']=='group' && $conf['config']['internal_type']=='file')       {
 
                                $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid='.intval($uid), array($field => ''));
 
                                $delFileArr = explode(',',$rec[$field]);
-                               reset($delFileArr);
-                               while(list(,$n)=each($delFileArr))      {
+                               foreach ($delFileArr as $n) {
                                        if ($n) {
                                                $fpath = $conf['config']['uploadfolder'].'/'.$n;
                                                unlink($fpath);
@@ -1103,8 +1090,7 @@ class user_feAdmin        {
                        $fieldArr=array();
                        if (is_array($fD) || $sFK=='DELETE')    {
                                if (is_array($fD))      {
-                                       reset($fD);
-                                       while(list($field,$value)=each($fD))    {
+                                       foreach ($fD as $field => $value) {
                                                $origArr[$field]=$value;
                                                $fieldArr[]=$field;
                                        }
@@ -1183,8 +1169,7 @@ class user_feAdmin        {
         * @return      string          The processed template HTML code
         */
        function removeRequired($templateCode,$failure) {
-               reset($this->requiredArr);
-               while(list(,$theField)=each($this->requiredArr))        {
+               foreach ($this->requiredArr as $theField) {
                        if (!t3lib_div::inList($failure,$theField))     {
                                $templateCode = $this->cObj->substituteSubpart($templateCode, '###SUB_REQUIRED_FIELD_'.$theField.'###', '');
                        }
@@ -1219,10 +1204,9 @@ class user_feAdmin       {
         */
        function modifyDataArrForFormUpdate($inputArr)  {
                if (is_array($this->conf[$this->cmdKey.'.']['evalValues.']))    {
-                       reset($this->conf[$this->cmdKey.'.']['evalValues.']);
-                       while(list($theField,$theValue)=each($this->conf[$this->cmdKey.'.']['evalValues.']))    {
+                       foreach ($this->conf[$this->cmdKey.'.']['evalValues.'] as $theField => $theValue) {
                                $listOfCommands = t3lib_div::trimExplode(',',$theValue,1);
-                               while(list(,$cmd)=each($listOfCommands))        {
+                               foreach ($listOfCommands as $cmd) {
                                        $cmdParts = split('\[|\]',$cmd);        // Point is to enable parameters after each command enclosed in brackets [..]. These will be in position 1 in the array.
                                        $theCmd = trim($cmdParts[0]);
                                        switch($theCmd) {
@@ -1239,10 +1223,10 @@ class user_feAdmin      {
                        }
                }
                if (is_array($this->conf['parseValues.']))      {
-                       reset($this->conf['parseValues.']);
-                       while(list($theField,$theValue)=each($this->conf['parseValues.']))      {
+                       while(list($theField,$theValue)=each()) {
+                       foreach ($this->conf['parseValues.'] as $theField => $theValue) {
                                $listOfCommands = t3lib_div::trimExplode(',',$theValue,1);
-                               while(list(,$cmd)=each($listOfCommands))        {
+                               foreach ($listOfCommands as $cmd) {
                                        $cmdParts = split('\[|\]',$cmd);        // Point is to enable parameters after each command enclosed in brackets [..]. These will be in position 1 in the array.
                                        $theCmd = trim($cmdParts[0]);
                                        switch($theCmd) {
@@ -1288,9 +1272,8 @@ class user_feAdmin        {
         */
        function setCObjects($templateCode,$currentArr=array(),$markerArray='',$specialPrefix='')       {
                if (is_array($this->conf['cObjects.'])) {
-                       reset($this->conf['cObjects.']);
 
-                       while(list($theKey,$theConf)=each($this->conf['cObjects.']))    {
+                       foreach ($this->conf['cObjects.'] as $theKey => $theConf) {
                                if (!strstr($theKey,'.'))       {
                                        if (strstr($templateCode,'###'.$specialPrefix.'CE_'.$theKey.'###'))     {
                                                $cObjCode = $this->cObj->cObjGetSingle($this->conf['cObjects.'][$theKey], $this->conf['cObjects.'][$theKey.'.'], 'cObjects.'.$theKey);
@@ -1406,8 +1389,7 @@ class user_feAdmin        {
                $userContent['rec'] = $this->cObj->getSubpart($userContent['all'], '###SUB_RECORD###');
                $adminContent['rec'] = $this->cObj->getSubpart($adminContent['all'], '###SUB_RECORD###');
 
-               reset($DBrows);
-               while(list(,$r)=each($DBrows))  {
+               foreach ($DBrows as $r) {
                        $markerArray = $this->cObj->fillInMarkerArray($this->markerArray, $r,'',0);
                        $markerArray = $this->setCObjects($userContent['rec'].$adminContent['rec'],$r,$markerArray,'ITEM_');
                        $markerArray['###SYS_AUTHCODE###'] = $this->authCode($r);
@@ -1607,7 +1589,7 @@ class user_feAdmin        {
                if ($this->conf['authcodeFields'])      {
                        $fieldArr = t3lib_div::trimExplode(',', $this->conf['authcodeFields'], 1);
                        $value='';
-                       while(list(,$field)=each($fieldArr))    {
+                       foreach ($fieldArr as $field) {
                                $value.=$r[$field].'|';
                        }
                        $value.=$extra.'|'.$this->conf['authcodeFields.']['addKey'];
@@ -1630,8 +1612,7 @@ class user_feAdmin        {
         */
        function setfixed($markerArray, $setfixed, $r)  {
                if (is_array($setfixed))        {
-                       reset($setfixed);
-                       while(list($theKey,$data)=each($setfixed))      {
+                       foreach ($setfixed as $theKey => $data) {
                                if (!strcmp($theKey,'DELETE'))  {
                                        $recCopy = $r;
                                        $string='&cmd=setfixed&sFK='.rawurlencode($theKey).'&rU='.$r['uid'];
@@ -1641,10 +1622,9 @@ class user_feAdmin       {
                                } elseif (strstr($theKey,'.'))  {
                                        $theKey = substr($theKey,0,-1);
                                        if (is_array($data))    {
-                                               reset($data);
                                                $recCopy = $r;
                                                $string='&cmd=setfixed&sFK='.rawurlencode($theKey).'&rU='.$r['uid'];
-                                               while(list($fieldName,$fieldValue)=each($data)) {
+                                               foreach ($data as $fieldName => $fieldValue) {
                                                        $string.='&fD%5B'.$fieldName.'%5D='.rawurlencode($fieldValue);
                                                        $recCopy[$fieldName]=$fieldValue;
                                                }
@@ -1669,8 +1649,7 @@ class user_feAdmin        {
        function setfixedHash($recCopy,$fields='')      {
                if ($fields)    {
                        $fieldArr = t3lib_div::trimExplode(',',$fields,1);
-                       reset($fieldArr);
-                       while(list($k,$v)=each($fieldArr))      {
+                       foreach ($fieldArr as $k => $v) {
                                $recCopy_temp[$k]=$recCopy[$v];
                        }
                } else {
index 968f5f2..a11ae16 100644 (file)
@@ -337,8 +337,7 @@ GL'.$this->WMid.'_out("");';
 
                $TEST='';
                if (count($GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid']))   {
-                       reset($GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid']);
-                       while(list(,$mIdStr)=each($GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid']))   {
+                       foreach ($GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid'] as $mIdStr) {
                                $this->WMhideCode.='
 GL_hideAll("'.$mIdStr.'");';
                                $this->WMrestoreScript.='
index 315e751..5ab71a8 100755 (executable)
@@ -68,7 +68,7 @@ if ($value=='') {
        $value=$GLOBALS['TSFE']->page['uid'];
 }
 $items=t3lib_div::intExplode(',',$value);
-while(list(,$id)=each($items))        {
+foreach ($items as $id) {
        $res = $GLOBALS['TSFE']->cObj->exec_getQuery('pages',Array('pidInList'=>$id,'orderBy'=>$altSortField));
        while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))        {
                $menuItemsArray[]=$row;
index 485f8ed..21c674d 100644 (file)
@@ -283,10 +283,9 @@ class user_plaintext {
         */
        function renderUploads($str,$upload_path='uploads/media/')      {
                $files = explode(',',$str);
-               reset($files);
                $lines=array();
                if ($this->conf['uploads.']['header'])  {$lines[]=$this->getString($this->conf['uploads.']['header']);}
-               while(list($k,$file)=each($files))      {
+               foreach ($files as $k => $file) {
                        $lines[]=$this->siteUrl.$upload_path.$file;
                }
                return implode(chr(10),$lines);
@@ -370,9 +369,8 @@ class user_plaintext {
         */
        function breakContent($str)     {
                $cParts = explode(chr(10),$str);
-               reset($cParts);
                $lines=array();
-               while(list(,$substrs)=each($cParts))    {
+               foreach ($cParts as $substrs) {
                        $lines[]=$this->breakLines($substrs);
                }
                return implode(chr(10),$lines);
@@ -391,10 +389,9 @@ class user_plaintext {
                $tConf = $this->conf['bulletlist.'][$type.'.'];
 
                $cParts = explode(chr(10),$str);
-               reset($cParts);
                $lines=array();
                $c=0;
-               while(list(,$substrs)=each($cParts))    {
+               foreach ($cParts as $substrs) {
                        $c++;
                        $bullet = $tConf['bullet'] ? $this->getString($tConf['bullet']) : ' - ';
                        $bLen=strlen($bullet);
@@ -417,11 +414,10 @@ class user_plaintext {
         */
        function breakTable($str)       {
                $cParts = explode(chr(10),$str);
-               reset($cParts);
                $lines=array();
                $cols = intval($this->conf['cols']) ? intval($this->conf['cols']) : 0 ;
                $c=0;
-               while(list(,$substrs)=each($cParts))    {
+               foreach ($cParts as $substrs) {
                        $c++;
                        if (trim($substrs))     {
                                $lineParts=explode('|',$substrs);
@@ -444,8 +440,7 @@ class user_plaintext {
                $outLines = array();
                $outLines[]=$this->addDiv($messure,'',$divChar,$joinChar,$cols);
 
-               reset($lines);
-               while(list($k,$v)=each($lines)) {
+               foreach ($lines as $k => $v) {
                        $top = intval($messure[1][$k]);
                        for ($aa=0;$aa<$top;$aa++)      {
                                $tempArr=array();
@@ -490,12 +485,9 @@ class user_plaintext {
        function traverseTable($tableLines)     {
                $maxLen=array();
                $maxLines=array();
-               reset($tableLines);
-               while(list($k,$v)=each($tableLines))    {
-                       reset($v);
-                       while(list($kk,$vv)=each($v))   {
-                               reset($vv);
-                               while(list($lk,$lv)=each($vv))  {
+               foreach ($tableLines as $k => $v) {
+                       foreach ($v as $kk => $vv) {
+                               foreach ($vv as $lk => $lv) {
                                        if (strlen($lv)>intval($maxLen[$kk]))   $maxLen[$kk]=strlen($lv);
                                }
                                if (count($vv)>intval($maxLines[$k]))   $maxLines[$k]=count($vv);
@@ -517,10 +509,9 @@ class user_plaintext {
        function renderImages($str,$links,$caption,$upload_path='uploads/pics/')        {
                $images = explode(',',$str);
                $linksArr = explode(',',$links);
-               reset($images);
                $lines=array();
                if ($this->conf['images.']['header'])   {$lines[]=$this->getString($this->conf['images.']['header']);}
-               while(list($k,$file)=each($images))     {
+               foreach ($images as $k => $file) {
                        $lines[]=$this->siteUrl.$upload_path.$file;
                        if ($links && count($linksArr)>1)       {
                                if (isset($linksArr[$k]))       {
index 523eb5f..cdbf783 100755 (executable)
@@ -118,7 +118,7 @@ $cols = intval($conf['cols']) ? intval($conf['cols']) : 3;
 
 $lines = explode(chr(10),$data);
 $imageArr = array();
-while(list($key,$content)=each($lines))        {
+foreach ($lines as $key => $content) {
        $content = trim($content);
        if ($content)   {
                $parts = explode('|',$content);
index e9ef217..69dcb4e 100644 (file)
@@ -337,8 +337,7 @@ GL'.$this->WMid.'_out("");';
 
                $TEST='';
                if (count($GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid']))   {
-                       reset($GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid']);
-                       while(list(,$mIdStr)=each($GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid']))   {
+                       foreach ($GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid'] as $mIdStr) {
                                $this->WMhideCode.='
 GL_hideAll("'.$mIdStr.'");';
                                $this->WMrestoreScript.='
index ffbd885..edc509e 100755 (executable)
@@ -342,11 +342,10 @@ class user_wapversion {
         */
        function menuCurrentLevel($indent)      {
                $rL = $GLOBALS['TSFE']->config['rootLine'];
-               reset($rL);
                $preSpace='';
                $out=array();
                        // Hierarchy menu
-               while(list($level,$data)=each($rL))     {
+               foreach ($rL as $level => $data) {
                        $preSign = count($rL)-1 > $level ? '-' : '>';
                        $menuItem = htmlspecialchars($preSign.' '.$data['title']);
                        $menuItem = $this->link($preSpace.$menuItem,$data['uid']);
@@ -355,8 +354,7 @@ class user_wapversion {
                }
                        // Current page menu:
                $menu = $this->cleanMenuArray($GLOBALS['TSFE']->sys_page->getMenu($GLOBALS['TSFE']->id));
-               reset($menu);
-               while(list(,$data)=each($menu)) {
+               foreach ($menu as $data) {
                        $preSign = count($this->cleanMenuArray($GLOBALS['TSFE']->sys_page->getMenu($data['uid']))) ? '+' : '*';
                        $menuItem = htmlspecialchars($preSign.' '.$data['title']);
                        $menuItem = $this->link($preSpace.$menuItem,$data['uid']);
index 08f8b67..375be8c 100644 (file)
@@ -58,8 +58,7 @@ $GLOBALS['TSFE']->newCObj();
 // LIBRARY INCLUSION, TypoScript
 // ******************************
 $temp_incFiles=TSpagegen::getIncFiles();
-reset($temp_incFiles);
-while(list(,$temp_file)=each($temp_incFiles))  {
+foreach ($temp_incFiles as $temp_file) {
        include_once('./'.$temp_file);
 }
 
index b199fa3..e86d0be 100644 (file)
@@ -62,7 +62,7 @@ $temp_publish_pages = explode(',', $BE_USER->adminPanel->getExtPublishList());
 $temp_publish_imagesTotal = array();
 $temp_publish_array = array(); // Collects the rendered pages.
 
-while(list(,$temp_publish_id)=each($temp_publish_pages))       {
+foreach ($temp_publish_pages as $temp_publish_id) {
        $TT->push('Page '.$temp_publish_id,'');
 //debug($temp_publish_id,1);
                $TSFE = t3lib_div::makeInstance('tslib_fe', $TYPO3_CONF_VARS, $temp_publish_id, 0);
@@ -121,8 +121,7 @@ $publishDir = $TYPO3_CONF_VARS['FE']['publish_dir'];
 if ($publishDir && @is_dir($publishDir))       {
        $publishDir = rtrim($publishDir, '/').'/';
        debug('Publishing in: '.$publishDir,1);
-       reset($temp_publish_array);
-       while(list($key,$val)=each($temp_publish_array))        {
+       foreach ($temp_publish_array as $key => $val) {
                $file = $publishDir.$key;
                t3lib_div::writeFile($file,$val[2]);
                debug('Writing: '.$file,1);