Documentation TYPO3 par Ameos

class.t3lib_recordlist.php

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 ***************************************************************/
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                 $tParam = $table ? '&table='.rawurlencode($table) : '';
00260                 switch($type)   {
00261                         case 'fwd':
00262                                 $href = $this->listURL().'&pointer='.($pointer-$this->iLimit).$tParam;
00263                                 return '<a href="'.htmlspecialchars($href).'">'.
00264                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/pilup.gif','width="14" height="14"').' alt="" />'.
00265                                                 '</a> <i>[1 - '.$pointer.']</i>';
00266                         break;
00267                         case 'rwd':
00268                                 $href = $this->listURL().'&pointer='.$pointer.$tParam;
00269                                 return '<a href="'.htmlspecialchars($href).'">'.
00270                                                 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/pildown.gif','width="14" height="14"').' alt="" />'.
00271                                                 '</a> <i>['.($pointer+1).' - '.$this->totalItems.']</i>';
00272                         break;
00273                 }
00274         }
00275 
00282         function listURL($altId='')     {
00283                 return $this->script.
00284                         '?id='.(strcmp($altId,'')?$altId:$this->id);
00285         }
00286 
00292         function CBfunctions()  {
00293                 return '
00294                 // checkOffCB()
00295         function checkOffCB(listOfCBnames)      {       //
00296                 var notChecked=0;
00297                 var total=0;
00298 
00299                         // Checking how many is checked, how many is not
00300                 var pointer=0;
00301                 var pos = listOfCBnames.indexOf(",");
00302                 while (pos!=-1) {
00303                         if (!cbValue(listOfCBnames.substr(pointer,pos-pointer))) notChecked++;
00304                         total++;
00305                         pointer=pos+1;
00306                         pos = listOfCBnames.indexOf(",",pointer);
00307                 }
00308                 if (!cbValue(listOfCBnames.substr(pointer))) notChecked++;
00309                 total++;
00310 
00311                         // Setting the status...
00312                 var flag = notChecked*2>total;
00313                 pointer=0;
00314                 pos = listOfCBnames.indexOf(",");
00315                 while (pos!=-1) {
00316                         setcbValue(listOfCBnames.substr(pointer,pos-pointer),flag);
00317 
00318                         pointer=pos+1;
00319                         pos = listOfCBnames.indexOf(",",pointer);
00320                 }
00321                 setcbValue(listOfCBnames.substr(pointer),flag);
00322         }
00323                 // cbValue()
00324         function cbValue(CBname)        {       //
00325                 var CBfullName = "CBC["+CBname+"]";
00326                 return (document.dblistForm[CBfullName] && document.dblistForm[CBfullName].checked ? 1 : 0);
00327         }
00328                 // setcbValue()
00329         function setcbValue(CBname,flag)        {       //
00330                 CBfullName = "CBC["+CBname+"]";
00331                 document.dblistForm[CBfullName].checked = flag ? "on" : 0;
00332         }
00333 
00334                 ';
00335         }
00336 
00342         function initializeLanguages()  {
00343                 global $TCA,$LANG;
00344 
00345                         // Look up page overlays:
00346                 $this->pageOverlays = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
00347                         '*',
00348                         'pages_language_overlay',
00349                         'pid='.intval($this->id).
00350                                 t3lib_BEfunc::deleteClause('pages_language_overlay'),
00351                         '',
00352                         '',
00353                         '',
00354                         'sys_language_uid'
00355                 );
00356 
00357                         // icons and language titles:
00358                 t3lib_div::loadTCA ('sys_language');
00359                 $flagAbsPath = t3lib_div::getFileAbsFileName($TCA['sys_language']['columns']['flag']['config']['fileFolder']);
00360                 $flagIconPath = $this->backPath.'../'.substr($flagAbsPath, strlen(PATH_site));
00361 
00362                 $this->modSharedTSconfig = t3lib_BEfunc::getModTSconfig($this->id, 'mod.SHARED');
00363                 $this->languageIconTitles = array();
00364 
00365                         // Set default:
00366                 $this->languageIconTitles[0]=array(
00367                         'uid' => 0,
00368                         'title' => strlen ($this->modSharedTSconfig['properties']['defaultLanguageFlag']) ? $this->modSharedTSconfig['properties']['defaultLanguageLabel'].' ('.$LANG->getLL('defaultLanguage').')' : $LANG->getLL('defaultLanguage'),
00369                         'ISOcode' => 'DEF',
00370                         'flagIcon' => strlen($this->modSharedTSconfig['properties']['defaultLanguageFlag']) && @is_file($flagAbsPath.$this->modSharedTSconfig['properties']['defaultLanguageFlag']) ? $flagIconPath.$this->modSharedTSconfig['properties']['defaultLanguageFlag'] : null,
00371                 );
00372 
00373                         // Set "All" language:
00374                 $this->languageIconTitles[-1]=array(
00375                         'uid' => -1,
00376                         'title' => $LANG->getLL ('multipleLanguages'),
00377                         'ISOcode' => 'DEF',
00378                         'flagIcon' => $flagIconPath.'multi-language.gif',
00379                 );
00380 
00381                         // Find all system languages:
00382                 $sys_languages = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
00383                         '*',
00384                         'sys_language',
00385                         ''
00386                 );
00387                 foreach($sys_languages as $row)         {
00388                         $this->languageIconTitles[$row['uid']] = $row;
00389 
00390                         if ($row['static_lang_isocode'])        {
00391                                 $staticLangRow = t3lib_BEfunc::getRecord('static_languages',$row['static_lang_isocode'],'lg_iso_2');
00392                                 if ($staticLangRow['lg_iso_2']) {
00393                                         $this->languageIconTitles[$row['uid']]['ISOcode'] = $staticLangRow['lg_iso_2'];
00394                                 }
00395                         }
00396                         if (strlen ($row['flag'])) {
00397                                 $this->languageIconTitles[$row['uid']]['flagIcon'] = @is_file($flagAbsPath.$row['flag']) ? $flagIconPath.$row['flag'] : '';
00398                         }
00399                 }
00400         }
00401 
00408         function languageFlag($sys_language_uid)        {
00409                 return ($this->languageIconTitles[$sys_language_uid]['flagIcon'] ? '<img src="'.$this->languageIconTitles[$sys_language_uid]['flagIcon'].'" class="absmiddle" alt="" />&nbsp;' : '').
00410                                 htmlspecialchars($this->languageIconTitles[$sys_language_uid]['title']);
00411         }
00412 }
00413 
00414 
00415 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_recordlist.php'])        {
00416         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_recordlist.php']);
00417 }
00418 ?>


Généré par Le spécialiste TYPO3 avec  doxygen 1.4.6