Documentation TYPO3 par Ameos |
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 1999-2006 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 ***************************************************************/ 00080 class t3lib_recordList { 00081 00082 // Used in this class: 00083 var $iLimit = 10; // default Max items shown 00084 var $leftMargin = 0; // OBSOLETE - NOT USED ANYMORE. leftMargin 00085 var $showIcon = 1; 00086 var $no_noWrap = 0; 00087 var $oddColumnsTDParams =''; // If set this is <td>-params for odd columns in addElement. Used with db_layout / pages section 00088 var $backPath=''; 00089 var $fieldArray = Array(); // Decides the columns shown. Filled with values that refers to the keys of the data-array. $this->fieldArray[0] is the title column. 00090 var $addElement_tdParams = array(); // Keys are fieldnames and values are td-parameters to add in addElement(); 00091 00092 // Not used in this class - but maybe extension classes... 00093 var $fixedL = 50; // Max length of strings 00094 var $script = ''; 00095 var $thumbScript = 'thumbs.php'; 00096 var $setLMargin=1; // Set to zero, if you don't want a left-margin with addElement function 00097 00098 var $counter=0; // Counter increased for each element. Used to index elements for the JavaScript-code that transfers to the clipboard 00099 var $totalItems = ''; // This could be set to the total number of items. Used by the fwd_rew_navigation... 00100 00101 // Internal (used in this class.) 00102 var $firstElementNumber=0; 00103 var $eCounter=0; 00104 var $HTMLcode=''; // String with accumulated HTML content 00105 00106 var $pageOverlays = array(); // Contains page translation languages 00107 var $languageIconTitles = array(); // Contains sys language icons and titles 00108 00109 00110 00123 function addElement($h,$icon,$data,$tdParams='',$lMargin='',$altLine='') { 00124 $noWrap = ($this->no_noWrap) ? '' : ' nowrap="nowrap"'; 00125 00126 // Start up: 00127 $out=' 00128 <!-- Element, begin: --> 00129 <tr>'; 00130 // Show icon and lines 00131 if ($this->showIcon) { 00132 $out.=' 00133 <td nowrap="nowrap"'.$tdParams.'>'; 00134 00135 if (!$h) { 00136 # $out.='<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/halfline.gif','width="18" height="8"').' alt="" />'; 00137 $out.='<img src="clear.gif" width="1" height="8" alt="" />'; 00138 } else { 00139 for ($a=0;$a<$h;$a++) { 00140 if (!$a) { 00141 # $out.= $altLine ? $altLine : '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/line.gif','width="18" height="16"').' alt="" />'; 00142 if ($icon) $out.= $icon; 00143 } else { 00144 # $out.= $altLine ? $altLine :'<br /><img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/line.gif','width="18" height="16"').' alt="" />'; 00145 } 00146 } 00147 } 00148 $out.='</td> 00149 '; 00150 } 00151 00152 // Init rendering. 00153 $colsp=''; 00154 $lastKey=''; 00155 $c=0; 00156 $ccount=0; 00157 $tdP[0] = $this->oddColumnsTDParams ? $this->oddColumnsTDParams : $tdParams; 00158 $tdP[1] = $tdParams; 00159 00160 // Traverse field array which contains the data to present: 00161 reset($this->fieldArray); 00162 while(list(,$vKey)=each($this->fieldArray)) { 00163 if (isset($data[$vKey])) { 00164 if ($lastKey) { 00165 $out.=' 00166 <td'. 00167 $noWrap. 00168 $tdP[($ccount%2)]. 00169 $colsp. 00170 $this->addElement_tdParams[$lastKey]. 00171 '>'.$data[$lastKey].'</td>'; 00172 } 00173 $lastKey=$vKey; 00174 $c=1; 00175 $ccount++; 00176 } else { 00177 if (!$lastKey) {$lastKey=$vKey;} 00178 $c++; 00179 } 00180 if ($c>1) {$colsp=' colspan="'.$c.'"';} else {$colsp='';} 00181 } 00182 if ($lastKey) { $out.=' 00183 <td'.$noWrap.$tdP[($ccount%2)].$colsp.$this->addElement_tdParams[$lastKey].'>'.$data[$lastKey].'</td>'; } 00184 00185 // End row 00186 $out.=' 00187 </tr>'; 00188 00189 // Return row. 00190 return $out; 00191 } 00192 00198 function writeTop() { 00199 } 00200 00206 function writeBottom() { 00207 $this->HTMLcode.=' 00208 00209 <!-- 00210 End of list table: 00211 --> 00212 <table border="0" cellpadding="0" cellspacing="0">'; 00213 $theIcon='<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/stopper.gif','width="18" height="16"').' alt="" />'; 00214 $this->HTMLcode.=$this->addElement(1,'','','',$this->leftMargin,$theIcon); 00215 $this->HTMLcode.=' 00216 </table>'; 00217 } 00218 00225 function fwd_rwd_nav($table='') { 00226 $code=''; 00227 if ($this->eCounter >= $this->firstElementNumber && $this->eCounter < $this->firstElementNumber+$this->iLimit) { 00228 if ($this->firstElementNumber && $this->eCounter==$this->firstElementNumber) { 00229 // reverse 00230 $theData = Array(); 00231 $titleCol=$this->fieldArray[0]; 00232 $theData[$titleCol] = $this->fwd_rwd_HTML('fwd',$this->eCounter,$table); 00233 $code=$this->addElement(1,'',$theData); 00234 } 00235 return Array(1,$code); 00236 } else { 00237 if ($this->eCounter==$this->firstElementNumber+$this->iLimit) { 00238 // forward 00239 $theData = Array(); 00240 $titleCol=$this->fieldArray[0]; 00241 $theData[$titleCol] = $this->fwd_rwd_HTML('rwd',$this->eCounter,$table); 00242 $code=$this->addElement(1,'',$theData); 00243 } 00244 return Array(0,$code); 00245 } 00246 00247 } 00248 00258 function fwd_rwd_HTML($type,$pointer,$table='') { 00259 $content = ''; 00260 $tParam = $table ? '&table='.rawurlencode($table) : ''; 00261 switch($type) { 00262 case 'fwd': 00263 $href = $this->listURL().'&pointer='.($pointer-$this->iLimit).$tParam; 00264 $content = '<a href="'.htmlspecialchars($href).'">'. 00265 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/pilup.gif','width="14" height="14"').' alt="" />'. 00266 '</a> <i>[1 - '.$pointer.']</i>'; 00267 break; 00268 case 'rwd': 00269 $href = $this->listURL().'&pointer='.$pointer.$tParam; 00270 $content = '<a href="'.htmlspecialchars($href).'">'. 00271 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/pildown.gif','width="14" height="14"').' alt="" />'. 00272 '</a> <i>['.($pointer+1).' - '.$this->totalItems.']</i>'; 00273 break; 00274 } 00275 return $content; 00276 } 00277 00284 function listURL($altId='') { 00285 return $this->script. 00286 '?id='.(strcmp($altId,'')?$altId:$this->id); 00287 } 00288 00294 function CBfunctions() { 00295 return ' 00296 // checkOffCB() 00297 function checkOffCB(listOfCBnames) { // 00298 var notChecked=0; 00299 var total=0; 00300 00301 // Checking how many is checked, how many is not 00302 var pointer=0; 00303 var pos = listOfCBnames.indexOf(","); 00304 while (pos!=-1) { 00305 if (!cbValue(listOfCBnames.substr(pointer,pos-pointer))) notChecked++; 00306 total++; 00307 pointer=pos+1; 00308 pos = listOfCBnames.indexOf(",",pointer); 00309 } 00310 if (!cbValue(listOfCBnames.substr(pointer))) notChecked++; 00311 total++; 00312 00313 // Setting the status... 00314 var flag = notChecked*2>total; 00315 pointer=0; 00316 pos = listOfCBnames.indexOf(","); 00317 while (pos!=-1) { 00318 setcbValue(listOfCBnames.substr(pointer,pos-pointer),flag); 00319 00320 pointer=pos+1; 00321 pos = listOfCBnames.indexOf(",",pointer); 00322 } 00323 setcbValue(listOfCBnames.substr(pointer),flag); 00324 } 00325 // cbValue() 00326 function cbValue(CBname) { // 00327 var CBfullName = "CBC["+CBname+"]"; 00328 return (document.dblistForm[CBfullName] && document.dblistForm[CBfullName].checked ? 1 : 0); 00329 } 00330 // setcbValue() 00331 function setcbValue(CBname,flag) { // 00332 CBfullName = "CBC["+CBname+"]"; 00333 document.dblistForm[CBfullName].checked = flag ? "on" : 0; 00334 } 00335 00336 '; 00337 } 00338 00344 function initializeLanguages() { 00345 global $TCA,$LANG; 00346 00347 // Look up page overlays: 00348 $this->pageOverlays = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows( 00349 '*', 00350 'pages_language_overlay', 00351 'pid='.intval($this->id). 00352 t3lib_BEfunc::deleteClause('pages_language_overlay'). 00353 t3lib_BEfunc::versioningPlaceholderClause('pages_language_overlay'), 00354 '', 00355 '', 00356 '', 00357 'sys_language_uid' 00358 ); 00359 00360 $t8Tools = t3lib_div::makeInstance('t3lib_transl8tools'); 00361 $this->languageIconTitles = $t8Tools->getSystemLanguages($this->id, $this->backPath); 00362 } 00363 00370 function languageFlag($sys_language_uid) { 00371 return ($this->languageIconTitles[$sys_language_uid]['flagIcon'] ? '<img src="'.$this->languageIconTitles[$sys_language_uid]['flagIcon'].'" class="absmiddle" alt="" /> ' : ''). 00372 htmlspecialchars($this->languageIconTitles[$sys_language_uid]['title']); 00373 } 00374 } 00375 00376 00377 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_recordlist.php']) { 00378 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_recordlist.php']); 00379 } 00380 ?>