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

typo3/sysext/rtehtmlarea/mod3/class.tx_rtehtmlarea_browse_links.php
typo3/sysext/rtehtmlarea/mod3/class.tx_rtehtmlarea_dam_browse_links.php
typo3/sysext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php
typo3/sysext/rtehtmlarea/mod5/class.tx_rtehtmlarea_user.php

index f8ade90..199e9d3 100644 (file)
@@ -759,8 +759,7 @@ class tx_rtehtmlarea_browse_links extends browse_links {
                                if (is_array($this->thisConfig['userLinks.']))  {
                                        $subcats=array();
                                        $v=$this->thisConfig['userLinks.'];
-                                       reset($v);
-                                       while(list($k2)=each($v))       {
+                                       foreach ($v as $k2 => $dummyValue) {
                                                $k2i = intval($k2);
                                                if (substr($k2,-1)=='.' && is_array($v[$k2i.'.']))      {
 
index 7fe5ade..8109b68 100644 (file)
@@ -227,8 +227,7 @@ class tx_rtehtmlarea_dam_browse_links extends tx_dam_browse_media {
                                $classesAnchor = array();
                                $classesAnchor['all'] = array();
                                if (is_array($RTEsetup['properties']['classesAnchor.'])) {
-                                       reset($RTEsetup['properties']['classesAnchor.']);
-                                       while(list($label,$conf)=each($RTEsetup['properties']['classesAnchor.'])) {
+                                       foreach ($RTEsetup['properties']['classesAnchor.'] as $label => $conf) {
                                                if (in_array($conf['class'], $classesAnchorArray)) {
                                                        $classesAnchor['all'][] = $conf['class'];
                                                        if (in_array($conf['type'], $anchorTypes)) {
@@ -246,10 +245,8 @@ class tx_rtehtmlarea_dam_browse_links extends tx_dam_browse_media {
                                                }
                                        }
                                }
-                               reset($anchorTypes);
-                               while (list(, $anchorType) = each($anchorTypes) ) {
-                                       reset($classesAnchorArray);
-                                       while(list(,$class)=each($classesAnchorArray)) {
+                               foreach ($anchorTypes as $anchorType) {
+                                       foreach ($classesAnchorArray as $class) {
                                                if (!in_array($class, $classesAnchor['all']) || (in_array($class, $classesAnchor['all']) && is_array($classesAnchor[$anchorType]) && in_array($class, $classesAnchor[$anchorType]))) {
                                                        $selected = '';
                                                        if ($this->setClass == $class || (!$this->setClass && $this->classesAnchorDefault[$anchorType] == $class)) {
@@ -622,8 +619,7 @@ class tx_rtehtmlarea_dam_browse_links extends tx_dam_browse_media {
                                if (is_array($this->thisConfig['userLinks.']))  {
                                        $subcats=array();
                                        $v=$this->thisConfig['userLinks.'];
-                                       reset($v);
-                                       while(list($k2)=each($v))       {
+                                       foreach ($v as $k2 => $dummyValue) {
                                                $k2i = intval($k2);
                                                if (substr($k2,-1)=='.' && is_array($v[$k2i.'.']))      {
 
index acdb57e..7ec4193 100644 (file)
@@ -931,8 +931,6 @@ class tx_rtehtmlarea_select_image extends browse_links {
                if ($expandFolder && $this->checkFolder($expandFolder)) {
                        $files = t3lib_div::getFilesInDir($expandFolder,($plainFlag?'jpg,jpeg,gif,png':$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']),1,1);       // $extensionList="",$prependPath=0,$order="")
                        if (is_array($files))   {
-                               reset($files);
-
                                $out.=$this->barheader(sprintf($LANG->getLL('images').' (%s):',count($files)));
 
                                $titleLen = intval($BE_USER->uc['titleLen']);
@@ -946,7 +944,7 @@ class tx_rtehtmlarea_select_image extends browse_links {
                                $imgObj->tempPath=PATH_site.$imgObj->tempPath;
 
                                $lines=array();
-                               while(list(,$filepath)=each($files))    {
+                               foreach ($files as $filepath) {
                                        $fI=pathinfo($filepath);
 
                                        $origFile = t3lib_div::rawUrlEncodeFP(substr($filepath,strlen(PATH_site)));
@@ -1019,7 +1017,7 @@ class tx_rtehtmlarea_select_image extends browse_links {
                                                </tr>';
 
                                                // Traverse files:
-                                       while(list(,$filepath)=each($files))    {
+                                       foreach ($files as $filepath) {
                                                $fI = pathinfo($filepath);
 
                                                        // URL of image:
index 28de698..b4a6f56 100644 (file)
@@ -179,8 +179,7 @@ class tx_rtehtmlarea_user {
                if (is_array($thisConfig['userElements.']))     {
 
                        $categories=array();
-                       reset($thisConfig['userElements.']);
-                       while(list($k)=each($thisConfig['userElements.']))      {
+                       foreach ($thisConfig['userElements.'] as $k => $value) {
                                $ki=intval($k);
                                $v = $thisConfig['userElements.'][$ki.'.'];
                                if (substr($k,-1)=="." && is_array($v)) {
@@ -195,9 +194,8 @@ class tx_rtehtmlarea_user {
                                                                if ($v['path'] && @is_dir(PATH_site.$v['path']))        {
                                                                        $files = t3lib_div::getFilesInDir(PATH_site.$v['path'],'gif,jpg,jpeg,png',0,'');
                                                                        if (is_array($files))   {
-                                                                               reset($files);
                                                                                $c=0;
-                                                                               while(list(,$filename)=each($files))    {
+                                                                               foreach ($files as $filename) {
                                                                                        $iInfo = @getimagesize(PATH_site.$v['path'].$filename);
                                                                                        $iInfo = $this->calcWH($iInfo,50,100);
 
@@ -221,8 +219,7 @@ class tx_rtehtmlarea_user {
                                                                $v=$mArray;
                                                        }
                                                }
-                                               reset($v);
-                                               while(list($k2)=each($v))       {
+                                               foreach ($v as $k2 => $dummyValue) {
                                                        $k2i = intval($k2);
                                                        if (substr($k2,-1)=='.' && is_array($v[$k2i.'.']))      {
                                                                $title = trim($v[$k2i]);
@@ -271,8 +268,7 @@ class tx_rtehtmlarea_user {
 
                        # Render menu of the items:
                        $lines=array();
-                       reset($categories);
-                       while(list($k,$v)=each($categories))    {
+                       foreach ($categories as $k => $v) {
                                $title = trim($thisConfig['userElements.'][$k]);
                                $openK = $k;
                                if (!$title)    {