Initial revision
[Packages/TYPO3.CMS.git] / typo3 / class.db_list_extra.inc
1 <?php
2 /***************************************************************
3 *  Copyright notice
4 *  
5 *  (c) 1999-2003 Kasper Skårhøj (kasper@typo3.com)
6 *  All rights reserved
7 *
8 *  This script is part of the TYPO3 project. The TYPO3 project is 
9 *  free software; you can redistribute it and/or modify
10 *  it under the terms of the GNU General Public License as published by
11 *  the Free Software Foundation; either version 2 of the License, or
12 *  (at your option) any later version.
13
14 *  The GNU General Public License can be found at
15 *  http://www.gnu.org/copyleft/gpl.html.
16 *  A copy is found in the textfile GPL.txt and important notices to the license 
17 *  from the author is found in LICENSE.txt distributed with these scripts.
18 *
19
20 *  This script is distributed in the hope that it will be useful,
21 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
22 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 *  GNU General Public License for more details.
24 *
25 *  This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /** 
28  * Include file extending recordList which extended t3lib_recordList
29  *
30  * @author      Kasper Skårhøj <kasper@typo3.com>
31  * @package TYPO3
32  * @subpackage core
33  *
34  */
35
36  class localRecordList extends recordList {
37         var $noControlPanels = 0;
38         var $showClipboard=0;
39         var $clipObj;
40         var $CBnames=array();
41         var $pageRow=array();
42         var $alternateBgColors=0;
43         var $allowedNewTables=array();
44         var $newWizards=0;
45         var $dontShowClipControlPanels=0;
46         
47         function writeTop($row,$path)   {
48                 global $LANG;
49                 
50                         // Makes the code for the pageicon in the top
51                 $this->pageRow=$row;
52                 $this->counter++;
53                 $iconfile = t3lib_iconWorks::getIcon("pages",$row);
54                 $alttext = t3lib_BEfunc::getRecordIconAltText($row,"pages");
55                 $titleCol="test";
56                 $this->fieldArray = Array($titleCol,"up");
57                 
58                 $out="<table border=0 cellpadding=0 cellspacing=0>";
59
60                 $theData = Array();
61                 $theData[$titleCol] = $this->widthGif;
62
63                         // Edit         
64                 $localCalcPerms = $GLOBALS["BE_USER"]->calcPerms($row);
65                 
66                 $theData["up"]=array();
67                 $theCtrlPanel =array();
68                 
69                 $theCtrlPanel[]='<a HREF="#" onClick="'.t3lib_BEfunc::viewOnClick($this->id,"",t3lib_BEfunc::BEgetRootLine($this->id)).'"><img src="'.$this->backPath.'gfx/zoom.gif" width="12" height="12" vspace=1 border="0" align=top'.t3lib_BEfunc::titleAttrib($LANG->sL("LLL:EXT:lang/locallang_core.php:labels.showPage")).'></a>';
70
71 //              debug($localCalcPerms);
72                 if ($localCalcPerms&2)  {
73                         if ($this->id)  {
74                                 $params="&edit[pages][".$row["uid"]."]=edit";
75                                 $theCtrlPanel[]='<A HREF="#" onClick="'.t3lib_BEfunc::editOnClick($params,"",-1).'"><img src="'.$this->backPath.'gfx/edit2.gif" width=11 height=12 vspace=2 border=0 align="top"'.t3lib_BEfunc::titleAttrib($LANG->getLL("editPage")).'></a>';
76                         }
77                         if (!$GLOBALS["SOBE"]->modTSconfig["properties"]["noCreateRecordsLink"])        {
78                                 $theCtrlPanel[]='<a href="#" onClick="return jumpExt(\'db_new.php?id='.$this->id.'\');"><img src="gfx/new_el.gif" width="11" height="12" border="0" align=top'.t3lib_BEfunc::titleAttrib($LANG->getLL("newRecordGeneral"),1).'></a>';
79                         }
80
81                         if ($this->id)  {
82                                 if ($row["hidden"])     {
83                                         $params="&data[pages][".$row["uid"]."][hidden]=0";
84                                         $theCtrlPanel[]='<A HREF="#" onClick="return jumpToUrl(\''.$GLOBALS["SOBE"]->doc->issueCommand($params,-1).'\');"><img src="'.$this->backPath.'gfx/button_unhide.gif" width=11 height=10 vspace=2 hspace=2 border=0'.t3lib_BEfunc::titleAttrib($LANG->getLL("unHidePage")).' align="top"></a>';
85                                 } else {
86                                         $params="&data[pages][".$row["uid"]."][hidden]=1";
87                                         $theCtrlPanel[]='<A HREF="#" onClick="return jumpToUrl(\''.$GLOBALS["SOBE"]->doc->issueCommand($params,-1).'\');"><img src="'.$this->backPath.'gfx/button_hide.gif" width=11 height=10 vspace=2 hspace=2 border=0'.t3lib_BEfunc::titleAttrib($LANG->getLL("hidePage")).' align="top"></a>';
88                                 }
89                         }
90                         if ($this->id)  {
91                                 $theCtrlPanel[]='<A HREF="#" onClick="return jumpExt(\'move_el.php?table=pages&uid='.$row["uid"].'\');"><img src="'.$this->backPath.'gfx/move_'.($table=="tt_content"?"record":"page").'.gif" width=11 height=12 border=0 align="top"'.t3lib_BEfunc::titleAttrib($LANG->getLL("move_page")).'></a>';
92                         }
93                 }
94                 if (($localCalcPerms&8) || ($localCalcPerms&16))        {
95                         $elFromTable = $this->clipObj->elFromTable("");
96                         if (count($elFromTable))        {
97                                 $theCtrlPanel[]='<a href="'.$this->clipObj->pasteUrl("",$this->id).'" onClick="return '.$this->clipObj->confirmMsg("pages",$this->pageRow,"into",$elFromTable).'"><img src="gfx/clip_pasteafter.gif" width="12" height="12" vspace=2 hspace=2 border="0"'.t3lib_BEfunc::titleAttrib($LANG->getLL("clip_paste")).' align="top"></a>';
98                         }
99                 }
100                 if (count($theCtrlPanel))       {
101                         $theData["up"][]='<table border=0 cellpadding=0 cellspacing=0 bgColor="'.$GLOBALS["SOBE"]->doc->bgColor4.'"><tr><td>'.implode('</td><td>',$theCtrlPanel).'</td></tr></table>';
102                 }
103                 
104
105
106                 $theData["up"][]='<A href="'.$this->listURL().'&clear_cache=1"><img src="'.$this->backPath.'gfx/clear_cache.gif" width=14 hspace=2 height=14 vspace=1 border=0'.t3lib_BEfunc::titleAttrib($LANG->sL("LLL:EXT:lang/locallang_core.php:labels.clear_cache")).' align="top"></a>';
107
108                 if ($this->table)       {
109                         $theData["up"][]='<A href="'.$this->listURL().'&csv=1"><img src="'.$this->backPath.'gfx/csv.gif" width=27 hspace=2 height=14 vspace=1 border=0'.t3lib_BEfunc::titleAttrib($LANG->sL("LLL:EXT:lang/locallang_core.php:labels.csv")).' align="top"></a>';
110                 }
111
112
113                 $theData["up"][]='<A href="'.$this->listURL().'"><img src="'.$this->backPath.'gfx/refresh_n.gif" width=14 hspace=2 height=14 vspace=1 border=0'.t3lib_BEfunc::titleAttrib($LANG->sL("LLL:EXT:lang/locallang_core.php:labels.reload")).' align="top"></a>';
114                 if ($row["uid"])        {
115                         $theIcon = '<img src="'.$this->backPath.$iconfile.'" width=18 height=16 border=0'.t3lib_BEfunc::titleAttrib($alttext).'">';
116                         $theIcon = $GLOBALS["SOBE"]->doc->wrapClickMenuOnIcon($theIcon,"pages",$this->id);
117
118                         $theData[$titleCol].="<BR>".t3lib_div::fixed_lgd_pre($path,$this->fixedL);
119                         $theData["up"][]='<A href="'.$this->listURL($row["pid"]).'"><img src="'.$this->backPath.'gfx/i/pages_up.gif" width=18 height=16 border=0'.t3lib_BEfunc::titleAttrib($LANG->sL("LLL:EXT:lang/locallang_core.php:labels.upOneLevel")).' align="top"></a>';
120                 } else {        
121                                 // root:0
122                         $theIcon='<img src="'.$this->backPath.'gfx/i/_icon_website.gif" width=18 height=16 border=0>';
123                         $theData[$titleCol].="<BR>".t3lib_div::fixed_lgd_pre($GLOBALS["TYPO3_CONF_VARS"]["SYS"]["sitename"],$this->fixedL);
124                 }
125
126                 if ($this->returnUrl)   {
127                         $theData["up"][]='<A href="'.t3lib_div::linkThisUrl($this->returnUrl,array("id"=>$this->id)).'" class="typo3-goBack"><img src="'.$this->backPath.'gfx/goback.gif" width=14 hspace=2 height=14 vspace=1 border=0'.t3lib_BEfunc::titleAttrib($LANG->sL("LLL:EXT:lang/locallang_core.php:labels.goBack")).' align="top"></a>';
128                 }
129                 
130                 $theData["up"]='<table border=0 cellpadding=0 cellspacing=0><tr><td>'.implode("</td><td>",$theData["up"]).'</td></tr></table>';
131                 $out.=$this->addelement(1,'',$theData,'',$this->leftMargin,$theIcon);
132 //debug($theData);
133                 $out.="</table>";
134                 $this->HTMLcode.=$out;
135         }
136         function linkClipboardHeaderIcon($string,$table,$cmd,$warning="")       {
137                 $onClickEvent = 'document.dblistForm.cmd.value=\''.$cmd.'\';document.dblistForm.cmd_table.value=\''.$table.'\';document.dblistForm.submit();';
138                 if ($warning)   $onClickEvent = 'if (confirm('.$GLOBALS['LANG']->JScharCode($warning).')){'.$onClickEvent.'}';
139                 return '<a href="#" onClick="'.$onClickEvent.'return false;">'.$string.'</a>';
140         }
141         function getTable($table,$id,$rowlist)  {
142                         // Adds the code of a single table
143                 global $TCA;
144                 t3lib_div::loadTCA($table);
145         //      echo $this->makeQuery($table, $id)."<BR>";
146
147                         // Init
148                 $titleCol = $TCA[$table]["ctrl"]["label"];
149                 $thumbsCol = $TCA[$table]["ctrl"]["thumbnail"];
150
151                 if (!$this->table && !$rowlist) {
152 //                      $this->addElement_tdParams[$titleCol]=' width="'.($GLOBALS["SOBE"]->MOD_SETTINGS["bigControlPanel"]?"230":"350").'"';
153                 }
154
155                         // Cleaning rowlist for duplicates and place the $titleCol as the first column always!
156                 $this->fieldArray=array();
157                 $this->fieldArray[] = $titleCol;
158                 if (!t3lib_div::inList($rowlist,"_CONTROL_"))   {
159                         $this->fieldArray[] = "_CONTROL_";
160                 }
161                 if ($this->showClipboard)       {
162                         $this->fieldArray[] = "_CLIPBOARD_";
163                 }
164                 if ($this->searchLevels)        {
165                         $this->fieldArray[]="_PATH_";
166                 }
167                 $this->fieldArray=array_unique(array_merge($this->fieldArray,t3lib_div::trimExplode(",",$rowlist,1)));
168                 if ($this->noControlPanels)     {
169                         $tempArray = array_flip($this->fieldArray);
170                         unset($tempArray["_CONTROL_"]);
171                         unset($tempArray["_CLIPBOARD_"]);
172                         $this->fieldArray = array_keys($tempArray);
173                 }
174                 
175                         // Select fields:
176                 $selectFields = $this->fieldArray;
177                 $selectFields[] = "uid";
178                 $selectFields[] = "pid";
179                 if ($thumbsCol) $selectFields[] = $thumbsCol;   // adding column for thumbnails
180                 if ($table=="pages")    {
181                         if (t3lib_extMgm::isLoaded("cms"))      {
182                                 $selectFields[] = "module";
183                                 $selectFields[] = "extendToSubpages";
184                         }
185                         $selectFields[] = "doktype";
186                 }
187                 if (is_array($TCA[$table]["ctrl"]["enablecolumns"]))    {
188                         $selectFields = array_merge($selectFields,$TCA[$table]["ctrl"]["enablecolumns"]);
189                 }
190                 if ($TCA[$table]["ctrl"]["type"])       {
191                         $selectFields[] = $TCA[$table]["ctrl"]["type"];
192                 }
193                 if ($TCA[$table]["ctrl"]["typeicon_column"])    {
194                         $selectFields[] = $TCA[$table]["ctrl"]["typeicon_column"];
195                 }
196                 if ($TCA[$table]["ctrl"]["label_alt"])  {
197                         $selectFields = array_merge($selectFields,t3lib_div::trimExplode(",",$TCA[$table]["ctrl"]["label_alt"],1));
198                 }
199                 $selectFields = array_unique($selectFields);            // Unique list!
200                 $selectFields = array_intersect($selectFields,$this->makeFieldList($table,1));          // Making sure that the fields in the field-list ARE in the field-list from TCA!
201                 $selFieldList = implode(",",$selectFields);             // implode it into a list of fields for the SQL-statement.
202
203                         // Query:               
204                 $query = $this->makeQuery($table, $id,"",$selFieldList);
205                 $this->setTotalItems();
206                 $dbCount=0;
207                 
208                 if ($this->totalItems)  {
209 #$pt=t3lib_div::milliseconds();         
210                         $result = mysql(TYPO3_db,$query);
211                         if (mysql_error()) {echo mysql_error(); debug($query);}
212                         $dbCount = mysql_num_rows($result);
213 #debug(array(t3lib_div::milliseconds()-$pt,$table));
214                 }
215                 $out="";
216                 if ($dbCount)   {
217                                 // Start table:
218                         $out.='<table border=0 cellpadding=0 cellspacing=0>';
219
220                                 // half line is drawn
221                         $theData = Array();
222                         if (!$this->table && !$rowlist) {
223 //                              $theData[$titleCol] = $this->widthGif;  // 
224                                 $theData[$titleCol] = '<img src=clear.gif width="'.($GLOBALS["SOBE"]->MOD_SETTINGS["bigControlPanel"]?"230":"350").'" height=1>';
225                                 if (in_array("_CONTROL_",$this->fieldArray))    $theData["_CONTROL_"]="";
226                                 if (in_array("_CLIPBOARD_",$this->fieldArray))  $theData["_CLIPBOARD_"]="";
227                         }
228                         $out.=$this->addelement(0,'',$theData,'',$this->leftMargin);
229
230                                 // header line is drawn
231                         $theData = Array();
232                         if ($this->disableSingleTableView)      {
233                                 $theData[$titleCol] = '<b>'.$GLOBALS["LANG"]->sL($TCA[$table]["ctrl"]["title"]).'</b> ('.$this->totalItems.')';
234                         } else $theData[$titleCol] = '<b>'.$this->linkWrapTable($table,$GLOBALS["LANG"]->sL($TCA[$table]["ctrl"]["title"]).'</b> ('.$this->totalItems.') <img src="'.$this->backPath.'gfx/'.($this->table?"minus":"plus").'bullet_list.gif" width="18" hspace=10 vspace=2 height="12" border="0" align="absmiddle"'.t3lib_BEfunc::titleAttrib($GLOBALS["LANG"]->getLL((!$this->table?"expandView":"contractView"))).'>');
235                         $theUpIcon = ($table=="pages"&&$this->id&&isset($this->pageRow["pid"])) ? '<A href="'.$this->listURL($this->pageRow["pid"]).'"><img src="gfx/i/pages_up.gif" width="18" height="16" border="0"'.t3lib_BEfunc::titleAttrib($GLOBALS["LANG"]->sL("LLL:EXT:lang/locallang_core.php:labels.upOneLevel")).' align="top"></a>':'';
236
237                         $out.=$this->addelement(1,$theUpIcon,$theData,' bgcolor="'.$this->headLineCol.'"','');
238
239                                 // Fixing a order table for sortby tables
240                         $this->currentTable=array();
241                         $currentIdList=array();
242                         $doSort = ($TCA[$table]["ctrl"]["sortby"] && !$this->sortField);
243 #                       if ($this->table || $doSort)    {
244                                 $prevUid=0;
245                                 $prevPrevUid=0;
246                                 while ($row = mysql_fetch_assoc($result))       {
247                                         $currentIdList[] = $row["uid"];
248                                         if ($doSort)    {
249                                                 if ($prevUid)   {
250                                                         $this->currentTable["prev"][$row["uid"]]=$prevPrevUid;
251                                                         $this->currentTable["next"][$prevUid]="-".$row["uid"];
252                                                         $this->currentTable["prevUid"][$row["uid"]]=$prevUid;
253                                                 }
254                                                 $prevPrevUid = isset($this->currentTable["prev"][$row["uid"]]) ? -$prevUid : $row["pid"];
255                                                 $prevUid=$row["uid"];
256                                         }
257                                 }
258                                 mysql_data_seek($result,0);
259 #                       }
260 //                      debug($this->currentTable);
261
262                                 // CSV initiated
263                         if ($this->csvOutput) $this->initCSV();
264
265                                 // items
266                         $iOut="";
267                         $this->CBnames=array();
268                         $this->duplicateStack=array();
269                         $this->eCounter=$this->firstElementNumber;
270                         $cc=0;
271                         while ($row = mysql_fetch_assoc($result))       {
272                                 list($flag,$code) = $this->fwd_rwd_nav($table);
273                                 $iOut.=$code;
274                                 if ($flag)      {
275                                         $cc++;
276                                         $row_bgColor=
277                                                 $this->alternateBgColors ? 
278                                                 (($cc%2)?'' :' bgColor="'.t3lib_div::modifyHTMLColor($GLOBALS["SOBE"]->doc->bgColor4,+10,+10,+10).'"') :
279                                                 '';
280
281                                                 // Initialization
282                                         $iconfile = t3lib_iconWorks::getIcon($table,$row);
283                                         $alttext = t3lib_BEfunc::getRecordIconAltText($row,$table);
284 //                                      $recTitle = strip_tags($row[$titleCol]);                // commented out 300700
285 //                                      $recTitle = htmlspecialchars($row[$titleCol]);
286                                         $recTitle = t3lib_BEfunc::getRecordTitle($table,$row,1);
287                                         
288                                         $this->counter++;
289
290                                                 // The icon with link   
291                                         $theIcon = '<img src="'.$this->backPath.$iconfile.'" width=18 height=16 border=0'.t3lib_BEfunc::titleAttrib($alttext).'>';
292                                         $theIcon = $GLOBALS["SOBE"]->doc->wrapClickMenuOnIcon($theIcon,$table,$row["uid"]);
293
294                                                 //      Preparing and getting the data-array
295                                         $theData = Array();
296                                         reset($this->fieldArray);
297                                         while(list(,$fCol)=each($this->fieldArray))     {
298                                                 if ($fCol==$titleCol)   {
299                                                         $theData[$fCol] = $this->linkWrapItems($table,$row["uid"],$recTitle,$row)."&nbsp;";
300                                                 } elseif ($fCol=="pid") {
301                                                         $theData[$fCol]=$row[$fCol];
302                                                 } elseif ($fCol=="_PATH_") {
303                                                         $theData[$fCol]="&nbsp;".$this->recPath($row["pid"]);
304                                                 } elseif ($fCol=="_CONTROL_") {
305                                                         $theData[$fCol]=$this->makeControl($table,$row);
306                                                 } elseif ($fCol=="_CLIPBOARD_") {
307                                                         $theData[$fCol]=$this->makeClip($table,$row);
308                                                 } else {
309                                                         $theData[$fCol]="&nbsp;".t3lib_BEfunc::getProcessedValueExtra($table,$fCol,$row[$fCol],100);
310                                                 }
311                                         }
312
313                                         if ($this->csvOutput) $this->addToCSV($row);
314                                         $iOut.=$this->addelement(1,$theIcon,$theData,$row_bgColor);
315                                         
316                                                 // Thumbsnails?
317                                         if ($this->thumbs && trim($row[$thumbsCol]))    {
318                                                 $iOut.=$this->addelement(4,"", Array($titleCol=>$this->thumbCode($row,$table,$thumbsCol)),$row_bgColor);
319                                         }
320                                 }
321                                 $this->eCounter++;      
322                         }
323
324                                 // field header line is drawn:
325                         $theData = Array();
326                         reset($this->fieldArray);
327                         while(list(,$fCol)=each($this->fieldArray))     {
328                                 $permsEdit = $this->calcPerms&($table=="pages"?2:16);
329                                 if ($fCol=="_PATH_")    {
330                                         $theData[$fCol]="&nbsp;<i>[".$GLOBALS["LANG"]->sL("LLL:EXT:lang/locallang_core.php:labels._PATH_")."]</i>&nbsp;";
331                                 } elseif ($fCol=="_CLIPBOARD_") {
332                                         $cells=array();
333                                         $elFromTable = $this->clipObj->elFromTable($table);
334                                         if (count($elFromTable))        {
335                                                 $cells[]='<a href="'.$this->clipObj->pasteUrl($table,$this->id).'" onClick="return '.$this->clipObj->confirmMsg("pages",$this->pageRow,"into",$elFromTable).'"><img src="gfx/clip_pasteafter.gif" width="12" height="12" border="0"'.t3lib_BEfunc::titleAttrib($GLOBALS["LANG"]->getLL("clip_paste")).'></a><img src=clear.gif width=2 height=1>';
336                                         }
337                                         if ($this->clipObj->current!="normal")  {
338                                                 $cells[]=$this->linkClipboardHeaderIcon('<img src="gfx/clip_copy.gif" width="12" height="12" border="0"'.t3lib_BEfunc::titleAttrib($GLOBALS["LANG"]->getLL("clip_selectMarked")).'>',$table,"setCB");
339
340                                                 $editIdList = implode(",",$currentIdList);
341 #debug(array($editIdList,$table));
342                                                 $editIdList = "'+editList('".$table."','".$editIdList."')+'";
343                                                 $params="&edit[".$table."][".$editIdList."]=edit&disHelp=1";
344                                                 $cells[]='<A HREF="#" onClick="'.t3lib_BEfunc::editOnClick($params,"",-1).'"><img src="gfx/edit2.gif" width="11" height="12" hspace=2 border="0"'.t3lib_BEfunc::titleAttrib($GLOBALS["LANG"]->getLL("clip_editMarked")).'></a>';
345
346                                                 $cells[]=$this->linkClipboardHeaderIcon('<img src="gfx/garbage.gif" width="11" height="12" border="0"'.t3lib_BEfunc::titleAttrib($GLOBALS["LANG"]->getLL("clip_deleteMarked")).'>',$table,"delete",sprintf($GLOBALS["LANG"]->getLL("clip_deleteMarkedWarning"),$GLOBALS["LANG"]->sL($TCA[$table]["ctrl"]["title"])));
347                                                 $cells[]='<img src=clear.gif width=6 height=1>';
348                                                 $cells[]='<a href="#" onClick="checkOffCB(\''.implode(",",$this->CBnames).'\'); return false;"><img src="gfx/clip_select.gif" width="12" height="12" border="0"'.t3lib_BEfunc::titleAttrib($GLOBALS["LANG"]->getLL("clip_markRecords")).'></a>';
349                                         } else {
350                                                 $cells[]="&nbsp;";
351                                         }
352                                         $theData[$fCol]=implode("",$cells);
353                                 } elseif ($fCol=="_CONTROL_") {
354                                         if (!$TCA[$table]["ctrl"]["readOnly"])  {
355                                                 if ($this->calcPerms&($table=="pages"?8:16) && $this->showNewRecLink($table))   {
356                                                         if ($table=="tt_content" && $this->newWizards)  {
357                                                                 $theData[$fCol]='<A HREF="#" onClick="return jumpExt(\'db_new_content_el.php?id='.$this->id.'\');"><img src="'.$this->backPath.'gfx/new_'.($table=="pages"?"page":"el").'.gif" width='.($table=="pages"?13:11).' height=12 border=0 align="top"'.t3lib_BEfunc::titleAttrib($GLOBALS["LANG"]->getLL("new")).'></a>';
358                                                         } elseif ($table=="pages" && $this->newWizards) {
359                                                                 $theData[$fCol]='<A HREF="db_new.php?id='.$this->id.'&pagesOnly=1returnUrl='.rawurlencode(t3lib_div::getIndpEnv("REQUEST_URI")).'"><img src="'.$this->backPath.'gfx/new_'.($table=="pages"?"page":"el").'.gif" width='.($table=="pages"?13:11).' height=12 border=0 align="top"'.t3lib_BEfunc::titleAttrib($GLOBALS["LANG"]->getLL("new")).'></a>';
360                                                         } else {
361                                                                 $params="&edit[".$table."][".$this->id."]=new";
362                                                                 $theData[$fCol]='<A HREF="#" onClick="'.t3lib_BEfunc::editOnClick($params,"",-1).'"><img src="'.$this->backPath.'gfx/new_'.($table=="pages"?"page":"el").'.gif" width='.($table=="pages"?13:11).' height=12 border=0 align="top"'.t3lib_BEfunc::titleAttrib($GLOBALS["LANG"]->getLL("new")).'></a>';
363                                                         }
364                                                 }
365                                                 if ($permsEdit && $this->table && is_array($currentIdList))     {
366                                                         $editIdList = implode(",",$currentIdList);
367                                                         if ($this->clipNumPane()) $editIdList = "'+editList('".$table."','".$editIdList."')+'";
368                                                         $params="&edit[".$table."][".$editIdList."]=edit&columnsOnly=".implode(",",$this->fieldArray)."&disHelp=1";
369                                                         $theData[$fCol].='<A HREF="#" onClick="'.t3lib_BEfunc::editOnClick($params,"",-1).'"><img src="'.$this->backPath.'gfx/edit2.gif" width=11 height=12 vspace=2 border=0 align="top"'.t3lib_BEfunc::titleAttrib($GLOBALS["LANG"]->getLL("editShownColumns")).'></a>';
370                                                 }
371                                         }
372                                 } else {
373                                         $theData[$fCol]="";
374                                         $theData[$fCol].='&nbsp;';
375                                         if ($this->table && is_array($currentIdList))   {
376                                                 if ($this->clipNumPane()) $theData[$fCol].='<A HREF="'.$this->listURL("",-1).'&duplicateField='.$fCol.'"><img src="gfx/select_duplicates.gif" width="11" height="11" vspace=2 border="0" align=top'.t3lib_BEfunc::titleAttrib($GLOBALS["LANG"]->getLL("clip_duplicates")).'></a>';
377                                                 if (!$TCA[$table]["ctrl"]["readOnly"] && $permsEdit && $TCA[$table]["columns"][$fCol])  {
378                                                         $editIdList = implode(",",$currentIdList);
379                                                         if ($this->clipNumPane()) $editIdList = "'+editList('".$table."','".$editIdList."')+'";
380                                                         $params="&edit[".$table."][".$editIdList."]=edit&columnsOnly=".$fCol."&disHelp=1";
381                                                         $theData[$fCol].='<A HREF="#" onClick="'.t3lib_BEfunc::editOnClick($params,"",-1).'"><img src="'.$this->backPath.'gfx/edit2.gif" width=11 height=12 vspace=2 border=0 align="top"'.t3lib_BEfunc::titleAttrib(sprintf($GLOBALS["LANG"]->getLL("editThisColumn"),ereg_replace(":$","",trim($GLOBALS["LANG"]->sL(t3lib_BEfunc::getItemLabel($table,$fCol)))))).'></a>';
382                                                 }
383                                         } else {
384 //                                              $theData[$fCol].='&nbsp;';
385                                         }
386                                         $theData[$fCol].=$this->addSortLink($GLOBALS["LANG"]->sL(t3lib_BEfunc::getItemLabel($table,$fCol,"&nbsp;<i>[|]</i>&nbsp;")),$fCol,$table);;
387                                 }
388                         }
389                         $out.=$this->addelement(1,'',$theData,' bgcolor="'.$this->subHeadLineCol.'"','');
390                                 // finish
391                         $out.=$iOut;
392                         $out.="</table>";       
393
394
395                         
396                                 // Output csv if...
397                         if ($this->csvOutput)   $this->outputCSV($table);       // This ends the page with exit.
398                 }
399                 return $out;
400         }
401         function clipNumPane()  {
402                 return in_Array("_CLIPBOARD_",$this->fieldArray) && $this->clipObj->current!="normal";
403         }
404         function addSortLink($code,$field,$table)       {
405                 if ($field=="_CONTROL_")        return $code;
406                 if ($field=="_CLIPBOARD_")      return $code;
407                 if ($this->disableSingleTableView)      return $code;
408                 if ($field=="_PATH_")   $field=pid;
409                 return '<A HREF="'.$this->listURL("",-1,"sortField,sortRev,table").'&table='.$table.'&sortField='.$field.'&sortRev='.($this->sortRev || ($this->sortField!=$field)?0:1).'">'.$code.
410                 ($this->sortField==$field?'<img src="gfx/red'.($this->sortRev?"up":"down").'.gif" hspace=2 width="7" height="4" border="0">':'').
411                 '</a>';
412         }
413         function makeControl($table,$row)       {
414                 global $TCA, $LANG;
415                 if ($this->dontShowClipControlPanels)   return "";
416
417                 t3lib_div::loadTCA($table);
418                 $cells=array();
419
420                 if ($table=="pages")    {
421                         $localCalcPerms = $GLOBALS["BE_USER"]->calcPerms(t3lib_BEfunc::getRecord("pages",$row["uid"]));
422                 }
423                 $permsEdit = ($table=="pages" && ($localCalcPerms&2)) || ($table!="pages" && ($this->calcPerms&16));
424                 
425                 
426                         // Show (only pages and tt_content elements)
427                 if ($table=="pages" || $table=="tt_content")    {
428                         $params="&edit[".$table."][".$row["uid"]."]=edit";
429                         $cells[]='<a href="#" onClick="'.t3lib_BEfunc::viewOnClick($table=="tt_content"?$this->id."#".$row["uid"]:$row["uid"]).'"><img src="'.$this->backPath.'gfx/zoom.gif" width=12 height=12 border=0 align="top"'.t3lib_BEfunc::titleAttrib($GLOBALS["LANG"]->sL("LLL:EXT:lang/locallang_core.php:labels.showPage")).'></a>';
430                 }
431                 
432                         // Edit: ( Only if permissions to edit the page-record of the content of the parent page ($this->id)
433                 if ($permsEdit) {
434                         $params="&edit[".$table."][".$row["uid"]."]=edit";
435                         $cells[]='<A HREF="#" onClick="'.t3lib_BEfunc::editOnClick($params,"",-1).'"><img src="'.$this->backPath.'gfx/edit2'.(!$TCA[$table]["ctrl"]["readOnly"]?"":"_d").'.gif" width=11 height=12 border=0 align="top"'.t3lib_BEfunc::titleAttrib($LANG->getLL("edit")).'></a>';
436                 }
437                 
438                 if (($table=="tt_content" && $permsEdit) || ($table=="pages"))  {
439                         $cells[]='<A HREF="#" onClick="return jumpExt(\'move_el.php?table='.$table.'&uid='.$row["uid"].'\');"><img src="'.$this->backPath.'gfx/move_'.($table=="tt_content"?"record":"page").'.gif" width=11 height=12 border=0 align="top"'.t3lib_BEfunc::titleAttrib($LANG->getLL("move_".($table=="tt_content"?"record":"page"))).'></a>';
440                 }
441                 
442                 if ($GLOBALS["SOBE"]->MOD_SETTINGS["bigControlPanel"] || $this->table)  {
443                                 // Info: (All records)
444                         $cells[]='<A HREF="#" onClick="top.launchView(\''.$table.'\', \''.$row["uid"].'\'); return false;"><img src="'.$this->backPath.'gfx/zoom2.gif" width=12 height=12 border=0 align="top"'.t3lib_BEfunc::titleAttrib($LANG->getLL("showInfo")).'></a>';
445         
446                         if (!$TCA[$table]["ctrl"]["readOnly"])  {
447                                         // Revert
448                                 $cells[]='<A HREF="#" onClick="return jumpExt(\'show_rechis.php?element='.rawurlencode($table.":".$row["uid"]).'\',\'#latest\');"><img src="'.$this->backPath.'gfx/history2.gif"  width="13" height="12" border=0'.t3lib_BEfunc::titleAttrib($GLOBALS["LANG"]->getLL("history")).' align="top"></a>';
449
450                                         // Perms
451                                 if ($table=="pages" && $GLOBALS["BE_USER"]->check("modules","web_perm"))        {
452                                         $cells[]='<A HREF="mod/web/perm/index.php?id='.$row["uid"].'&return_id='.$row["uid"].'&edit=1"><img src="'.$this->backPath.'gfx/perm.gif" width="7" hspace=2 height="12" border=0'.t3lib_BEfunc::titleAttrib($GLOBALS["LANG"]->getLL("permissions")).' align="top"></a>';
453                                 }
454         
455                                         // New :
456                                 if ($TCA[$table]["ctrl"]["sortby"] || $TCA[$table]["ctrl"]["useColumnsForDefaultValues"])       {       // ONLY if the records in the table are sorted by a "sortby"-row
457                                         if (
458                                                 ($table!="pages" && ($this->calcPerms&16)) ||   // For NON-pages, must have permission to edit content on this parent page
459                                                 ($table=="pages" && ($this->calcPerms&8))               // For pages, must have permission to create new pages here.
460                                                 )       {       
461                                                 if ($this->showNewRecLink($table))      {
462                                                         $params="&edit[".$table."][".(-$row["uid"])."]=new";
463                                                         $cells[]='<A HREF="#" onClick="'.t3lib_BEfunc::editOnClick($params,"",-1).'"><img src="'.$this->backPath.'gfx/new_'.($table=="pages"?"page":"el").'.gif" width='.($table=="pages"?13:11).' height=12 border=0 align="top"'.t3lib_BEfunc::titleAttrib($LANG->getLL("new".($table=="pages"?"Page":"Record"))).'></a>';
464                                                 }
465                                         } 
466                                 }
467
468                                         // Up/Down
469                                 if ($permsEdit && $TCA[$table]["ctrl"]["sortby"]  && !$this->sortField && !$this->searchLevels) {       //
470                                         if (isset($this->currentTable["prev"][$row["uid"]]))    {       // Up
471                                                 $params="&cmd[".$table."][".$row["uid"]."][move]=".$this->currentTable["prev"][$row["uid"]];
472                                                 $cells[]='<A HREF="#" onClick="return jumpToUrl(\''.$GLOBALS["SOBE"]->doc->issueCommand($params,-1).'\');"><img src="'.$this->backPath.'gfx/button_up.gif" width=11 height=10 border=0'.t3lib_BEfunc::titleAttrib($GLOBALS["LANG"]->getLL("moveUp")).' align="top"></a>';
473                                         } else {
474                                                 $cells[]='<img src="clear.gif" width=11 height=10 align="top">';
475                                         }
476                                         if ($this->currentTable["next"][$row["uid"]])   {       // Down
477                                                 $params="&cmd[".$table."][".$row["uid"]."][move]=".$this->currentTable["next"][$row["uid"]];
478                                                 $cells[]='<A HREF="#" onClick="return jumpToUrl(\''.$GLOBALS["SOBE"]->doc->issueCommand($params,-1).'\');"><img src="'.$this->backPath.'gfx/button_down.gif" width=11 height=10 border=0'.t3lib_BEfunc::titleAttrib($GLOBALS["LANG"]->getLL("moveDown")).' align="top"></a>';
479                                         } else {
480                                                 $cells[]='<img src="clear.gif" width=11 height=10 align="top">';
481                                         }
482                                 }
483                 
484                                         // Hide
485                                 $hiddenField = $TCA[$table]["ctrl"]["enablecolumns"]["disabled"];
486                                 if ($permsEdit && $hiddenField && $TCA[$table]["columns"][$hiddenField] && (!$TCA[$table]["columns"][$hiddenField]["exclude"] || $GLOBALS["BE_USER"]->check("non_exclude_fields",$table.":".$hiddenField)))     {
487                                         if ($row[$hiddenField]) {
488                                                 $params="&data[".$table."][".$row["uid"]."][".$hiddenField."]=0";
489                                                 $cells[]='<A HREF="#" onClick="return jumpToUrl(\''.$GLOBALS["SOBE"]->doc->issueCommand($params,-1).'\');"><img src="'.$this->backPath.'gfx/button_unhide.gif" width=11 height=10 border=0'.t3lib_BEfunc::titleAttrib($GLOBALS["LANG"]->getLL("unHide".($table=="pages"?"Page":""))).' align="top"></a>';
490                                         } else {
491                                                 $params="&data[".$table."][".$row["uid"]."][".$hiddenField."]=1";
492                                                 $cells[]='<A HREF="#" onClick="return jumpToUrl(\''.$GLOBALS["SOBE"]->doc->issueCommand($params,-1).'\');"><img src="'.$this->backPath.'gfx/button_hide.gif" width=11 height=10 border=0'.t3lib_BEfunc::titleAttrib($GLOBALS["LANG"]->getLL("hide".($table=="pages"?"Page":""))).' align="top"></a>';
493                                         }
494                                 }
495                 
496                                         // Delete
497                                 if (
498                                         ($table=="pages" && ($localCalcPerms&4)) || ($table!="pages" && ($this->calcPerms&16))
499                                         )       {
500                                         $params="&cmd[".$table."][".$row["uid"]."][delete]=1";
501                                         $cells[]='<A HREF="#" onClick="if (confirm('.$GLOBALS['LANG']->JScharCode($LANG->getLL("deleteWarning")).')) {jumpToUrl(\''.$GLOBALS["SOBE"]->doc->issueCommand($params,-1).'\');} return false;"><img src="'.$this->backPath.'gfx/garbage.gif" width=11 height=12 border=0 align="top"'.t3lib_BEfunc::titleAttrib($LANG->getLL("delete")).'></a>';
502                                 }
503                 
504                                         // Levels
505                                 if ($permsEdit && $table=="pages" && !$this->searchLevels)      {
506                                         if ($this->calcPerms&8) {
507                                                 $params="&cmd[".$table."][".$row["uid"]."][move]=".-$this->id;
508                                                 $cells[]='<A HREF="#" onClick="return jumpToUrl(\''.$GLOBALS["SOBE"]->doc->issueCommand($params,-1).'\');"><img src="'.$this->backPath.'gfx/button_left.gif" width=11 height=10 border=0'.t3lib_BEfunc::titleAttrib($GLOBALS["LANG"]->getLL("prevLevel")).' align="top"></a>';
509                                         }
510                                                 // Down
511                                         if ($this->currentTable["prevUid"][$row["uid"]])        {
512                                                 $localCalcPerms = $GLOBALS["BE_USER"]->calcPerms(t3lib_BEfunc::getRecord("pages",$this->currentTable["prevUid"][$row["uid"]]));
513                                                 if ($localCalcPerms&8)  {
514                                                         $params="&cmd[".$table."][".$row["uid"]."][move]=".$this->currentTable["prevUid"][$row["uid"]];
515                                                         $cells[]='<A HREF="#" onClick="return jumpToUrl(\''.$GLOBALS["SOBE"]->doc->issueCommand($params,-1).'\');"><img src="'.$this->backPath.'gfx/button_right.gif" width=11 height=10 border=0'.t3lib_BEfunc::titleAttrib($GLOBALS["LANG"]->getLL("nextLevel")).' align="top"></a>';
516                                                 } else {
517                                                         $cells[]='<img src="clear.gif" width=11 height=10 align="top">';
518                                                 }
519                                         } else {
520                                                 $cells[]='<img src="clear.gif" width=11 height=10 align="top">';
521                                         }
522                                 }
523                         }
524                 }
525                 
526                 if ($lockInfo=t3lib_BEfunc::isRecordLocked($table,$row["uid"])) {
527 //                      debug($lockInfo);
528                         $cells[]='<a href="#" onClick="alert('.$GLOBALS['LANG']->JScharCode($lockInfo["msg"]).');return false;"><img src="gfx/recordlock_warning3.gif" width="17" height="12" border="0"'.t3lib_BEfunc::titleAttrib($lockInfo["msg"]).'></a>';
529                 }
530                 
531                 return '<table border=0 cellpadding=1 cellspacing=0 bgColor="'.$GLOBALS["SOBE"]->doc->bgColor4.'"><tr><td>'.implode("</td><td>",$cells).'</td></tr></table>';
532         }
533         function makeClip($table,$row)  {
534                 global $TCA;
535                 if ($this->dontShowClipControlPanels)   return "";
536                 $cells=array();
537
538                 if ($this->clipObj->current=="normal")  {
539                         $isSel = (string)$this->clipObj->isSelected($table,$row["uid"]);
540                         $cells[]='<a href="#" onClick="return jumpSelf(\''.$this->clipObj->selUrlDB($table,$row["uid"],1,($isSel=="copy"),array("returnUrl"=>"")).'\');"><img src="gfx/clip_copy'.($isSel=="copy"?"_h":"").'.gif" width="12" height="12" border="0"'.t3lib_BEfunc::titleAttrib($GLOBALS["LANG"]->sL("LLL:EXT:lang/locallang_core.php:cm.copy")).'></a>';
541                         $cells[]='<a href="#" onClick="return jumpSelf(\''.$this->clipObj->selUrlDB($table,$row["uid"],0,($isSel=="cut"),array("returnUrl"=>"")).'\');"><img src="gfx/clip_cut'.($isSel=="cut"?"_h":"").'.gif" width="12" height="12" border="0"'.t3lib_BEfunc::titleAttrib($GLOBALS["LANG"]->sL("LLL:EXT:lang/locallang_core.php:cm.cut")).'></a>';
542                 } else {
543                         $n=$table."|".$row["uid"];
544                         $this->CBnames[]=$n;
545
546                         $checked = ($this->clipObj->isSelected($table,$row["uid"])?" checked":"");
547
548                         $duplField = t3lib_div::GPvar("duplicateField");
549                         if ($duplField && isset($row[$duplField]))      {
550                                 $checked="";
551                                 if (in_array($row[$duplField], $this->duplicateStack))  {
552                                         $checked=" checked";
553                                 }
554                                 $this->duplicateStack[] = $row[$duplField];
555                         }
556                         
557                         $cells[]='<input type="hidden" name="CBH['.$n.']" value="0"><input type="checkbox" name="CBC['.$n.']" value="1" style="width:12;height:12;margin:0 0 0 0;"'.$checked.'>';
558                         $cells[]='<img src=clear.gif width=10 height=1>';
559                 }
560                 
561                 $elFromTable = $this->clipObj->elFromTable($table);
562                 if (count($elFromTable) && $TCA[$table]["ctrl"]["sortby"])      {
563                         $cells[]='<a href="'.$this->clipObj->pasteUrl($table,-$row["uid"]).'" onClick="return '.$this->clipObj->confirmMsg($table,$row,"after",$elFromTable).'"><img src="gfx/clip_pasteafter.gif" width="12" height="12" border="0"'.t3lib_BEfunc::titleAttrib($GLOBALS["LANG"]->getLL("clip_pasteAfter")).'></a>';
564                 }
565                 $elFromTable = $this->clipObj->elFromTable("");
566                 if ($table=="pages" && $elFromTable)    {
567                         $cells[]='<a href="'.$this->clipObj->pasteUrl("",$row["uid"]).'" onClick="return '.$this->clipObj->confirmMsg($table,$row,"into",$elFromTable).'"><img src="gfx/clip_pasteinto.gif" width="12" height="12" border="0"'.t3lib_BEfunc::titleAttrib($GLOBALS["LANG"]->getLL("clip_pasteInto")).'></a>';
568                 }
569
570                 if ($GLOBALS["CLIENT"]["BROWSER"]=="net" && $GLOBALS["CLIENT"]["VERSION"]<5)    {
571                         $w100 = '';
572                         $w40 = '';
573                 } else {
574                         $w100 = ' width="100%"';
575                         $w40 = ' width="40%"';
576                 }
577                 return '<table border=0 cellpadding=1 cellspacing=0 bgColor="'.$GLOBALS["SOBE"]->doc->bgColor5.'"'.$w100.'><tr><td'.$w40.'>&nbsp;</td><td align=center>'.implode("</td><td>",$cells).'</td><td'.$w40.'>&nbsp;</td></tr></table>';
578         }
579         function fieldSelectBox($table,$formFields=1)   {
580                 global $TCA;
581                 t3lib_div::loadTCA($table);
582                 $formElements=array("","");
583                 if ($formFields)        {
584                         $formElements=array('<form action="'.$this->listURL().'" method="POST">','</form>');
585                 }
586
587                 $setFields=is_array($this->setFields[$table]) ? $this->setFields[$table] : array();
588                         // Make level selector:
589                 $fields = $this->makeFieldList($table);
590                 $fields[]="_PATH_";
591                 $fields[]="_CONTROL_";
592                 $fields[]="_CLIPBOARD_";
593                 $opt=array();
594                 reset($fields);
595                 $opt[] = '<option value=""></option>';
596                 while(list(,$fN)=each($fields)) {
597                         $fL = is_array($TCA[$table]["columns"][$fN]) ? ereg_replace(":$","",$GLOBALS["LANG"]->sL($TCA[$table]["columns"][$fN]["label"])) : "[".$fN."]";
598                         $opt[] = '<option value="'.$fN.'"'.(in_array($fN,$setFields)?" selected":"").'>'.htmlspecialchars($fL).'</option>';
599                 }
600                 $lMenu = '<select size='.t3lib_div::intInRange(count($fields)+1,3,20).' multiple name="displayFields['.$table.'][]">'.implode("",$opt).'</select>';
601                 
602                         // Table with the search box:
603                 $content.= '
604                 <table border=0 cellpadding=1 cellspacing=0>
605                 '.$formElements[0].'
606                         <tr>
607                                 <td><img src=clear.gif width='.$this->spaceSearchBoxFromLeft.' height=1></td>
608                                 <td bgcolor="#9BA1A8">
609                                         <table border=0 cellpadding=0 cellspacing=0 bgcolor="'.$GLOBALS["TBE_TEMPLATE"]->bgColor4.'">
610                                         <tr>
611                                                 <td>'.$lMenu.'</td>
612                                                 <td><input type="Submit" name="search" value="'.$GLOBALS["LANG"]->sL("LLL:EXT:lang/locallang_core.php:labels.setFields").'"></td>
613                                         </tr>
614                                         </table>                        
615                                 </td>
616                         </tr>'.$formElements[1].'
617                 </table>
618                 ';
619                 return $content;
620         }
621         function initCSV()      {
622                 $this->csvLines=array();
623                 
624                 reset($this->fieldArray);
625                 $csvRow=array();
626                 while(list(,$fN)=each($this->fieldArray))       {
627                         $csvRow[]=$fN;
628                 }
629                 $this->setCsvRow($csvRow);
630                 $this->csvLines[]="";
631         }
632         function addToCSV($row) {
633                 reset($this->fieldArray);
634                 $csvRow=array();
635                 while(list(,$fN)=each($this->fieldArray))       {
636                         if ($fN=="_PATH_")      {
637                                 $csvRow[]=$this->recPath($row["pid"]);
638                         } else {
639                                 $csvRow[]=$row[$fN];
640                         }
641                 }
642                 $this->setCsvRow($csvRow);
643         }
644         function setCsvRow($csvRow)     {
645                 $this->csvLines[] = t3lib_div::csvValues($csvRow);
646         }
647         function outputCSV($prefix)     {
648                 $filename=$prefix."_".date("dmy-Hi").".csv";
649                 $mimeType = "application/octet-stream";
650                 Header("Content-Type: ".$mimeType);
651                 Header("Content-Disposition: attachment; filename=".$filename);
652                 echo implode(chr(13).chr(10),$this->csvLines);
653                 exit;
654         }
655         function recPath($pid)  {
656                 if (!isset($this->recPath_cache[$pid])) {
657                         $this->recPath_cache[$pid] = t3lib_BEfunc::getRecordPath ($pid,$this->perms_clause,20);
658                 }
659                 return $this->recPath_cache[$pid];
660         }
661         function showNewRecLink($table) {
662                 return !count($this->allowedNewTables) || in_array($table,$this->allowedNewTables);
663         }
664         function makeReturnUrl()        {
665                 return '&returnUrl='.rawurlencode(t3lib_div::getIndpEnv("REQUEST_URI"));
666         }
667 }
668
669  
670
671 if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["typo3/class.db_list_extra.inc"])   {
672         include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["typo3/class.db_list_extra.inc"]);
673 }
674
675 ?>