Main Page | Directories | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages | Examples

t3lib_queryGenerator Class Reference

List of all members.

Public Member Functions

 makeFieldList ()
 init ($name, $table, $fieldList="")
 [Describe function...]
 setAndCleanUpExternalLists ($name, $list, $force="")
 [Describe function...]
 procesData ($qC="")
 [Describe function...]
 cleanUpQueryConfig ($queryConfig)
 [Describe function...]
 getFormElements ($subLevel=0, $queryConfig="", $parent="")
 [Describe function...]
 printCodeArray ($codeArr, $l=0)
 [Describe function...]
 formatQ ($str)
 [Describe function...]
 mkOperatorSelect ($name, $op, $draw, $submit)
 [Describe function...]
 mkTypeSelect ($name, $fieldName, $prepend="FIELD_")
 [Describe function...]
 verifyType ($fieldName)
 [Describe function...]
 verifyComparison ($comparison, $neg)
 [Describe function...]
 mkFieldToInputSelect ($name, $fieldName)
 [Describe function...]
 mkTableSelect ($name, $cur)
 [Describe function...]
 mkCompSelect ($name, $comparison, $neg)
 [Describe function...]
 getSubscript ($arr)
 [Describe function...]
 initUserDef ()
 [Describe function...]
 userDef ()
 [Describe function...]
 userDefCleanUp ($queryConfig)
 [Describe function...]
 getQuery ($queryConfig, $pad="")
 [Describe function...]
 getQuerySingle ($conf, $first)
 [Describe function...]
 cleanInputVal ($conf, $suffix="")
 [Describe function...]
 getUserDefQuery ($qcArr)
 [Describe function...]
 updateIcon ()
 [Describe function...]
 getLabelCol ()
 [Describe function...]
 makeSelectorTable ($modSettings, $enableList="table,fields,query,group,order,limit")
 [Describe function...]
 getSelectQuery ($qString="")
 [Describe function...]
 JSbottom ($formname="forms[0]")
 [Describe function...]

Public Attributes

 $lang
 $compSQL
 $comp_offsets
 $noWrap = " nowrap"
 $name
 $table
 $fieldList
 $fields = array()
 $extFieldLists = array()
 $queryConfig = array()
 $enablePrefix = 0
 $enableQueryParts = 0
 $extJSCODE = ""

Member Function Documentation

t3lib_queryGenerator::cleanInputVal conf,
suffix = ""
 

[Describe function...]

Parameters:
[type] $conf: ...
[type] $suffix: ...
Returns:
[type] ...

Definition at line 824 of file class.t3lib_querygenerator.php.

Referenced by cleanUpQueryConfig(), and getQuerySingle().

00824                                              {
00825       if(($conf["comparison"] >> 5==0) || ($conf["comparison"]==32 || $conf["comparison"]==33)) {
00826          $inputVal = $conf["inputValue".$suffix];
00827       } else {
00828          if ($conf["comparison"]==39 || $conf["comparison"]==38)  {  // in list:
00829             $inputVal = implode(",",t3lib_div::intExplode(",",$conf["inputValue".$suffix]));
00830          } else {
00831             $inputVal = doubleval($conf["inputValue".$suffix]);
00832          }
00833       }
00834       return $inputVal;
00835    }

t3lib_queryGenerator::cleanUpQueryConfig queryConfig  ) 
 

[Describe function...]

Parameters:
[type] $queryConfig: ...
Returns:
[type] ...

Definition at line 411 of file class.t3lib_querygenerator.php.

References $queryConfig, cleanInputVal(), userDefCleanUp(), verifyComparison(), and verifyType().

Referenced by makeSelectorTable().

00411                                              {
00412       //since we dont traverse the array using numeric keys in the upcoming whileloop make sure it's fresh and clean before displaying
00413       if (is_array($queryConfig))   {
00414          ksort($queryConfig);
00415       } else {
00416          //queryConfig should never be empty!
00417          if(!$queryConfig[0] || !$queryConfig[0]["type"]) $queryConfig[0] = array("type"=>"FIELD_");
00418       }
00419          // Traverse:
00420       reset($queryConfig);
00421       $c=0;
00422       $arrCount=0;
00423       while(list($key,$conf)=each($queryConfig))   {
00424          if(substr($conf["type"],0,6)=="FIELD_") {
00425             $fName = substr($conf["type"],6);
00426             $fType = $this->fields[$fName]["type"];
00427          } elseif($conf["type"]=="newlevel") {
00428             $fType = $conf["type"];
00429          } else {
00430             $fType = "ignore";
00431          }
00432 //       debug($fType);
00433          switch($fType) {
00434             case "newlevel":
00435                if(!$queryConfig[$key]["nl"]) $queryConfig[$key]["nl"][0]["type"] = "FIELD_";
00436                $queryConfig[$key]["nl"]=$this->cleanUpQueryConfig($queryConfig[$key]["nl"]);
00437             break;
00438             case "userdef":
00439                $queryConfig[$key]=$this->userDefCleanUp($queryConfig[$key]);
00440             break;
00441             case "ignore":
00442             default:
00443 //             debug($queryConfig[$key]);
00444                $verifiedName=$this->verifyType($fName);
00445                $queryConfig[$key]["type"]="FIELD_".$this->verifyType($verifiedName);
00446 
00447                if($conf["comparison"] >> 5 != $this->comp_offsets[$fType]) $conf["comparison"] = $this->comp_offsets[$fType] << 5;
00448                $queryConfig[$key]["comparison"]=$this->verifyComparison($conf["comparison"],$conf["negate"]?1:0);
00449 
00450                $queryConfig[$key]["inputValue"]=$this->cleanInputVal($queryConfig[$key]);
00451                $queryConfig[$key]["inputValue1"]=$this->cleanInputVal($queryConfig[$key],1);
00452 
00453 //             debug($queryConfig[$key]);
00454          break;
00455          }
00456       }
00457       return $queryConfig;
00458    }

t3lib_queryGenerator::formatQ str  ) 
 

[Describe function...]

Parameters:
[type] $str: ...
Returns:
[type] ...

Definition at line 578 of file class.t3lib_querygenerator.php.

00578                            {
00579       return '<font size=1 face=verdana color=maroon><i>'.$str.'</i></font>';
00580    }

t3lib_queryGenerator::getFormElements subLevel = 0,
queryConfig = "",
parent = ""
 

[Describe function...]

Parameters:
[type] $subLevel: ...
[type] $queryConfig: ...
[type] $parent: ...
Returns:
[type] ...

Definition at line 468 of file class.t3lib_querygenerator.php.

References $queryConfig, getQuerySingle(), mkCompSelect(), mkOperatorSelect(), mkTypeSelect(), and updateIcon().

Referenced by makeSelectorTable().

00468                                                                      {
00469       $codeArr=array();
00470       if (!is_array($queryConfig))  $queryConfig=$this->queryConfig;
00471 
00472       reset($queryConfig);
00473       $c=0;
00474       $arrCount=0;
00475       while(list($key,$conf)=each($queryConfig))   {
00476          $subscript = $parent."[$key]";
00477          $lineHTML = "";
00478          $lineHTML.=$this->mkOperatorSelect($this->name.$subscript,$conf["operator"],$c,($conf["type"]!="FIELD_"));
00479          if(substr($conf["type"],0,6)=="FIELD_") {
00480             $fName = substr($conf["type"],6);
00481             $fType = $this->fields[$fName]["type"];
00482             if($conf["comparison"] >> 5 != $this->comp_offsets[$fType]) $conf["comparison"] = $this->comp_offsets[$fType] << 5;
00483 
00484             //nasty nasty...
00485             //make sure queryConfig contains _actual_ comparevalue.
00486             //mkCompSelect don't care, but getQuery does.
00487             $queryConfig[$key]["comparison"] += (isset($conf["negate"])-($conf["comparison"]%2));
00488 
00489          } elseif($conf["type"]=="newlevel") {
00490             $fType = $conf["type"];
00491          } else {
00492             $fType = "ignore";
00493          }
00494 //       debug($fType);
00495          switch($fType) {
00496             case "ignore":
00497             break;
00498             case "newlevel":
00499                if(!$queryConfig[$key]["nl"]) $queryConfig[$key]["nl"][0]["type"] = "FIELD_";
00500                $lineHTML.='<input type="hidden" name="'.$this->name.$subscript.'[type]" value="newlevel">';
00501                $codeArr[$arrCount]["sub"] = $this->getFormElements($subLevel+1,$queryConfig[$key]["nl"],$subscript."[nl]");
00502             break;
00503             case "userdef":
00504                 $lineHTML.=$this->userDef($this->name.$subscript,$conf,$fName,$fType);
00505             break;
00506             default:
00507                $lineHTML.=$this->mkTypeSelect($this->name.$subscript.'[type]',$fName);
00508                $lineHTML.=$this->mkCompSelect($this->name.$subscript.'[comparison]',$conf["comparison"],$conf["negate"]?1:0);
00509                $lineHTML.='<input type="checkbox" '.($conf["negate"]?"checked":"").' name="'.$this->name.$subscript.'[negate]'.'" onClick="submit();">';
00510 
00511                if ($conf["comparison"]==37 || $conf["comparison"]==36)  {  // between:
00512                   $lineHTML.='<input type="text" value="'.htmlspecialchars($conf["inputValue"]).'" name="'.$this->name.$subscript.'[inputValue]'.'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(5).'>
00513                   <input type="text" value="'.htmlspecialchars($conf["inputValue1"]).'" name="'.$this->name.$subscript.'[inputValue1]'.'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(5).'>
00514                   '; // onChange="submit();"
00515                } elseif ($fType=="date") {
00516                   $lineHTML.='<input type="text" name="'.$this->name.$subscript.'[inputValue]_hr'.'"'.$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]'.'">';
00517                   $this->extJSCODE.='typo3FormFieldSet("'.$this->name.$subscript.'[inputValue]", "datetime", "", 0,0);';
00518                } else {
00519                   $lineHTML.='<input type="text" value="'.htmlspecialchars($conf["inputValue"]).'" name="'.$this->name.$subscript.'[inputValue]'.'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(10).'>';  // onChange="submit();"
00520                }
00521             break;
00522          }
00523          if($fType != "ignore") {
00524             $lineHTML .= $this->updateIcon();
00525             $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.'">';
00526             $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.'">';
00527             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.'">';
00528 
00529             if($c!=0 && $fType!="newlevel") {
00530                $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.'">';
00531             }
00532             if($fType=="newlevel") {
00533                $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.'">';
00534             }
00535 
00536             $codeArr[$arrCount]["html"] = $lineHTML;
00537             $codeArr[$arrCount]["query"] = $this->getQuerySingle($conf,$c>0?0:1);
00538             $arrCount++;
00539             $c++;
00540          }
00541       }
00542 //    $codeArr[$arrCount] .='<input type="hidden" name="CMD" value="displayQuery">';
00543       $this->queryConfig = $queryConfig;
00544 //modifyHTMLColor($color,$R,$G,$B)
00545       return $codeArr;
00546    }

t3lib_queryGenerator::getLabelCol  ) 
 

[Describe function...]

Returns:
[type] ...

Definition at line 860 of file class.t3lib_querygenerator.php.

References $TCA.

00860                            {
00861       global $TCA;
00862       return $TCA[$this->table]["ctrl"]["label"];
00863    }

t3lib_queryGenerator::getQuery queryConfig,
pad = ""
 

[Describe function...]

Parameters:
[type] $queryConfig: ...
[type] $pad: ...
Returns:
[type] ...

Definition at line 773 of file class.t3lib_querygenerator.php.

Referenced by getSelectQuery().

00773                                             {
00774       $qs = "";
00775       //since wo dont traverse the array using numeric keys in the upcoming whileloop make sure it's fresh and clean
00776       ksort($queryConfig);
00777       reset($queryConfig);
00778       $first=1;
00779       while(list($key,$conf) = each($queryConfig)) {
00780          switch($conf["type"]) {
00781             case "newlevel":
00782                $qs.=chr(10).$pad.trim($conf["operator"])." (".$this->getQuery($queryConfig[$key]["nl"],$pad."   ").chr(10).$pad.")";
00783             break;
00784             case "userdef":
00785                $qs.=chr(10).$pad.getUserDefQuery($conf,$first);
00786             break;
00787             default:
00788                $qs.=chr(10).$pad.$this->getQuerySingle($conf,$first);
00789             break;
00790          }
00791          $first=0;
00792       }
00793       return $qs;
00794    }

t3lib_queryGenerator::getQuerySingle conf,
first
 

[Describe function...]

Parameters:
[type] $conf: ...
[type] $first: ...
Returns:
[type] ...

Definition at line 803 of file class.t3lib_querygenerator.php.

References cleanInputVal(), and table().

Referenced by getFormElements().

00803                                           {
00804       $prefix = $this->enablePrefix ? $this->table."." : "";
00805       if (!$first)   {$qs.= trim(($conf["operator"]?$conf["operator"]:"AND"))." ";}    // Is it OK to insert the AND operator if none is set?
00806       $qsTmp = str_replace("#FIELD#",$prefix.trim(substr($conf["type"],6)),$this->compSQL[$conf["comparison"]]);
00807       $inputVal = $this->cleanInputVal($conf);
00808       $qsTmp = str_replace("#VALUE#", $GLOBALS['TYPO3_DB']->quoteStr($inputVal, $this->table),$qsTmp);
00809       if ($conf["comparison"]==37 || $conf["comparison"]==36)  {  // between:
00810          $inputVal = $this->cleanInputVal($conf,"1");
00811          $qsTmp = str_replace("#VALUE1#", $GLOBALS['TYPO3_DB']->quoteStr($inputVal, $this->table),$qsTmp);
00812       }
00813       $qs .= trim($qsTmp);
00814       return $qs;
00815    }

t3lib_queryGenerator::getSelectQuery qString = ""  ) 
 

[Describe function...]

Parameters:
[type] $qString: ...
Returns:
[type] ...

Definition at line 976 of file class.t3lib_querygenerator.php.

References getQuery().

00976                                           {
00977       if (!$qString) $qString=$this->getQuery($this->queryConfig);
00978 
00979       $query = $GLOBALS['TYPO3_DB']->SELECTquery(
00980                   $this->extFieldLists["queryFields"],
00981                   $this->table,
00982                   $qString.t3lib_BEfunc::deleteClause($this->table),
00983                   trim($this->extFieldLists["queryGroup"]),
00984                   $this->extFieldLists["queryOrder"] ? trim($this->extFieldLists["queryOrder_SQL"]) : '',
00985                   $this->extFieldLists["queryLimit"]
00986                );
00987       return $query;
00988    }

t3lib_queryGenerator::getSubscript arr  ) 
 

[Describe function...]

Parameters:
[type] $arr: ...
Returns:
[type] ...

Definition at line 729 of file class.t3lib_querygenerator.php.

Referenced by procesData().

00729                                {
00730       while(is_array($arr)) {
00731          reset($arr);
00732          list($key,)=each($arr);
00733          $retArr[] = $key;
00734          $arr = $arr[$key];
00735       }
00736       return $retArr;
00737    }

t3lib_queryGenerator::getUserDefQuery qcArr  ) 
 

[Describe function...]

Parameters:
[type] $qcArr: ...
Returns:
[type] ...

Definition at line 843 of file class.t3lib_querygenerator.php.

00843                                      {
00844    }

t3lib_queryGenerator::init name,
table,
fieldList = ""
 

[Describe function...]

Parameters:
[type] $name: ...
[type] $table: ...
[type] $fieldList: ...
Returns:
[type] ...

Definition at line 203 of file class.t3lib_querygenerator.php.

References $fieldList, $TCA, initUserDef(), makeFieldList(), and table().

00203                                              {
00204       global $TCA;
00205 
00206          // Analysing the fields in the table.
00207       if (is_array($TCA[$table]))   {
00208          t3lib_div::loadTCA($table);
00209          $this->name = $name;
00210          $this->table = $table;
00211          $this->fieldList = $fieldList ? $fieldList : $this->makeFieldList();
00212 
00213          $fieldArr = t3lib_div::trimExplode(",",$this->fieldList,1);
00214          reset($fieldArr);
00215          while(list(,$fN)=each($fieldArr))   {
00216             $fC = $TCA[$this->table]["columns"][$fN];
00217             if (is_array($fC) && $fC["label"])  {
00218                $this->fields[$fN]["label"] = ereg_replace(":$","",trim($GLOBALS["LANG"]->sL($fC["label"])));
00219                switch($fC["config"]["type"]) {
00220                   case "input":
00221                      if (eregi("int|year",$fC["config"]["eval"])) {
00222                         $this->fields[$fN]["type"]="number";
00223                      } elseif (eregi("date|time",$fC["config"]["eval"]))   {
00224                         $this->fields[$fN]["type"]="date";
00225                      } else {
00226                         $this->fields[$fN]["type"]="text";
00227                      }
00228                   break;
00229                   case "check":
00230                   case "select":
00231                      $this->fields[$fN]["type"]="number";
00232                   break;
00233                   case "text":
00234                   default:
00235                      $this->fields[$fN]["type"]="text";
00236                   break;
00237                }
00238 
00239             } else {
00240                $this->fields[$fN]["label"]="[FIELD: ".$fN."]";
00241                $this->fields[$fN]["type"]="number";
00242             }
00243          }
00244       }
00245 
00246       /* // EXAMPLE:
00247       $this->queryConfig = array(
00248          array(
00249             "operator" => "AND",
00250             "type" => "FIELD_spaceBefore",
00251          ),
00252          array(
00253             "operator" => "AND",
00254             "type" => "FIELD_records",
00255             "negate" => 1,
00256             "inputValue" => "foo foo"
00257          ),
00258          array(
00259             "type" => "newlevel",
00260             "nl" => array(
00261                array(
00262                   "operator" => "AND",
00263                   "type" => "FIELD_spaceBefore",
00264                   "negate" => 1,
00265                   "inputValue" => "foo foo"
00266                ),
00267                array(
00268                   "operator" => "AND",
00269                   "type" => "FIELD_records",
00270                   "negate" => 1,
00271                   "inputValue" => "foo foo"
00272                )
00273             )
00274          ),
00275          array(
00276             "operator" => "OR",
00277             "type" => "FIELD_maillist",
00278          )
00279       );
00280       */
00281       $this->initUserDef();
00282    }

t3lib_queryGenerator::initUserDef  ) 
 

[Describe function...]

Returns:
[type] ...

Definition at line 744 of file class.t3lib_querygenerator.php.

Referenced by init().

00744                            {
00745 
00746    }

t3lib_queryGenerator::JSbottom formname = "forms[0]"  ) 
 

[Describe function...]

Parameters:
[type] $formname: ...
Returns:
[type] ...

[Describe function...]

Parameters:
[type] $theField, evallist, is_in, checkbox, checkboxValue, checkbox_off: ...
Returns:
[type] ...

Definition at line 996 of file class.t3lib_querygenerator.php.

References $out.

Referenced by makeSelectorTable().

00996                                              {
00997       if ($this->extJSCODE)   {
00998          $out.='
00999          <script language="javascript" type="text/javascript" src="'.$GLOBALS["BACK_PATH"].'t3lib/jsfunc.evalfield.js"></script>
01000          <script language="javascript" type="text/javascript">
01001             var evalFunc = new evalFunc;
01002             function typo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue)   {
01003                var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
01004                var theValue = document.'.$formname.'[theField].value;
01005                if (checkbox && theValue==checkboxValue)  {
01006                   document.'.$formname.'[theField+"_hr"].value="";
01007                   if (document.'.$formname.'[theField+"_cb"])  document.'.$formname.'[theField+"_cb"].checked = "";
01008                } else {
01009                   document.'.$formname.'[theField+"_hr"].value = evalFunc.outputObjValue(theFObj, theValue);
01010                   if (document.'.$formname.'[theField+"_cb"])  document.'.$formname.'[theField+"_cb"].checked = "on";
01011                }
01012             }
01013 
01020             function typo3FormFieldGet(theField, evallist, is_in, checkbox, checkboxValue, checkbox_off) {
01021                var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
01022                if (checkbox_off) {
01023                   document.'.$formname.'[theField].value=checkboxValue;
01024                }else{
01025                   document.'.$formname.'[theField].value = evalFunc.evalObjValue(theFObj, document.'.$formname.'[theField+"_hr"].value);
01026                }
01027                typo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue);
01028             }
01029          </script>
01030          <script language="javascript" type="text/javascript">'.$this->extJSCODE.'</script>';
01031          return $out;
01032       }
01033    }

t3lib_queryGenerator::makeFieldList  ) 
 

Returns:
[type] ...

Definition at line 176 of file class.t3lib_querygenerator.php.

References $TCA.

Referenced by init().

00176                               {
00177       global $TCA;
00178       $fieldListArr = array();
00179       if (is_array($TCA[$this->table]))   {
00180          t3lib_div::loadTCA($this->table);
00181          reset($TCA[$this->table]["columns"]);
00182          while(list($fN)=each($TCA[$this->table]["columns"]))  {
00183             $fieldListArr[]=$fN;
00184          }
00185          $fieldListArr[]="uid";
00186          $fieldListArr[]="pid";
00187          if ($TCA[$this->table]["ctrl"]["tstamp"]) $fieldListArr[]=$TCA[$this->table]["ctrl"]["tstamp"];
00188          if ($TCA[$this->table]["ctrl"]["crdate"]) $fieldListArr[]=$TCA[$this->table]["ctrl"]["crdate"];
00189          if ($TCA[$this->table]["ctrl"]["cruser_id"]) $fieldListArr[]=$TCA[$this->table]["ctrl"]["cruser_id"];
00190          if ($TCA[$this->table]["ctrl"]["sortby"]) $fieldListArr[]=$TCA[$this->table]["ctrl"]["sortby"];
00191       }
00192       return implode(",",$fieldListArr);
00193    }

t3lib_queryGenerator::makeSelectorTable modSettings,
enableList = "table,fields,query,group,order,limit"
 

[Describe function...]

Parameters:
[type] $modSettings: ...
[type] $enableList: ...
Returns:
[type] ...

Definition at line 872 of file class.t3lib_querygenerator.php.

References $out, cleanUpQueryConfig(), getFormElements(), JSbottom(), mkFieldToInputSelect(), mkTableSelect(), mkTypeSelect(), printCodeArray(), procesData(), setAndCleanUpExternalLists(), table(), and updateIcon().

00872                                                                                                 {
00873       $enableArr=explode(",",$enableList);
00874          // Make output
00875       $TDparams = ' class="bgColor5" nowrap';
00876 
00877       if (in_array("table",$enableArr))   {
00878          $out='
00879          <tr>
00880             <td'.$TDparams.'><strong>Select a table:</strong></td>
00881             <td'.$TDparams.'>'.$this->mkTableSelect("SET[queryTable]",$this->table).'</td>
00882          </tr>';
00883       }
00884       if ($this->table) {
00885 
00886             // Init fields:
00887          $this->setAndCleanUpExternalLists("queryFields",$modSettings["queryFields"],"uid,".$this->getLabelCol());
00888          $this->setAndCleanUpExternalLists("queryGroup",$modSettings["queryGroup"]);
00889          $this->setAndCleanUpExternalLists("queryOrder",$modSettings["queryOrder"].",".$modSettings["queryOrder2"]);
00890 
00891             // Limit:
00892          $this->extFieldLists["queryLimit"]=$modSettings["queryLimit"];
00893          if (!$this->extFieldLists["queryLimit"])  $this->extFieldLists["queryLimit"]=100;
00894          $parts = t3lib_div::intExplode(",",$this->extFieldLists["queryLimit"]);
00895          $this->extFieldLists["queryLimit"] = implode(",",array_slice($parts,0,2));
00896 
00897             // Insert Descending parts
00898          if ($this->extFieldLists["queryOrder"])   {
00899             $descParts = explode(",",$modSettings["queryOrderDesc"].",".$modSettings["queryOrder2Desc"]);
00900             $orderParts = explode(",",$this->extFieldLists["queryOrder"]);
00901             reset($orderParts);
00902             $reList=array();
00903             while(list($kk,$vv)=each($orderParts)) {
00904                $reList[]=$vv.($descParts[$kk]?" DESC":"");
00905             }
00906             $this->extFieldLists["queryOrder_SQL"] = implode(",",$reList);
00907          }
00908 
00909             // Query Generator:
00910          $this->procesData($modSettings["queryConfig"] ? unserialize($modSettings["queryConfig"]) : "");
00911    //    debug($this->queryConfig);
00912          $this->queryConfig = $this->cleanUpQueryConfig($this->queryConfig);
00913    //    debug($this->queryConfig);
00914          $this->enableQueryParts = $modSettings["search_query_smallparts"];
00915 
00916          $codeArr=$this->getFormElements();
00917          $queryCode=$this->printCodeArray($codeArr);
00918 
00919          if (in_array("fields",$enableArr))  {
00920             $out.='
00921             <tr>
00922                <td'.$TDparams.'><strong>Select fields:</strong></td>
00923                <td'.$TDparams.'>'.$this->mkFieldToInputSelect("SET[queryFields]",$this->extFieldLists["queryFields"]).'</td>
00924             </tr>';
00925          }
00926          if (in_array("query",$enableArr))   {
00927             $out.='<tr>
00928                <td colspan=2'.$TDparams.'><strong>Make Query:</strong></td>
00929             </tr>
00930             <tr>
00931                <td colspan=2>'.$queryCode.'</td>
00932             </tr>
00933             ';
00934          }
00935          if (in_array("group",$enableArr))   {
00936             $out.='<tr>
00937                <td'.$TDparams.'><strong>Group By:</strong></td>
00938                <td'.$TDparams.'>'.$this->mkTypeSelect("SET[queryGroup]",$this->extFieldLists["queryGroup"],"").'</td>
00939             </tr>';
00940          }
00941          if (in_array("order",$enableArr))   {
00942             $orderByArr = explode(",",$this->extFieldLists["queryOrder"]);
00943       //    debug($orderByArr);
00944             $orderBy="";
00945             $orderBy.=$this->mkTypeSelect("SET[queryOrder]",$orderByArr[0],"").
00946             "&nbsp;".t3lib_BEfunc::getFuncCheck($GLOBALS["SOBE"]->id,"SET[queryOrderDesc]",$modSettings["queryOrderDesc"])."&nbsp;Descending";
00947             if ($orderByArr[0])  {
00948                $orderBy.= "<BR>".$this->mkTypeSelect("SET[queryOrder2]",$orderByArr[1],"").
00949                "&nbsp;".t3lib_BEfunc::getFuncCheck($GLOBALS["SOBE"]->id,"SET[queryOrder2Desc]",$modSettings["queryOrder2Desc"])."&nbsp;Descending";
00950             }
00951             $out.='<tr>
00952                <td'.$TDparams.'><strong>Order By:</strong></td>
00953                <td'.$TDparams.'>'.$orderBy.'</td>
00954             </tr>';
00955          }
00956          if (in_array("limit",$enableArr))   {
00957             $limit = '<input type="Text" value="'.htmlspecialchars($this->extFieldLists["queryLimit"]).'" name="SET[queryLimit]"'.$GLOBALS["TBE_TEMPLATE"]->formWidth(10).'>'.$this->updateIcon();
00958             $out.='<tr>
00959                <td'.$TDparams.'><strong>Limit:</strong></td>
00960                <td'.$TDparams.'>'.$limit.'</td>
00961             </tr>
00962             ';
00963          }
00964       }
00965       $out='<table border=0 cellpadding=3 cellspacing=1>'.$out.'</table>';
00966       $out.=$this->JSbottom();
00967       return $out;
00968    }

t3lib_queryGenerator::mkCompSelect name,
comparison,
neg
 

[Describe function...]

Parameters:
[type] $name: ...
[type] $comparison: ...
[type] $neg: ...
Returns:
[type] ...

Definition at line 711 of file class.t3lib_querygenerator.php.

References $out.

Referenced by getFormElements().

00711                                                    {
00712       $compOffSet = $comparison >> 5;
00713       $out='<select name="'.$name.'" onChange="submit();">';
00714       for($i=32*$compOffSet+$neg;$i<32*($compOffSet+1);$i+=2) {
00715          if($this->lang["comparison"][$i."_"]) {
00716             $out.='<option value="'.$i.'"'.(($i >> 1)==($comparison >> 1) ? ' selected':'').'>'.$this->lang["comparison"][$i."_"].'</option>';
00717          }
00718       }
00719       $out.='</select>';
00720       return $out;
00721    }

t3lib_queryGenerator::mkFieldToInputSelect name,
fieldName
 

[Describe function...]

Parameters:
[type] $name: ...
[type] $fieldName: ...
Returns:
[type] ...

Definition at line 668 of file class.t3lib_querygenerator.php.

References $out, and updateIcon().

Referenced by makeSelectorTable().

00668                                                    {
00669       $out='<input type="Text" value="'.htmlspecialchars($fieldName).'" name="'.$name.'"'.$GLOBALS["TBE_TEMPLATE"]->formWidth().'>'.$this->updateIcon();
00670       $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>';
00671       $out.='<BR><select name="_fieldListDummy" size=5 onChange="document.forms[0][\''.$name.'\'].value+=\',\'+this.value">';
00672       reset($this->fields);
00673       while(list($key,)=each($this->fields)) {
00674          if ($GLOBALS["BE_USER"]->check("non_exclude_fields",$this->table.":".$key))   {
00675             $out.='<option value="'.$prepend.$key.'"'.($key==$fieldName ? ' selected':'').'>'.$this->fields[$key]["label"].'</option>';
00676          }
00677       }
00678       $out.='</select>';
00679       return $out;
00680    }

t3lib_queryGenerator::mkOperatorSelect name,
op,
draw,
submit
 

[Describe function...]

Parameters:
[type] $name: ...
[type] $op: ...
[type] $draw: ...
[type] $submit: ...
Returns:
[type] ...

Definition at line 591 of file class.t3lib_querygenerator.php.

References $out.

Referenced by getFormElements().

00591                                                       {
00592       if ($draw)  {
00593          $out='<select name="'.$name.'[operator]"'.($submit?' onChange="submit();"':'').'>'; //
00594          $out.='<option value="AND"'.(!$op||$op=="AND" ? ' selected':'').'>'.$this->lang["AND"].'</option>';
00595          $out.='<option value="OR"'.($op=="OR" ? ' selected':'').'>'.$this->lang["OR"].'</option>';
00596          $out.='</select>';
00597       } else {
00598          $out.='<input type="hidden" value="'.$op.'" name="'.$name.'[operator]">';
00599          $out.='<img src="clear.gif" height="1" width="47">';
00600 
00601       }
00602       return $out;
00603    }

t3lib_queryGenerator::mkTableSelect name,
cur
 

[Describe function...]

Parameters:
[type] $name: ...
[type] $cur: ...
Returns:
[type] ...

Definition at line 689 of file class.t3lib_querygenerator.php.

References $out.

Referenced by makeSelectorTable().

00689                                        {
00690       global $TCA;
00691       $out='<select name="'.$name.'" onChange="submit();">';
00692       $out.='<option value=""></option>';
00693       reset($TCA);
00694       while(list($tN)=each($TCA)) {
00695          if ($GLOBALS["BE_USER"]->check("tables_select",$tN))  {
00696             $out.='<option value="'.$tN.'"'.($tN==$cur ? ' selected':'').'>'.$GLOBALS["LANG"]->sl($TCA[$tN]["ctrl"]["title"]).'</option>';
00697          }
00698       }
00699       $out.='</select>';
00700       return $out;
00701    }

t3lib_queryGenerator::mkTypeSelect name,
fieldName,
prepend = "FIELD_"
 

[Describe function...]

Parameters:
[type] $name: ...
[type] $fieldName: ...
[type] $prepend: ...
Returns:
[type] ...

Definition at line 613 of file class.t3lib_querygenerator.php.

References $out.

Referenced by getFormElements(), and makeSelectorTable().

00613                                                                {
00614       $out='<select name="'.$name.'" onChange="submit();">';
00615       $out.='<option value=""></option>';
00616       reset($this->fields);
00617       while(list($key,)=each($this->fields)) {
00618          if ($GLOBALS["BE_USER"]->check("non_exclude_fields",$this->table.":".$key))   {
00619             $out.='<option value="'.$prepend.$key.'"'.($key==$fieldName ? ' selected':'').'>'.$this->fields[$key]["label"].'</option>';
00620          }
00621       }
00622       $out.='</select>';
00623       return $out;
00624    }

t3lib_queryGenerator::printCodeArray codeArr,
l = 0
 

[Describe function...]

Parameters:
[type] $codeArr: ...
[type] $l: ...
Returns:
[type] ...

Definition at line 555 of file class.t3lib_querygenerator.php.

References $out, and table().

Referenced by makeSelectorTable().

00555                                           {
00556       reset($codeArr);
00557       $line="";
00558       if ($l)     $indent='<td><img height="1" width="50"></td>';
00559       $lf=$l*30;
00560       $bgColor = t3lib_div::modifyHTMLColor($GLOBALS["TBE_TEMPLATE"]->bgColor2,$lf,$lf,$lf);
00561       while(list($k,$v)=each($codeArr))   {
00562          $line.= '<tr>'.$indent.'<td bgcolor="'.$bgColor.'"'.$this->noWrap.'>'.$v["html"].'</td></tr>';
00563          if ($this->enableQueryParts)  {$line.= '<tr>'.$indent.'<td>'.$this->formatQ($v["query"]).'</td></tr>';}
00564          if (is_array($v["sub"]))   {
00565             $line.= '<tr>'.$indent.'<td'.$this->noWrap.'>'.$this->printCodeArray($v["sub"],$l+1).'</td></tr>';
00566          }
00567       }
00568       $out='<table border=0 cellpadding=0 cellspacing=1>'.$line.'</table>';
00569       return $out;
00570    }

t3lib_queryGenerator::procesData qC = ""  ) 
 

[Describe function...]

Parameters:
[type] $qC: ...
Returns:
[type] ...

Definition at line 308 of file class.t3lib_querygenerator.php.

References getSubscript().

Referenced by makeSelectorTable().

00308                                  {
00309       $this->queryConfig = $qC;
00310 
00311       $POST = t3lib_div::_POST();
00312 
00313       // if delete...
00314       if($POST["qG_del"]) {
00315          //initialize array to work on, save special parameters
00316          $ssArr = $this->getSubscript($POST["qG_del"]);
00317          $workArr =& $this->queryConfig;
00318          for($i=0;$i<sizeof($ssArr)-1;$i++) {
00319             $workArr =& $workArr[$ssArr[$i]];
00320          }
00321          // delete the entry and move the other entries
00322          unset($workArr[$ssArr[$i]]);
00323          for($j=$ssArr[$i];$j<sizeof($workArr);$j++) {
00324             $workArr[$j] = $workArr[$j+1];
00325             unset($workArr[$j+1]);
00326          }
00327       }
00328 
00329       // if insert...
00330       if($POST["qG_ins"]) {
00331          //initialize array to work on, save special parameters
00332          $ssArr = $this->getSubscript($POST["qG_ins"]);
00333          $workArr =& $this->queryConfig;
00334          for($i=0;$i<sizeof($ssArr)-1;$i++) {
00335             $workArr =& $workArr[$ssArr[$i]];
00336          }
00337          // move all entries above position where new entry is to be inserted
00338          for($j=sizeof($workArr);$j>$ssArr[$i];$j--) {
00339             $workArr[$j] = $workArr[$j-1];
00340          }
00341          //clear new entry position
00342          unset($workArr[$ssArr[$i]+1]);
00343          $workArr[$ssArr[$i]+1]['type'] = "FIELD_";
00344       }
00345 
00346       // if move up...
00347       if($POST["qG_up"]) {
00348          //initialize array to work on
00349          $ssArr = $this->getSubscript($POST["qG_up"]);
00350          $workArr =& $this->queryConfig;
00351          for($i=0;$i<sizeof($ssArr)-1;$i++) {
00352             $workArr =& $workArr[$ssArr[$i]];
00353          }
00354          //swap entries
00355          $qG_tmp = $workArr[$ssArr[$i]];
00356          $workArr[$ssArr[$i]] = $workArr[$ssArr[$i]-1];
00357          $workArr[$ssArr[$i]-1] = $qG_tmp;
00358       }
00359 
00360       // if new level...
00361       if($POST["qG_nl"]) {
00362          //initialize array to work on
00363          $ssArr = $this->getSubscript($POST["qG_nl"]);
00364          $workArr =& $this->queryConfig;
00365          for($i=0;$i<sizeof($ssArr)-1;$i++) {
00366             $workArr =& $workArr[$ssArr[$i]];
00367          }
00368          // Do stuff:
00369          $tempEl = $workArr[$ssArr[$i]];
00370          if (is_array($tempEl))  {
00371             if ($tempEl["type"]!="newlevel") {
00372                $workArr[$ssArr[$i]]=array(
00373                   "type" => "newlevel",
00374                   "operator" => $tempEl["operator"],
00375                   "nl" => array($tempEl)
00376                );
00377             }
00378          }
00379       }
00380 
00381       // if collapse level...
00382       if($POST["qG_remnl"]) {
00383          //initialize array to work on
00384          $ssArr = $this->getSubscript($POST["qG_remnl"]);
00385          $workArr =& $this->queryConfig;
00386          for($i=0;$i<sizeof($ssArr)-1;$i++) {
00387             $workArr =& $workArr[$ssArr[$i]];
00388          }
00389 
00390          // Do stuff:
00391          $tempEl = $workArr[$ssArr[$i]];
00392          if (is_array($tempEl))  {
00393             if ($tempEl["type"]=="newlevel") {
00394                $a1 = array_slice($workArr,0,$ssArr[$i]);
00395                $a2 = array_slice($workArr,$ssArr[$i]);
00396                array_shift($a2);
00397                $a3 = $tempEl["nl"];
00398                $a3[0]["operator"] = $tempEl["operator"];
00399                $workArr=array_merge($a1,$a3,$a2);
00400             }
00401          }
00402       }
00403    }

t3lib_queryGenerator::setAndCleanUpExternalLists name,
list,
force = ""
 

[Describe function...]

Parameters:
[type] $name: ...
[type] $list: ...
[type] $force: ...
Returns:
[type] ...

Definition at line 292 of file class.t3lib_querygenerator.php.

References $fields.

Referenced by makeSelectorTable().

00292                                                                {
00293       $fields = array_unique(t3lib_div::trimExplode(",",$list.",".$force,1));
00294       reset($fields);
00295       $reList=array();
00296       while(list(,$fN)=each($fields))  {
00297          if ($this->fields[$fN])    $reList[]=$fN;
00298       }
00299       $this->extFieldLists[$name]=implode(",",$reList);
00300    }

t3lib_queryGenerator::updateIcon  ) 
 

[Describe function...]

Returns:
[type] ...

Definition at line 851 of file class.t3lib_querygenerator.php.

Referenced by getFormElements(), makeSelectorTable(), and mkFieldToInputSelect().

00851                            {
00852       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">';
00853    }

t3lib_queryGenerator::userDef  ) 
 

[Describe function...]

Returns:
[type] ...

Definition at line 753 of file class.t3lib_querygenerator.php.

00753                         {
00754    }

t3lib_queryGenerator::userDefCleanUp queryConfig  ) 
 

[Describe function...]

Parameters:
[type] $queryConfig: ...
Returns:
[type] ...

Definition at line 762 of file class.t3lib_querygenerator.php.

Referenced by cleanUpQueryConfig().

00762                                           {
00763       return $queryConfig;
00764    }

t3lib_queryGenerator::verifyComparison comparison,
neg
 

[Describe function...]

Parameters:
[type] $comparison: ...
[type] $neg: ...
Returns:
[type] ...

Definition at line 649 of file class.t3lib_querygenerator.php.

Referenced by cleanUpQueryConfig().

00649                                                 {
00650       $compOffSet = $comparison >> 5;
00651       $first=-1;
00652       for($i=32*$compOffSet+$neg;$i<32*($compOffSet+1);$i+=2) {
00653          if ($first==-1)   $first = $i;
00654          if (($i >> 1)==($comparison >> 1))  {
00655             return $i;
00656          }
00657       }
00658       return $first;
00659    }

t3lib_queryGenerator::verifyType fieldName  ) 
 

[Describe function...]

Parameters:
[type] $fieldName: ...
Returns:
[type] ...

Definition at line 632 of file class.t3lib_querygenerator.php.

References $key.

Referenced by cleanUpQueryConfig().

00632                                     {
00633       reset($this->fields);
00634       $first = "";
00635       while(list($key,)=each($this->fields)) {
00636          if (!$first)   $first = $key;
00637          if ($key==$fieldName) return $key;
00638       }
00639       return $first;
00640    }


Member Data Documentation

t3lib_queryGenerator::$comp_offsets
 

Initial value:

 array(
      "text" => 0,
      "number" => 1,
      "date" => 1
   )

Definition at line 150 of file class.t3lib_querygenerator.php.

t3lib_queryGenerator::$compSQL
 

Initial value:

 array(
         // Type = text offset = 0
      "0" => "#FIELD# LIKE '%#VALUE#%'",
      "1" => "#FIELD# NOT LIKE '%#VALUE#%'",
      "2" => "#FIELD# LIKE '#VALUE#%'",
      "3" => "#FIELD# NOT LIKE '#VALUE#%'",
      "4" => "#FIELD# LIKE '%#VALUE#'",
      "5" => "#FIELD# NOT LIKE '%#VALUE#'",
      "6" => "#FIELD# = '#VALUE#'",
      "7" => "#FIELD# != '#VALUE#'",
         // Type = date,number , offset = 32
      "32" => "#FIELD# = '#VALUE#'",
      "33" => "#FIELD# != '#VALUE#'",
      "34" => "#FIELD# > #VALUE#",
      "35" => "#FIELD# < #VALUE#",
      "36" => "#FIELD# >= #VALUE# AND #FIELD# <= #VALUE1#",
      "37" => "NOT (#FIELD# >= #VALUE# AND #FIELD# <= #VALUE1#)",
      "38" => "#FIELD# IN (#VALUE#)",
      "39" => "#FIELD# NOT IN (#VALUE#)",
      "40" => "(#FIELD# & #VALUE#)=#VALUE#",
      "41" => "(#FIELD# & #VALUE#)!=#VALUE#",
      "42" => "(#FIELD# | #VALUE#)=#VALUE#",
      "43" => "(#FIELD# | #VALUE#)!=#VALUE#"
   )

Definition at line 125 of file class.t3lib_querygenerator.php.

t3lib_queryGenerator::$enablePrefix = 0
 

Definition at line 163 of file class.t3lib_querygenerator.php.

t3lib_queryGenerator::$enableQueryParts = 0
 

Definition at line 164 of file class.t3lib_querygenerator.php.

t3lib_queryGenerator::$extFieldLists = array()
 

Definition at line 161 of file class.t3lib_querygenerator.php.

t3lib_queryGenerator::$extJSCODE = ""
 

Definition at line 165 of file class.t3lib_querygenerator.php.

t3lib_queryGenerator::$fieldList
 

Definition at line 159 of file class.t3lib_querygenerator.php.

Referenced by init().

t3lib_queryGenerator::$fields = array()
 

Definition at line 160 of file class.t3lib_querygenerator.php.

Referenced by setAndCleanUpExternalLists().

t3lib_queryGenerator::$lang
 

Initial value:

 array(
      "OR" => "or",
      "AND" => "and",
      "comparison" => array(
             // Type = text   offset = 0
         "0_" => "contains",
         "1_" => "does not contain",
         "2_" => "starts with",
         "3_" => "does not start with",
         "4_" => "ends with",
         "5_" => "does not end with",
         "6_" => "equals",
         "7_" => "does not equal",
             // Type = date,number ,   offset = 32
         "32_" => "equals",
         "33_" => "does not equal",
         "34_" => "is greater than",
         "35_" => "is less than",
         "36_" => "is between",
         "37_" => "is not between",
         "38_" => "is in list",
         "39_" => "is not in list",
         "40_" => "binary AND equals",
         "41_" => "binary AND does not equal",
         "42_" => "binary OR equals",
         "43_" => "binary OR does not equal"
      )
   )

Definition at line 96 of file class.t3lib_querygenerator.php.

t3lib_queryGenerator::$name
 

Definition at line 157 of file class.t3lib_querygenerator.php.

t3lib_queryGenerator::$noWrap = " nowrap"
 

Definition at line 155 of file class.t3lib_querygenerator.php.

t3lib_queryGenerator::$queryConfig = array()
 

Definition at line 162 of file class.t3lib_querygenerator.php.

Referenced by cleanUpQueryConfig(), and getFormElements().

t3lib_queryGenerator::$table
 

Definition at line 158 of file class.t3lib_querygenerator.php.


The documentation for this class was generated from the following file:
Generated on Sun Oct 3 01:07:08 2004 for TYPO3core 3.7.0 dev by  doxygen 1.3.8-20040913