class.t3lib_querygenerator.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 2001-2008 Christian Jul Jensen (christian@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00027 /**
00028  * Class for generating front end for building queries
00029  *
00030  * $Id: class.t3lib_querygenerator.php 4432 2008-11-07 03:52:22Z flyguide $
00031  *
00032  * @author  Christian Jul Jensen <christian@typo3.com>
00033  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00034  * @coauthor    Jo Hasenau <info@cybercraft.de>
00035  */
00036 /**
00037  * [CLASS/FUNCTION INDEX of SCRIPT]
00038  *
00039  *
00040  *
00041  *   98: class t3lib_queryGenerator
00042  *  245:     function makeFieldList()
00043  *  273:     function init($name,$table,$fieldList='')
00044  *  410:     function setAndCleanUpExternalLists($name,$list,$force='')
00045  *  426:     function procesData($qC='')
00046  *  529:     function cleanUpQueryConfig($queryConfig)
00047  *  586:     function getFormElements($subLevel=0,$queryConfig='',$parent='')
00048  *  744:     function makeOptionList($fN, $conf, $table)
00049  *  953:     function printCodeArray($codeArr,$l=0)
00050  *  976:     function formatQ($str)
00051  *  989:     function mkOperatorSelect($name,$op,$draw,$submit)
00052  * 1011:     function mkTypeSelect($name,$fieldName,$prepend='FIELD_')
00053  * 1032:     function verifyType($fieldName)
00054  * 1049:     function verifyComparison($comparison,$neg)
00055  * 1068:     function mkFieldToInputSelect($name,$fieldName)
00056  * 1091:     function mkTableSelect($name,$cur)
00057  * 1113:     function mkCompSelect($name,$comparison,$neg)
00058  * 1131:     function getSubscript($arr)
00059  * 1146:     function initUserDef()
00060  * 1155:     function userDef()
00061  * 1164:     function userDefCleanUp($queryConfig)
00062  * 1175:     function getQuery ($queryConfig,$pad='')
00063  * 1205:     function getQuerySingle($conf,$first)
00064  * 1245:     function cleanInputVal($conf,$suffix='')
00065  * 1270:     function getUserDefQuery ($qcArr)
00066  * 1278:     function updateIcon()
00067  * 1287:     function getLabelCol()
00068  * 1299:     function makeSelectorTable($modSettings,$enableList='table,fields,query,group,order,limit')
00069  * 1431:     function getTreeList($id, $depth, $begin=0, $perms_clause)
00070  * 1465:     function getSelectQuery($qString = '', $fN = '')
00071  * 1504:     function JSbottom($formname='forms[0]')
00072  * 1510:     function typo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue)
00073  * 1528:     function typo3FormFieldGet(theField, evallist, is_in, checkbox, checkboxValue, checkbox_off)
00074  *
00075  * TOTAL FUNCTIONS: 32
00076  * (This index is automatically created/updated by the extension "extdeveval")
00077  *
00078  */
00079 
00080 
00081 
00082 
00083 
00084 
00085 
00086 
00087 
00088 
00089 
00090 /**
00091  * Class for generating front end for building queries
00092  *
00093  * @author  Christian Jul Jensen <christian@typo3.com>
00094  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00095  * @package TYPO3
00096  * @subpackage t3lib
00097  */
00098 class t3lib_queryGenerator  {
00099     var $lang = array(
00100         'OR' => 'or',
00101         'AND' => 'and',
00102         'comparison' => array(
00103                  // Type = text offset = 0
00104             '0_' => 'contains',
00105             '1_' => 'does not contain',
00106             '2_' => 'starts with',
00107             '3_' => 'does not start with',
00108             '4_' => 'ends with',
00109             '5_' => 'does not end with',
00110             '6_' => 'equals',
00111             '7_' => 'does not equal',
00112                  // Type = number , offset = 32
00113             '32_' => 'equals',
00114             '33_' => 'does not equal',
00115             '34_' => 'is greater than',
00116             '35_' => 'is less than',
00117             '36_' => 'is between',
00118             '37_' => 'is not between',
00119             '38_' => 'is in list',
00120             '39_' => 'is not in list',
00121             '40_' => 'binary AND equals',
00122             '41_' => 'binary AND does not equal',
00123             '42_' => 'binary OR equals',
00124             '43_' => 'binary OR does not equal',
00125                 // Type = multiple, relation, files , offset = 64
00126             '64_' => 'equals',
00127             '65_' => 'does not equal',
00128             '66_' => 'contains',
00129             '67_' => 'does not contain',
00130             '68_' => 'is in list',
00131             '69_' => 'is not in list',
00132             '70_' => 'binary AND equals',
00133             '71_' => 'binary AND does not equal',
00134             '72_' => 'binary OR equals',
00135             '73_' => 'binary OR does not equal',
00136                 // Type = date,time  offset = 96
00137             '96_' => 'equals',
00138             '97_' => 'does not equal',
00139             '98_' => 'is greater than',
00140             '99_' => 'is less than',
00141             '100_' => 'is between',
00142             '101_' => 'is not between',
00143             '102_' => 'binary AND equals',
00144             '103_' => 'binary AND does not equal',
00145             '104_' => 'binary OR equals',
00146             '105_' => 'binary OR does not equal',
00147                 // Type = boolean,  offset = 128
00148             '128_' => 'is True',
00149             '129_' => 'is False',
00150                 // Type = binary , offset = 160
00151             '160_' => 'equals',
00152             '161_' => 'does not equal',
00153             '162_' => 'contains',
00154             '163_' => 'does not contain'
00155         )
00156     );
00157 
00158     var $compSQL = array(
00159             // Type = text  offset = 0
00160         '0' => "#FIELD# LIKE '%#VALUE#%'",
00161         '1' => "#FIELD# NOT LIKE '%#VALUE#%'",
00162         '2' => "#FIELD# LIKE '#VALUE#%'",
00163         '3' => "#FIELD# NOT LIKE '#VALUE#%'",
00164         '4' => "#FIELD# LIKE '%#VALUE#'",
00165         '5' => "#FIELD# NOT LIKE '%#VALUE#'",
00166         '6' => "#FIELD# = '#VALUE#'",
00167         '7' => "#FIELD# != '#VALUE#'",
00168             // Type = number, offset = 32
00169         '32' => "#FIELD# = '#VALUE#'",
00170         '33' => "#FIELD# != '#VALUE#'",
00171         '34' => '#FIELD# > #VALUE#',
00172         '35' => '#FIELD# < #VALUE#',
00173         '36' => '#FIELD# >= #VALUE# AND #FIELD# <= #VALUE1#',
00174         '37' => 'NOT (#FIELD# >= #VALUE# AND #FIELD# <= #VALUE1#)',
00175         '38' => '#FIELD# IN (#VALUE#)',
00176         '39' => '#FIELD# NOT IN (#VALUE#)',
00177         '40' => '(#FIELD# & #VALUE#)=#VALUE#',
00178         '41' => '(#FIELD# & #VALUE#)!=#VALUE#',
00179         '42' => '(#FIELD# | #VALUE#)=#VALUE#',
00180         '43' => '(#FIELD# | #VALUE#)!=#VALUE#',
00181             // Type = multiple, relation, files , offset = 64
00182         '64' => "#FIELD# = '#VALUE#'",
00183         '65' => "#FIELD# != '#VALUE#'",
00184         '66' => "#FIELD# LIKE '%#VALUE#%' AND #FIELD# LIKE '%#VALUE1#%'",
00185         '67' => "(#FIELD# NOT LIKE '%#VALUE#%' OR #FIELD# NOT LIKE '%#VALUE1#%')",
00186         '68' => '#FIELD# IN (#VALUE#)',
00187         '69' => '#FIELD# NOT IN (#VALUE#)',
00188         '70' => '(#FIELD# & #VALUE#)=#VALUE#',
00189         '71' => '(#FIELD# & #VALUE#)!=#VALUE#',
00190         '72' => '(#FIELD# | #VALUE#)=#VALUE#',
00191         '73' => '(#FIELD# | #VALUE#)!=#VALUE#',
00192             // Type = date, offset = 32
00193         '96' => "#FIELD# = '#VALUE#'",
00194         '97' => "#FIELD# != '#VALUE#'",
00195         '98' => '#FIELD# > #VALUE#',
00196         '99' => '#FIELD# < #VALUE#',
00197         '100' => '#FIELD# >= #VALUE# AND #FIELD# <= #VALUE1#',
00198         '101' => 'NOT (#FIELD# >= #VALUE# AND #FIELD# <= #VALUE1#)',
00199         '102' => '(#FIELD# & #VALUE#)=#VALUE#',
00200         '103' => '(#FIELD# & #VALUE#)!=#VALUE#',
00201         '104' => '(#FIELD# | #VALUE#)=#VALUE#',
00202         '105' => '(#FIELD# | #VALUE#)!=#VALUE#',
00203             // Type = boolean, offset = 128
00204         '128' => "#FIELD# = '1'",
00205         '129' => "#FIELD# != '1'",
00206             // Type = binary = 160
00207         '160' => "#FIELD# = '#VALUE#'",
00208         '161' => "#FIELD# != '#VALUE#'",
00209         '162' => '(#FIELD# & #VALUE#)=#VALUE#',
00210         '163' => '(#FIELD# & #VALUE#)=0'
00211     );
00212 
00213     var $comp_offsets = array(
00214         'text' => 0,
00215         'number' => 1,
00216         'multiple' => 2,
00217         'relation' => 2,
00218         'files' => 2,
00219         'date' => 3,
00220         'time' => 3,
00221         'boolean' => 4,
00222         'binary' => 5
00223     );
00224     var $noWrap=' nowrap';
00225 
00226     var $name;          // Form data name prefix
00227     var $table;         // table for the query
00228     var $fieldList;     // field list
00229     var $fields = array();  // Array of the fields possible
00230     var $extFieldLists = array();
00231     var $queryConfig=array(); // The query config
00232     var $enablePrefix=0;
00233     var $enableQueryParts = 0;
00234     var $extJSCODE='';
00235 
00236     protected $formName = '';
00237 
00238 
00239 
00240 
00241 
00242 
00243 
00244     /**
00245      * @return  [type]      ...
00246      */
00247     function makeFieldList()    {
00248         global $TCA;
00249         $fieldListArr = array();
00250         if (is_array($TCA[$this->table]))   {
00251             t3lib_div::loadTCA($this->table);
00252             reset($TCA[$this->table]['columns']);
00253             while(list($fN)=each($TCA[$this->table]['columns']))    {
00254                 $fieldListArr[]=$fN;
00255             }
00256             $fieldListArr[]='uid';
00257             $fieldListArr[]='pid';
00258             $fieldListArr[]='deleted';
00259             if ($TCA[$this->table]['ctrl']['tstamp'])   $fieldListArr[]=$TCA[$this->table]['ctrl']['tstamp'];
00260             if ($TCA[$this->table]['ctrl']['crdate'])   $fieldListArr[]=$TCA[$this->table]['ctrl']['crdate'];
00261             if ($TCA[$this->table]['ctrl']['cruser_id'])    $fieldListArr[]=$TCA[$this->table]['ctrl']['cruser_id'];
00262             if ($TCA[$this->table]['ctrl']['sortby'])   $fieldListArr[]=$TCA[$this->table]['ctrl']['sortby'];
00263         }
00264         return implode(',',$fieldListArr);
00265     }
00266 
00267     /**
00268      * [Describe function...]
00269      *
00270      * @param   [type]      $name: ...
00271      * @param   [type]      $table: ...
00272      * @param   [type]      $fieldList: ...
00273      * @return  [type]      ...
00274      */
00275     function init($name,$table,$fieldList='')   {
00276         global $TCA;
00277 
00278             // Analysing the fields in the table.
00279         if (is_array($TCA[$table])) {
00280             t3lib_div::loadTCA($table);
00281             $this->name = $name;
00282             $this->table = $table;
00283             $this->fieldList = $fieldList ? $fieldList : $this->makeFieldList();
00284 
00285             $fieldArr = t3lib_div::trimExplode(',',$this->fieldList,1);
00286             reset($fieldArr);
00287             while(list(,$fN)=each($fieldArr))   {
00288                 $fC = $TCA[$this->table]['columns'][$fN];
00289                 $this->fields[$fN] = $fC['config'];
00290                 $this->fields[$fN]['exclude'] = $fC['exclude'];
00291                 if (is_array($fC) && $fC['label'])  {
00292                     $this->fields[$fN]['label'] = ereg_replace(':$','',trim($GLOBALS['LANG']->sL($fC['label'])));
00293                     switch ($this->fields[$fN]['type']) {
00294                         case 'input':
00295                             if (eregi('int|year', $this->fields[$fN]['eval']))  {
00296                                 $this->fields[$fN]['type']='number';
00297                             } elseif (eregi('time', $this->fields[$fN]['eval']))    {
00298                                 $this->fields[$fN]['type'] = 'time';
00299                             } elseif (eregi('date', $this->fields[$fN]['eval']))    {
00300                                 $this->fields[$fN]['type']='date';
00301                             } else {
00302                                 $this->fields[$fN]['type']='text';
00303                             }
00304                         break;
00305                         case 'check':
00306                             if (!$this->fields[$fN]['items'])   {
00307                                 $this->fields[$fN]['type'] = 'boolean';
00308                             } else {
00309                                 $this->fields[$fN]['type'] = 'binary';
00310                             }
00311                         break;
00312                         case 'radio':
00313                             $this->fields[$fN]['type'] = 'multiple';
00314                         break;
00315                         case 'select':
00316                             $this->fields[$fN]['type'] = 'multiple';
00317                             if ($this->fields[$fN]['foreign_table'])    {
00318                                 $this->fields[$fN]['type'] = 'relation';
00319                             }
00320                             if ($this->fields[$fN]['special'])  {
00321                                 $this->fields[$fN]['type'] = 'text';
00322                             }
00323                         break;
00324                         case 'group':
00325                             $this->fields[$fN]['type'] = 'files';
00326                             if ($this->fields[$fN]['internal_type'] == 'db')    {
00327                                 $this->fields[$fN]['type'] = 'relation';
00328                             }
00329                         break;
00330                         case 'user':
00331                         case 'flex':
00332                         case 'passthrough':
00333                         case 'none':
00334                         case 'text':
00335                         default:
00336                             $this->fields[$fN]['type']='text';
00337                         break;
00338                     }
00339 
00340                 } else {
00341                     $this->fields[$fN]['label']='[FIELD: '.$fN.']';
00342                     switch ($fN)    {
00343                         case 'pid':
00344                             $this->fields[$fN]['type'] = 'relation';
00345                             $this->fields[$fN]['allowed'] = 'pages';
00346                         break;
00347                         case 'cruser_id':
00348                             $this->fields[$fN]['type'] = 'relation';
00349                             $this->fields[$fN]['allowed'] = 'be_users';
00350                         break;
00351                         case 'tstamp':
00352                         case 'crdate':
00353                             $this->fields[$fN]['type'] = 'time';
00354                         break;
00355                         case 'deleted':
00356                             $this->fields[$fN]['type'] = 'boolean';
00357                         break;
00358                         default:
00359                             $this->fields[$fN]['type'] = 'number';
00360                         break;
00361                     }
00362                 }
00363             }
00364         }
00365 
00366         /*  // EXAMPLE:
00367         $this->queryConfig = array(
00368             array(
00369                 'operator' => 'AND',
00370                 'type' => 'FIELD_spaceBefore',
00371             ),
00372             array(
00373                 'operator' => 'AND',
00374                 'type' => 'FIELD_records',
00375                 'negate' => 1,
00376                 'inputValue' => 'foo foo'
00377             ),
00378             array(
00379                 'type' => 'newlevel',
00380                 'nl' => array(
00381                     array(
00382                         'operator' => 'AND',
00383                         'type' => 'FIELD_spaceBefore',
00384                         'negate' => 1,
00385                         'inputValue' => 'foo foo'
00386                     ),
00387                     array(
00388                         'operator' => 'AND',
00389                         'type' => 'FIELD_records',
00390                         'negate' => 1,
00391                         'inputValue' => 'foo foo'
00392                     )
00393                 )
00394             ),
00395             array(
00396                 'operator' => 'OR',
00397                 'type' => 'FIELD_maillist',
00398             )
00399         );
00400         */
00401         $this->initUserDef();
00402     }
00403 
00404     /**
00405      * [Describe function...]
00406      *
00407      * @param   [type]      $name: ...
00408      * @param   [type]      $list: ...
00409      * @param   [type]      $force: ...
00410      * @return  [type]      ...
00411      */
00412     function setAndCleanUpExternalLists($name,$list,$force='')  {
00413         $fields = array_unique(t3lib_div::trimExplode(',',$list.','.$force,1));
00414         reset($fields);
00415         $reList=array();
00416         while(list(,$fN)=each($fields)) {
00417             if ($this->fields[$fN])     $reList[]=$fN;
00418         }
00419         $this->extFieldLists[$name]=implode(',',$reList);
00420     }
00421 
00422     /**
00423      * [Describe function...]
00424      *
00425      * @param   [type]      $qC: ...
00426      * @return  [type]      ...
00427      */
00428     function procesData($qC='') {
00429         $this->queryConfig = $qC;
00430 
00431         $POST = t3lib_div::_POST();
00432 
00433         // if delete...
00434         if($POST['qG_del']) {
00435             //initialize array to work on, save special parameters
00436             $ssArr = $this->getSubscript($POST['qG_del']);
00437             $workArr =& $this->queryConfig;
00438             for($i=0;$i<sizeof($ssArr)-1;$i++) {
00439                 $workArr =& $workArr[$ssArr[$i]];
00440             }
00441             // delete the entry and move the other entries
00442             unset($workArr[$ssArr[$i]]);
00443             for($j=$ssArr[$i];$j<sizeof($workArr);$j++) {
00444                 $workArr[$j] = $workArr[$j+1];
00445                 unset($workArr[$j+1]);
00446             }
00447         }
00448 
00449         // if insert...
00450         if($POST['qG_ins']) {
00451             //initialize array to work on, save special parameters
00452             $ssArr = $this->getSubscript($POST['qG_ins']);
00453             $workArr =& $this->queryConfig;
00454             for($i=0;$i<sizeof($ssArr)-1;$i++) {
00455                 $workArr =& $workArr[$ssArr[$i]];
00456             }
00457             // move all entries above position where new entry is to be inserted
00458             for($j=sizeof($workArr);$j>$ssArr[$i];$j--) {
00459                 $workArr[$j] = $workArr[$j-1];
00460             }
00461             //clear new entry position
00462             unset($workArr[$ssArr[$i]+1]);
00463             $workArr[$ssArr[$i]+1]['type'] = 'FIELD_';
00464         }
00465 
00466         // if move up...
00467         if($POST['qG_up']) {
00468             //initialize array to work on
00469             $ssArr = $this->getSubscript($POST['qG_up']);
00470             $workArr =& $this->queryConfig;
00471             for($i=0;$i<sizeof($ssArr)-1;$i++) {
00472                 $workArr =& $workArr[$ssArr[$i]];
00473             }
00474             //swap entries
00475             $qG_tmp = $workArr[$ssArr[$i]];
00476             $workArr[$ssArr[$i]] = $workArr[$ssArr[$i]-1];
00477             $workArr[$ssArr[$i]-1] = $qG_tmp;
00478         }
00479 
00480         // if new level...
00481         if($POST['qG_nl']) {
00482             //initialize array to work on
00483             $ssArr = $this->getSubscript($POST['qG_nl']);
00484             $workArr =& $this->queryConfig;
00485             for($i=0;$i<sizeof($ssArr)-1;$i++) {
00486                 $workArr =& $workArr[$ssArr[$i]];
00487             }
00488             // Do stuff:
00489             $tempEl = $workArr[$ssArr[$i]];
00490             if (is_array($tempEl))  {
00491                 if ($tempEl['type']!='newlevel')    {
00492                     $workArr[$ssArr[$i]]=array(
00493                         'type' => 'newlevel',
00494                         'operator' => $tempEl['operator'],
00495                         'nl' => array($tempEl)
00496                     );
00497                 }
00498             }
00499         }
00500 
00501         // if collapse level...
00502         if($POST['qG_remnl']) {
00503             //initialize array to work on
00504             $ssArr = $this->getSubscript($POST['qG_remnl']);
00505             $workArr =& $this->queryConfig;
00506             for($i=0;$i<sizeof($ssArr)-1;$i++) {
00507                 $workArr =& $workArr[$ssArr[$i]];
00508             }
00509 
00510             // Do stuff:
00511             $tempEl = $workArr[$ssArr[$i]];
00512             if (is_array($tempEl))  {
00513                 if ($tempEl['type']=='newlevel')    {
00514                     $a1 = array_slice($workArr,0,$ssArr[$i]);
00515                     $a2 = array_slice($workArr,$ssArr[$i]);
00516                     array_shift($a2);
00517                     $a3 = $tempEl['nl'];
00518                     $a3[0]['operator'] = $tempEl['operator'];
00519                     $workArr=array_merge($a1,$a3,$a2);
00520                 }
00521             }
00522         }
00523     }
00524 
00525     /**
00526      * [Describe function...]
00527      *
00528      * @param   [type]      $queryConfig: ...
00529      * @return  [type]      ...
00530      */
00531     function cleanUpQueryConfig($queryConfig)   {
00532         //since we dont traverse the array using numeric keys in the upcoming whileloop make sure it's fresh and clean before displaying
00533         if (is_array($queryConfig)) {
00534             ksort($queryConfig);
00535         } else {
00536             //queryConfig should never be empty!
00537             if(!$queryConfig[0] || !$queryConfig[0]['type']) $queryConfig[0] = array('type'=>'FIELD_');
00538         }
00539             // Traverse:
00540         reset($queryConfig);
00541         $c=0;
00542         $arrCount=0;
00543         while(list($key,$conf)=each($queryConfig))  {
00544             if(substr($conf['type'],0,6)=='FIELD_') {
00545                 $fName = substr($conf['type'],6);
00546                 $fType = $this->fields[$fName]['type'];
00547             } elseif($conf['type']=='newlevel') {
00548                 $fType = $conf['type'];
00549             } else {
00550                 $fType = 'ignore';
00551             }
00552 //          debug($fType);
00553             switch($fType)  {
00554                 case 'newlevel':
00555                     if(!$queryConfig[$key]['nl']) $queryConfig[$key]['nl'][0]['type'] = 'FIELD_';
00556                     $queryConfig[$key]['nl']=$this->cleanUpQueryConfig($queryConfig[$key]['nl']);
00557                 break;
00558                 case 'userdef':
00559                     $queryConfig[$key]=$this->userDefCleanUp($queryConfig[$key]);
00560                 break;
00561                 case 'ignore':
00562                 default:
00563 //                  debug($queryConfig[$key]);
00564                     $verifiedName=$this->verifyType($fName);
00565                     $queryConfig[$key]['type']='FIELD_'.$this->verifyType($verifiedName);
00566 
00567                     if($conf['comparison'] >> 5 != $this->comp_offsets[$fType]) $conf['comparison'] = $this->comp_offsets[$fType] << 5;
00568                     $queryConfig[$key]['comparison']=$this->verifyComparison($conf['comparison'],$conf['negate']?1:0);
00569 
00570                     $queryConfig[$key]['inputValue']=$this->cleanInputVal($queryConfig[$key]);
00571                     $queryConfig[$key]['inputValue1']=$this->cleanInputVal($queryConfig[$key],1);
00572 
00573 //                  debug($queryConfig[$key]);
00574             break;
00575             }
00576         }
00577         return $queryConfig;
00578     }
00579 
00580     /**
00581      * [Describe function...]
00582      *
00583      * @param   [type]      $subLevel: ...
00584      * @param   [type]      $queryConfig: ...
00585      * @param   [type]      $parent: ...
00586      * @return  [type]      ...
00587      */
00588     function getFormElements($subLevel=0,$queryConfig='',$parent='')    {
00589         $codeArr=array();
00590         if (!is_array($queryConfig))    $queryConfig=$this->queryConfig;
00591 
00592         reset($queryConfig);
00593         $c=0;
00594         $arrCount=0;
00595         while(list($key,$conf)=each($queryConfig))  {
00596             $subscript = $parent.'['.$key.']';
00597             $lineHTML = '';
00598             $lineHTML.=$this->mkOperatorSelect($this->name.$subscript,$conf['operator'],$c,($conf['type']!='FIELD_'));
00599             if(substr($conf['type'],0,6)=='FIELD_') {
00600                 $fName = substr($conf['type'],6);
00601                 $this->fieldName = $fName;
00602                 $fType = $this->fields[$fName]['type'];
00603                 if($conf['comparison'] >> 5 != $this->comp_offsets[$fType]) $conf['comparison'] = $this->comp_offsets[$fType] << 5;
00604 
00605                 //nasty nasty...
00606                 //make sure queryConfig contains _actual_ comparevalue.
00607                 //mkCompSelect don't care, but getQuery does.
00608                 $queryConfig[$key]['comparison'] += (isset($conf['negate'])-($conf['comparison']%2));
00609 
00610             } elseif($conf['type']=='newlevel') {
00611                 $fType = $conf['type'];
00612             } else {
00613                 $fType = 'ignore';
00614             }
00615             switch($fType)  {
00616                 case 'ignore':
00617                 break;
00618                 case 'newlevel':
00619                     if(!$queryConfig[$key]['nl']) $queryConfig[$key]['nl'][0]['type'] = 'FIELD_';
00620                     $lineHTML.='<input type="hidden" name="'.$this->name.$subscript.'[type]" value="newlevel">';
00621                     $codeArr[$arrCount]['sub'] = $this->getFormElements($subLevel+1,$queryConfig[$key]['nl'],$subscript.'[nl]');
00622                 break;
00623                 case 'userdef':
00624                      $lineHTML.=$this->userDef($this->name.$subscript,$conf,$fName,$fType);
00625                 break;
00626                 case 'date':
00627                     $lineHTML.=$this->mkTypeSelect($this->name.$subscript.'[type]',$fName);
00628                     $lineHTML.=$this->mkCompSelect($this->name.$subscript.'[comparison]',$conf['comparison'],$conf['negate']?1:0);
00629                     $lineHTML.='<input type="checkbox"'.($conf['negate']?' checked':'').' name="'.$this->name.$subscript.'[negate]'.'" onClick="submit();">';
00630 
00631                     if ($conf['comparison']==100 || $conf['comparison']==101)   {   // between
00632                         $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]'.'">';
00633                         $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]'.'">';
00634                         $this->extJSCODE.='typo3form.fieldSet("'.$this->name.$subscript.'[inputValue]", "date", "", 0,0);';
00635                         $this->extJSCODE.='typo3form.fieldSet("'.$this->name.$subscript.'[inputValue1]", "date", "", 0,0);';
00636                     } else {
00637                         $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]'.'">';
00638                         $this->extJSCODE.='typo3form.fieldSet("'.$this->name.$subscript.'[inputValue]", "date", "", 0,0);';
00639                     }
00640                 break;
00641                 case 'time':
00642                     $lineHTML.=$this->mkTypeSelect($this->name.$subscript.'[type]', $fName);
00643                     $lineHTML.=$this->mkCompSelect($this->name.$subscript.'[comparison]', $conf['comparison'], $conf['negate']?1:0);
00644 
00645                     $lineHTML.='<input type="checkbox"'.($conf['negate']?' checked':'').' name="'.$this->name.$subscript.'[negate]'.'" onClick="submit();">';
00646                     if ($conf['comparison']==100 || $conf['comparison']==101)   {   // between:
00647                         $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]'.'">';
00648                         $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]'.'">';
00649                         $this->extJSCODE.='typo3form.fieldSet("'.$this->name.$subscript.'[inputValue]", "datetime", "", 0,0);';
00650                         $this->extJSCODE.='typo3form.fieldSet("'.$this->name.$subscript.'[inputValue1]", "datetime", "", 0,0);';
00651                     } else {
00652                         $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]'.'">';
00653                         $this->extJSCODE.='typo3form.fieldSet("'.$this->name.$subscript.'[inputValue]", "datetime", "", 0,0);';
00654                     }
00655                 break;
00656                 case 'multiple':
00657                 case 'binary':
00658                 case 'relation':
00659                     $lineHTML.=$this->mkTypeSelect($this->name.$subscript.'[type]', $fName);
00660                     $lineHTML.=$this->mkCompSelect($this->name.$subscript.'[comparison]', $conf['comparison'], $conf['negate']?1:0);
00661                     $lineHTML.='<input type="checkbox"'.($conf['negate']?' checked':'').' name="'.$this->name.$subscript.'[negate]'.'" onClick="submit();">';
00662                     if ($conf['comparison']==68 || $conf['comparison']==69 || $conf['comparison']==162 || $conf['comparison']==163) {
00663                         $lineHTML.='<select name="'.$this->name.$subscript.'[inputValue]'.'[]" style="vertical-align:top;" size="5" multiple>';
00664                     } elseif ($conf['comparison']==66 || $conf['comparison']==67)   {
00665                         if (is_array($conf['inputValue']))  {
00666                             $conf['inputValue'] = implode(',', $conf['inputValue']);
00667                         }
00668                         $lineHTML.= '<input type="text" value="'.htmlspecialchars($conf['inputValue']).'" name="'.$this->name.$subscript.'[inputValue]'.'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(10).'>';
00669                     } else {
00670                         $lineHTML.= '<select name="'.$this->name.$subscript.'[inputValue]'.'" style="vertical-align:top;" onChange="submit();">';
00671                     }
00672                     if ($conf['comparison']!=66 && $conf['comparison']!=67) {
00673                         $lineHTML.= $this->makeOptionList($fName, $conf, $this->table);
00674                         $lineHTML.= '</select>';
00675                     }
00676                 break;
00677                 case 'files':
00678                     $lineHTML.= $this->mkTypeSelect($this->name.$subscript.'[type]', $fName);
00679                     $lineHTML.= $this->mkCompSelect($this->name.$subscript.'[comparison]', $conf['comparison'], $conf['negate']?1:0);
00680                     $lineHTML.= '<input type="checkbox"'.($conf['negate']?' checked':'').' name="'.$this->name.$subscript.'[negate]'.'" onClick="submit();">';
00681                     if ($conf['comparison']==68 || $conf['comparison']==69) {
00682                         $lineHTML .= '<select name="'.$this->name.$subscript.'[inputValue]'.'[]" style="vertical-align:top;" size="5" multiple>';
00683                     } else {
00684                         $lineHTML .= '<select name="'.$this->name.$subscript.'[inputValue]'.'" style="vertical-align:top;" onChange="submit();">';
00685                     }
00686                     $lineHTML .= '<option value=""></option>'.$this->makeOptionList($fName, $conf, $this->table);
00687                     $lineHTML .= '</select>';
00688                     if ($conf['comparison']==66 || $conf['comparison']==67) {
00689                         $lineHTML .= ' + <input type="text" value="'.htmlspecialchars($conf['inputValue1']).'" name="'.$this->name.$subscript.'[inputValue1]'.'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(10).'>';
00690                     }
00691                 break;
00692                 case 'boolean':
00693                     $lineHTML .= $this->mkTypeSelect($this->name.$subscript.'[type]', $fName);
00694                     $lineHTML .= $this->mkCompSelect($this->name.$subscript.'[comparison]', $conf['comparison'], $conf['negate']?1:0);
00695                     $lineHTML .= '<input type="checkbox"'.($conf['negate']?' checked':'').' name="'.$this->name.$subscript.'[negate]'.'" onClick="submit();">';
00696                     $lineHTML .= '<input type="hidden" value="1" name="'.$this->name.$subscript.'[inputValue]'.'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(10).'>';
00697                 break;
00698                 default:
00699                     $lineHTML .= $this->mkTypeSelect($this->name.$subscript.'[type]', $fName);
00700                     $lineHTML .= $this->mkCompSelect($this->name.$subscript.'[comparison]', $conf['comparison'], $conf['negate']?1:0);
00701                     $lineHTML .= '<input type="checkbox"'.($conf['negate']?' checked':'').' name="'.$this->name.$subscript.'[negate]'.'" onClick="submit();">';
00702                     if ($conf['comparison']==37 || $conf['comparison']==36) {   // between:
00703                         $lineHTML.='<input type="text" value="'.htmlspecialchars($conf['inputValue']).'" name="'.$this->name.$subscript.'[inputValue]'.'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(5).'>
00704                         <input type="text" value="'.htmlspecialchars($conf['inputValue1']).'" name="'.$this->name.$subscript.'[inputValue1]'.'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(5).'>';    // onChange='submit();'
00705                     } else {
00706                         $lineHTML.='<input type="text" value="'.htmlspecialchars($conf['inputValue']).'" name="'.$this->name.$subscript.'[inputValue]'.'"'.$GLOBALS['TBE_TEMPLATE']->formWidth(10).'>'; // onChange="submit();"
00707                     }
00708                 break;
00709             }
00710             if($fType != 'ignore') {
00711                 $lineHTML .= $this->updateIcon();
00712                 if ($loopcount) {
00713                     $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.'">';
00714                 }
00715                 $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.'">';
00716                 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.'">';
00717 
00718                 if($c!=0 && $fType!='newlevel') {
00719                     $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.'">';
00720                 }
00721                 if($fType=='newlevel') {
00722                     $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.'">';
00723                 }
00724 
00725                 $codeArr[$arrCount]['html'] = $lineHTML;
00726                 $codeArr[$arrCount]['query'] = $this->getQuerySingle($conf,$c>0?0:1);
00727                 $arrCount++;
00728                 $c++;
00729             }
00730             $loopcount = 1;
00731         }
00732 //      $codeArr[$arrCount] .='<input type="hidden" name="CMD" value="displayQuery">';
00733         $this->queryConfig = $queryConfig;
00734 //modifyHTMLColor($color,$R,$G,$B)
00735         return $codeArr;
00736     }
00737 
00738     /**
00739      * [Describe function...]
00740      *
00741      * @param   [type]      $codeArr: ...
00742      * @param   [type]      $l: ...
00743      * @param   [type]      $table: ...
00744      * @return  [type]      ...
00745      */
00746     function makeOptionList($fN, $conf, $table) {
00747         $fieldSetup = $this->fields[$fN];
00748         if ($fieldSetup['type']=='files')   {
00749             if ($conf['comparison']==66 || $conf['comparison']==67) {
00750                 $fileExtArray = explode(',', $fieldSetup['allowed']);
00751                 natcasesort($fileExtArray);
00752                 foreach ($fileExtArray as $fileExt) {
00753                     if (t3lib_div::inList($conf['inputValue'], $fileExt))   {
00754                         $out .= '<option value="'.$fileExt.'" selected>.'.$fileExt.'</option>';
00755                     } else {
00756                         $out .= '<option value="'.$fileExt.'">.'.$fileExt.'</option>';
00757                     }
00758                 }
00759             }
00760             $d = dir(t3lib_div::getIndpEnv(TYPO3_DOCUMENT_ROOT).'/'.$fieldSetup['uploadfolder']);
00761             while (false !== ($entry=$d->read()))   {
00762                 if ($entry=='.' || $entry=='..')    {
00763                     continue;
00764                 }
00765                 $fileArray[] = $entry;
00766             }
00767             $d->close();
00768             natcasesort($fileArray);
00769             foreach ($fileArray as $fileName)   {
00770                 if (t3lib_div::inList($conf['inputValue'], $fileName))  {
00771                     $out .= '<option value="'.$fileName.'" selected>'.$fileName.'</option>';
00772                 } else {
00773                     $out .= '<option value="'.$fileName.'">'.$fileName.'</option>';
00774                 }
00775             }
00776         }
00777         if ($fieldSetup['type']=='multiple')    {
00778             foreach ($fieldSetup['items'] as $key=>$val)    {
00779                 if (substr($val[0], 0, 4) == 'LLL:')    {
00780                     $value = $GLOBALS['LANG']->sL($val[0]);
00781                 } else {
00782                     $value = $val[0];
00783                 }
00784                 if (t3lib_div::inList($conf['inputValue'], $val[1]))    {
00785                     $out .= '<option value="'.$val[1].'" selected>'.$value.'</option>';
00786                 } else {
00787                     $out .= '<option value="'.$val[1].'">'.$value.'</option>';
00788                 }
00789             }
00790         }
00791         if ($fieldSetup['type']=='binary')  {
00792             foreach ($fieldSetup['items'] as $key=>$val)    {
00793                 if (substr($val[0], 0, 4)=='LLL:')  {
00794                     $value = $GLOBALS['LANG']->sL($val[0]);
00795                 } else {
00796                     $value = $val[0];
00797                 }
00798                 if (t3lib_div::inList($conf['inputValue'], pow(2, $key)))   {
00799                     $out .= '<option value="'.pow(2, $key).'" selected>'.$value.'</option>';
00800                 } else {
00801                     $out .= '<option value="'.pow(2, $key).'">'.$value.'</option>';
00802                 }
00803             }
00804         }
00805         if ($fieldSetup['type']=='relation')    {
00806             if ($fieldSetup['items'])   {
00807                 foreach ($fieldSetup['items'] as $key=>$val)    {
00808                     if (substr($val[0], 0, 4) == 'LLL:')    {
00809                         $value = $GLOBALS['LANG']->sL($val[0]);
00810                     } else {
00811                         $value = $val[0];
00812                     }
00813                     if (t3lib_div::inList($conf['inputValue'], $val[1]))    {
00814                         $out .= '<option value="'.$val[1].'" selected>'.$value.'</option>';
00815                     } else {
00816                         $out .= '<option value="'.$val[1].'">'.$value.'</option>';
00817                     }
00818                 }
00819             }
00820             global $TCA;
00821             if (stristr($fieldSetup['allowed'], ','))   {
00822                 $from_table_Arr = explode(',', $fieldSetup['allowed']);
00823                 $useTablePrefix = 1;
00824                 if (!$fieldSetup['prepend_tname'])  {
00825                     $checkres = $GLOBALS['TYPO3_DB']->exec_SELECTquery($fN, $table, t3lib_BEfunc::deleteClause($table), $groupBy = '', $orderBy = '', $limit = '');
00826                     if ($checkres)  {
00827                         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($checkres)) {
00828                             if (stristr($row[$fN], ','))    {
00829                                 $checkContent = explode(',', $row[$fN]);
00830                                 foreach ($checkContent as $singleValue) {
00831                                     if (!stristr($singleValue, '_'))    {
00832                                         $dontPrefixFirstTable = 1;
00833                                     }
00834                                 }
00835                             } else {
00836                                 $singleValue = $row[$fN];
00837                                 if (strlen($singleValue) && !stristr($singleValue, '_'))    {
00838                                     $dontPrefixFirstTable = 1;
00839                                 }
00840                             }
00841                         }
00842                     }
00843                 }
00844             } else {
00845                 $from_table_Arr[0] = $fieldSetup['allowed'];
00846             }
00847             if ($fieldSetup['prepend_tname'])   {
00848                 $useTablePrefix = 1;
00849             }
00850             if ($fieldSetup['foreign_table'])   {
00851                 $from_table_Arr[0] = $fieldSetup['foreign_table'];
00852             }
00853             $counter = 0;
00854             while (list(, $from_table) = each($from_table_Arr)) {
00855                 if (($useTablePrefix && !$dontPrefixFirstTable && $counter!=1) || $counter==1)  {
00856                     $tablePrefix = $from_table.'_';
00857                 }
00858                 $counter = 1;
00859                 if (is_array($TCA[$from_table]))    {
00860                     t3lib_div::loadTCA($from_table);
00861                     $labelField = $TCA[$from_table]['ctrl']['label'];
00862                     $altLabelField = $TCA[$from_table]['ctrl']['label_alt'];
00863                     if ($TCA[$from_table]['columns'][$labelField]['config']['items'])   {
00864                         foreach ($TCA[$from_table]['columns'][$labelField]['config']['items'] as $labelArray)   {
00865                             if (substr($labelArray[0], 0, 4) == 'LLL:') {
00866                                 $labelFieldSelect[$labelArray[1]] = $GLOBALS['LANG']->sL($labelArray[0]);
00867                             } else {
00868                                 $labelFieldSelect[$labelArray[1]] = $labelArray[0];
00869                             }
00870                         }
00871                         $useSelectLabels = 1;
00872                     }
00873                     if ($TCA[$from_table]['columns'][$altLabelField]['config']['items'])    {
00874                         foreach ($TCA[$from_table]['columns'][$altLabelField]['config']['items'] as $altLabelArray) {
00875                             if (substr($altLabelArray[0], 0, 4) == 'LLL:')  {
00876                                 $altLabelFieldSelect[$altLabelArray[1]] = $GLOBALS['LANG']->sL($altLabelArray[0]);
00877                             } else {
00878                                 $altLabelFieldSelect[$altLabelArray[1]] = $altLabelArray[0];
00879                             }
00880                         }
00881                         $useAltSelectLabels = 1;
00882                     }
00883                     $altLabelFieldSelect = $altLabelField ? ','.$altLabelField : '';
00884                     $select_fields = 'uid,'.$labelField.$altLabelFieldSelect;
00885                     if (!$GLOBALS['BE_USER']->isAdmin() && $GLOBALS['TYPO3_CONF_VARS']['BE']['lockBeUserToDBmounts'])   {
00886                         $webMounts = $GLOBALS['BE_USER']->returnWebmounts();
00887                         $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
00888                         foreach ($webMounts as $key => $val)    {
00889                             if ($webMountPageTree)  {
00890                                 $webMountPageTreePrefix = ',';
00891                             }
00892                             $webMountPageTree .= $webMountPageTreePrefix.$this->getTreeList($val, 999, $begin = 0, $perms_clause);
00893                         }
00894                         if ($from_table=='pages')   {
00895                             $where_clause = 'uid IN ('.$webMountPageTree.') ';
00896                             if (!$GLOBALS['SOBE']->MOD_SETTINGS['show_deleted'])    {
00897                                 $where_clause .= t3lib_BEfunc::deleteClause($from_table).' AND'.$perms_clause;
00898                             }
00899                         } else {
00900                             $where_clause = 'pid IN ('.$webMountPageTree.') ';
00901                             if (!$GLOBALS['SOBE']->MOD_SETTINGS['show_deleted'])    {
00902                                 $where_clause .= t3lib_BEfunc::deleteClause($from_table);
00903                             }
00904                         }
00905                     } else {
00906                         $where_clause = 'uid';
00907                         if (!$GLOBALS['SOBE']->MOD_SETTINGS['show_deleted'])    {
00908                                 $where_clause .= t3lib_BEfunc::deleteClause($from_table);
00909                         }
00910                     }
00911                     $orderBy = 'uid';
00912                     if (!$this->tableArray[$from_table])    {
00913                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select_fields, $from_table, $where_clause, $groupBy = '', $orderBy, $limit = '');
00914                     }
00915                     if ($res)   {
00916                         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))  {
00917                             $this->tableArray[$from_table][] = $row;
00918                         }
00919                     }
00920                     foreach ($this->tableArray[$from_table] as $key=>$val)  {
00921                         if ($useSelectLabels)   {
00922                             $outArray[$tablePrefix.$val['uid']] = htmlspecialchars($labelFieldSelect[$val[$labelField]]);
00923                         } elseif ($val[$labelField])    {
00924                             $outArray[$tablePrefix.$val['uid']] = htmlspecialchars($val[$labelField]);
00925                         } elseif ($useAltSelectLabels)  {
00926                             $outArray[$tablePrefix.$val['uid']] = htmlspecialchars($altLabelFieldSelect[$val[$altLabelField]]);
00927                         } else {
00928                             $outArray[$tablePrefix.$val['uid']] = htmlspecialchars($val[$altLabelField]);
00929                         }
00930                     }
00931                     if ($GLOBALS['SOBE']->MOD_SETTINGS['options_sortlabel'] && is_array($outArray)) {
00932                         natcasesort($outArray);
00933                     }
00934                 }
00935             }
00936             foreach ($outArray as $key2 => $val2)   {
00937                 if (t3lib_div::inList($conf['inputValue'], $key2))  {
00938                     $out .= '<option value="'.$key2.'" selected>['.$key2.'] '.$val2.'</option>';
00939                 } else {
00940                     $out .= '<option value="'.$key2.'">['.$key2.'] '.$val2.'</option>';
00941                 }
00942             }
00943         }
00944         return $out;
00945     }
00946 
00947 
00948      /**
00949  * [Describe function...]
00950  *
00951  * @param   [type]      $codeArr: ...
00952  * @param   [type]      $l: ...
00953  * @return  [type]      ...
00954  */
00955     function printCodeArray($codeArr,$l=0)  {
00956         reset($codeArr);
00957         $line='';
00958         if ($l)     $indent='<td style="vertical-align:top;"><img height="1" width="50"></td>';
00959         $lf=$l*30;
00960         $bgColor = t3lib_div::modifyHTMLColor($GLOBALS['TBE_TEMPLATE']->bgColor2,$lf,$lf,$lf);
00961         while(list($k,$v)=each($codeArr))   {
00962             $line.= '<tr>'.$indent.'<td bgcolor="'.$bgColor.'"'.$this->noWrap.'>'.$v['html'].'</td></tr>';
00963             if ($this->enableQueryParts)    {$line.= '<tr>'.$indent.'<td>'.$this->formatQ($v['query']).'</td></tr>';}
00964             if (is_array($v['sub']))    {
00965                 $line.= '<tr>'.$indent.'<td'.$this->noWrap.'>'.$this->printCodeArray($v['sub'],$l+1).'</td></tr>';
00966             }
00967         }
00968         $out='<table border="0" cellpadding="0" cellspacing="1">'.$line.'</table>';
00969         return $out;
00970     }
00971 
00972     /**
00973      * [Describe function...]
00974      *
00975      * @param   [type]      $str: ...
00976      * @return  [type]      ...
00977      */
00978     function formatQ($str)  {
00979         return '<font size="1" face="verdana" color="maroon"><i>'.$str.'</i></font>';
00980     }
00981 
00982     /**
00983      * [Describe function...]
00984      *
00985      * @param   [type]      $name: ...
00986      * @param   [type]      $op: ...
00987      * @param   [type]      $draw: ...
00988      * @param   [type]      $submit: ...
00989      * @return  [type]      ...
00990      */
00991     function mkOperatorSelect($name,$op,$draw,$submit)  {
00992         if ($draw)  {
00993             $out='<select name="'.$name.'[operator]"'.($submit?' onChange="submit();"':'').'>'; //
00994             $out.='<option value="AND"'.(!$op||$op=="AND" ? ' selected':'').'>'.$this->lang["AND"].'</option>';
00995             $out.='<option value="OR"'.($op=='OR' ? ' selected':'').'>'.$this->lang['OR'].'</option>';
00996             $out.='</select>';
00997         } else {
00998             $out.='<input type="hidden" value="'.$op.'" name="'.$name.'[operator]">';
00999             $out.='<img src="clear.gif" height="1" width="47">';
01000 
01001         }
01002         return $out;
01003     }
01004 
01005     /**
01006      * [Describe function...]
01007      *
01008      * @param   [type]      $name: ...
01009      * @param   [type]      $fieldName: ...
01010      * @param   [type]      $prepend: ...
01011      * @return  [type]      ...
01012      */
01013     function mkTypeSelect($name,$fieldName,$prepend='FIELD_')   {
01014         $out='<select name="'.$name.'" onChange="submit();">';
01015         $out.='<option value=""></option>';
01016         reset($this->fields);
01017         while(list($key,)=each($this->fields)) {
01018             if (!$fieldValue['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields', $this->table.':'.$key)) {
01019                 $label = $this->fields[$key]['label'];
01020                 $label_alt = $this->fields[$key]['label_alt'];
01021                 $out .= '<option value="'.$prepend.$key.'"'.($key==$fieldName ? ' selected' : '').'>'.$label.'</option>';
01022             }
01023         }
01024         $out.='</select>';
01025         return $out;
01026     }
01027 
01028     /**
01029      * [Describe function...]
01030      *
01031      * @param   [type]      $fieldName: ...
01032      * @return  [type]      ...
01033      */
01034     function verifyType($fieldName) {
01035         reset($this->fields);
01036         $first = '';
01037         while(list($key,)=each($this->fields)) {
01038             if (!$first)    $first = $key;
01039             if ($key==$fieldName) return $key;