"TYPO3 4.0.1: typo3_src-4.0.1/typo3/class.db_list_extra.inc Source File", "datetime" => "Sat Dec 2 19:22:20 2006", "date" => "2 Dec 2006", "doxygenversion" => "1.4.6", "projectname" => "TYPO3 4.0.1", "projectnumber" => "4.0.1" ); get_header($doxygen_vars); ?>

class.db_list_extra.inc

00001 <?php
00002 /*************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00091 class localRecordList extends recordList {
00092 
00093                 // External:
00094         var $alternateBgColors=FALSE;                   // If true, table rows in the list will alternate in background colors (and have background colors at all!)
00095         var $allowedNewTables=array();                  // Used to indicate which tables (values in the array) that can have a create-new-record link. If the array is empty, all tables are allowed.
00096         var $newWizards=FALSE;                                  // If true, the control panel will contain links to the create-new wizards for pages and tt_content elements (normally, the link goes to just creating a new element without the wizards!).
00097 
00098         var $dontShowClipControlPanels=FALSE;   // If true, will disable the rendering of clipboard + control panels.
00099         var $showClipboard=FALSE;                               // If true, will show the clipboard in the field list.
00100         var $noControlPanels = FALSE;                   // If true, will DISABLE all control panels in lists. (Takes precedence)
00101         var $clickMenuEnabled = TRUE;                   // If true, clickmenus will be rendered
00102 
00103 
00104 
00105 
00106                 // Internal:
00107         var $pageRow=array();                                   // Set to the page record (see writeTop())
00108 
00109         var $csvLines=array();                                  // Used to accumulate CSV lines in for CSV export.
00110         var $csvOutput=FALSE;                                   // If set, the listing is returned as CSV instead.
00111 
00112         var $clipObj;                                                   // Clipboard object
00113         var $CBnames=array();                                   // Tracking names of elements (for clipboard use)
00114         var $duplicateStack=array();                    // Used to track which elements has duplicates and how many
00115 
00116 
00123         function writeTop($row) {
00124                 global $LANG;
00125 
00126                         // Makes the code for the pageicon in the top
00127                 $this->pageRow = $row;
00128                 $this->counter++;
00129                 $alttext = t3lib_BEfunc::getRecordIconAltText($row,'pages');
00130                 $iconImg = t3lib_iconWorks::getIconImage('pages',$row,$this->backPath,'class="absmiddle" title="'.htmlspecialchars($alttext).'"');
00131                 $titleCol = 'test';     // pseudo title column name
00132                 $this->fieldArray = Array($titleCol,'up');              // Setting the fields to display in the list (this is of course "pseudo fields" since this is the top!)
00133 
00134 
00135                         // Filling in the pseudo data array:
00136                 $theData = Array();
00137                 $theData[$titleCol] = $this->widthGif;
00138 
00139                         // Get users permissions for this row:
00140                 $localCalcPerms = $GLOBALS['BE_USER']->calcPerms($row);
00141 
00142                 $theData['up']=array();
00143 
00144                         // Initialize control panel for currect page ($this->id):
00145                         // Some of the controls are added only if $this->id is set - since they make sense only on a real page, not root level.
00146                 $theCtrlPanel =array();
00147 
00148                         // "View page" icon is added:
00149                 $theCtrlPanel[]='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::viewOnClick($this->id,'',t3lib_BEfunc::BEgetRootLine($this->id))).'">'.
00150                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/zoom.gif','width="12" height="12"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.showPage',1).'" alt="" />'.
00151                                                 '</a>';
00152 
00153                         // If edit permissions are set (see class.t3lib_userauthgroup.php)
00154                 if ($localCalcPerms&2)  {
00155 
00156                                 // Adding "Edit page" icon:
00157                         if ($this->id)  {
00158                                 $params='&edit[pages]['.$row['uid'].']=edit';
00159                                 $theCtrlPanel[]='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,'',-1)).'">'.
00160                                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2.gif','width="11" height="12"').' title="'.$LANG->getLL('editPage',1).'" alt="" />'.
00161                                                                 '</a>';
00162                         }
00163 
00164                                 // Adding "New record" icon:
00165                         if (!$GLOBALS['SOBE']->modTSconfig['properties']['noCreateRecordsLink'])        {
00166                                 $theCtrlPanel[]='<a href="#" onclick="'.htmlspecialchars('return jumpExt(\'db_new.php?id='.$this->id.'\');').'">'.
00167                                                                 '<img'.t3lib_iconWorks::skinImg('','gfx/new_el.gif','width="11" height="12"').' title="'.$LANG->getLL('newRecordGeneral',1).'" alt="" />'.
00168                                                                 '</a>';
00169                         }
00170 
00171                                 // Adding "Hide/Unhide" icon:
00172                         if ($this->id)  {
00173                                 if ($row['hidden'])     {
00174                                         $params='&data[pages]['.$row['uid'].'][hidden]=0';
00175                                         $theCtrlPanel[]='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$GLOBALS['SOBE']->doc->issueCommand($params,-1).'\');').'">'.
00176                                                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_unhide.gif','width="11" height="10"').' title="'.$LANG->getLL('unHidePage',1).'" alt="" />'.
00177                                                                         '</a>';
00178                                 } else {
00179                                         $params='&data[pages]['.$row['uid'].'][hidden]=1';
00180                                         $theCtrlPanel[]='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$GLOBALS['SOBE']->doc->issueCommand($params,-1).'\');').'">'.
00181                                                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_hide.gif','width="11" height="10"').' title="'.$LANG->getLL('hidePage',1).'" alt="" />'.
00182                                                                         '</a>';
00183                                 }
00184                         }
00185 
00186                                 // Adding "move page" button:
00187                         if ($this->id)  {
00188                                 $theCtrlPanel[]='<a href="#" onclick="'.htmlspecialchars('return jumpExt(\'move_el.php?table=pages&uid='.$row['uid'].'\');').'">'.
00189                                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/move_'.($this->table=='tt_content'?'record':'page').'.gif','width="11" height="12"').' title="'.$LANG->getLL('move_page',1).'" alt="" />'.
00190                                                                 '</a>';
00191                         }
00192                 }
00193 
00194                         // "Paste into page" link:
00195                 if (($localCalcPerms&8) || ($localCalcPerms&16))        {
00196                         $elFromTable = $this->clipObj->elFromTable('');
00197                         if (count($elFromTable))        {
00198                                 $theCtrlPanel[]='<a href="'.htmlspecialchars($this->clipObj->pasteUrl('',$this->id)).'" onclick="'.htmlspecialchars('return '.$this->clipObj->confirmMsg('pages',$this->pageRow,'into',$elFromTable)).'">'.
00199                                                                 '<img'.t3lib_iconWorks::skinImg('','gfx/clip_pasteafter.gif','width="12" height="12"').' title="'.$LANG->getLL('clip_paste',1).'" alt="" />'.
00200                                                                 '</a>';
00201                         }
00202                 }
00203 
00204                         // Finally, compile all elements of the control panel into table cells:
00205                 if (count($theCtrlPanel))       {
00206                         $theData['up'][]='
00207 
00208                                 <!--
00209                                         Control panel for page
00210                                 -->
00211                                 <table border="0" cellpadding="0" cellspacing="0" class="bgColor4" id="typo3-dblist-ctrltop">
00212                                         <tr>
00213                                                 <td>'.implode('</td>
00214                                                 <td>',$theCtrlPanel).'</td>
00215                                         </tr>
00216                                 </table>';
00217                 }
00218 
00219 
00220                         // Add "clear-cache" link:
00221                 $theData['up'][]='<a href="'.htmlspecialchars($this->listURL().'&clear_cache=1').'">'.
00222                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/clear_cache.gif','width="14" height="14"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.clear_cache',1).'" alt="" />'.
00223                                                 '</a>';
00224 
00225                         // Add "CSV" link, if a specific table is shown:
00226                 if ($this->table)       {
00227                         $theData['up'][]='<a href="'.htmlspecialchars($this->listURL().'&csv=1').'">'.
00228                                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/csv.gif','width="27" height="14"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.csv',1).'" alt="" />'.
00229                                                         '</a>';
00230                 }
00231 
00232                         // Add "Export" link, if a specific table is shown:
00233                 if ($this->table && t3lib_extMgm::isLoaded('impexp'))   {
00234                         $theData['up'][]='<a href="'.htmlspecialchars($this->backPath.t3lib_extMgm::extRelPath('impexp').'app/index.php?tx_impexp[action]=export&tx_impexp[list][]='.rawurlencode($this->table.':'.$this->id)).'">'.
00235                                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,t3lib_extMgm::extRelPath('impexp').'export.gif',' width="18" height="16"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:rm.export',1).'" alt="" />'.
00236                                                         '</a>';
00237                 }
00238 
00239                         // Add "refresh" link:
00240                 $theData['up'][]='<a href="'.htmlspecialchars($this->listURL()).'">'.
00241                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/refresh_n.gif','width="14" height="14"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.reload',1).'" alt="" />'.
00242                                                 '</a>';
00243 
00244 
00245                         // Add icon with clickmenu, etc:
00246                 if ($this->id)  {       // If there IS a real page...:
00247 
00248                                 // Setting title of page + the "Go up" link:
00249                         $theData[$titleCol].='<br /><span title="'.htmlspecialchars($row['_thePathFull']).'">'.htmlspecialchars(t3lib_div::fixed_lgd_cs($row['_thePath'],-$this->fixedL)).'</span>';
00250                         $theData['up'][]='<a href="'.htmlspecialchars($this->listURL($row['pid'])).'" onclick="setHighlight('.$row['pid'].')">'.
00251                                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/i/pages_up.gif','width="18" height="16"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.upOneLevel',1).'" alt="" />'.
00252                                                         '</a>';
00253 
00254                                 // Make Icon:
00255                         $theIcon = $this->clickMenuEnabled ? $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconImg,'pages',$this->id) : $iconImg;
00256                 } else {        // On root-level of page tree:
00257 
00258                                 // Setting title of root (sitename):
00259                         $theData[$titleCol].='<br />'.htmlspecialchars(t3lib_div::fixed_lgd_cs($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'],-$this->fixedL));
00260 
00261                                 // Make Icon:
00262                         $theIcon = '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/i/_icon_website.gif','width="18" height="16"').' alt="" />';
00263                 }
00264 
00265                         // If there is a returnUrl given, add a back-link:
00266                 if ($this->returnUrl)   {
00267                         $theData['up'][]='<a href="'.htmlspecialchars(t3lib_div::linkThisUrl($this->returnUrl,array('id'=>$this->id))).'" class="typo3-goBack">'.
00268                                                         '<img'.t3lib_iconWorks::skinImg($GLOBALS["BACK_PATH"],'gfx/goback.gif','width="14" height="14"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.goBack',1).'" alt="" />'.
00269                                                         '</a>';
00270                 }
00271 
00272                         // Finally, the "up" pseudo field is compiled into a table - has been accumulated in an array:
00273                 $theData['up']='
00274                         <table border="0" cellpadding="0" cellspacing="0">
00275                                 <tr>
00276                                         <td>'.implode('</td>
00277                                         <td>',$theData['up']).'</td>
00278                                 </tr>
00279                         </table>';
00280 
00281                         // ... and the element row is created:
00282                 $out.=$this->addelement(1,$theIcon,$theData,'',$this->leftMargin);
00283 
00284                         // ... and wrapped into a table and added to the internal ->HTMLcode variable:
00285                 $this->HTMLcode.='
00286 
00287 
00288                 <!--
00289                         Page header for db_list:
00290                 -->
00291                         <table border="0" cellpadding="0" cellspacing="0" id="typo3-dblist-top">
00292                                 '.$out.'
00293                         </table>';
00294         }
00295 
00304         function getTable($table,$id,$rowlist)  {
00305                 global $TCA;
00306 
00307                         // Loading all TCA details for this table:
00308                 t3lib_div::loadTCA($table);
00309 
00310                         // Init
00311                 $addWhere = '';
00312                 $titleCol = $TCA[$table]['ctrl']['label'];
00313                 $thumbsCol = $TCA[$table]['ctrl']['thumbnail'];
00314                 $l10nEnabled = $TCA[$table]['ctrl']['languageField'] && $TCA[$table]['ctrl']['transOrigPointerField'] && !$TCA[$table]['ctrl']['transOrigPointerTable'];
00315 
00316                         // Cleaning rowlist for duplicates and place the $titleCol as the first column always!
00317                 $this->fieldArray=array();
00318                 $this->fieldArray[] = $titleCol;        // Add title column
00319                 if ($this->localizationView && $l10nEnabled)    {
00320                         $this->fieldArray[] = '_LOCALIZATION_';
00321                         $this->fieldArray[] = '_LOCALIZATION_b';
00322                         $addWhere.=' AND '.$TCA[$table]['ctrl']['languageField'].'<=0';
00323                 }
00324                 if (!t3lib_div::inList($rowlist,'_CONTROL_'))   {
00325                         $this->fieldArray[] = '_CONTROL_';
00326                 }
00327                 if ($this->showClipboard)       {
00328                         $this->fieldArray[] = '_CLIPBOARD_';
00329                 }
00330                 if (!$this->dontShowClipControlPanels)  {
00331                         $this->fieldArray[]='_REF_';
00332                 }
00333                 if ($this->searchLevels)        {
00334                         $this->fieldArray[]='_PATH_';
00335                 }
00336                         // Cleaning up:
00337                 $this->fieldArray=array_unique(array_merge($this->fieldArray,t3lib_div::trimExplode(',',$rowlist,1)));
00338                 if ($this->noControlPanels)     {
00339                         $tempArray = array_flip($this->fieldArray);
00340                         unset($tempArray['_CONTROL_']);
00341                         unset($tempArray['_CLIPBOARD_']);
00342                         $this->fieldArray = array_keys($tempArray);
00343                 }
00344 
00345                         // Creating the list of fields to include in the SQL query:
00346                 $selectFields = $this->fieldArray;
00347                 $selectFields[] = 'uid';
00348                 $selectFields[] = 'pid';
00349                 if ($thumbsCol) $selectFields[] = $thumbsCol;   // adding column for thumbnails
00350                 if ($table=='pages')    {
00351                         if (t3lib_extMgm::isLoaded('cms'))      {
00352                                 $selectFields[] = 'module';
00353                                 $selectFields[] = 'extendToSubpages';
00354                         }
00355                         $selectFields[] = 'doktype';
00356                 }
00357                 if (is_array($TCA[$table]['ctrl']['enablecolumns']))    {
00358                         $selectFields = array_merge($selectFields,$TCA[$table]['ctrl']['enablecolumns']);
00359                 }
00360                 if ($TCA[$table]['ctrl']['type'])       {
00361                         $selectFields[] = $TCA[$table]['ctrl']['type'];
00362                 }
00363                 if ($TCA[$table]['ctrl']['typeicon_column'])    {
00364                         $selectFields[] = $TCA[$table]['ctrl']['typeicon_column'];
00365                 }
00366                 if ($TCA[$table]['ctrl']['versioningWS'])       {
00367                         $selectFields[] = 't3ver_id';
00368                         $selectFields[] = 't3ver_state';
00369                         $selectFields[] = 't3ver_wsid';
00370                         $selectFields[] = 't3ver_swapmode';             // Filtered out when pages in makeFieldList()
00371                 }
00372                 if ($l10nEnabled)       {
00373                         $selectFields[] = $TCA[$table]['ctrl']['languageField'];
00374                         $selectFields[] = $TCA[$table]['ctrl']['transOrigPointerField'];
00375                 }
00376                 if ($TCA[$table]['ctrl']['label_alt'])  {
00377                         $selectFields = array_merge($selectFields,t3lib_div::trimExplode(',',$TCA[$table]['ctrl']['label_alt'],1));
00378                 }
00379                 $selectFields = array_unique($selectFields);            // Unique list!
00380                 $selectFields = array_intersect($selectFields,$this->makeFieldList($table,1));          // Making sure that the fields in the field-list ARE in the field-list from TCA!
00381                 $selFieldList = implode(',',$selectFields);             // implode it into a list of fields for the SQL-statement.
00382 
00383                         // Create the SQL query for selecting the elements in the listing:
00384                 $queryParts = $this->makeQueryArray($table, $id,$addWhere,$selFieldList);       // (API function from class.db_list.inc)
00385                 $this->setTotalItems($queryParts);              // Finding the total amount of records on the page (API function from class.db_list.inc)
00386 
00387                         // Init:
00388                 $dbCount = 0;
00389                 $out = '';
00390 
00391                         // If the count query returned any number of records, we perform the real query, selecting records.
00392                 if ($this->totalItems)  {
00393                         $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
00394                         $dbCount = $GLOBALS['TYPO3_DB']->sql_num_rows($result);
00395                 }
00396 
00397                 $LOISmode = $this->listOnlyInSingleTableMode && !$this->table;
00398 
00399                         // If any records was selected, render the list:
00400                 if ($dbCount)   {
00401 
00402                                 // Half line is drawn between tables:
00403                         if (!$LOISmode) {
00404                                 $theData = Array();
00405                                 if (!$this->table && !$rowlist) {
00406                                         $theData[$titleCol] = '<img src="clear.gif" width="'.($GLOBALS['SOBE']->MOD_SETTINGS['bigControlPanel']?'230':'350').'" height="1" alt="" />';
00407                                         if (in_array('_CONTROL_',$this->fieldArray))    $theData['_CONTROL_']='';
00408                                         if (in_array('_CLIPBOARD_',$this->fieldArray))  $theData['_CLIPBOARD_']='';
00409                                 }
00410                                 $out.=$this->addelement(0,'',$theData,'class="c-table-row-spacer"',$this->leftMargin);
00411                         }
00412 
00413                                 // Header line is drawn
00414                         $theData = Array();
00415                         if ($this->disableSingleTableView)      {
00416                                 $theData[$titleCol] = '<span class="c-table">'.$GLOBALS['LANG']->sL($TCA[$table]['ctrl']['title'],1).'</span> ('.$this->totalItems.')';
00417                         } else {
00418                                 $theData[$titleCol] = $this->linkWrapTable($table,'<span class="c-table">'.$GLOBALS['LANG']->sL($TCA[$table]['ctrl']['title'],1).'</span> ('.$this->totalItems.') <img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/'.($this->table?'minus':'plus').'bullet_list.gif','width="18" height="12"').' hspace="10" class="absmiddle" title="'.$GLOBALS['LANG']->getLL(!$this->table?'expandView':'contractView',1).'" alt="" />');
00419                         }
00420 
00421                                 // CSH:
00422                         $theData[$titleCol].= t3lib_BEfunc::cshItem($table,'',$this->backPath,'',FALSE,'margin-bottom:0px; white-space: normal;');
00423 
00424                         if ($LOISmode)  {
00425                                 $out.='
00426                                         <tr>
00427                                                 <td class="c-headLineTable" style="width:95%;">'.$theData[$titleCol].'</td>
00428                                         </tr>';
00429 
00430                                 if ($GLOBALS['BE_USER']->uc["edit_showFieldHelp"])      {
00431                                         $GLOBALS['LANG']->loadSingleTableDescription($table);
00432                                         if (isset($GLOBALS['TCA_DESCR'][$table]['columns']['']))        {
00433                                                 $onClick = 'vHWin=window.open(\'view_help.php?tfID='.$table.'.\',\'viewFieldHelp\',\'height=400,width=600,status=0,menubar=0,scrollbars=1\');vHWin.focus();return false;';
00434                                                 $out.='
00435                                         <tr>
00436                                                 <td class="c-tableDescription">'.t3lib_BEfunc::helpTextIcon($table,'',$this->backPath,TRUE).$GLOBALS['TCA_DESCR'][$table]['columns']['']['description'].'</td>
00437                                         </tr>';
00438                                         }
00439                                 }
00440                         } else {
00441                                 $theUpIcon = ($table=='pages'&&$this->id&&isset($this->pageRow['pid'])) ? '<a href="'.htmlspecialchars($this->listURL($this->pageRow['pid'])).'" onclick="setHighlight('.$this->pageRow['pid'].')"><img'.t3lib_iconWorks::skinImg('','gfx/i/pages_up.gif','width="18" height="16"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.upOneLevel',1).'" alt="" /></a>':'';
00442                                 $out.=$this->addelement(1,$theUpIcon,$theData,' class="c-headLineTable"','');
00443                         }
00444 
00445                         If (!$LOISmode) {
00446                                         // Fixing a order table for sortby tables
00447                                 $this->currentTable = array();
00448                                 $currentIdList = array();
00449                                 $doSort = ($TCA[$table]['ctrl']['sortby'] && !$this->sortField);
00450 
00451                                 $prevUid = 0;
00452                                 $prevPrevUid = 0;
00453                                 $accRows = array();     // Accumulate rows here
00454                                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result))    {
00455                                         $accRows[] = $row;
00456                                         $currentIdList[] = $row['uid'];
00457                                         if ($doSort)    {
00458                                                 if ($prevUid)   {
00459                                                         $this->currentTable['prev'][$row['uid']] = $prevPrevUid;
00460                                                         $this->currentTable['next'][$prevUid] = '-'.$row['uid'];
00461                                                         $this->currentTable['prevUid'][$row['uid']] = $prevUid;
00462                                                 }
00463                                                 $prevPrevUid = isset($this->currentTable['prev'][$row['uid']]) ? -$prevUid : $row['pid'];
00464                                                 $prevUid=$row['uid'];
00465                                         }
00466                                 }
00467                                 $GLOBALS['TYPO3_DB']->sql_free_result($result);
00468 
00469                                         // CSV initiated
00470                                 if ($this->csvOutput) $this->initCSV();
00471 
00472                                         // Render items:
00473                                 $this->CBnames=array();
00474                                 $this->duplicateStack=array();
00475                                 $this->eCounter=$this->firstElementNumber;
00476 
00477                                 $iOut = '';
00478                                 $cc = 0;
00479                                 foreach($accRows as $row)       {
00480 
00481                                                 // Forward/Backwards navigation links:
00482                                         list($flag,$code) = $this->fwd_rwd_nav($table);
00483                                         $iOut.=$code;
00484 
00485                                                 // If render item, increment counter and call function
00486                                         if ($flag)      {
00487                                                 $cc++;
00488                                                 $iOut.= $this->renderListRow($table,$row,$cc,$titleCol,$thumbsCol);
00489 
00490                                                         // If localization view is enabled it means that the selected records are either default or All language and here we will not select translations which point to the main record:
00491                                                 if ($this->localizationView && $l10nEnabled)    {
00492 
00493                                                                 // Look for translations of this record:
00494                                                         $translations = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
00495                                                                 $selFieldList,
00496                                                                 $table,
00497                                                                 'pid='.$row['pid'].
00498                                                                         ' AND '.$TCA[$table]['ctrl']['languageField'].'>0'.
00499                                                                         ' AND '.$TCA[$table]['ctrl']['transOrigPointerField'].'='.intval($row['uid']).
00500                                                                         t3lib_BEfunc::deleteClause($table).
00501                                                                         t3lib_BEfunc::versioningPlaceholderClause($table)
00502                                                         );
00503 
00504                                                                 // For each available translation, render the record:
00505                                                         if (is_array($translations)) {
00506                                                                 foreach($translations as $lRow) {
00507                                                                         if ($GLOBALS['BE_USER']->checkLanguageAccess($lRow[$TCA[$table]['ctrl']['languageField']]))     {
00508                                                                                 $iOut.=$this->renderListRow($table,$lRow,$cc,$titleCol,$thumbsCol,18);
00509                                                                         }
00510                                                                 }
00511                                                         }
00512                                                 }
00513                                         }
00514 
00515                                                 // Counter of total rows incremented:
00516                                         $this->eCounter++;
00517                                 }
00518 
00519                                         // The header row for the table is now created:
00520                                 $out.=$this->renderListHeader($table,$currentIdList);
00521                         }
00522 
00523                                 // The list of records is added after the header:
00524                         $out.=$iOut;
00525 
00526                                 // ... and it is all wrapped in a table:
00527                         $out='
00528 
00529 
00530 
00531                         <!--
00532                                 DB listing of elements: "'.htmlspecialchars($table).'"
00533                         -->
00534                                 <table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist'.($LOISmode?' typo3-dblist-overview':'').'">
00535                                         '.$out.'
00536                                 </table>';
00537 
00538                                 // Output csv if...
00539                         if ($this->csvOutput)   $this->outputCSV($table);       // This ends the page with exit.
00540                 }
00541 
00542                         // Return content:
00543                 return $out;
00544         }
00545 
00559         function renderListRow($table,$row,$cc,$titleCol,$thumbsCol,$indent=0)  {
00560                 $iOut = '';
00561 
00562                 if (strlen($this->searchString))        {       // If in search mode, make sure the preview will show the correct page
00563                         $id_orig = $this->id;
00564                         $this->id = $row['pid'];
00565                 }
00566 
00567                         // In offline workspace, look for alternative record:
00568                 t3lib_BEfunc::workspaceOL($table, $row, $GLOBALS['BE_USER']->workspace);
00569 
00570                         // Background color, if any:
00571                 $row_bgColor=
00572                         $this->alternateBgColors ?
00573                         (($cc%2)?'' :' class="db_list_alt"') :
00574                         '';
00575 
00576                         // Overriding with versions background color if any:
00577                 $row_bgColor = $row['_CSSCLASS'] ? ' class="'.$row['_CSSCLASS'].'"' : $row_bgColor;
00578 
00579                         // Initialization
00580                 $alttext = t3lib_BEfunc::getRecordIconAltText($row,$table);
00581                 $recTitle = t3lib_BEfunc::getRecordTitle($table,$row);
00582 
00583                         // Incr. counter.
00584                 $this->counter++;
00585 
00586                         // The icon with link
00587                 $iconImg = t3lib_iconWorks::getIconImage($table,$row,$this->backPath,'title="'.htmlspecialchars($alttext).'"'.($indent ? ' style="margin-left: '.$indent.'px;"' : ''));
00588                 $theIcon = $this->clickMenuEnabled ? $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconImg,$table,$row['uid']) : $iconImg;
00589 
00590                         // Preparing and getting the data-array
00591                 $theData = Array();
00592                 foreach($this->fieldArray as $fCol)     {
00593                         if ($fCol==$titleCol)   {
00594                                 if ($GLOBALS['TCA'][$table]['ctrl']['label_alt'] && ($GLOBALS['TCA'][$table]['ctrl']['label_alt_force'] || !strcmp($row[$fCol],'')))    {
00595                                         $altFields=t3lib_div::trimExplode(',',$GLOBALS['TCA'][$table]['ctrl']['label_alt'],1);
00596                                         $tA=array();
00597                                         if ($row[$fCol])        { $tA[]=$row[$fCol]; }
00598                                         while(list(,$fN)=each($altFields))      {
00599                                                 $t = t3lib_BEfunc::getProcessedValueExtra($table,$fN,$row[$fN],$GLOBALS['BE_USER']->uc['titleLen'],$row['uid']);
00600                                                 if($t)  { $tA[] = $t; }
00601                                         }
00602                                         if ($GLOBALS['TCA'][$table]['ctrl']['label_alt_force']) { $t=implode(', ',$tA); }
00603                                         if ($t) { $recTitle = $t; }
00604                                 } else {
00605                                         $recTitle = t3lib_BEfunc::getProcessedValueExtra($table,$fCol,$row[$fCol],$GLOBALS['BE_USER']->uc['titleLen'],$row['uid']);
00606                                 }
00607                                 $theData[$fCol] = $this->linkWrapItems($table,$row['uid'],$recTitle,$row);
00608                         } elseif ($fCol=='pid') {
00609                                 $theData[$fCol]=$row[$fCol];
00610                         } elseif ($fCol=='_PATH_') {
00611                                 $theData[$fCol]=$this->recPath($row['pid']);
00612                         } elseif ($fCol=='_REF_') {
00613                                 $theData[$fCol]=$this->makeRef($table,$row['uid']);
00614                         } elseif ($fCol=='_CONTROL_') {
00615                                 $theData[$fCol]=$this->makeControl($table,$row);
00616                         } elseif ($fCol=='_CLIPBOARD_') {
00617                                 $theData[$fCol]=$this->makeClip($table,$row);
00618                         } elseif ($fCol=='_LOCALIZATION_') {
00619                                 list($lC1, $lC2) = $this->makeLocalizationPanel($table,$row);
00620                                 $theData[$fCol] = $lC1;
00621                                 $theData[$fCol.'b'] = $lC2;
00622                         } elseif ($fCol=='_LOCALIZATION_b') {
00623                                 // Do nothing, has been done above.
00624                         } else {
00625                                 $theData[$fCol] = $this->linkUrlMail(htmlspecialchars(t3lib_BEfunc::getProcessedValueExtra($table,$fCol,$row[$fCol],100,$row['uid'])),$row[$fCol]);
00626                         }
00627                 }
00628 
00629                 if (strlen($this->searchString))        {       // Reset the ID if it was overwritten
00630                         $this->id = $id_orig;
00631                 }
00632 
00633                         // Add row to CSV list:
00634                 if ($this->csvOutput) $this->addToCSV($row,$table);
00635 
00636                         // Create element in table cells:
00637                 $iOut.=$this->addelement(1,$theIcon,$theData,$row_bgColor);
00638 
00639                         // Render thumbsnails if a thumbnail column exists and there is content in it:
00640                 if ($this->thumbs && trim($row[$thumbsCol]))    {
00641                         $iOut.=$this->addelement(4,'', Array($titleCol=>$this->thumbCode($row,$table,$thumbsCol)),$row_bgColor);
00642                 }
00643 
00644                         // Finally, return table row element:
00645                 return $iOut;
00646         }
00647 
00657         function renderListHeader($table,$currentIdList)        {
00658                 global $TCA, $LANG;
00659 
00660                         // Init:
00661                 $theData = Array();
00662 
00663                         // Traverse the fields:
00664                 foreach($this->fieldArray as $fCol)     {
00665 
00666                                 // Calculate users permissions to edit records in the table:
00667                         $permsEdit = $this->calcPerms & ($table=='pages'?2:16);
00668 
00669                         switch((string)$fCol)   {
00670                                 case '_PATH_':                  // Path
00671                                         $theData[$fCol] = '<i>['.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels._PATH_',1).']</i>';
00672                                 break;
00673                                 case '_REF_':                   // References
00674                                         $theData[$fCol] = '<i>['.$LANG->sL('LLL:EXT:lang/locallang_mod_file_list.xml:c__REF_',1).']</i>';
00675                                 break;
00676                                 case '_LOCALIZATION_':                  // Path
00677                                         $theData[$fCol] = '<i>['.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels._LOCALIZATION_',1).']</i>';
00678                                 break;
00679                                 case '_LOCALIZATION_b':                 // Path
00680                                         $theData[$fCol] = $LANG->getLL('Localize',1);
00681                                 break;
00682                                 case '_CLIPBOARD_':             // Clipboard:
00683                                         $cells=array();
00684 
00685                                                 // If there are elements on the clipboard for this table, then display the "paste into" icon:
00686                                         $elFromTable = $this->clipObj->elFromTable($table);
00687                                         if (count($elFromTable))        {
00688                                                 $cells[]='<a href="'.htmlspecialchars($this->clipObj->pasteUrl($table,$this->id)).'" onclick="'.htmlspecialchars('return '.$this->clipObj->confirmMsg('pages',$this->pageRow,'into',$elFromTable)).'">'.
00689                                                                 '<img'.t3lib_iconWorks::skinImg('','gfx/clip_pasteafter.gif','width="12" height="12"').' title="'.$LANG->getLL('clip_paste',1).'" alt="" />'.
00690                                                                 '</a>';
00691                                         }
00692 
00693                                                 // If the numeric clipboard pads are enabled, display the control icons for that:
00694                                         if ($this->clipObj->current!='normal')  {
00695 
00696                                                         // The "select" link:
00697                                                 $cells[]=$this->linkClipboardHeaderIcon('<img'.t3lib_iconWorks::skinImg('','gfx/clip_copy.gif','width="12" height="12"').' title="'.$LANG->getLL('clip_selectMarked',1).'" alt="" />',$table,'setCB');
00698 
00699                                                         // The "edit marked" link:
00700                                                 $editIdList = implode(',',$currentIdList);
00701                                                 $editIdList = "'+editList('".$table."','".$editIdList."')+'";
00702                                                 $params='&edit['.$table.']['.$editIdList.']=edit&disHelp=1';
00703                                                 $cells[]='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,'',-1)).'">'.
00704                                                                 '<img'.t3lib_iconWorks::skinImg('','gfx/edit2.gif','width="11" height="12"').' title="'.$LANG->getLL('clip_editMarked',1).'" alt="" />'.
00705                                                                 '</a>';
00706 
00707                                                         // The "Delete marked" link:
00708                                                 $cells[]=$this->linkClipboardHeaderIcon('<img'.t3lib_iconWorks::skinImg('','gfx/garbage.gif','width="11" height="12"').' title="'.$LANG->getLL('clip_deleteMarked',1).'" alt="" />',$table,'delete',sprintf($LANG->getLL('clip_deleteMarkedWarning'),$LANG->sL($TCA[$table]['ctrl']['title'])));
00709 
00710                                                         // The "Select all" link:
00711                                                 $cells[]='<a href="#" onclick="'.htmlspecialchars('checkOffCB(\''.implode(',',$this->CBnames).'\'); return false;').'">'.
00712                                                                 '<img'.t3lib_iconWorks::skinImg('','gfx/clip_select.gif','width="12" height="12"').' title="'.$LANG->getLL('clip_markRecords',1).'" alt="" />'.
00713                                                                 '</a>';
00714                                         } else {
00715                                                 $cells[]='';
00716                                         }
00717                                         $theData[$fCol]=implode('',$cells);
00718                                 break;
00719                                 case '_CONTROL_':               // Control panel:
00720                                         if (!$TCA[$table]['ctrl']['readOnly'])  {
00721 
00722                                                         // If new records can be created on this page, add links:
00723                                                 if ($this->calcPerms&($table=='pages'?8:16) && $this->showNewRecLink($table))   {
00724                                                         if ($table=="tt_content" && $this->newWizards)  {
00725                                                                         //  If mod.web_list.newContentWiz.overrideWithExtension is set, use that extension's create new content wizard instead:
00726                                                                 $tmpTSc = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'],'mod.web_list');
00727                                                                 $tmpTSc = $tmpTSc ['properties']['newContentWiz.']['overrideWithExtension'];
00728                                                                 $newContentWizScriptPath = t3lib_extMgm::isLoaded($tmpTSc) ? (t3lib_extMgm::extRelPath($tmpTSc).'mod1/db_new_content_el.php') : 'sysext/cms/layout/db_new_content_el.php';
00729 
00730                                                                 $theData[$fCol]='<a href="#" onclick="'.htmlspecialchars('return jumpExt(\''.$newContentWizScriptPath.'?id='.$this->id.'\');').'">'.
00731                                                                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/new_'.($table=='pages'?'page':'el').'.gif','width="'.($table=='pages'?13:11).'" height="12"').' title="'.$LANG->getLL('new',1).'" alt="" />'.
00732                                                                                                 '</a>';
00733                                                         } elseif ($table=='pages' && $this->newWizards) {
00734                                                                 $theData[$fCol]='<a href="'.htmlspecialchars('db_new.php?id='.$this->id.'&pagesOnly=1returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))).'">'.
00735                                                                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/new_'.($table=='pages'?'page':'el').'.gif','width="'.($table=='pages'?13:11).'" height="12"').' title="'.$LANG->getLL('new',1).'" alt="" />'.
00736                                                                                                 '</a>';
00737                                                         } else {
00738                                                                 $params='&edit['.$table.']['.$this->id.']=new';
00739                                                                 $theData[$fCol]='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,'',-1)).'">'.
00740                                                                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/new_'.($table=='pages'?'page':'el').'.gif','width="'.($table=='pages'?13:11).'" height="12"').' title="'.$LANG->getLL('new',1).'" alt="" />'.
00741                                                                                                 '</a>';
00742                                                         }
00743                                                 }
00744 
00745                                                         // If the table can be edited, add link for editing ALL SHOWN fields for all listed records:
00746                                                 if ($permsEdit && $this->table && is_array($currentIdList))     {
00747                                                         $editIdList = implode(',',$currentIdList);
00748                                                         if ($this->clipNumPane()) $editIdList = "'+editList('".$table."','".$editIdList."')+'";
00749                                                         $params='&edit['.$table.']['.$editIdList.']=edit&columnsOnly='.implode(',',$this->fieldArray).'&disHelp=1';
00750                                                         $theData[$fCol].='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,'',-1)).'">'.
00751                                                                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2.gif','width="11" height="12"').' title="'.$LANG->getLL('editShownColumns',1).'" alt="" />'.
00752                                                                                         '</a>';
00753                                                 }
00754                                         }
00755                                 break;
00756                                 default:                        // Regular fields header:
00757                                         $theData[$fCol]='';
00758                                         if ($this->table && is_array($currentIdList))   {
00759 
00760                                                         // If the numeric clipboard pads are selected, show duplicate sorting link:
00761                                                 if ($this->clipNumPane()) {
00762                                                         $theData[$fCol].='<a href="'.htmlspecialchars($this->listURL('',-1).'&duplicateField='.$fCol).'">'.
00763                                                                                         '<img'.t3lib_iconWorks::skinImg('','gfx/select_duplicates.gif','width="11" height="11"').' title="'.$LANG->getLL('clip_duplicates',1).'" alt="" />'.
00764                                                                                         '</a>';
00765                                                 }
00766 
00767                                                         // If the table can be edited, add link for editing THIS field for all listed records:
00768                                                 if (!$TCA[$table]['ctrl']['readOnly'] && $permsEdit && $TCA[$table]['columns'][$fCol])  {
00769                                                         $editIdList = implode(',',$currentIdList);
00770                                                         if ($this->clipNumPane()) $editIdList = "'+editList('".$table."','".$editIdList."')+'";
00771                                                         $params='&edit['.$table.']['.$editIdList.']=edit&columnsOnly='.$fCol.'&disHelp=1';
00772                                                         $iTitle = sprintf($LANG->getLL('editThisColumn'),ereg_replace(':$','',trim($LANG->sL(t3lib_BEfunc::getItemLabel($table,$fCol)))));
00773                                                         $theData[$fCol].='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,'',-1)).'">'.
00774                                                                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2.gif','width="11" height="12"').' title="'.htmlspecialchars($iTitle).'" alt="" />'.
00775                                                                                         '</a>';
00776                                                 }
00777                                         }
00778                                         $theData[$fCol].=$this->addSortLink($LANG->sL(t3lib_BEfunc::getItemLabel($table,$fCol,'<i>[|]</i>')),$fCol,$table);
00779                                 break;
00780                         }
00781                 }
00782 
00783                         // Create and return header table row:
00784                 return $this->addelement(1,'',$theData,' class="c-headLine"','');
00785         }
00786 
00787 
00788 
00789 
00790 
00791 
00792         /*********************************
00793          *
00794          * Rendering of various elements
00795          *
00796          *********************************/
00797 
00805         function makeControl($table,$row)       {
00806                 global $TCA, $LANG, $SOBE;
00807                 if ($this->dontShowClipControlPanels)   return '';
00808 
00809                         // Initialize:
00810                 t3lib_div::loadTCA($table);
00811                 $cells=array();
00812 
00813                         // If the listed table is 'pages' we have to request the permission settings for each page:
00814                 if ($table=='pages')    {
00815                         $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages',$row['uid']));
00816                 }
00817 
00818                         // This expresses the edit permissions for this particular element:
00819                 $permsEdit = ($table=='pages' && ($localCalcPerms&2)) || ($table!='pages' && ($this->calcPerms&16));
00820 
00821                         // "Show" link (only pages and tt_content elements)
00822                 if ($table=='pages' || $table=='tt_content')    {
00823                         $params='&edit['.$table.']['.$row['uid'].']=edit';
00824                         $cells[]='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::viewOnClick($table=='tt_content'?$this->id.'#'.$row['uid']:$row['uid'])).'">'.
00825                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/zoom.gif','width="12" height="12"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.showPage',1).'" alt="" />'.
00826                                         '</a>';
00827                 }
00828 
00829                         // "Edit" link: ( Only if permissions to edit the page-record of the content of the parent page ($this->id)
00830                 if ($permsEdit) {
00831                         $params='&edit['.$table.']['.$row['uid'].']=edit';
00832                         $cells[]='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,'',-1)).'">'.
00833                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2'.(!$TCA[$table]['ctrl']['readOnly']?'':'_d').'.gif','width="11" height="12"').' title="'.$LANG->getLL('edit',1).'" alt="" />'.
00834                                         '</a>';
00835                 }
00836 
00837                         // "Move" wizard link for pages/tt_content elements:
00838                 if (($table=="tt_content" && $permsEdit) || ($table=='pages'))  {
00839                         $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpExt(\'move_el.php?table='.$table.'&uid='.$row['uid'].'\');').'">'.
00840                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/move_'.($table=='tt_content'?'record':'page').'.gif','width="11" height="12"').' title="'.$LANG->getLL('move_'.($table=='tt_content'?'record':'page'),1).'" alt="" />'.
00841                                         '</a>';
00842                 }
00843 
00844                         // If the extended control panel is enabled OR if we are seeing a single table:
00845                 if ($SOBE->MOD_SETTINGS['bigControlPanel'] || $this->table)     {
00846 
00847                                 // "Info": (All records)
00848                         $cells[]='<a href="#" onclick="'.htmlspecialchars('top.launchView(\''.$table.'\', \''.$row['uid'].'\'); return false;').'">'.
00849                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/zoom2.gif','width="12" height="12"').' title="'.$LANG->getLL('showInfo',1).'" alt="" />'.
00850                                         '</a>';
00851 
00852                                 // If the table is NOT a read-only table, then show these links:
00853                         if (!$TCA[$table]['ctrl']['readOnly'])  {
00854 
00855                                         // "Revert" link (history/undo)
00856                                 $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpExt(\'show_rechis.php?element='.rawurlencode($table.':'.$row['uid']).'\',\'#latest\');').'">'.
00857                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/history2.gif','width="13" height="12"').' title="'.$LANG->getLL('history',1).'" alt="" />'.
00858                                                 '</a>';
00859 
00860                                         // Versioning:
00861                                 if (t3lib_extMgm::isLoaded('version'))  {
00862                                         $vers = t3lib_BEfunc::selectVersionsOfRecord($table, $row['uid'], 'uid', $GLOBALS['BE_USER']->workspace);
00863                                         if (is_array($vers))    {       // If table can be versionized.
00864                                                 if (count($vers)>1)     {
00865                                                         $st = 'background-color: #FFFF00; font-weight: bold;';
00866                                                         $lab = count($vers)-1;
00867                                                 } else {
00868                                                         $st = 'background-color: #9999cc; font-weight: bold;';
00869                                                         $lab = 'V';
00870                                                 }
00871 
00872                                                 $cells[]='<a href="'.htmlspecialchars(t3lib_extMgm::extRelPath('version')).'cm1/index.php?table='.rawurlencode($table).'&uid='.rawurlencode($row['uid']).'" style="'.htmlspecialchars($st).'">'.
00873                                                                 $lab.
00874                                                                 '</a>';
00875                                         }
00876                                 }
00877 
00878                                         // "Edit Perms" link:
00879                                 if ($table=='pages' && $GLOBALS['BE_USER']->check('modules','web_perm'))        {
00880                                         $cells[]='<a href="'.htmlspecialchars('mod/web/perm/index.php?id='.$row['uid'].'&return_id='.$row['uid'].'&edit=1').'">'.
00881                                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/perm.gif','width="7" height="12"').' title="'.$LANG->getLL('permissions',1).'" alt="" />'.
00882                                                         '</a>';
00883                                 }
00884 
00885                                         // "New record after" link (ONLY if the records in the table are sorted by a "sortby"-row or if default values can depend on previous record):
00886                                 if ($TCA[$table]['ctrl']['sortby'] || $TCA[$table]['ctrl']['useColumnsForDefaultValues'])       {
00887                                         if (
00888                                                 ($table!='pages' && ($this->calcPerms&16)) ||   // For NON-pages, must have permission to edit content on this parent page
00889                                                 ($table=='pages' && ($this->calcPerms&8))               // For pages, must have permission to create new pages here.
00890                                                 )       {
00891                                                 if ($this->showNewRecLink($table))      {
00892                                                         $params='&edit['.$table.']['.(-$row['uid']).']=new';
00893                                                         $cells[]='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,'',-1)).'">'.
00894                                                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/new_'.($table=='pages'?'page':'el').'.gif','width="'.($table=='pages'?13:11).'" height="12"').' title="'.$LANG->getLL('new'.($table=='pages'?'Page':'Record'),1).'" alt="" />'.
00895                                                                         '</a>';
00896                                                 }
00897                                         }
00898                                 }
00899 
00900                                         // "Up/Down" links
00901                                 if ($permsEdit && $TCA[$table]['ctrl']['sortby']  && !$this->sortField && !$this->searchLevels) {
00902                                         if (isset($this->currentTable['prev'][$row['uid']]))    {       // Up
00903                                                 $params='&cmd['.$table.']['.$row['uid'].'][move]='.$this->currentTable['prev'][$row['uid']];
00904                                                 $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'">'.
00905                                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_up.gif','width="11" height="10"').' title="'.$LANG->getLL('moveUp',1).'" alt="" />'.
00906                                                                 '</a>';
00907                                         } else {
00908                                                 $cells[]='<img src="clear.gif" '.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_up.gif','width="11" height="10"',2).' alt="" />';
00909                                         }
00910                                         if ($this->currentTable['next'][$row['uid']])   {       // Down
00911                                                 $params='&cmd['.$table.']['.$row['uid'].'][move]='.$this->currentTable['next'][$row['uid']];
00912                                                 $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'">'.
00913                                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_down.gif','width="11" height="10"').' title="'.$LANG->getLL('moveDown',1).'" alt="" />'.
00914                                                                 '</a>';
00915                                         } else {
00916                                                 $cells[]='<img src="clear.gif" '.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_down.gif','width="11" height="10"',2).' alt="" />';
00917                                         }
00918                                 }
00919 
00920                                         // "Hide/Unhide" links:
00921                                 $hiddenField = $TCA[$table]['ctrl']['enablecolumns']['disabled'];
00922                                 if ($permsEdit && $hiddenField && $TCA[$table]['columns'][$hiddenField] && (!$TCA[$table]['columns'][$hiddenField]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields',$table.':'.$hiddenField)))     {
00923                                         if ($row[$hiddenField]) {
00924                                                 $params='&data['.$table.']['.$row['uid'].']['.$hiddenField.']=0';
00925                                                 $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'">'.
00926                                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_unhide.gif','width="11" height="10"').' title="'.$LANG->getLL('unHide'.($table=='pages'?'Page':''),1).'" alt="" />'.
00927                                                                 '</a>';
00928                                         } else {
00929                                                 $params='&data['.$table.']['.$row['uid'].']['.$hiddenField.']=1';
00930                                                 $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'">'.
00931                                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_hide.gif','width="11" height="10"').' title="'.$LANG->getLL('hide'.($table=='pages'?'Page':''),1).'" alt="" />'.
00932                                                                 '</a>';
00933                                         }
00934                                 }
00935 
00936                                         // "Delete" link:
00937                                 if (
00938                                         ($table=='pages' && ($localCalcPerms&4)) || ($table!='pages' && ($this->calcPerms&16))
00939                                         )       {
00940                                         $params='&cmd['.$table.']['.$row['uid'].'][delete]=1';
00941                                         $cells[]='<a href="#" onclick="'.htmlspecialchars('if (confirm('.$LANG->JScharCode($LANG->getLL('deleteWarning').t3lib_BEfunc::referenceCount($table,$row['uid'],' (There are %s reference(s) to this record!)')).')) {jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');} return false;').'">'.
00942                                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/garbage.gif','width="11" height="12"').' title="'.$LANG->getLL('delete',1).'" alt="" />'.
00943                                                         '</a>';
00944                                 }
00945 
00946                                         // "Levels" links: Moving pages into new levels...
00947                                 if ($permsEdit && $table=='pages' && !$this->searchLevels)      {
00948 
00949                                                 // Up (Paste as the page right after the current parent page)
00950                                         if ($this->calcPerms&8) {
00951                                                 $params='&cmd['.$table.']['.$row['uid'].'][move]='.-$this->id;
00952                                                 $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'">'.
00953                                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_left.gif','width="11" height="10"').' title="'.$LANG->getLL('prevLevel',1).'" alt="" />'.
00954                                                                 '</a>';
00955                                         }
00956                                                 // Down (Paste as subpage to the page right above)
00957                                         if ($this->currentTable['prevUid'][$row['uid']])        {
00958                                                 $localCalcPerms = $GLOBALS['BE_USER']->calcPerms(t3lib_BEfunc::getRecord('pages',$this->currentTable['prevUid'][$row['uid']]));
00959                                                 if ($localCalcPerms&8)  {
00960                                                         $params='&cmd['.$table.']['.$row['uid'].'][move]='.$this->currentTable['prevUid'][$row['uid']];
00961                                                         $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpToUrl(\''.$SOBE->doc->issueCommand($params,-1).'\');').'">'.
00962                                                                         '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_right.gif','width="11" height="10"').' title="'.$LANG->getLL('nextLevel',1).'" alt="" />'.
00963                                                                         '</a>';
00964                                                 } else {
00965                                                         $cells[]='<img src="clear.gif" '.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_right.gif','width="11" height="10"',2).' alt="" />';
00966                                                 }
00967                                         } else {
00968                                                 $cells[]='<img src="clear.gif" '.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_right.gif','width="11" height="10"',2).' alt="" />';
00969                                         }
00970                                 }
00971                         }
00972                 }
00973 
00974                         // If the record is edit-locked by another user, we will show a little warning sign:
00975                 if ($lockInfo=t3lib_BEfunc::isRecordLocked($table,$row['uid'])) {
00976                         $cells[]='<a href="#" onclick="'.htmlspecialchars('alert('.$LANG->JScharCode($lockInfo['msg']).');return false;').'">'.
00977                                         '<img'.t3lib_iconWorks::skinImg('','gfx/recordlock_warning3.gif','width="17" height="12"').' title="'.htmlspecialchars($lockInfo['msg']).'" alt="" />'.
00978                                         '</a>';
00979                 }
00980 
00981 
00982                         // Compile items into a DIV-element:
00983                 return '
00984                                                                                         <!-- CONTROL PANEL: '.$table.':'.$row['uid'].' -->
00985                                                                                         <div class="typo3-DBctrl">'.implode('',$cells).'</div>';
00986         }
00987 
00995         function makeClip($table,$row)  {
00996                 global $TCA, $LANG;
00997 
00998                         // Return blank, if disabled:
00999                 if ($this->dontShowClipControlPanels)   return '';
01000                 $cells=array();
01001 
01002 
01003                         // Return blank, if disabled:
01004                         // Whether a numeric clipboard pad is active or the normal pad we will see different content of the panel:
01005                 if ($this->clipObj->current=='normal')  {       // For the "Normal" pad:
01006 
01007                                 // Show copy/cut icons:
01008                         $isSel = (string)$this->clipObj->isSelected($table,$row['uid']);
01009                         $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpSelf(\''.$this->clipObj->selUrlDB($table,$row['uid'],1,($isSel=='copy'),array('returnUrl'=>'')).'\');').'">'.
01010                                         '<img'.t3lib_iconWorks::skinImg('','gfx/clip_copy'.($isSel=='copy'?'_h':'').'.gif','width="12" height="12"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:cm.copy',1).'" alt="" />'.
01011                                         '</a>';
01012                         $cells[]='<a href="#" onclick="'.htmlspecialchars('return jumpSelf(\''.$this->clipObj->selUrlDB($table,$row['uid'],0,($isSel=='cut'),array('returnUrl'=>'')).'\');').'">'.
01013                                         '<img'.t3lib_iconWorks::skinImg('','gfx/clip_cut'.($isSel=='cut'?'_h':'').'.gif','width="12" height="12"').' title="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:cm.cut',1).'" alt="" />'.
01014                                         '</a>';
01015 
01016                 } else {        // For the numeric clipboard pads (showing checkboxes where one can select elements on/off)
01017 
01018                                 // Setting name of the element in ->CBnames array:
01019                         $n=$table.'|'.$row['uid'];
01020                         $this->CBnames[]=$n;
01021 
01022                                 // Check if the current element is selected and if so, prepare to set the checkbox as selected:
01023                         $checked = ($this->clipObj->isSelected($table,$row['uid'])?' checked="checked"':'');
01024 
01025                                 // If the "duplicateField" value is set then select all elements which are duplicates...
01026                         if ($this->duplicateField && isset($row[$this->duplicateField]))        {
01027                                 $checked='';
01028                                 if (in_array($row[$this->duplicateField], $this->duplicateStack))       {
01029                                         $checked=' checked="checked"';
01030                                 }
01031                                 $this->duplicateStack[] = $row[$this->duplicateField];
01032                         }
01033 
01034                                 // Adding the checkbox to the panel:
01035                         $cells[]='<input type="hidden" name="CBH['.$n.']" value="0" /><input type="checkbox" name="CBC['.$n.']" value="1" class="smallCheckboxes"'.$checked.' />';
01036                 }
01037 
01038                         // Now, looking for selected elements from the current table:
01039                 $elFromTable = $this->clipObj->elFromTable($table);
01040                 if (count($elFromTable) && $TCA[$table]['ctrl']['sortby'])      {       // IF elements are found and they can be individually ordered, then add a "paste after" icon:
01041                         $cells[]='<a href="'.htmlspecialchars($this->clipObj->pasteUrl($table,-$row['uid'])).'" onclick="'.htmlspecialchars('return '.$this->clipObj->confirmMsg($table,$row,'after',$elFromTable)).'">'.
01042                                         '<img'.t3lib_iconWorks::skinImg('','gfx/clip_pasteafter.gif','width="12" height="12"').' title="'.$LANG->getLL('clip_pasteAfter',1).'" alt="" />'.
01043                                         '</a>';
01044                 }
01045 
01046                         // Now, looking for elements in general:
01047                 $elFromTable = $this->clipObj->elFromTable('');
01048                 if ($table=='pages' && count($elFromTable))     {
01049                         $cells[]='<a href="'.htmlspecialchars($this->clipObj->pasteUrl('',$row['uid'])).'" onclick="'.htmlspecialchars('return '.$this->clipObj->confirmMsg($table,$row,'into',$elFromTable)).'">'.
01050                                         '<img'.t3lib_iconWorks::skinImg('','gfx/clip_pasteinto.gif','width="12" height="12"').' title="'.$LANG->getLL('clip_pasteInto',1).'" alt="" />'.
01051                                         '</a>';
01052                 }
01053 
01054                         // Compile items into a DIV-element:
01055                 return '                                                        <!-- CLIPBOARD PANEL: '.$table.':'.$row['uid'].' -->
01056                                                                                         <div class="typo3-clipCtrl">'.implode('',$cells).'</div>';
01057         }
01058 
01066         function makeRef($table,$uid)   {
01067 
01068                         // Look up the path:
01069                 $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
01070                         '*',
01071                         'sys_refindex',
01072                         'ref_table='.$GLOBALS['TYPO3_DB']->fullQuoteStr($table,'sys_refindex').
01073                                 ' AND ref_uid='.intval($uid).
01074                                 ' AND deleted=0'
01075                 );
01076 
01077                         // Compile information for title tag:
01078                 $infoData=array();
01079                 if (is_array($rows)) {
01080                         foreach($rows as $row)  {
01081                                 $infoData[]=$row['tablename'].':'.$row['recuid'].':'.$row['field'];
01082                         }
01083                 }
01084 
01085                 return count($infoData) ? '<a href="#" onclick="'.htmlspecialchars('top.launchView(\''.$table.'\', \''.$uid.'\'); return false;').'" title="'.htmlspecialchars(t3lib_div::fixed_lgd(implode(' / ',$infoData),100)).'">'.count($infoData).'</a>' : '';
01086         }
01087 
01095         function makeLocalizationPanel($table,$row)     {
01096                 global $TCA,$LANG;
01097 
01098                 $out = array(
01099                         0 => '',
01100                         1 => '',
01101                 );
01102                 if ($TCA[$table]['ctrl']['languageField'] && $TCA[$table]['ctrl']['transOrigPointerField'] && !$TCA[$table]['ctrl']['transOrigPointerTable'])   {
01103 
01104                                 // Language title and icon:
01105                         $out[0] = $this->languageFlag($row[$TCA[$table]['ctrl']['languageField']]);
01106 
01107                                 // Create new localizations links:
01108                         if ($row[$TCA[$table]['ctrl']['languageField']] <=0)    {
01109 
01110                                         // Look for translations of this record, index by language field value:
01111                                 $translations = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
01112                                         'uid,'.$TCA[$table]['ctrl']['languageField'],
01113                                         $table,
01114                                         'pid='.intval($this->id).
01115                                                 ' AND '.$TCA[$table]['ctrl']['languageField'].'>0'.
01116                                                 ' AND '.$TCA[$table]['ctrl']['transOrigPointerField'].'='.intval($row['uid']).
01117                                                 t3lib_BEfunc::deleteClause($table).
01118                                                 t3lib_BEfunc::versioningPlaceholderClause($table),
01119                                         '',
01120                                         '',
01121                                         '',
01122                                         $TCA[$table]['ctrl']['languageField']
01123                                 );
01124 
01125                                         // Traverse page translations and add icon for each language that does NOT yet exist:
01126                                 $lNew = '';
01127                                 foreach($this->pageOverlays as $lUid_OnPage => $lsysRec)        {
01128                                         if (!isset($translations[$lUid_OnPage]) && $GLOBALS['BE_USER']->checkLanguageAccess($lUid_OnPage))      {
01129                                                 $href = $GLOBALS['TBE_TEMPLATE']->issueCommand(
01130                                                         '&cmd['.$table.']['.$row['uid'].'][localize]='.$lUid_OnPage,
01131                                                         $this->listURL().'&justLocalized='.rawurlencode($table.':'.$row['uid'].':'.$lUid_OnPage)
01132                                                 );
01133 
01134                                                 $lC = ($this->languageIconTitles[$lUid_OnPage]['flagIcon'] ? '<img src="'.$this->languageIconTitles[$lUid_OnPage]['flagIcon'].'" class="absmiddle" alt="" />' : $this->languageIconTitles[$lUid_OnPage]['title']);
01135                                                 $lC = '<a href="'.htmlspecialchars($href).'">'.$lC.'</a> ';
01136 
01137                                                 $lNew.=$lC;
01138                                         }
01139                                 }
01140 
01141                                 if ($lNew)      $out[1].= $lNew;
01142                         } else {
01143                                 $out[0] = '&nbsp;&nbsp;&nbsp;&nbsp;'.$out[0];
01144                         }
01145                 }
01146 
01147                 return $out;
01148         }
01149 
01157         function fieldSelectBox($table,$formFields=1)   {
01158                 global $TCA, $LANG;
01159 
01160                         // Init:
01161                 t3lib_div::loadTCA($table);
01162                 $formElements=array('','');
01163                 if ($formFields)        {
01164                         $formElements=array('<form action="'.htmlspecialchars($this->listURL()).'" method="post">','</form>');
01165                 }
01166 
01167                         // Load already selected fields, if any:
01168                 $setFields=is_array($this->setFields[$table]) ? $this->setFields[$table] : array();
01169 
01170                         // Request fields from table:
01171                 $fields = $this->makeFieldList($table);
01172 
01173                         // Add pseudo "control" fields
01174                 $fields[]='tstamp';
01175                 $fields[]='crdate';
01176                 $fields[]='_PATH_';
01177                 $fields[]='_REF_';
01178                 $fields[]='_LOCALIZATION_';
01179                 $fields[]='_CONTROL_';
01180                 $fields[]='_CLIPBOARD_';
01181 
01182                         // Create an option for each field:
01183                 $opt=array();
01184                 $opt[] = '<option value=""></option>';
01185                 foreach($fields as $fN) {
01186                         $fL = is_array($TCA[$table]['columns'][$fN]) ? ereg_replace(':$','',$LANG->sL($TCA[$table]['columns'][$fN]['label'])) : '['.$fN.']';    // Field label
01187                         $opt[] = '
01188                                                                                         <option value="'.$fN.'"'.(in_array($fN,$setFields)?' selected="selected"':'').'>'.htmlspecialchars($fL).'</option>';
01189                 }
01190 
01191                         // Compile the options into a multiple selector box:
01192                 $lMenu = '
01193                                                                                 <select size="'.t3lib_div::intInRange(count($fields)+1,3,20).'" multiple="multiple" name="displayFields['.$table.'][]">'.implode('',$opt).'
01194                                                                                 </select>
01195                                 ';
01196 
01197                         // Table with the field selector::
01198                 $content.= '
01199                         '.$formElements[0].'
01200 
01201                                 <!--
01202                                         Field selector for extended table view:
01203                                 -->
01204                                 <table border="0" cellpadding="0" cellspacing="0" class="bgColor4" id="typo3-dblist-fieldSelect">
01205                                         <tr>
01206                                                 <td>'.$lMenu.'</td>
01207                                                 <td><input type="submit" name="search" value="'.$LANG->sL('LLL:EXT:lang/locallang_core.php:labels.setFields',1).'" /></td>
01208                                         </tr>
01209                                 </table>
01210                         '.$formElements[1];
01211                 return $content;
01212         }
01213 
01214 
01215 
01216 
01217 
01218 
01219 
01220 
01221 
01222 
01223 
01224         /*********************************
01225          *
01226          * Helper functions
01227          *
01228          *********************************/
01229 
01240         function linkClipboardHeaderIcon($string,$table,$cmd,$warning='')       {
01241                 $onClickEvent = 'document.dblistForm.cmd.value=\''.$cmd.'\';document.dblistForm.cmd_table.value=\''.$table.'\';document.dblistForm.submit();';
01242                 if ($warning)   $onClickEvent = 'if (confirm('.$GLOBALS['LANG']->JScharCode($warning).')){'.$onClickEvent.'}';
01243                 return '<a href="#" onclick="'.htmlspecialchars($onClickEvent.'return false;').'">'.$string.'</a>';
01244         }
01245 
01251         function clipNumPane()  {
01252                 return in_Array('_CLIPBOARD_',$this->fieldArray) && $this->clipObj->current!='normal';
01253         }
01254 
01265         function addSortLink($code,$field,$table)       {
01266 
01267                         // Certain circumstances just return string right away (no links):
01268                 if ($field=='_CONTROL_' || $field=='_LOCALIZATION_' || $field=='_CLIPBOARD_' || $field=='_REF_' || $this->disableSingleTableView)       return $code;
01269 
01270                         // If "_PATH_" (showing record path) is selected, force sorting by pid field (will at least group the records!)
01271                 if ($field=='_PATH_')   $field=pid;
01272 
01273                         //       Create the sort link:
01274                 $sortUrl = $this->listURL('',-1,'sortField,sortRev,table').'&table='.$table.'&sortField='.$field.'&sortRev='.($this->sortRev || ($this->sortField!=$field)?0:1);
01275                 $sortArrow = ($this->sortField==$field?'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/red'.($this->sortRev?'up':'down').'.gif','width="7" height="4"').' alt="" />':'');
01276 
01277                         // Return linked field:
01278                 return '<a href="'.htmlspecialchars($sortUrl).'">'.$code.
01279                                 $sortArrow.
01280                                 '</a>';
01281         }
01282 
01290         function recPath($pid)  {
01291                 if (!isset($this->recPath_cache[$pid])) {
01292                         $this->recPath_cache[$pid] = t3lib_BEfunc::getRecordPath($pid,$this->perms_clause,20);
01293                 }
01294                 return $this->recPath_cache[$pid];
01295         }
01296 
01303         function showNewRecLink($table) {
01304                 return !count($this->allowedNewTables) || in_array($table,$this->allowedNewTables);
01305         }
01306 
01313         function makeReturnUrl()        {
01314                 return '&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
01315         }
01316 
01317 
01318 
01319 
01320 
01321 
01322 
01323 
01324 
01325 
01326 
01327         /************************************
01328          *
01329          * CSV related functions
01330          *
01331          ************************************/
01332 
01338         function initCSV()      {
01339 
01340                         // Reset:
01341                 $this->csvLines=array();
01342 
01343                         // Getting header line with field names:
01344                 $csvRow=array();
01345                 foreach($this->fieldArray as $fN)       {
01346                         $csvRow[]=$fN;
01347                 }
01348 
01349                         // Set the header + an empty row:
01350                 $this->setCsvRow($csvRow);
01351                 $this->csvLines[]='';
01352         }
01353 
01361         function addToCSV($row,$table)  {
01362 
01363                         // Traversing fields, adding values from $row:
01364                 $csvRow=array();
01365                 foreach($this->fieldArray as $fN)       {
01366                         if ($fN=='_PATH_')      {
01367                                 $csvRow[]=$this->recPath($row['pid']);
01368                         } elseif ($fN=='_REF_') {
01369                                 $csvRow[]=$this->makeRef($table, $row['uid']);
01370                         } else {
01371                                 $csvRow[]=$row[$fN];
01372                         }
01373                 }
01374 
01375                         // Set the values in the CSV list
01376                 $this->setCsvRow($csvRow);
01377         }
01378 
01385         function setCsvRow($csvRow)     {
01386                 $this->csvLines[] = t3lib_div::csvValues($csvRow);
01387         }
01388 
01396         function outputCSV($prefix)     {
01397 
01398                         // Setting filename:
01399                 $filename=$prefix.'_'.date('dmy-Hi').'.csv';
01400 
01401                         // Creating output header:
01402                 $mimeType = 'application/octet-stream';
01403                 Header('Content-Type: '.$mimeType);
01404                 Header('Content-Disposition: attachment; filename='.$filename);
01405 
01406                         // Printing the content of the CSV lines:
01407                 echo implode(chr(13).chr(10),$this->csvLines);
01408 
01409                         // Exits:
01410                 exit;
01411         }
01412 }
01413 
01414 
01415 
01416 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.db_list_extra.inc'])   {
01417         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/class.db_list_extra.inc']);
01418 }
01419 ?>