Fixed issue #13670: Performance optimization: change while(list() to foreach() (thank...
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_querygenerator.php
old mode 100755 (executable)
new mode 100644 (file)
index a4d580d..1a22c9f
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 2001-2006 Christian Jul Jensen (christian@typo3.com)
+*  (c) 2001-2009 Christian Jul Jensen (christian@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -233,6 +233,8 @@ class t3lib_queryGenerator  {
        var $enableQueryParts = 0;
        var $extJSCODE='';
 
+       protected $formName = '';
+
 
 
 
@@ -247,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';
@@ -281,20 +282,19 @@ 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'];
                                if (is_array($fC) && $fC['label'])      {
-                                       $this->fields[$fN]['label'] = ereg_replace(':$','',trim($GLOBALS['LANG']->sL($fC['label'])));
+                                       $this->fields[$fN]['label'] = rtrim(trim($GLOBALS['LANG']->sL($fC['label'])), ':');
                                        switch ($this->fields[$fN]['type'])     {
                                                case 'input':
-                                                       if (eregi('int|year', $this->fields[$fN]['eval']))      {
+                                                       if (preg_match('/int|year/i', $this->fields[$fN]['eval']))      {
                                                                $this->fields[$fN]['type']='number';
-                                                       } elseif (eregi('time', $this->fields[$fN]['eval']))    {
+                                                       } elseif (preg_match('/time/i', $this->fields[$fN]['eval']))    {
                                                                $this->fields[$fN]['type'] = 'time';
-                                                       } elseif (eregi('date', $this->fields[$fN]['eval']))    {
+                                                       } elseif (preg_match('/date/i', $this->fields[$fN]['eval']))    {
                                                                $this->fields[$fN]['type']='date';
                                                        } else {
                                                                $this->fields[$fN]['type']='text';
@@ -409,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);
@@ -535,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'];
@@ -587,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_'));
@@ -624,31 +621,31 @@ class t3lib_queryGenerator        {
                                case 'date':
                                        $lineHTML.=$this->mkTypeSelect($this->name.$subscript.'[type]',$fName);
                                        $lineHTML.=$this->mkCompSelect($this->name.$subscript.'[comparison]',$conf['comparison'],$conf['negate']?1:0);
-                                       $lineHTML.='<input type="checkbox"'.($conf['negate']?' checked':'').' name="'.$this->name.$subscript.'[negate]'.'" onClick="submit();">';
+                                       $lineHTML.='<input type="checkbox" class="checkbox"' . ($conf['negate']?' checked':'').' name="'.$this->name.$subscript.'[negate]'.'" onClick="submit();">';
 
                                        if ($conf['comparison']==100 || $conf['comparison']==101)       {       // between
-                                               $lineHTML.='<input type="text" name="'.$this->name.$subscript.'[inputValue]_hr'.'" value="'.strftime('%e-%m-%Y', $conf['inputValue']).'" '.$GLOBALS['TBE_TEMPLATE']->formWidth(10).' onChange="typo3FormFieldGet(\''.$this->name.$subscript.'[inputValue]\', \'date\', \'\', 0,0);"><input type="hidden" value="'.htmlspecialchars($conf['inputValue']).'" name="'.$this->name.$subscript.'[inputValue]'.'">';
-                                               $lineHTML.='<input type="text" name="'.$this->name.$subscript.'[inputValue1]_hr'.'" value="'.strftime('%e-%m-%Y', $conf['inputValue1']).'" '.$GLOBALS['TBE_TEMPLATE']->formWidth(10).' onChange="typo3FormFieldGet(\''.$this->name.$subscript.'[inputValue1]\', \'date\', \'\', 0,0);"><input type="hidden" value="'.htmlspecialchars($conf['inputValue1']).'" name="'.$this->name.$subscript.'[inputValue1]'.'">';
-                                               $this->extJSCODE.='typo3FormFieldSet("'.$this->name.$subscript.'[inputValue]", '.date.', "", 0,0);';
-                                               $this->extJSCODE.='typo3FormFieldSet("'.$this->name.$subscript.'[inputValue1]", '.date.', "", 0,0);';
+                                               $lineHTML.='<input type="text" name="'.$this->name.$subscript.'[inputValue]_hr'.'" value="'.strftime('%e-%m-%Y', $conf['inputValue']).'" '.$GLOBALS['TBE_TEMPLATE']->formWidth(10).' onChange="typo3form.fieldGet(\''.$this->name.$subscript.'[inputValue]\', \'date\', \'\', 0,0);"><input type="hidden" value="'.htmlspecialchars($conf['inputValue']).'" name="'.$this->name.$subscript.'[inputValue]'.'">';
+                                               $lineHTML.='<input type="text" name="'.$this->name.$subscript.'[inputValue1]_hr'.'" value="'.strftime('%e-%m-%Y', $conf['inputValue1']).'" '.$GLOBALS['TBE_TEMPLATE']->formWidth(10).' onChange="typo3form.fieldGet(\''.$this->name.$subscript.'[inputValue1]\', \'date\', \'\', 0,0);"><input type="hidden" value="'.htmlspecialchars($conf['inputValue1']).'" name="'.$this->name.$subscript.'[inputValue1]'.'">';
+                                               $this->extJSCODE.='typo3form.fieldSet("'.$this->name.$subscript.'[inputValue]", "date", "", 0,0);';
+                                               $this->extJSCODE.='typo3form.fieldSet("'.$this->name.$subscript.'[inputValue1]", "date", "", 0,0);';
                                        } else {
-                                               $lineHTML.='<input type="text" name="'.$this->name.$subscript.'[inputValue]_hr'.'" value="'.strftime('%e-%m-%Y', $conf['inputValue']).'" '.$GLOBALS['TBE_TEMPLATE']->formWidth(10).' onChange="typo3FormFieldGet(\''.$this->name.$subscript.'[inputValue]\', \'date\', \'\', 0,0);"><input type="hidden" value="'.htmlspecialchars($conf['inputValue']).'" name="'.$this->name.$subscript.'[inputValue]'.'">';
-                                               $this->extJSCODE.='typo3FormFieldSet("'.$this->name.$subscript.'[inputValue]", '.date.', "", 0,0);';
+                                               $lineHTML.='<input type="text" name="'.$this->name.$subscript.'[inputValue]_hr'.'" value="'.strftime('%e-%m-%Y', $conf['inputValue']).'" '.$GLOBALS['TBE_TEMPLATE']->formWidth(10).' onChange="typo3form.fieldGet(\''.$this->name.$subscript.'[inputValue]\', \'date\', \'\', 0,0);"><input type="hidden" value="'.htmlspecialchars($conf['inputValue']).'" name="'.$this->name.$subscript.'[inputValue]'.'">';
+                                               $this->extJSCODE.='typo3form.fieldSet("'.$this->name.$subscript.'[inputValue]", "date", "", 0,0);';
                                        }
                                break;
                                case 'time':
                                        $lineHTML.=$this->mkTypeSelect($this->name.$subscript.'[type]', $fName);
                                        $lineHTML.=$this->mkCompSelect($this->name.$subscript.'[comparison]', $conf['comparison'], $conf['negate']?1:0);
 
-                                       $lineHTML.='<input type="checkbox"'.($conf['negate']?' checked':'').' name="'.$this->name.$subscript.'[negate]'.'" onClick="submit();">';
+                                       $lineHTML.='<input type="checkbox" class="checkbox"'.($conf['negate']?' checked':'').' name="'.$this->name.$subscript.'[negate]'.'" onClick="submit();">';
                                        if ($conf['comparison']==100 || $conf['comparison']==101)       {       // between:
-                                               $lineHTML.='<input type="text" name="'.$this->name.$subscript.'[inputValue]_hr'.'" value="'.strftime('%H:%M %e-%m-%Y', $conf['inputValue']).'" '.$GLOBALS['TBE_TEMPLATE']->formWidth(10).' onChange="typo3FormFieldGet(\''.$this->name.$subscript.'[inputValue]\', \'datetime\', \'\', 0,0);"><input type="hidden" value="'.htmlspecialchars($conf['inputValue']).'" name="'.$this->name.$subscript.'[inputValue]'.'">';
-                                               $lineHTML.='<input type="text" name="'.$this->name.$subscript.'[inputValue1]_hr'.'" value="'.strftime('%H:%M %e-%m-%Y', $conf['inputValue1']).'" '.$GLOBALS['TBE_TEMPLATE']->formWidth(10).' onChange="typo3FormFieldGet(\''.$this->name.$subscript.'[inputValue1]\', \'datetime\', \'\', 0,0);"><input type="hidden" value="'.htmlspecialchars($conf['inputValue1']).'" name="'.$this->name.$subscript.'[inputValue1]'.'">';
-                                               $this->extJSCODE.='typo3FormFieldSet("'.$this->name.$subscript.'[inputValue]", '.datetime.', "", 0,0);';
-                                               $this->extJSCODE.='typo3FormFieldSet("'.$this->name.$subscript.'[inputValue1]", '.datetime.', "", 0,0);';
+                                               $lineHTML.='<input type="text" name="'.$this->name.$subscript.'[inputValue]_hr'.'" value="'.strftime('%H:%M %e-%m-%Y', $conf['inputValue']).'" '.$GLOBALS['TBE_TEMPLATE']->formWidth(10).' onChange="typo3form.fieldGet(\''.$this->name.$subscript.'[inputValue]\', \'datetime\', \'\', 0,0);"><input type="hidden" value="'.htmlspecialchars($conf['inputValue']).'" name="'.$this->name.$subscript.'[inputValue]'.'">';
+                                               $lineHTML.='<input type="text" name="'.$this->name.$subscript.'[inputValue1]_hr'.'" value="'.strftime('%H:%M %e-%m-%Y', $conf['inputValue1']).'" '.$GLOBALS['TBE_TEMPLATE']->formWidth(10).' onChange="typo3form.fieldGet(\''.$this->name.$subscript.'[inputValue1]\', \'datetime\', \'\', 0,0);"><input type="hidden" value="'.htmlspecialchars($conf['inputValue1']).'" name="'.$this->name.$subscript.'[inputValue1]'.'">';
+                                               $this->extJSCODE.='typo3form.fieldSet("'.$this->name.$subscript.'[inputValue]", "datetime", "", 0,0);';
+                                               $this->extJSCODE.='typo3form.fieldSet("'.$this->name.$subscript.'[inputValue1]", "datetime", "", 0,0);';
                                        } else {
-                                               $lineHTML.='<input type="text" name="'.$this->name.$subscript.'[inputValue]_hr'.'" value="'.strftime('%H:%M %e-%m-%Y', $conf['inputValue']).'" '.$GLOBALS['TBE_TEMPLATE']->formWidth(10).' onChange="typo3FormFieldGet(\''.$this->name.$subscript.'[inputValue]\', \'datetime\', \'\', 0,0);"><input type="hidden" value="'.htmlspecialchars($conf['inputValue']).'" name="'.$this->name.$subscript.'[inputValue]'.'">';
-                                               $this->extJSCODE.='typo3FormFieldSet("'.$this->name.$subscript.'[inputValue]", '.datetime.', "", 0,0);';
+                                               $lineHTML.='<input type="text" name="'.$this->name.$subscript.'[inputValue]_hr'.'" value="'.strftime('%H:%M %e-%m-%Y', intval($conf['inputValue'])).'" '.$GLOBALS['TBE_TEMPLATE']->formWidth(10).' onChange="typo3form.fieldGet(\''.$this->name.$subscript.'[inputValue]\', \'datetime\', \'\', 0,0);"><input type="hidden" value="'.htmlspecialchars($conf['inputValue']).'" name="'.$this->name.$subscript.'[inputValue]'.'">';
+                                               $this->extJSCODE.='typo3form.fieldSet("'.$this->name.$subscript.'[inputValue]", "datetime", "", 0,0);';
                                        }
                                break;
                                case 'multiple':
@@ -656,7 +653,7 @@ class t3lib_queryGenerator  {
                                case 'relation':
                                        $lineHTML.=$this->mkTypeSelect($this->name.$subscript.'[type]', $fName);
                                        $lineHTML.=$this->mkCompSelect($this->name.$subscript.'[comparison]', $conf['comparison'], $conf['negate']?1:0);
-                                       $lineHTML.='<input type="checkbox"'.($conf['negate']?' checked':'').' name="'.$this->name.$subscript.'[negate]'.'" onClick="submit();">';
+                                       $lineHTML.='<input type="checkbox" class="checkbox"'.($conf['negate']?' checked':'').' name="'.$this->name.$subscript.'[negate]'.'" onClick="submit();">';
                                        if ($conf['comparison']==68 || $conf['comparison']==69 || $conf['comparison']==162 || $conf['comparison']==163) {
                                                $lineHTML.='<select name="'.$this->name.$subscript.'[inputValue]'.'[]" style="vertical-align:top;" size="5" multiple>';
                                        } elseif ($conf['comparison']==66 || $conf['comparison']==67)   {
@@ -675,7 +672,7 @@ class t3lib_queryGenerator  {
                                case 'files':
                                        $lineHTML.= $this->mkTypeSelect($this->name.$subscript.'[type]', $fName);
                                        $lineHTML.= $this->mkCompSelect($this->name.$subscript.'[comparison]', $conf['comparison'], $conf['negate']?1:0);
-                                       $lineHTML.= '<input type="checkbox"'.($conf['negate']?' checked':'').' name="'.$this->name.$subscript.'[negate]'.'" onClick="submit();">';
+                                       $lineHTML.= '<input type="checkbox" class="checkbox"'.($conf['negate']?' checked':'').' name="'.$this->name.$subscript.'[negate]'.'" onClick="submit();">';
                                        if ($conf['comparison']==68 || $conf['comparison']==69) {
                                                $lineHTML .= '<select name="'.$this->name.$subscript.'[inputValue]'.'[]" style="vertical-align:top;" size="5" multiple>';
                                        } else {
@@ -690,13 +687,13 @@ class t3lib_queryGenerator        {
                                case 'boolean':
                                        $lineHTML .= $this->mkTypeSelect($this->name.$subscript.'[type]', $fName);
                                        $lineHTML .= $this->mkCompSelect($this->name.$subscript.'[comparison]', $conf['comparison'], $conf['negate']?1:0);
-                                       $lineHTML .= '<input type="checkbox"'.($conf['negate']?' checked':'').' name="'.$this->name.$subscript.'[negate]'.'" onClick="submit();">';
+                                       $lineHTML .= '<input type="checkbox" class="checkbox"'.($conf['negate']?' checked':'').' name="'.$this->name.$subscript.'[negate]'.'" onClick="submit();">';
                                        $lineHTML .= '<input type="hidden" value="1" name="'.$this->name.$subscript.'[inputValue]'.'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(10).'>';
                                break;
                                default:
                                        $lineHTML .= $this->mkTypeSelect($this->name.$subscript.'[type]', $fName);
                                        $lineHTML .= $this->mkCompSelect($this->name.$subscript.'[comparison]', $conf['comparison'], $conf['negate']?1:0);
-                                       $lineHTML .= '<input type="checkbox"'.($conf['negate']?' checked':'').' name="'.$this->name.$subscript.'[negate]'.'" onClick="submit();">';
+                                       $lineHTML .= '<input type="checkbox" class="checkbox"'.($conf['negate']?' checked':'').' name="'.$this->name.$subscript.'[negate]'.'" onClick="submit();">';
                                        if ($conf['comparison']==37 || $conf['comparison']==36) {       // between:
                                                $lineHTML.='<input type="text" value="'.htmlspecialchars($conf['inputValue']).'" name="'.$this->name.$subscript.'[inputValue]'.'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(5).'>
                                                <input type="text" value="'.htmlspecialchars($conf['inputValue1']).'" name="'.$this->name.$subscript.'[inputValue1]'.'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(5).'>';    // onChange='submit();'
@@ -708,16 +705,16 @@ class t3lib_queryGenerator        {
                        if($fType != 'ignore') {
                                $lineHTML .= $this->updateIcon();
                                if ($loopcount) {
-                                       $lineHTML .= '<input type="image" border="0" src="'.$GLOBALS['BACK_PATH'].'gfx/garbage.gif" class="absmiddle" width="11" height="12" hspace="3" vspace="3" title="Remove condition" name="qG_del'.$subscript.'">';
+                                       $lineHTML .= '<input type="image" border="0" ' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/garbage.gif', 'width="11" height="12"') . 'title="Remove condition" name="qG_del'.$subscript.'">';
                                }
-                               $lineHTML .= '<input type="image" border="0" src="'.$GLOBALS['BACK_PATH'].'gfx/add.gif" class="absmiddle" width="12" height="12" hspace="3" vspace="3" title="Add condition" name="qG_ins'.$subscript.'">';
-                               if($c!=0) $lineHTML.= '<input type="image" border="0" src="'.$GLOBALS['BACK_PATH'].'gfx/pil2up.gif" class="absmiddle" width="12" height="7" hspace="3" vspace="3" title="Move up" name="qG_up'.$subscript.'">';
+                               $lineHTML .= '<input type="image" border="0" ' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/add.gif', 'width="12" height="12"') . ' title="Add condition" name="qG_ins'.$subscript.'">';
+                               if($c!=0) $lineHTML.= '<input type="image" border="0" ' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/pil2up.gif', 'width="12" height="7"') . ' title="Move up" name="qG_up'.$subscript.'">';
 
                                if($c!=0 && $fType!='newlevel') {
-                                       $lineHTML.= '<input type="image" border="0" src="'.$GLOBALS['BACK_PATH'].'gfx/pil2right.gif" class="absmiddle" height="12" width="7" hspace="3" vspace="3" title="New level" name="qG_nl'.$subscript.'">';
+                                       $lineHTML.= '<input type="image" border="0" ' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/pil2right.gif', 'height="12" width="7"') . ' title="New level" name="qG_nl'.$subscript.'">';
                                }
                                if($fType=='newlevel') {
-                                       $lineHTML.= '<input type="image" border="0" src="'.$GLOBALS['BACK_PATH'].'gfx/pil2left.gif" class="absmiddle" height="12" width="7" hspace="3" vspace="3" title="Collapse new level" name="qG_remnl'.$subscript.'">';
+                                       $lineHTML.= '<input type="image" border="0" ' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/pil2left.gif',  'height="12" width="7"') . ' title="Collapse new level" name="qG_remnl'.$subscript.'">';
                                }
 
                                $codeArr[$arrCount]['html'] = $lineHTML;
@@ -903,7 +900,7 @@ class t3lib_queryGenerator  {
                                        } else {
                                                $where_clause = 'uid';
                                                if (!$GLOBALS['SOBE']->MOD_SETTINGS['show_deleted'])    {
-                                                       $where_clause .= t3lib_BEfunc::deleteClause($from_table);
+                                                       $where_clause .= t3lib_BEfunc::deleteClause($from_table);
                                                }
                                        }
                                        $orderBy = 'uid';
@@ -951,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']))        {
@@ -974,7 +970,7 @@ class t3lib_queryGenerator  {
         * @return      [type]          ...
         */
        function formatQ($str)  {
-               return '<font size="1" face="verdana" color="maroon"><i>'.$str.'</i></font>';
+               return '<font size="1" face="verdana" color="maroon"><i>' . htmlspecialchars($str) . '</i></font>';
        }
 
        /**
@@ -1011,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'];
@@ -1030,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;
                }
@@ -1067,10 +1061,9 @@ class t3lib_queryGenerator       {
         */
        function mkFieldToInputSelect($name,$fieldName) {
                $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 src="'.$GLOBALS['BACK_PATH'].'gfx/garbage.gif" class="absmiddle" width="11" height="12" hspace="3" vspace="3" title="Clear list" border="0"></a>';
+               $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'];
@@ -1092,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>';
                        }
@@ -1176,18 +1168,17 @@ 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.=chr(10).$pad.trim($conf['operator']).' ('.$this->getQuery($queryConfig[$key]['nl'],$pad.'   ').chr(10).$pad.')';
+                                       $qs.=LF.$pad.trim($conf['operator']).' ('.$this->getQuery($queryConfig[$key]['nl'],$pad.'   ').LF.$pad.')';
                                break;
                                case 'userdef':
-                                       $qs.=chr(10).$pad.getUserDefQuery($conf,$first);
+                                       $qs.=LF.$pad.getUserDefQuery($conf,$first);
                                break;
                                default:
-                                       $qs.=chr(10).$pad.$this->getQuerySingle($conf,$first);
+                                       $qs.=LF.$pad.$this->getQuerySingle($conf,$first);
                                break;
                        }
                        $first=0;
@@ -1276,7 +1267,7 @@ class t3lib_queryGenerator        {
         * @return      [type]          ...
         */
        function updateIcon()   {
-               return '<input type="image" border="0" src="'.$GLOBALS['BACK_PATH'].'gfx/refresh_n.gif" class="absmiddle" width="14" height="14" hspace="3" vspace="3" title="Update" name="just_update">';
+               return '<input type="image" border="0" ' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/refresh_n.gif',  'width="14" height="14"') . ' title="Update" name="just_update">';
        }
 
        /**
@@ -1331,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);
@@ -1376,10 +1366,10 @@ class t3lib_queryGenerator      {
                //              debug($orderByArr);
                                $orderBy='';
                                $orderBy.=$this->mkTypeSelect('SET[queryOrder]',$orderByArr[0],'').
-                               '&nbsp;'.t3lib_BEfunc::getFuncCheck($GLOBALS['SOBE']->id,'SET[queryOrderDesc]',$modSettings['queryOrderDesc']).'&nbsp;Descending';
+                               '&nbsp;'.t3lib_BEfunc::getFuncCheck($GLOBALS['SOBE']->id,'SET[queryOrderDesc]',$modSettings['queryOrderDesc'],'','','id="checkQueryOrderDesc"').'&nbsp;<label for="checkQueryOrderDesc">Descending</label>';
                                if ($orderByArr[0])     {
                                        $orderBy.= '<BR>'.$this->mkTypeSelect('SET[queryOrder2]',$orderByArr[1],'').
-                                       '&nbsp;'.t3lib_BEfunc::getFuncCheck($GLOBALS['SOBE']->id,'SET[queryOrder2Desc]',$modSettings['queryOrder2Desc']).'&nbsp;Descending';
+                                       '&nbsp;'.t3lib_BEfunc::getFuncCheck($GLOBALS['SOBE']->id,'SET[queryOrder2Desc]',$modSettings['queryOrder2Desc'],'','','id="checkQueryOrder2Desc"').'&nbsp;<label for="checkQueryOrder2Desc">Descending</label>';
                                }
                                $out.='<tr>
                                        <td'.$TDparams.'><strong>Order By:</strong></td>
@@ -1414,8 +1404,8 @@ class t3lib_queryGenerator        {
                                ';
                        }
                }
-               $out='<table border="0" cellpadding="3" cellspacing="1">'.$out.'</table>';
-               $out.=$this->JSbottom();
+               $out='<table border="0" cellpadding="3" cellspacing="1" class="qg-make-query">'.$out.'</table>';
+               $out.=$this->JSbottom($this->formName);
                return $out;
        }
 
@@ -1480,7 +1470,9 @@ class t3lib_queryGenerator        {
                                $qString .= ' AND pid IN ('.$webMountPageTree.')';
                        }
                }
-               $fieldlist = $this->extFieldLists['queryFields'].',pid,deleted';
+               $fieldlist = $this->extFieldLists['queryFields'] .
+                       ',pid' .
+                       ($GLOBALS['TCA'][$this->table]['ctrl']['delete'] ? ',' . $GLOBALS['TCA'][$this->table]['ctrl']['delete'] : '');
                if (!$GLOBALS['SOBE']->MOD_SETTINGS['show_deleted'])    {
                        $qString .= t3lib_BEfunc::deleteClause($this->table);
                }
@@ -1501,43 +1493,29 @@ class t3lib_queryGenerator      {
         * @param       [type]          $formname: ...
         * @return      [type]          ...
         */
-       function JSbottom($formname='forms[0]') {
+       function JSbottom($formname)    {
                if ($this->extJSCODE)   {
                        $out.='
                        <script language="javascript" type="text/javascript" src="'.$GLOBALS['BACK_PATH'].'../t3lib/jsfunc.evalfield.js"></script>
+                       <script language="javascript" type="text/javascript" src="'.$GLOBALS['BACK_PATH'].'jsfunc.tbe_editor.js"></script>
                        <script language="javascript" type="text/javascript">
-                               var evalFunc = new evalFunc;
-                               function typo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue)  {
-                                       var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
-                                       var theValue = document.'.$formname.'[theField].value;
-                                       if (checkbox && theValue==checkboxValue)        {
-                                               document.'.$formname.'[theField+"_hr"].value="";
-                                               if (document.'.$formname.'[theField+"_cb"])     document.'.$formname.'[theField+"_cb"].checked = "";
-                                       } else {
-                                               document.'.$formname.'[theField+"_hr"].value = evalFunc.outputObjValue(theFObj, theValue);
-                                               if (document.'.$formname.'[theField+"_cb"])     document.'.$formname.'[theField+"_cb"].checked = "on";
-                                       }
-                               }
+                               TBE_EDITOR.formname = "'.$formname.'";
+                               TBE_EDITOR.formnameUENC = "'.rawurlencode($formname).'";
+                               TBE_EDITOR.backend_interface = "'.$GLOBALS['BE_USER']->uc['interfaceSetup'].'";
+                               '.$this->extJSCODE.'
+                       </script>';
+                       return $out;
+               }
+       }
 
        /**
-        * [Describe function...]
+        * Sets the current name of the input form.
         *
-        * @param       [type]          $theField, evallist, is_in, checkbox, checkboxValue, checkbox_off: ...
-        * @return      [type]          ...
+        * @param       string          $formName: The name of the form.
+        * @return      void
         */
-                               function typo3FormFieldGet(theField, evallist, is_in, checkbox, checkboxValue, checkbox_off)    {
-                                       var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
-                                       if (checkbox_off)       {
-                                               document.'.$formname.'[theField].value=checkboxValue;
-                                       }else{
-                                               document.'.$formname.'[theField].value = evalFunc.evalObjValue(theFObj, document.'.$formname.'[theField+"_hr"].value);
-                                       }
-                                       typo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue);
-                               }
-                       </script>
-                       <script language="javascript" type="text/javascript">'.$this->extJSCODE.'</script>';
-                       return $out;
-               }
+       public function setFormName($formName) {
+               $this->formName = trim($formName);
        }
 }
 
@@ -1545,4 +1523,5 @@ class t3lib_queryGenerator        {
 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_querygenerator.php'])   {
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_querygenerator.php']);
 }
+
 ?>