| [ Index ] |
|
Code source de Typo3 4.1.3 |
1 <?php 2 /*************************************************************** 3 * Copyright notice 4 * 5 * (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com) 6 * All rights reserved 7 * 8 * This script is part of the TYPO3 project. The TYPO3 project is 9 * free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2 of the License, or 12 * (at your option) any later version. 13 * 14 * The GNU General Public License can be found at 15 * http://www.gnu.org/copyleft/gpl.html. 16 * A copy is found in the textfile GPL.txt and important notices to the license 17 * from the author is found in LICENSE.txt distributed with these scripts. 18 * 19 * 20 * This script is distributed in the hope that it will be useful, 21 * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 * GNU General Public License for more details. 24 * 25 * This copyright notice MUST APPEAR in all copies of the script! 26 ***************************************************************/ 27 /** 28 * Include file extending db_list.inc for use with the web_layout module 29 * 30 * $Id: class.tx_cms_layout.php 1868 2006-12-12 11:24:10Z ingmars $ 31 * Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj 32 * XHTML compliant 33 * 34 * @author Kasper Skaarhoj <kasperYYYY@typo3.com> 35 */ 36 /** 37 * [CLASS/FUNCTION INDEX of SCRIPT] 38 * 39 * 40 * 41 * 115: class tx_cms_layout extends recordList 42 * 43 * SECTION: Renderings 44 * 180: function getTable($table,$id) 45 * 240: function getTable_pages($id) 46 * 378: function getTable_tt_content($id) 47 * 754: function getTable_fe_users($id) 48 * 780: function getTable_sys_note($id) 49 * 873: function getTable_tt_board($id) 50 * 955: function getTable_tt_address($id) 51 * 985: function getTable_tt_links($id) 52 * 1011: function getTable_tt_guest($id) 53 * 1026: function getTable_tt_news($id) 54 * 1047: function getTable_tt_calender($id) 55 * 1097: function getTable_tt_products($id) 56 * 57 * SECTION: Generic listing of items 58 * 1143: function makeOrdinaryList($table, $id, $fList, $icon=0, $addWhere='') 59 * 1224: function dataFields($fieldArr,$table,$row,$out=array()) 60 * 1275: function headerFields($fieldArr,$table,$out=array()) 61 * 62 * SECTION: Additional functions; Pages 63 * 1317: function pages_getTree($theRows,$pid,$qWhere,$treeIcons,$depth) 64 * 1350: function pages_drawItem($row,$fieldArr) 65 * 66 * SECTION: Additional functions; Content Elements 67 * 1461: function tt_content_drawColHeader($colName,$editParams,$newParams) 68 * 1513: function tt_content_drawHeader($row,$space=0,$disableMoveAndNewButtons=FALSE,$langMode=FALSE) 69 * 1643: function tt_content_drawItem($row, $isRTE=FALSE) 70 * 1806: function getNonTranslatedTTcontentUids($defLanguageCount,$id,$lP) 71 * 1836: function newLanguageButton($defLanguageCount,$lP) 72 * 1857: function infoGif($infoArr) 73 * 1873: function newContentElementOnClick($id,$colPos,$sys_language) 74 * 1891: function linkEditContent($str,$row) 75 * 1909: function linkRTEbutton($row) 76 * 1930: function languageSelector($id) 77 * 1967: function getResult($result) 78 * 79 * SECTION: Additional functions; Message board items (tt_board) 80 * 2036: function tt_board_getTree($theRows,$parent,$pid,$qWhere,$treeIcons) 81 * 2071: function tt_board_drawItem($table,$row,$re) 82 * 83 * SECTION: Various helper functions 84 * 2118: function numberOfRecords($table,$pid) 85 * 2137: function renderText($input) 86 * 2151: function getIcon($table,$row) 87 * 2174: function getProcessedValue($table,$fieldList,$row,&$info) 88 * 2194: function isDisabled($table,$row) 89 * 2212: function wordWrapper($content,$max=50,$char=' -') 90 * 2229: function noEditIcon($label='noEditItems') 91 * 2238: function cleanTableNames() 92 * 2274: function isRTEforField($table,$row,$field) 93 * 2304: function getSpecConfForField($table,$row,$field) 94 * 95 * SECTION: External renderings 96 * 2341: function getPageInfoBox($rec,$edit=0) 97 * 2510: function getTableMenu($id) 98 * 2575: function strip_tags($content, $fillEmptyContent=false) 99 * 100 * TOTAL FUNCTIONS: 43 101 * (This index is automatically created/updated by the extension "extdeveval") 102 * 103 */ 104 105 106 107 108 /** 109 * Child class for the Web > Page module 110 * 111 * @author Kasper Skaarhoj <kasperYYYY@typo3.com> 112 * @package TYPO3 113 * @subpackage core 114 */ 115 class tx_cms_layout extends recordList { 116 117 // External, static: For page statistics: 118 var $stat_select_field='page_id'; // fieldname from sys_stat to select on. 119 var $stat_codes=array(); // eg. "HITS_days:-1" 120 121 // External, static: Flags of various kinds: 122 var $pI_showUser=0; // If true, users/groups are shown in the page info box. 123 var $pI_showStat=1; // If true, hit statistics are shown in the page info box. 124 var $nextThree = 3; // The number of successive records to edit when showing content elements. 125 var $pages_noEditColumns=0; // If true, disables the edit-column icon for tt_content elements 126 var $option_showBigButtons=1; // If true, shows big buttons for editing page properties, moving, creating elements etc. in the columns view. 127 var $option_newWizard=1; // If true, new-wizards are linked to rather than the regular new-element list. 128 var $ext_function=0; // If set to "1", will link a big button to content element wizard. 129 var $doEdit=1; // If true, elements will have edit icons (probably this is whethere the user has permission to edit the page content). Set externally. 130 var $agePrefixes = ' min| hrs| days| yrs'; // Age prefixes for displaying times. May be set externally to localized values. 131 var $externalTables = array(); // Array of tables which is configured to be listed by the Web > Page module in addition to the default tables. 132 var $descrTable; // "Pseudo" Description -table name 133 var $defLangBinding=FALSE; // If set true, the language mode of tt_content elements will be rendered with hard binding between default language content elements and their translations! 134 135 // External, static: Configuration of tt_content element display: 136 var $tt_contentConfig = Array ( 137 'showInfo' => 1, // Boolean: Display info-marks or not 138 'showCommands' => 1, // Boolean: Display up/down arrows and edit icons for tt_content records 139 'showCommands_info' => 1, // Boolean: Displays infoGif with the command buttons 140 'single' => 1, // Boolean: If set, the content of column(s) $this->tt_contentConfig['showSingleCol'] is shown in the total width of the page 141 'showSingleCol' => 0, // The column(s) to show if single mode (under each other) 142 'languageCols' => 0, 143 'languageMode' => 0, 144 'languageColsPointer' => 0, 145 'showHidden' => 1, // Displays hidden records as well 146 'sys_language_uid' => 0, // Which language 147 'cols' => '1,0,2,3' // The order of the rows: Default is left(1), Normal(0), right(2), margin(3) 148 ); 149 150 // Internal, dynamic: 151 var $allowedTableNames=array(); // Will contain a list of tables which can be listed by the user. 152 var $activeTables = array(); // Contains icon/title of pages which are listed in the tables menu (see getTableMenu() function ) 153 var $tt_contentData = Array( 154 'nextThree' => Array(), 155 'prev' => Array(), 156 'next' => Array() 157 ); 158 var $CType_labels=array(); // Used to store labels for CTypes for tt_content elements 159 var $itemLabels=array(); // Used to store labels for the various fields in tt_content elements 160 161 162 163 164 165 166 167 /***************************************** 168 * 169 * Renderings 170 * 171 *****************************************/ 172 173 /** 174 * Adds the code of a single table 175 * 176 * @param string Table name 177 * @param integer Current page id 178 * @return string HTML for listing. 179 */ 180 function getTable($table,$id) { 181 182 // Load full table definition: 183 t3lib_div::loadTCA($table); 184 185 if (isset($this->externalTables[$table])) { 186 $fList = $this->externalTables[$table][0]['fList']; // eg. "name;title;email;company,image" 187 $icon = $this->externalTables[$table][0]['icon']; // Boolean, 188 189 // Create listing 190 $out = $this->makeOrdinaryList($table, $id, $fList, $icon); 191 return $out; 192 } else { 193 // Branch out based on table name: 194 // Notice: Most of these tables belongs to other extensions than 'cms'. Each of these tables can be rendered only if the extensions they belong to is loaded. 195 switch($table) { 196 case 'pages': 197 return $this->getTable_pages($id); 198 break; 199 case 'tt_content': 200 return $this->getTable_tt_content($id); 201 break; 202 case 'fe_users': 203 return $this->getTable_fe_users($id); 204 break; 205 case 'sys_note': 206 return $this->getTable_sys_note($id); 207 break; 208 case 'tt_board': 209 return $this->getTable_tt_board($id); 210 break; 211 case 'tt_address': 212 return $this->getTable_tt_address($id); 213 break; 214 case 'tt_links': 215 return $this->getTable_tt_links($id); 216 break; 217 case 'tt_guest': 218 return $this->getTable_tt_guest($id); 219 break; 220 case 'tt_news': 221 return $this->getTable_tt_news($id); 222 break; 223 case 'tt_calender': 224 return $this->getTable_tt_calender($id); 225 break; 226 case 'tt_products': 227 return $this->getTable_tt_products($id); 228 break; 229 } 230 } 231 } 232 233 /** 234 * Renders records from the pages table from page id 235 * (Used to get information about the page tree content by "Web>Info"!) 236 * 237 * @param integer Page id 238 * @return string HTML for the listing 239 */ 240 function getTable_pages($id) { 241 global $TCA; 242 243 // Initializing: 244 $out=''; 245 $delClause = t3lib_BEfunc::deleteClause('pages').' AND '.$GLOBALS['BE_USER']->getPagePermsClause(1); // Select clause for pages: 246 247 // Select current page: 248 if (!$id) { 249 $row = $GLOBALS['SOBE']->pageinfo; // The root has a pseudo record in pageinfo... 250 } else { 251 $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'pages', 'uid='.intval($id).$delClause); 252 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result); 253 t3lib_BEfunc::workspaceOL('pages', $row); 254 } 255 256 // If there was found a page: 257 if (is_array($row)) { 258 259 // Select which fields to show: 260 $pKey = $GLOBALS['SOBE']->MOD_SETTINGS['function']=='tx_cms_webinfo_hits' ? 'hits' : $GLOBALS['SOBE']->MOD_SETTINGS['pages']; 261 switch($pKey) { 262 case 'hits': 263 $this->fieldArray = explode(',','title,'.implode(',',$this->stat_codes)); 264 break; 265 case 1: 266 $this->cleanTableNames(); 267 $tableNames=$this->allowedTableNames; 268 $this->fieldArray = explode(',','title,uid,'.implode(',',array_keys($tableNames))); 269 break; 270 case 2: 271 $this->fieldArray = explode(',','title,uid,lastUpdated,newUntil,no_cache,cache_timeout,php_tree_stop,TSconfig,storage_pid,is_siteroot,fe_login_mode'); 272 break; 273 default: 274 $this->fieldArray = explode(',','title,uid,alias,starttime,endtime,fe_group,target,url,shortcut,shortcut_mode'); 275 break; 276 } 277 278 // Getting select-depth: 279 $depth=intval($GLOBALS['SOBE']->MOD_SETTINGS['pages_levels']); 280 281 // Half line is drawn 282 $theData = Array(); 283 $theData['subject'] = $this->widthGif; 284 $out.=$this->addelement(0,'',$theData); 285 286 // Overriding a few things: 287 $this->no_noWrap=0; 288 $this->oddColumnsTDParams=' class="bgColor3-20"'; 289 290 // Items 291 $this->eCounter=$this->firstElementNumber; 292 293 // Creating elements: 294 list($flag,$code) = $this->fwd_rwd_nav(); 295 $out.=$code; 296 $editUids=array(); 297 if ($flag) { 298 299 // Getting children: 300 $theRows = Array(); 301 $theRows = $this->pages_getTree($theRows,$row['uid'],$delClause.t3lib_BEfunc::versioningPlaceholderClause('pages'),'',$depth); 302 if ($GLOBALS['BE_USER']->doesUserHaveAccess($row,2)) $editUids[]=$row['uid']; 303 $out.=$this->pages_drawItem($row,$this->fieldArray); 304 305 // Traverse all pages selected: 306 foreach($theRows as $n => $sRow) { 307 if ($GLOBALS['BE_USER']->doesUserHaveAccess($sRow,2)) $editUids[]=$sRow['uid']; 308 $out.=$this->pages_drawItem($sRow,$this->fieldArray); 309 } 310 $this->eCounter++; 311 } 312 313 // Header line is drawn 314 $theData = Array(); 315 $editIdList = implode(',', $editUids); 316 317 // Traverse fields (as set above) in order to create header values: 318 foreach($this->fieldArray as $field) { 319 if ($editIdList && isset($TCA['pages']['columns'][$field]) && $field!='uid' && !$this->pages_noEditColumns) { 320 $params='&edit[pages]['.$editIdList.']=edit&columnsOnly='.$field.'&disHelp=1'; 321 $iTitle = sprintf($GLOBALS['LANG']->getLL('editThisColumn'),ereg_replace(':$','',trim($GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel('pages',$field))))); 322 $eI= '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,'')).'">'. 323 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2.gif','width="11" height="12"').' title="'.htmlspecialchars($iTitle).'" alt="" />'. 324 '</a>'; 325 } else $eI=''; 326 switch($field) { 327 case 'title': 328 $theData[$field] = ' <b>'.$GLOBALS['LANG']->sL($TCA['pages']['columns'][$field]['label']).'</b>'.$eI; 329 break; 330 case 'uid': 331 $theData[$field] = ' <b>ID:</b>'; 332 break; 333 default: 334 if (substr($field,0,6)=='table_') { 335 $f2 = substr($field,6); 336 if ($TCA[$f2]) { 337 $theData[$field] = ' '.t3lib_iconWorks::getIconImage($f2,array(),$this->backPath,'title="'.$GLOBALS['LANG']->sL($TCA[$f2]['ctrl']['title'],1).'"'); 338 } 339 } elseif (substr($field,0,5)=='HITS_') { 340 $fParts = explode(':',substr($field,5)); 341 switch($fParts[0]) { 342 case 'days': 343 $timespan = mktime (0,0,0)+intval($fParts[1])*3600*24; 344 $theData[$field]=' '.date('d',$timespan); 345 break; 346 default: 347 $theData[$field] = ''; 348 break; 349 } 350 } else { 351 $theData[$field] = ' <b>'.$GLOBALS['LANG']->sL($TCA['pages']['columns'][$field]['label'],1).'</b>'.$eI; 352 } 353 break; 354 } 355 } 356 357 // Start table: 358 $this->oddColumnsTDParams = ''; 359 360 // CSH: 361 $out = t3lib_BEfunc::cshItem($this->descrTable,'func_'.$pKey,$GLOBALS['BACK_PATH']). 362 ' 363 <table border="0" cellpadding="0" cellspacing="0" class="typo3-page-pages"> 364 '.$this->addelement(1,'',$theData,' class="c-headLine"',20). 365 $out.' 366 </table>'; 367 } 368 $this->oddColumnsTDParams = ''; 369 return $out; 370 } 371 372 /** 373 * Renders Content Elements from the tt_content table from page id 374 * 375 * @param integer Page id 376 * @return string HTML for the listing 377 */ 378 function getTable_tt_content($id) { 379 global $TCA; 380 381 $this->initializeLanguages(); 382 383 // Initialize: 384 $RTE = $GLOBALS['BE_USER']->isRTE(); 385 $lMarg=1; 386 $showHidden = $this->tt_contentConfig['showHidden']?'':t3lib_BEfunc::BEenableFields('tt_content'); 387 $pageTitleParamForAltDoc='&recTitle='.rawurlencode(t3lib_BEfunc::getRecordTitle('pages',t3lib_BEfunc::getRecordWSOL('pages',$id),TRUE)); 388 389 // Get labels for CTypes and tt_content element fields in general: 390 $this->CType_labels =array(); 391 foreach($TCA['tt_content']['columns']['CType']['config']['items'] as $val) { 392 $this->CType_labels[$val[1]]=$GLOBALS['LANG']->sL($val[0]); 393 } 394 $this->itemLabels =array(); 395 foreach($TCA['tt_content']['columns'] as $name => $val) { 396 $this->itemLabels[$name]=$GLOBALS['LANG']->sL($val['label']); 397 } 398 399 400 // Select display mode: 401 if (!$this->tt_contentConfig['single']) { // MULTIPLE column display mode, side by side: 402 403 // Setting language list: 404 $langList = $this->tt_contentConfig['sys_language_uid']; 405 if ($this->tt_contentConfig['languageMode']) { 406 if ($this->tt_contentConfig['languageColsPointer']) { 407 $langList='0,'.$this->tt_contentConfig['languageColsPointer']; 408 } else { 409 $langList=implode(',',array_keys($this->tt_contentConfig['languageCols'])); 410 } 411 $languageColumn = array(); 412 } 413 $langListArr = explode(',',$langList); 414 $defLanguageCount = array(); 415 $defLangBinding = array(); 416 417 // For EACH languages... : 418 foreach($langListArr as $lP) { // If NOT languageMode, then we'll only be through this once. 419 $showLanguage = $this->defLangBinding && $lP==0 ? ' AND sys_language_uid IN (0,-1)' : ' AND sys_language_uid='.$lP; 420 $cList = explode(',',$this->tt_contentConfig['cols']); 421 $content = array(); 422 $head = array(); 423 424 // For EACH column, render the content into a variable: 425 foreach($cList as $key) { 426 if (!$lP) $defLanguageCount[$key] = array(); 427 428 // Select content elements from this column/language: 429 $queryParts = $this->makeQueryArray('tt_content', $id, 'AND colPos='.intval($key).$showHidden.$showLanguage); 430 $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts); 431 432 // If it turns out that there are not content elements in the column, then display a big button which links directly to the wizard script: 433 if ($this->doEdit && $this->option_showBigButtons && !intval($key) && !$GLOBALS['TYPO3_DB']->sql_num_rows($result)) { 434 $onClick = "window.location.href='db_new_content_el.php?id=".$id.'&colPos='.intval($key).'&sys_language_uid='.$lP.'&uid_pid='.$id.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))."';"; 435 $theNewButton = $GLOBALS['SOBE']->doc->t3Button($onClick,$GLOBALS['LANG']->getLL('newPageContent')); 436 $content[$key].= '<img src="clear.gif" width="1" height="5" alt="" /><br />'.$theNewButton; 437 } 438 439 // Traverse any selected elements and render their display code: 440 $rowArr = $this->getResult($result); 441 442 foreach($rowArr as $rKey => $row) { 443 t3lib_BEfunc::workspaceOL('tt_content', $row); 444 445 if ((int)$row['t3ver_state']!=2) { 446 $singleElementHTML = ''; 447 if (!$lP) $defLanguageCount[$key][] = $row['uid']; 448 449 $editUidList.= $row['uid'].','; 450 $singleElementHTML.= $this->tt_content_drawHeader($row,$this->tt_contentConfig['showInfo']?15:5, $this->defLangBinding && $lP>0, TRUE); 451 452 $isRTE = $RTE && $this->isRTEforField('tt_content',$row,'bodytext'); 453 $singleElementHTML.= '<div '.($row['_ORIG_uid'] ? ' class="ver-element"' :'').'>'.$this->tt_content_drawItem($row,$isRTE).'</div>'; 454 455 if ($this->defLangBinding && $this->tt_contentConfig['languageMode']) { 456 $defLangBinding[$key][$lP][$row[($lP ? 'l18n_parent' : 'uid')]] = $singleElementHTML; 457 } else { 458 $content[$key].= $singleElementHTML; 459 } 460 } else { unset($rowArr[$rKey]); } 461 } 462 463 // Add new-icon link, header: 464 $newP = $this->newContentElementOnClick($id,$key,$lP); 465 $head[$key].= $this->tt_content_drawColHeader(t3lib_BEfunc::getProcessedValue('tt_content','colPos',$key), ($this->doEdit&&count($rowArr)?'&edit[tt_content]['.$editUidList.']=edit'.$pageTitleParamForAltDoc:''), $newP); 466 $editUidList = ''; 467 } 468 469 // For EACH column, fit the rendered content into a table cell: 470 $out=''; 471 foreach($cList as $k => $key) { 472 if (!$k) { 473 $out.= ' 474 <td><img src="clear.gif" width="'.$lMarg.'" height="1" alt="" /></td>'; 475 } else { 476 $out.= ' 477 <td><img src="clear.gif" width="4" height="1" alt="" /></td> 478 <td bgcolor="black"><img src="clear.gif" width="1" height="1" alt="" /></td> 479 <td><img src="clear.gif" width="4" height="1" alt="" /></td>'; 480 } 481 $out.= ' 482 <td valign="top">'.$head[$key].$content[$key].'</td>'; 483 484 // Storing content for use if languageMode is set: 485 if ($this->tt_contentConfig['languageMode']) { 486 $languageColumn[$key][$lP] = $head[$key].$content[$key]; 487 if (!$this->defLangBinding) { 488 $languageColumn[$key][$lP].='<br /><br />'.$this->newLanguageButton($this->getNonTranslatedTTcontentUids($defLanguageCount[$key],$id,$lP),$lP); 489 } 490 } 491 } 492 493 // Wrap the cells into a table row: 494 $out = ' 495 <table border="0" cellpadding="0" cellspacing="0" width="480" class="typo3-page-cols"> 496 <tr>'.$out.' 497 </tr> 498 </table>'; 499 500 // CSH: 501 $out.= t3lib_BEfunc::cshItem($this->descrTable,'columns_multi',$GLOBALS['BACK_PATH']); 502 } 503 504 // If language mode, then make another presentation: 505 // Notice that THIS presentation will override the value of $out! But it needs the code above to execute since $languageColumn is filled with content we need! 506 if ($this->tt_contentConfig['languageMode']) { 507 508 // Get language selector: 509 $languageSelector = $this->languageSelector($id); 510 511 // Reset out - we will make new content here: 512 $out=''; 513 // Separator between language columns (black thin line) 514 $midSep = ' 515 <td><img src="clear.gif" width="4" height="1" alt="" /></td> 516 <td bgcolor="black"><img src="clear.gif" width="1" height="1" alt="" /></td> 517 <td><img src="clear.gif" width="4" height="1" alt="" /></td>'; 518 519 // Traverse languages found on the page and build up the table displaying them side by side: 520 $cCont=array(); 521 $sCont=array(); 522 foreach($langListArr as $lP) { 523 524 // Header: 525 $cCont[$lP]=' 526 <td valign="top" align="center" class="bgColor6"><strong>'.htmlspecialchars($this->tt_contentConfig['languageCols'][$lP]).'</strong></td>'; 527 528 // "View page" icon is added: 529 $viewLink = '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::viewOnClick($this->id,$this->backPath,t3lib_BEfunc::BEgetRootLine($this->id),'','','&L='.$lP)).'">'. 530 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/zoom.gif','width="12" height="12"').' class="absmiddle" title="" alt="" />'. 531 '</a>'; 532 533 // Language overlay page header: 534 if ($lP) { 535 536 list($lpRecord) = t3lib_BEfunc::getRecordsByField('pages_language_overlay','pid',$id,'AND sys_language_uid='.intval($lP)); 537 t3lib_BEfunc::workspaceOL('pages_language_overlay',$lpRecord); 538 $params='&edit[pages_language_overlay]['.$lpRecord['uid'].']=edit&overrideVals[pages_language_overlay][sys_language_uid]='.$lP; 539 $lPLabel = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon(t3lib_iconWorks::getIconImage('pages_language_overlay',$lpRecord,$this->backPath,' class="absmiddle"'),'pages_language_overlay',$lpRecord['uid']). 540 $viewLink. 541 ($GLOBALS['BE_USER']->check('tables_modify','pages_language_overlay') ? '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath)).'">'. 542 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2.gif','width="11" height="12"').' title="'.$GLOBALS['LANG']->getLL('edit',1).'" class="absmiddle" alt="" />'. 543 '</a>' : ''). 544 htmlspecialchars(t3lib_div::fixed_lgd_cs($lpRecord['title'],20)); 545 } else { 546 $lPLabel = $viewLink; 547 } 548 $sCont[$lP]=' 549 <td nowrap="nowrap">'.$lPLabel.'</td>'; 550 } 551 // Add headers: 552 $out.=' 553 <tr>'.implode($midSep,$cCont).' 554 </tr>'; 555 $out.=' 556 <tr>'.implode($midSep,$sCont).' 557 </tr>'; 558 559 // Traverse previously built content for the columns: 560 foreach($languageColumn as $cKey => $cCont) { 561 $out.=' 562 <tr> 563 <td valign="top">'.implode('</td>'.$midSep.' 564 <td valign="top">',$cCont).'</td> 565 </tr>'; 566 567 if ($this->defLangBinding) { 568 // "defLangBinding" mode 569 foreach($defLanguageCount[$cKey] as $defUid) { 570 $cCont=array(); 571 foreach($langListArr as $lP) { 572 $cCont[] = $defLangBinding[$cKey][$lP][$defUid]. 573 '<br/>'.$this->newLanguageButton($this->getNonTranslatedTTcontentUids(array($defUid),$id,$lP),$lP); 574 } 575 $out.=' 576 <tr> 577 <td valign="top">'.implode('</td>'.$midSep.' 578 <td valign="top">',$cCont).'</td> 579 </tr>'; 580 } 581 582 // Create spacer: 583 $cCont=array(); 584 foreach($langListArr as $lP) { 585 $cCont[] = ' '; 586 } 587 $out.=' 588 <tr> 589 <td valign="top">'.implode('</td>'.$midSep.' 590 <td valign="top">',$cCont).'</td> 591 </tr>'; 592 } 593 } 594 595 // Finally, wrap it all in a table and add the language selector on top of it: 596 $out = $languageSelector.' 597 <table border="0" cellpadding="0" cellspacing="0" width="480" class="typo3-page-langMode"> 598 '.$out.' 599 </table>'; 600 601 // CSH: 602 $out.= t3lib_BEfunc::cshItem($this->descrTable,'language_list',$GLOBALS['BACK_PATH']); 603 } 604 } else { // SINGLE column mode (columns shown beneath each other): 605 #debug('single column'); 606 if ($this->tt_contentConfig['sys_language_uid']==0 || !$this->defLangBinding) { 607 608 // Initialize: 609 if ($this->defLangBinding && $this->tt_contentConfig['sys_language_uid']==0) { 610 $showLanguage = ' AND sys_language_uid IN (0,-1)'; 611 $lP = 0; 612 } else { 613 $showLanguage = ' AND sys_language_uid='.$this->tt_contentConfig['sys_language_uid']; 614 $lP = $this->tt_contentConfig['sys_language_uid']; 615 } 616 617 $cList = explode(',',$this->tt_contentConfig['showSingleCol']); 618 $content=array(); 619 $out=''; 620 621 // Expand the table to some preset dimensions: 622 $out.=' 623 <tr> 624 <td><img src="clear.gif" width="'.$lMarg.'" height="1" alt="" /></td> 625 <td valign="top"><img src="clear.gif" width="150" height="1" alt="" /></td> 626 <td><img src="clear.gif" width="10" height="1" alt="" /></td> 627 <td valign="top"><img src="clear.gif" width="300" height="1" alt="" /></td> 628 </tr>'; 629 630 // Traverse columns to display top-on-top 631 while(list($counter,$key)=each($cList)) { 632 633 // Select content elements: 634 $queryParts = $this->makeQueryArray('tt_content', $id, 'AND colPos='.intval($key).$showHidden.$showLanguage); 635 $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts); 636 $c = 0; 637 $rowArr = $this->getResult($result); 638 $rowOut = ''; 639 640 // If it turns out that there are not content elements in the column, then display a big button which links directly to the wizard script: 641 if ($this->doEdit && $this->option_showBigButtons && !intval($key) && !$GLOBALS['TYPO3_DB']->sql_num_rows($result)) { 642 $onClick="window.location.href='db_new_content_el.php?id=".$id.'&colPos='.intval($key).'&sys_language_uid='.$lP.'&uid_pid='.$id.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))."';"; 643 $theNewButton=$GLOBALS['SOBE']->doc->t3Button($onClick,$GLOBALS['LANG']->getLL('newPageContent')); 644 $theNewButton='<img src="clear.gif" width="1" height="5" alt="" /><br />'.$theNewButton; 645 } else $theNewButton=''; 646 647 // Traverse any selected elements: 648 foreach($rowArr as $rKey => $row) { 649 t3lib_BEfunc::workspaceOL('tt_content', $row); 650 651 if ((int)$row['t3ver_state']!=2) { 652 653 $c++; 654 $editUidList.=$row['uid'].','; 655 $isRTE=$RTE && $this->isRTEforField('tt_content',$row,'bodytext'); 656 657 // Create row output: 658 $rowOut.=' 659 <tr> 660 <td></td> 661 <td valign="top">'.$this->tt_content_drawHeader($row).'</td> 662 <td> </td> 663 <td'.($row['_ORIG_uid'] ? ' class="ver-element"' :'').' valign="top">'.$this->tt_content_drawItem($row,$isRTE).'</td> 664 </tr>'; 665 666 // If the element was not the last element, add a divider line: 667 if ($c != $GLOBALS['TYPO3_DB']->sql_num_rows($result)) { 668 $rowOut.=' 669 <tr> 670 <td></td> 671 <td colspan="3"><img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/stiblet_medium2.gif','width="468" height="1"').' class="c-divider" alt="" /></td> 672 </tr>'; 673 } 674 } else { unset($rowArr[$rKey]); } 675 } 676 677 // Add spacer between sections in the vertical list 678 if ($counter) { 679 $out.=' 680 <tr> 681 <td></td> 682 <td colspan="3"><br /><br /><br /><br /></td> 683 </tr>'; 684 } 685 686 // Add section header: 687 $newP = $this->newContentElementOnClick($id,$key,$this->tt_contentConfig['sys_language_uid']); 688 $out.=' 689 690 <!-- Column header: --> 691 <tr> 692 <td></td> 693 <td valign="top" colspan="3">'. 694 $this->tt_content_drawColHeader(t3lib_BEfunc::getProcessedValue('tt_content','colPos',$key), ($this->doEdit&&count($rowArr)?'&edit[tt_content]['.$editUidList.']=edit'.$pageTitleParamForAltDoc:''), $newP). 695 $theNewButton. 696 '<br /></td> 697 </tr>'; 698 699 // Finally, add the content from the records in this column: 700 $out.=$rowOut; 701 } 702 703 // Finally, wrap all table rows in one, big table: 704 $out = ' 705 <table border="0" cellpadding="0" cellspacing="0" width="400" class="typo3-page-columnsMode"> 706 '.$out.' 707 </table>'; 708 709 // CSH: 710 $out.= t3lib_BEfunc::cshItem($this->descrTable,'columns_single',$GLOBALS['BACK_PATH']); 711 } else { 712 $out = '<br/><br/>'.$GLOBALS['SOBE']->doc->icons(1).'Sorry, you cannot view a single language in this localization mode (Default Language Binding is enabled)<br/><br/>'; 713 } 714 } 715 716 717 // Add the big buttons to page: 718 if ($this->option_showBigButtons) { 719 $bArray=array(); 720 721 if (!$GLOBALS['SOBE']->current_sys_language) { 722 if ($this->ext_CALC_PERMS&2) $bArray[0]=$GLOBALS['SOBE']->doc->t3Button(t3lib_BEfunc::editOnClick('&edit[pages]['.$id."]=edit",$this->backPath,''),$GLOBALS['LANG']->getLL('editPageProperties')); 723 } else { 724 if ($this->doEdit && $GLOBALS['BE_USER']->check('tables_modify','pages_language_overlay')) { 725 list($languageOverlayRecord) = t3lib_BEfunc::getRecordsByField('pages_language_overlay','pid',$id,'AND sys_language_uid='.intval($GLOBALS['SOBE']->current_sys_language)); 726 $bArray[0]=$GLOBALS['SOBE']->doc->t3Button(t3lib_BEfunc::editOnClick('&edit[pages_language_overlay]['.$languageOverlayRecord['uid']."]=edit",$this->backPath,''),$GLOBALS['LANG']->getLL('editPageProperties_curLang')); 727 } 728 } 729 if ($this->ext_CALC_PERMS&4 || $this->ext_CALC_PERMS&2) $bArray[1]=$GLOBALS['SOBE']->doc->t3Button("window.location.href='".$this->backPath."move_el.php?table=pages&uid=".$id.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))."';",$GLOBALS['LANG']->getLL('move_page')); 730 if ($this->ext_CALC_PERMS&8) $bArray[2]=$GLOBALS['SOBE']->doc->t3Button("window.location.href='".$this->backPath."db_new.php?id=".$id.'&pagesOnly=1&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))."';",$GLOBALS['LANG']->getLL('newPage2')); 731 if ($this->doEdit && $this->ext_function==1) $bArray[3]=$GLOBALS['SOBE']->doc->t3Button("window.location.href='db_new_content_el.php?id=".$id.'&sys_language_uid='.$GLOBALS['SOBE']->current_sys_language.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))."';",$GLOBALS['LANG']->getLL('newPageContent2')); 732 $out = ' 733 <table border="0" cellpadding="4" cellspacing="0" class="typo3-page-buttons"> 734 <tr> 735 <td>'.implode('</td> 736 <td>',$bArray).'</td> 737 </tr> 738 </table> 739 <img src="clear.gif" width="1" height="5" alt="" /><br /> 740 '.t3lib_BEfunc::cshItem($this->descrTable,'button_panel',$GLOBALS['BACK_PATH']). // CSH 741 $out; 742 } 743 744 // Return content: 745 return $out; 746 } 747 748 /** 749 * Renders Frontend Users from the fe_users table from page id 750 * 751 * @param integer Page id 752 * @return string HTML for the listing 753 */ 754 function getTable_fe_users($id) { 755 756 $this->addElement_tdParams=array( 757 'username'=>' nowrap="nowrap"', 758 'password'=>' nowrap="nowrap"', 759 'usergroup'=>' nowrap="nowrap"', 760 'name'=>' nowrap="nowrap"', 761 'address'=>' nowrap="nowrap"', 762 'zip'=>' nowrap="nowrap"', 763 'city'=>' nowrap="nowrap"', 764 'email'=>' nowrap="nowrap"', 765 'telephone'=>' nowrap="nowrap"' 766 ); 767 $fList = 'username,password,usergroup,name,email,telephone,address,zip,city'; 768 $out = $this->makeOrdinaryList('fe_users',$id, $fList, 1); 769 $this->addElement_tdParams=array(); 770 return $out; 771 } 772 773 /** 774 * Renders records from the sys_notes table from page id 775 * NOTICE: Requires the sys_note extension to be loaded. 776 * 777 * @param integer Page id 778 * @return string HTML for the listing 779 */ 780 function getTable_sys_note($id) { 781 global $TCA; 782 783 if (!t3lib_extMgm::isLoaded('sys_note')) return ''; 784 785 // INIT: 786 $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1); 787 $tree = $this->getTreeObject($id,intval($GLOBALS['SOBE']->MOD_SETTINGS['pages_levels']),$perms_clause); 788 789 $this->itemLabels =array(); 790 foreach($TCA['sys_note']['columns'] as $name => $val) { 791 $this->itemLabels[$name]=$GLOBALS['LANG']->sL($val['label']); 792 } 793 794 // If page ids were found, select all sys_notes from the page ids: 795 $out=''; 796 if (count($tree->ids)) { 797 $delClause = t3lib_BEfunc::deleteClause('sys_note').t3lib_BEfunc::versioningPlaceholderClause('sys_note'); 798 $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_note', 'pid IN ('.implode(',',$tree->ids).') AND (personal=0 OR cruser='.intval($GLOBALS['BE_USER']->user['uid']).')'.$delClause); 799 $dbCount = $GLOBALS['TYPO3_DB']->sql_num_rows($result); 800 801 // If sys_notes were found, render them: 802 if ($dbCount) { 803 $this->fieldArray = explode(',','__cmds__,info,note'); 804 805 // header line is drawn 806 $theData = Array(); 807 $theData['__cmds__'] =''; 808 $theData['info'] = '<b>Info</b><br /><img src="clear.gif" height="1" width="220" alt="" />'; 809 $theData['note'] = '<b>Note</b>'; 810 $out.=$this->addelement(1,'',$theData,' class="c-headLine"',20); 811 812 // half line is drawn 813 $theData = Array(); 814 $theData['info'] = $this->widthGif; 815 $out.=$this->addelement(0,'',$theData); 816 817 $this->no_noWrap=1; 818 819 // Items 820 $this->eCounter=$this->firstElementNumber; 821 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { 822 t3lib_BEfunc::workspaceOL('sys_note', $row); 823 824 list($flag,$code) = $this->fwd_rwd_nav(); 825 $out.=$code; 826 if ($flag) { 827 $color = Array ( 828 0 => '', // No category 829 1 => ' class="bgColor4"', // Instructions 830 2 => ' class="bgColor2"', // Template 831 3 => '', // Notes 832 4 => ' class="bgColor5"' // To-do 833 ); 834 $tdparams = $color[$row['category']]; 835 $info = Array();; 836 $theData = Array(); 837 $this->getProcessedValue('sys_note','subject,category,author,email,personal',$row,$info); 838 $cont=implode('<br />',$info); 839 $head = '<b>Page:</b> '.t3lib_BEfunc::getRecordPath($row['pid'],$perms_clause,10).'<br />'; 840 841 $theData['__cmds__']= $this->getIcon('sys_note',$row); 842 $theData['info'] = $head.$cont; 843 $theData['note'] = nl2br($row['message']); 844 845 $out.=$this->addelement(1,'',$theData,$tdparams,20); 846 847 848 // half line is drawn 849 $theData = Array(); 850 $theData['info'] = $this->widthGif; 851 $out.=$this->addelement(0,'',$theData); 852 } 853 $this->eCounter++; 854 } 855 856 // Wrap it all in a table: 857 $out=' 858 <table border="0" cellpadding="1" cellspacing="2" width="480" class="typo3-page-sysnote"> 859 '.$out.' 860 </table>'; 861 } 862 } 863 return $out; 864 } 865 866 /** 867 * Renders records from the tt_board table from page id 868 * NOTICE: Requires the tt_board extension to be loaded. 869 * 870 * @param integer Page id 871 * @return string HTML for the listing 872 */ 873 function getTable_tt_board($id) { 874 875 // Initialize: 876 $delClause = t3lib_BEfunc::deleteClause('tt_board').t3lib_BEfunc::versioningPlaceholderClause('tt_board'); 877 $queryParts = $this->makeQueryArray('tt_board', $id, 'AND parent=0'); 878 $this->setTotalItems($queryParts); 879 $dbCount = 0; 880 881 // If items were selected, make query: 882 if ($this->totalItems) { 883 $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts); 884 $dbCount = $GLOBALS['TYPO3_DB']->sql_num_rows($result); 885 } 886 887 // If results came out of that, render the list: 888 $out=''; 889 if ($dbCount) { 890 891 // Setting fields to display first: 892 if ($GLOBALS['SOBE']->MOD_SETTINGS['tt_board']=='expand') { 893 $this->fieldArray = explode(',','subject,author,date,age'); 894 } else { 895 $this->fieldArray = explode(',','subject,author,date,age,replys'); 896 } 897 898 // Header line is drawn 899 $theData = Array(); 900 $theData['subject'] = '<b>'.$GLOBALS['LANG']->getLL('tt_board_subject',1).'</b>'; 901 $theData['author'] = '<b>'.$GLOBALS['LANG']->getLL('tt_board_author',1).'</b>'; 902 $theData['date'] = '<b>'.$GLOBALS['LANG']->getLL('tt_board_date',1).'</b>'; 903 $theData['age'] = '<b>'.$GLOBALS['LANG']->getLL('tt_board_age',1).'</b>'; 904 if ($GLOBALS['SOBE']->MOD_SETTINGS['tt_board']!='expand') { 905 $theData['replys'] = '<b>'.$GLOBALS['LANG']->getLL('tt_board_RE',1).'</b>'; 906 } 907 $out.=$this->addelement(1,'',$theData,' class="c-headLine"',20); 908 909 // half line is drawn 910 $theData = Array(); 911 $theData['subject'] = $this->widthGif; 912 $out.=$this->addelement(0,'',$theData); 913 914 // Items 915 $this->eCounter=$this->firstElementNumber; 916 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { 917 t3lib_BEfunc::workspaceOL('tt_board', $row); 918 919 list($flag,$code) = $this->fwd_rwd_nav(); 920 $out.=$code; 921 922 if ($flag) { 923 924 $theRows = Array(); 925 $theRows = $this->tt_board_getTree ($theRows,$row['uid'],$id,$delClause,''); 926 $out.=$this->tt_board_drawItem('tt_board',$row,count($theRows)); 927 928 if ($GLOBALS['SOBE']->MOD_SETTINGS['tt_board']=='expand') { 929 reset($theRows); 930 while(list($n,$sRow)=each($theRows)) { 931 $out.=$this->tt_board_drawItem('tt_board',$sRow,0); 932 } 933 } 934 } 935 $this->eCounter++; 936 } 937 938 // Wrap it all in a table: 939 $out=' 940 <table border="0" cellpadding="0" cellspacing="0" class="typo3-page-listTTboard"> 941 '.$out.' 942 </table>'; 943 } 944 945 return $out; 946 } 947 948 /** 949 * Renders address records from the tt_address table from page id 950 * NOTICE: Requires the tt_address extension to be loaded. 951 * 952 * @param integer Page id 953 * @return string HTML for the listing 954 */ 955 function getTable_tt_address($id) { 956 957 // Define fieldlist to show: 958 switch($GLOBALS['SOBE']->MOD_SETTINGS['tt_address']) { 959 case 1: 960 $icon = 0; 961 $fList = 'name,address,zip,city,country'; 962 break; 963 case 2: 964 $icon = 1; 965 $fList = 'name;title;email;company,image'; 966 break; 967 default: 968 $icon = 0; 969 $fList = 'name,email,www,phone,fax,mobile'; 970 break; 971 } 972 973 // Create listing 974 $out = $this->makeOrdinaryList('tt_address',$id, $fList, $icon); 975 return $out; 976 } 977 978 /** 979 * Renders link records from the tt_links table from page id 980 * NOTICE: Requires the tt_links extension to be loaded. 981 * 982 * @param integer Page id 983 * @return string HTML for the listing 984 */ 985 function getTable_tt_links($id) { 986 987 // Define fieldlist to show: 988 switch($GLOBALS['SOBE']->MOD_SETTINGS['tt_links']) { 989 case 1: 990 $fList = 'title,hidden,url'; 991 break; 992 case 2: 993 $fList = 'title;url,note2'; 994 break; 995 default: 996 $fList = 'title;url,note'; 997 break; 998 } 999 1000 $out = $this->makeOrdinaryList('tt_links',$id, $fList,1); 1001 return $out; 1002 } 1003 1004 /** 1005 * Renders link records from the tt_links table from page id 1006 * NOTICE: Requires the tt_links extension to be loaded. 1007 * 1008 * @param integer Page id 1009 * @return string HTML for the listing 1010 */ 1011 function getTable_tt_guest($id) { 1012 1013 // Define fieldlist to show: 1014 $fList = 'title;cr_name;cr_email,note'; 1015 $out = $this->makeOrdinaryList('tt_guest',$id, $fList, 1); 1016 return $out; 1017 } 1018 1019 /** 1020 * Renders news items from the tt_news table from page id 1021 * NOTICE: Requires the tt_news extension to be loaded. 1022 * 1023 * @param integer Page id 1024 * @return string HTML for the listing 1025 */ 1026 function getTable_tt_news($id) { 1027 1028 $this->addElement_tdParams=array( 1029 'title'=>' nowrap="nowrap"', 1030 'datetime'=>' nowrap="nowrap"', 1031 'starttime'=>' nowrap="nowrap"', 1032 'author'=>' nowrap="nowrap"' 1033 ); 1034 $fList = 'title,author,author_email,datetime,starttime,category,image'; 1035 $out = $this->makeOrdinaryList('tt_news',$id, $fList, 1); 1036 $this->addElement_tdParams=array(); 1037 return $out; 1038 } 1039 1040 /** 1041 * Renders calender elements link records from the tt_calender table from page id 1042 * NOTICE: Requires the tt_calender extension to be loaded. 1043 * 1044 * @param integer Page id 1045 * @return string HTML for the listing 1046 */ 1047 function getTable_tt_calender($id) { 1048 1049 $type=$GLOBALS['SOBE']->MOD_SETTINGS['tt_calender']; 1050 switch($type) { 1051 case 'date': 1052 // Date default 1053 $fList = 'date,title'; 1054 $icon=0; 1055 $out = $this->makeOrdinaryList('tt_calender',$id, $fList, $icon, ' AND type=0'); 1056 return $out; 1057 break; 1058 case 'date_ext': 1059 // Date extended 1060 $fList = 'title;date;time;datetext;link,note'; 1061 $icon=1; 1062 $out = $this->makeOrdinaryList('tt_calender',$id, $fList, $icon, ' AND type=0'); 1063 return $out; 1064 break; 1065 case 'todo': 1066 // Todo default 1067 $fList = 'title,complete,priority,date'; 1068 $icon=0; 1069 $out = $this->makeOrdinaryList('tt_calender',$id, $fList, $icon, ' AND type=1'); 1070 return $out; 1071 break; 1072 case 'todo_ext': 1073 // Todo extended 1074 $fList = 'title;complete;priority;date;workgroup;responsible;category,note'; 1075 $icon=1; 1076 $out = $this->makeOrdinaryList('tt_calender',$id, $fList, $icon, ' AND type=1'); 1077 return $out; 1078 break; 1079 default: 1080 // Overview, both todo and calender 1081 $fList = 'title,date,time,week'; 1082 $icon=1; 1083 $out = $this->makeOrdinaryList('tt_calender',$id, $fList, $icon, ' AND type=0'); 1084 $out.= $this->makeOrdinaryList('tt_calender',$id, $fList, $icon, ' AND type=1'); 1085 return $out; 1086 break; 1087 } 1088 } 1089 1090 /** 1091 * Renders shopping elements from the tt_products table from page id 1092 * NOTICE: Requires the tt_products extension to be loaded. 1093 * 1094 * @param integer Page id 1095 * @return string HTML for the listing 1096 */ 1097 function getTable_tt_products($id) { 1098 1099 $type = $GLOBALS['SOBE']->MOD_SETTINGS['tt_products']; 1100 switch($type) { 1101 case 'ext': 1102 $fList = 'title;itemnumber;price;price2;inStock;category,image,note'; 1103 $icon=1; 1104 $out = $this->makeOrdinaryList('tt_products',$id, $fList, $icon); 1105 break; 1106 default: 1107 $fList = 'title,itemnumber,price,category,image'; 1108 $icon=1; 1109 $out = $this->makeOrdinaryList('tt_products',$id, $fList, $icon); 1110 break; 1111 } 1112 1113 return $out; 1114 } 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 /********************************** 1128 * 1129 * Generic listing of items 1130 * 1131 **********************************/ 1132 1133 /** 1134 * Creates a standard list of elements from a table. 1135 * 1136 * @param string Table name 1137 * @param integer Page id. 1138 * @param string Comma list of fields to display 1139 * @param boolean If true, icon is shown 1140 * @param string Additional WHERE-clauses. 1141 * @return string HTML table 1142 */ 1143 function makeOrdinaryList($table, $id, $fList, $icon=0, $addWhere='') { 1144 global $TCA; 1145 1146 // Initialize: 1147 $out = ''; 1148 $queryParts = $this->makeQueryArray($table, $id, $addWhere); 1149 $this->setTotalItems($queryParts); 1150 $dbCount = 0; 1151 1152 // Make query for records if there were any records found in the count operation: 1153 if ($this->totalItems) { 1154 $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts); 1155 $dbCount = $GLOBALS['TYPO3_DB']->sql_num_rows($result); 1156 } 1157 1158 // If records were found, render the list: 1159 $out = ''; 1160 if ($dbCount) { 1161 1162 // Set fields 1163 $this->fieldArray = explode(',','__cmds__,'.$fList); 1164 1165 // Header line is drawn 1166 $theData = array(); 1167 $theData = $this->headerFields($this->fieldArray,$table,$theData); 1168 if ($this->doEdit) { 1169 $theData['__cmds__'] = '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick('&edit['.$table.']['.$this->id.']=new',$this->backPath)).'">'. 1170 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/new_el.gif').' title="'.$GLOBALS['LANG']->getLL('new',1).'" alt="" />'. 1171 '</a>'; 1172 } 1173 $out.= $this->addelement(1,'',$theData,' class="c-headLine"',15); 1174 1175 // Render Items 1176 $this->eCounter = $this->firstElementNumber; 1177 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { 1178 t3lib_BEfunc::workspaceOL($table, $row); 1179 1180 list($flag,$code) = $this->fwd_rwd_nav(); 1181 $out.= $code; 1182 if ($flag) { 1183 $params = '&edit['.$table.']['.$row['uid'].']=edit'; 1184 $Nrow = array(); 1185 1186 // Setting icons/edit links: 1187 if ($icon) { 1188 $Nrow['__cmds__']= $this->getIcon($table,$row); 1189 } 1190 if ($this->doEdit) { 1191 $Nrow['__cmds__'].= '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath)).'">'. 1192 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2.gif','width="11" height="12"').' title="'.$GLOBALS['LANG']->getLL('edit',1).'" alt="" />'. 1193 '</a>'; 1194 } else { 1195 $Nrow['__cmds__'].= $this->noEditIcon(); 1196 } 1197 1198 // Get values: 1199 $Nrow = $this->dataFields($this->fieldArray,$table,$row,$Nrow); 1200 $tdparams = $this->eCounter%2 ? ' class="bgColor4"' : ' class="bgColor4-20"'; 1201 $out.= $this->addelement(1,'',$Nrow,$tdparams); 1202 } 1203 $this->eCounter++; 1204 } 1205 1206 // Wrap it all in a table: 1207 $out=' 1208 1209 <!-- 1210 STANDARD LIST OF "'.$table.'" 1211 --> 1212 <table border="0" cellpadding="1" cellspacing="2" width="480" id="typo3-page-stdlist"> 1213 '.$out.' 1214 </table>'; 1215 } 1216 return $out; 1217 } 1218 1219 /** 1220 * Adds content to all data fields in $out array 1221 * 1222 * @param array Array of fields to display. Each field name has a special feature which is that the field name can be specified as more field names. Eg. "field1,field2;field3". Field 2 and 3 will be shown in the same cell of the table separated by <br /> while field1 will have its own cell. 1223 * @param string Table name 1224 * @param array Record array 1225 * @param array Array to which the data is added 1226 * @return array $out array returned after processing. 1227 * @see makeOrdinaryList() 1228 */ 1229 function dataFields($fieldArr,$table,$row,$out=array()) { 1230 global $TCA; 1231 1232 // Check table validity: 1233 if ($TCA[$table]) { 1234 t3lib_div::loadTCA($table); 1235 $thumbsCol = $TCA[$table]['ctrl']['thumbnail']; 1236 1237 // Traverse fields: 1238 foreach($fieldArr as $fieldName) { 1239 1240 if ($TCA[$table]['columns'][$fieldName]) { // Each field has its own cell (if configured in TCA) 1241 if ($fieldName==$thumbsCol) { // If the column is a thumbnail column: 1242 $out[$fieldName] = $this->thumbCode($row,$table,$fieldName); 1243 } else { // ... otherwise just render the output: 1244 $out[$fieldName] = nl2br(htmlspecialchars(trim(t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getProcessedValue($table,$fieldName,$row[$fieldName],0,0,0,$row['uid']),250)))); 1245 } 1246 } else { // Each field is separated by <br /> and shown in the same cell (If not a TCA field, then explode the field name with ";" and check each value there as a TCA configured field) 1247 $theFields = explode(';',$fieldName); 1248 1249 // Traverse fields, separated by ";" (displayed in a single cell). 1250 foreach($theFields as $fName2) { 1251 if ($TCA[$table]['columns'][$fName2]) { 1252 $out[$fieldName].= '<b>'.$GLOBALS['LANG']->sL($TCA[$table]['columns'][$fName2]['label'],1).'</b>'. 1253 ' '. 1254 htmlspecialchars(t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getProcessedValue($table,$fName2,$row[$fName2],0,0,0,$row['uid']),25)). 1255 '<br />'; 1256 } 1257 } 1258 } 1259 // If no value, add a nbsp. 1260 if (!$out[$fieldName]) $out[$fieldName]=' '; 1261 1262 // Wrap in dimmed-span tags if record is "disabled" 1263 if ($this->isDisabled($table,$row)) { 1264 $out[$fieldName] = $GLOBALS['TBE_TEMPLATE']->dfw($out[$fieldName]); 1265 } 1266 } 1267 } 1268 return $out; 1269 } 1270 1271 /** 1272 * Header fields made for the listing of records 1273 * 1274 * @param array Field names 1275 * @param string The table name 1276 * @param array Array to which the headers are added. 1277 * @return array $out returned after addition of the header fields. 1278 * @see makeOrdinaryList() 1279 */ 1280 function headerFields($fieldArr,$table,$out=array()) { 1281 global $TCA; 1282 1283 t3lib_div::loadTCA($table); 1284 1285 foreach($fieldArr as $fieldName) { 1286 $ll = $GLOBALS['LANG']->sL($TCA[$table]['columns'][$fieldName]['label'],1); 1287 $out[$fieldName] = '<b>'.($ll?$ll:' ').'</b>'; 1288 } 1289 return $out; 1290 } 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 /********************************** 1307 * 1308 * Additional functions; Pages 1309 * 1310 **********************************/ 1311 1312 /** 1313 * Adds pages-rows to an array, selecting recursively in the page tree. 1314 * 1315 * @param array Array which will accumulate page rows 1316 * @param integer Pid to select from 1317 * @param string Query-where clause 1318 * @param string Prefixed icon code. 1319 * @param integer Depth (decreasing) 1320 * @return array $theRows, but with added rows. 1321 */ 1322 function pages_getTree($theRows,$pid,$qWhere,$treeIcons,$depth) { 1323 $depth--; 1324 if ($depth>=0) { 1325 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'pages', 'pid='.intval($pid).$qWhere, '', 'sorting'); 1326 $c=0; 1327 $rc = $GLOBALS['TYPO3_DB']->sql_num_rows($res); 1328 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 1329 t3lib_BEfunc::workspaceOL('pages', $row); 1330 $c++; 1331 $row['treeIcons'] = $treeIcons.'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/join'.($rc==$c?'bottom':'').'.gif','width="18" height="16"').' alt="" />'; 1332 $theRows[]=$row; 1333 1334 // Get the branch 1335 $spaceOutIcons = '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/'.($rc==$c?'blank.gif':'line.gif'),'width="18" height="16"').' alt="" />'; 1336 $theRows = $this->pages_getTree($theRows,$row['uid'],$qWhere,$treeIcons.$spaceOutIcons,$row['php_tree_stop']?0:$depth); 1337 } 1338 } else { 1339 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'pages', 'pid='.intval($pid).$qWhere); 1340 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res); 1341 if ($row[0]) { 1342 $this->plusPages[$pid]=$row[0]; 1343 } 1344 } 1345 return $theRows; 1346 } 1347 1348 /** 1349 * Adds a list item for the pages-rendering 1350 * 1351 * @param array Record array 1352 * @param array Field list 1353 * @return string HTML for the item 1354 */ 1355 function pages_drawItem($row,$fieldArr) { 1356 global $TCA; 1357 1358 // Initialization 1359 $theIcon=$this->getIcon('pages',$row); 1360 1361 // Preparing and getting the data-array 1362 $theData = Array(); 1363 foreach($fieldArr as $field) { 1364 switch($field) { 1365 case 'title': 1366 $red = $this->plusPages[$row['uid']] ? '<font color="red"><b>+ </b></font>' : ''; 1367 $pTitle = htmlspecialchars(t3lib_BEfunc::getProcessedValue('pages',$field,$row[$field],20)); 1368 if ($red) { 1369 $pTitle = '<a href="'.htmlspecialchars($this->script.'?id='.$row['uid']).'">'.$pTitle.'</a>'; 1370 } 1371 $theData[$field]=$row['treeIcons'].$theIcon.$red.$pTitle.' '; 1372 break; 1373 case 'php_tree_stop': 1374 case 'TSconfig': 1375 $theData[$field] = $row[$field]?' <b>x</b>':' '; 1376 break; 1377 case 'uid': 1378 if ($GLOBALS['BE_USER']->doesUserHaveAccess($row,2)) { 1379 $params='&edit[pages]['.$row['uid'].']=edit'; 1380 $eI= '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,'')).'">'. 1381 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2.gif','width="11" height="12"').' title="'.$GLOBALS['LANG']->getLL('editThisPage',1).'" alt="" />'. 1382 '</a>'; 1383 } else $eI=''; 1384 $theData[$field] = '<span align="right">'.$row['uid'].$eI.'</span>'; 1385 break; 1386 default: 1387 if (substr($field,0,6)=='table_') { 1388 $f2 = substr($field,6); 1389 if ($TCA[$f2]) { 1390 $c = $this->numberOfRecords($f2,$row['uid']); 1391 $theData[$field] = ' '.($c?$c:''); 1392 } 1393 } elseif (substr($field,0,5)=='HITS_') { 1394 if (t3lib_extMgm::isLoaded('sys_stat')) { 1395 $fParts = explode(':',substr($field,5)); 1396 switch($fParts[0]) { 1397 case 'days': 1398 $timespan = mktime (0,0,0)+intval($fParts[1])*3600*24; 1399 // Page hits 1400 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery( 1401 'count(*)', 1402 'sys_stat', 1403 $this->stat_select_field.'='.intval($row['uid']).' 1404 AND tstamp>='.intval($timespan).' 1405 AND tstamp<'.intval($timespan+3600*24) 1406 ); 1407 list($number) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res); 1408 if ($number) { 1409 // Sessions 1410 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery( 1411 'count(*)', 1412 'sys_stat', 1413 $this->stat_select_field.'='.intval($row['uid']).' 1414 AND tstamp>='.intval($timespan).' 1415 AND tstamp<'.intval($timespan+3600*24).' 1416 AND surecookie!=""', 1417 'surecookie' 1418 ); 1419 $scnumber = $GLOBALS['TYPO3_DB']->sql_num_rows($res); 1420 1421 $number.= '/'.$scnumber; 1422 } else { 1423 $number=''; 1424 } 1425 break; 1426 } 1427 $theData[$field]= ' '.$number; 1428 } else { 1429 $theData[$field]= ' '; 1430 } 1431 } else { 1432 $theData[$field]= ' '.htmlspecialchars(t3lib_BEfunc::getProcessedValue('pages',$field,$row[$field])); 1433 } 1434 break; 1435 } 1436 } 1437 $this->addElement_tdParams['title'] = ($row['_CSSCLASS'] ? ' class="'.$row['_CSSCLASS'].'"' : ''); 1438 return $this->addelement(1,'',$theData); 1439 } 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 /********************************** 1453 * 1454 * Additional functions; Content Elements 1455 * 1456 **********************************/ 1457 1458 /** 1459 * Draw header for a content element column: 1460 * 1461 * @param string Column name 1462 * @param string Edit params (Syntax: &edit[...] for alt_doc.php) 1463 * @param string New element params (Syntax: &edit[...] for alt_doc.php) 1464 * @return string HTML table 1465 */ 1466 function tt_content_drawColHeader($colName,$editParams,$newParams) { 1467 1468 // Create header row: 1469 $out = ' 1470 <tr> 1471 <td class="bgColor2" nowrap="nowrap"><img src="clear.gif" width="1" height="2" alt="" /><br /><div align="center"><b>'.htmlspecialchars(strtoupper($colName)).'</b></div><img src="clear.gif" width="1" height="2" alt="" /></td> 1472 </tr>'; 1473 1474 // Create command links: 1475 if ($this->tt_contentConfig['showCommands']) { 1476 // Start cell: 1477 $out.= ' 1478 <tr> 1479 <td class="bgColor5">'; 1480 1481 // Edit whole of column: 1482 if ($editParams) { 1483 $out.='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($editParams,$this->backPath)).'">'. 1484 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2.gif','width="11" height="12"').' title="'.$GLOBALS['LANG']->getLL('editColumn',1).'" alt="" />'. 1485 '</a>'; 1486 } 1487 // New record: 1488 if ($newParams) { 1489 $out.='<a href="#" onclick="'.htmlspecialchars($newParams).'">'. 1490 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/new_record.gif','width="16" height="12"').' title="'.$GLOBALS['LANG']->getLL('newInColumn',1).'" alt="" />'. 1491 '</a>'; 1492 } 1493 // End cell: 1494 $out.= ' 1495 </td> 1496 </tr>'; 1497 } 1498 1499 // Wrap and return: 1500 return ' 1501 <table border="0" cellpadding="0" cellspacing="0" width="100%" class="typo3-page-colHeader">'.($space?' 1502 <tr> 1503 <td><img src="clear.gif" height="'.$space.'" alt="" /></td> 1504 </tr>':''). 1505 $out.' 1506 </table>'; 1507 } 1508 1509 /** 1510 * Draw the header for a single tt_content element 1511 * 1512 * @param array Record array 1513 * @param integer Amount of pixel space above the header. 1514 * @param boolean If set the buttons for creating new elements and moving up and down are not shown. 1515 * @param boolean If set, we are in language mode and flags will be shown for languages 1516 * @return string HTML table with the record header. 1517 */ 1518 function tt_content_drawHeader($row,$space=0,$disableMoveAndNewButtons=FALSE,$langMode=FALSE) { 1519 global $TCA; 1520 1521 // Load full table description: 1522 t3lib_div::loadTCA('tt_content'); 1523 1524 // Get record locking status: 1525 if ($lockInfo=t3lib_BEfunc::isRecordLocked('tt_content',$row['uid'])) { 1526 $lockIcon='<a href="#" onclick="'.htmlspecialchars('alert('.$GLOBALS['LANG']->JScharCode($lockInfo['msg']).');return false;').'">'. 1527 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/recordlock_warning3.gif','width="17" height="12"').' title="'.htmlspecialchars($lockInfo['msg']).'" alt="" />'. 1528 '</a>'; 1529 } else $lockIcon=''; 1530 1531 // Create header with icon/lock-icon/title: 1532 $header = $this->getIcon('tt_content',$row). 1533 $lockIcon. 1534 ($langMode ? $this->languageFlag($row['sys_language_uid']) : ''). 1535 ' <b>'.htmlspecialchars($this->CType_labels[$row['CType']]).'</b>'; 1536 $out = ' 1537 <tr> 1538 <td class="bgColor4">'.$header.'</td> 1539 </tr>'; 1540 1541 // If show info is set...; 1542 if ($this->tt_contentConfig['showInfo']) { 1543 1544 // Get processed values: 1545 $info = Array(); 1546 $this->getProcessedValue('tt_content','hidden,starttime,endtime,fe_group,spaceBefore,spaceAfter,section_frame,sectionIndex,linkToTop',$row,$info); 1547 1548 // Render control panel for the element: 1549 if ($this->tt_contentConfig['showCommands'] && $this->doEdit) { 1550 1551 // Start control cell: 1552 $out.= ' 1553 <!-- Control Panel --> 1554 <tr> 1555 <td class="bgColor5">'; 1556 1557 // Edit content element: 1558 $params='&edit[tt_content]['.$this->tt_contentData['nextThree'][$row['uid']].']=edit'; 1559 $out.='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath)).'">'. 1560 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2.gif','width="11" height="12"').' title="'.htmlspecialchars($this->nextThree>1?sprintf($GLOBALS['LANG']->getLL('nextThree'),$this->nextThree):$GLOBALS['LANG']->getLL('edit')).'" alt="" />'. 1561 '</a>'; 1562 1563 if (!$disableMoveAndNewButtons) { 1564 // New content element: 1565 if ($this->option_newWizard) { 1566 $onClick="window.location.href='db_new_content_el.php?id=".$row['pid'].'&sys_language_uid='.$row['sys_language_uid'].'&colPos='.$row['colPos'].'&uid_pid='.(-$row['uid']).'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))."';"; 1567 } else { 1568 $params='&edit[tt_content]['.(-$row['uid']).']=new'; 1569 $onClick = t3lib_BEfunc::editOnClick($params,$this->backPath); 1570 } 1571 $out.='<a href="#" onclick="'.htmlspecialchars($onClick).'">'. 1572 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/new_record.gif','width="16" height="12"').' title="'.$GLOBALS['LANG']->getLL('newAfter',1).'" alt="" />'. 1573 '</a>'; 1574 1575 // Move element up: 1576 if ($this->tt_contentData['prev'][$row['uid']]) { 1577 $params='&cmd[tt_content]['.$row['uid'].'][move]='.$this->tt_contentData['prev'][$row['uid']]; 1578 $out.='<a href="'.htmlspecialchars($GLOBALS['SOBE']->doc->issueCommand($params)).'">'. 1579 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_up.gif','width="11" height="10"').' title="'.$GLOBALS['LANG']->getLL('moveUp',1).'" alt="" />'. 1580 '</a>'; 1581 } else { 1582 $out.='<img src="clear.gif" '.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_up.gif','width="11" height="10"',2).' alt="" />'; 1583 } 1584 // Move element down: 1585 if ($this->tt_contentData['next'][$row['uid']]) { 1586 $params='&cmd[tt_content]['.$row['uid'].'][move]='.$this->tt_contentData['next'][$row['uid']]; 1587 $out.='<a href="'.htmlspecialchars($GLOBALS['SOBE']->doc->issueCommand($params)).'">'. 1588 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_down.gif','width="11" height="10"').' title="'.$GLOBALS['LANG']->getLL('moveDown',1).'" alt="" />'. 1589 '</a>'; 1590 } else { 1591 $out.='<img src="clear.gif" '.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_down.gif','width="11" height="10"',2).' alt="" />'; 1592 } 1593 } 1594 1595 // Hide element: 1596 $hiddenField = $TCA['tt_content']['ctrl']['enablecolumns']['disabled']; 1597 if ($hiddenField && $TCA['tt_content']['columns'][$hiddenField] && (!$TCA['tt_content']['columns'][$hiddenField]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields','tt_content:'.$hiddenField))) { 1598 if ($row[$hiddenField]) { 1599 $params='&data[tt_content]['.($row['_ORIG_uid'] ? $row['_ORIG_uid'] : $row['uid']).']['.$hiddenField.']=0'; 1600 $out.='<a href="'.htmlspecialchars($GLOBALS['SOBE']->doc->issueCommand($params)).'">'. 1601 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_unhide.gif','width="11" height="10"').' title="'.$GLOBALS['LANG']->getLL('unHide',1).'" alt="" />'. 1602 '</a>'; 1603 } else { 1604 $params='&data[tt_content]['.($row['_ORIG_uid'] ? $row['_ORIG_uid'] : $row['uid']).']['.$hiddenField.']=1'; 1605 $out.='<a href="'.htmlspecialchars($GLOBALS['SOBE']->doc->issueCommand($params)).'">'. 1606 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_hide.gif','width="11" height="10"').' title="'.$GLOBALS['LANG']->getLL('hide',1).'" alt="" />'. 1607 '</a>'; 1608 } 1609 } 1610 1611 // Delete 1612 $params='&cmd[tt_content]['.$row['uid'].'][delete]=1'; 1613 $out.='<a href="'.htmlspecialchars($GLOBALS['SOBE']->doc->issueCommand($params)).'" onclick="'.htmlspecialchars('return confirm('.$GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->getLL('deleteWarning')).');').'">'. 1614 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/garbage.gif','width="11" height="12"').' title="'.$GLOBALS['LANG']->getLL('deleteItem',1).'" alt="" />'. 1615 '</a>'; 1616 1617 // End cell: 1618 $out.= ' 1619 </td> 1620 </tr>'; 1621 } 1622 1623 // Display info from records fields: 1624 if (count($info)) { 1625 $out.= ' 1626 <tr> 1627 <td class="bgColor4-20">'.implode('<br />',$info).'</td> 1628 </tr>'; 1629 } 1630 } 1631 // Wrap the whole header in a table: 1632 return ' 1633 <table border="0" cellpadding="0" cellspacing="0" class="typo3-page-ceHeader">'.($space?' 1634 <tr> 1635 <td><img src="clear.gif" height="'.$space.'" alt="" /></td> 1636 </tr>':''). 1637 $out.' 1638 </table>'; 1639 } 1640 1641 /** 1642 * Draws the preview content for a content element 1643 * 1644 * @param string Content element 1645 * @param boolean Set if the RTE link can be created. 1646 * @return string HTML 1647 */ 1648 function tt_content_drawItem($row, $isRTE=FALSE) { 1649 global $TCA; 1650 1651 $out=''; 1652 $outHeader=''; 1653 1654 // Make header: 1655 if ($row['header'] && $row['header_layout']!=100) { 1656 $infoArr = Array(); 1657 $this->getProcessedValue('tt_content','header_position,header_layout,header_link',$row,$infoArr); 1658 1659 $outHeader= ($row['date'] ? htmlspecialchars($this->itemLabels['date'].' '.t3lib_BEfunc::date($row['date'])).'<br />':''). 1660 $this->infoGif($infoArr). 1661 '<b>'.$this->linkEditContent($this->renderText($row['header']),$row).'</b><br />'; 1662 } 1663 1664 // Make content: 1665 $infoArr=Array(); 1666 switch($row['CType']) { 1667 case 'header': 1668 if ($row['subheader']) { 1669 $this->getProcessedValue('tt_content','layout',$row,$infoArr); 1670 $out.= $this->infoGif($infoArr). 1671 $this->linkEditContent($this->renderText($row['subheader']),$row).'<br />'; 1672 } 1673 break; 1674 case 'text': 1675 case 'textpic': 1676 case 'image': 1677 if ($row['CType']=='text' || $row['CType']=='textpic') { 1678 if ($row['bodytext']) { 1679 $this->getProcessedValue('tt_content','text_align,text_face,text_size,text_color,text_properties',$row,$infoArr); 1680 $out.= $this->infoGif($infoArr). 1681 $this->linkEditContent($this->renderText($row['bodytext']),$row).'<br />'; 1682 } 1683 } 1684 if ($row['CType']=='textpic' || $row['CType']=='image') { 1685 if ($row['image']) { 1686 $infoArr=Array(); 1687 $this->getProcessedValue('tt_content','imageorient,imagecols,image_noRows,imageborder,imageheight,image_link,image_zoom,image_compression,image_effects,image_frames',$row,$infoArr); 1688 $out.= $this->infoGif($infoArr). 1689 $this->thumbCode($row,'tt_content','image').'<br />'; 1690 1691 if ($row['imagecaption']) { 1692 $infoArr=Array(); 1693 $this->getProcessedValue('tt_content','imagecaption_position',$row,$infoArr); 1694 $out.= $this->infoGif($infoArr). 1695 $this->linkEditContent($this->renderText($row['imagecaption']),$row).'<br />'; 1696 } 1697 } 1698 } 1699 break; 1700 case 'bullets': 1701 if ($row['bodytext']) { 1702 $this->getProcessedValue('tt_content','layout,text_align,text_face,text_size,text_color,text_properties',$row,$infoArr); 1703 $out.= $this->infoGif($infoArr). 1704 $this->linkEditContent($this->renderText($row['bodytext']),$row).'<br />'; 1705 } 1706 break; 1707 case 'table': 1708 if ($row['bodytext']) { 1709 $this->getProcessedValue('tt_content','table_bgColor,table_border,table_cellspacing,cols,layout,text_align,text_face,text_size,text_color,text_properties',$row,$infoArr); 1710 $out.= $this->infoGif($infoArr). 1711 $this->linkEditContent($this->renderText($row['bodytext']),$row).'<br />'; 1712 } 1713 break; 1714 case 'uploads': 1715 if ($row['media']) { 1716 $this->getProcessedValue('tt_content','media,select_key,layout,filelink_size,table_bgColor,table_border,table_cellspacing',$row,$infoArr); 1717 $out.= $this->infoGif($infoArr). 1718 $this->linkEditContent($this->renderText($row['bodytext']),$row).'<br />'; 1719 } 1720 break; 1721 case 'multimedia': 1722 if ($row['multimedia']) { 1723 $out.= $this->renderText($row['multimedia']).'<br />'; 1724 $out.= $this->renderText($row['parameters']).'<br />'; 1725 } 1726 break; 1727 case 'mailform': 1728 if ($row['bodytext']) { 1729 $this->getProcessedValue('tt_content','pages,subheader',$row,$infoArr); 1730 $out.= $this->infoGif($infoArr). 1731 $this->linkEditContent($this->renderText($row['bodytext']),$row).'<br />'; 1732 } 1733 break; 1734 case 'splash': 1735 if ($row['bodytext']) { 1736 $out.= $this->linkEditContent($this->renderText($row['bodytext']),$row).'<br />'; 1737 } 1738 if ($row['image']) { 1739 $infoArr=Array(); 1740 $this->getProcessedValue('tt_content','imagewidth',$row,$infoArr); 1741 $out.= $this->infoGif($infoArr). 1742 $this->thumbCode($row,'tt_content','image').'<br />'; 1743 } 1744 break; 1745 case 'menu': 1746 if ($row['pages']) { 1747 $this->getProcessedValue('tt_content','menu_type',$row,$infoArr); 1748 $out.= $this->infoGif($infoArr). 1749 $this->linkEditContent($row['pages'],$row).'<br />'; 1750 } 1751 break; 1752 case 'shortcut': 1753 if ($row['records']) { 1754 $this->getProcessedValue('tt_content','layout',$row,$infoArr); 1755 $out.= $this->infoGif($infoArr). 1756 $this->linkEditContent($row['shortcut'],$row).'<br />'; 1757 } 1758 break; 1759 case 'list': 1760 $this->getProcessedValue('tt_content','layout',$row,$infoArr); 1761 $out.= $this->infoGif($infoArr). 1762 $GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel('tt_content','list_type'),1).' '. 1763 $GLOBALS['LANG']->sL(t3lib_BEfunc::getLabelFromItemlist('tt_content','list_type',$row['list_type']),1).'<br />'; 1764 1765 $out.= $GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel('tt_content','select_key'),1).' '.$row['select_key'].'<br />'; 1766 1767 $infoArr=Array(); 1768 $this->getProcessedValue('tt_content','recursive',$row,$infoArr); 1769 $out.= $this->infoGif($infoArr). 1770 $GLOBALS['LANG']->sL(t3lib_BEfunc::getLabelFromItemlist('tt_content','pages',$row['pages']),1).'<br />'; 1771 break; 1772 case 'script': 1773 $out.= $GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel('tt_content','select_key'),1).' '.$row['select_key'].'<br />'; 1774 $out.= '<br />'.$this->linkEditContent($this->renderText($row['bodytext']),$row).'<br />'; 1775 $out.= '<br />'.$this->linkEditContent($this->renderText($row['imagecaption']),$row).'<br />'; 1776 break; 1777 default: 1778 if ($row['bodytext']) { 1779 $out.=$this->linkEditContent($this->renderText($row['bodytext']),$row).'<br />'; 1780 } 1781 break; 1782 } 1783 1784 // Wrap span-tags: 1785 $out = ' 1786 <span class="exampleContent">'.$out.'</span>'; 1787 // Add header: 1788 $out = $outHeader.$out; 1789 // Add RTE button: 1790 if ($isRTE) { 1791 $out.= $this->linkRTEbutton($row); 1792 } 1793 1794 // Return values: 1795 if ($this->isDisabled('tt_content',$row)) { 1796 return $GLOBALS['TBE_TEMPLATE']->dfw($out); 1797 } else { 1798 return $out; 1799 } 1800 } 1801 1802 /** 1803 * Filters out all tt_content uids which are already translated so only non-translated uids is left. 1804 * Selects across columns, but within in the same PID. Columns are expect to be the same for translations and original but this may be a conceptual error (?) 1805 * 1806 * @param array Numeric array with uids of tt_content elements in the default language 1807 * @param integer Page pid 1808 * @param integer Sys language UID 1809 * @return array Modified $defLanguageCount 1810 */ 1811 function getNonTranslatedTTcontentUids($defLanguageCount,$id,$lP) { 1812 if ($lP && count($defLanguageCount)) { 1813 1814 // Select all translations here: 1815 $queryParts = $this->makeQueryArray('tt_content', $id, 'AND sys_language_uid='.intval($lP).' AND l18n_parent IN ('.implode(',',$defLanguageCount).')'); 1816 $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts); 1817 1818 // Flip uids: 1819 $defLanguageCount = array_flip($defLanguageCount); 1820 1821 // Traverse any selected elements and unset original UID if any: 1822 $rowArr = $this->getResult($result); 1823 foreach($rowArr as $row) { 1824 unset($defLanguageCount[$row['l18n_parent']]); 1825 } 1826 1827 // Flip again: 1828 $defLanguageCount = array_keys($defLanguageCount); 1829 } 1830 1831 return $defLanguageCount; 1832 } 1833 1834 /** 1835 * Creates button which is used to create copies of records.. 1836 * 1837 * @param array Numeric array with uids of tt_content elements in the default language 1838 * @param integer Sys language UID 1839 * @return string "Copy languages" button, if available. 1840 */ 1841 function newLanguageButton($defLanguageCount,$lP) { 1842 if ($this->doEdit && count($defLanguageCount) && $lP) { 1843 1844 $params = ''; 1845 foreach($defLanguageCount as $uidVal) { 1846 $params.='&cmd[tt_content]['.$uidVal.'][localize]='.$lP; 1847 } 1848 1849 // Copy for language: 1850 $onClick = "window.location.href='".$GLOBALS['SOBE']->doc->issueCommand($params)."'; return false;"; 1851 $theNewButton = $GLOBALS['SOBE']->doc->t3Button($onClick,$GLOBALS['LANG']->getLL('newPageContent_copyForLang').' ['.count($defLanguageCount).']'); 1852 return $theNewButton; 1853 } 1854 } 1855 1856 /** 1857 * Returns an icon, which has its title attribute set to a massive amount of information about the element. 1858 * 1859 * @param array Array where values are human readable output of field values (not htmlspecialchars()'ed though). The values are imploded by a linebreak. 1860 * @return string HTML img tag if applicable. 1861 */ 1862 function infoGif($infoArr) { 1863 if (count($infoArr) && $this->tt_contentConfig['showInfo']) { 1864 $out='<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/zoom2.gif','width="12" height="12"').' title="'.htmlspecialchars(implode(chr(10),$infoArr)).'" alt="" /> '; 1865 return $out; 1866 } 1867 } 1868 1869 /** 1870 * Creates onclick-attribute content for a new content element 1871 * 1872 * @param integer Page id where to create the element. 1873 * @param integer Preset: Column position value 1874 * @param integer Preset: Sys langauge value 1875 * @return string String for onclick attribute. 1876 * @see getTable_tt_content() 1877 */ 1878 function newContentElementOnClick($id,$colPos,$sys_language) { 1879 if ($this->option_newWizard) { 1880 $onClick="window.location.href='db_new_content_el.php?id=".$id.'&colPos='.$colPos.'&sys_language_uid='.$sys_language.'&uid_pid='.$id.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'))."';"; 1881 } else { 1882 $onClick=t3lib_BEfunc::editOnClick('&edit[tt_content]['.$id.']=new&defVals[tt_content][colPos]='.$colPos.'&defVals[tt_content][sys_language_uid]='.$sys_language,$this->backPath); 1883 } 1884 return $onClick; 1885 } 1886 1887 /** 1888 * Will create a link on the input string and possible a big button after the string which links to editing in the RTE 1889 * Used for content element content displayed so the user can click the content / "Edit in Rich Text Editor" button 1890 * 1891 * @param string String to link. Must be prepared for HTML output. 1892 * @param array The row. 1893 * @return string If the whole thing was editable ($this->doEdit) $str is return with link around. Otherwise just $str. 1894 * @see getTable_tt_content() 1895 */ 1896 function linkEditContent($str,$row) { 1897 $addButton=''; 1898 $onClick = ''; 1899 1900 if ($this->doEdit) { 1901 // Setting onclick action for content link: 1902 $onClick=t3lib_BEfunc::editOnClick('&edit[tt_content]['.$row['uid'].']=edit',$this->backPath); 1903 } 1904 // Return link 1905 return $onClick ? '<a href="#" onclick="'.htmlspecialchars($onClick).'" title="'.$GLOBALS['LANG']->getLL('edit',1).'">'.$str.'</a>'.$addButton : $str; 1906 } 1907 1908 /** 1909 * Adds a button to edit the row in RTE wizard 1910 * 1911 * @param array The row of tt_content element 1912 * @return string Button to click if you want to edit in RTE wizard. 1913 */ 1914 function linkRTEbutton($row) { 1915 $params = array(); 1916 $params['table'] = 'tt_content'; 1917 $params['uid'] = $row['uid']; 1918 $params['pid'] = $row['pid']; 1919 $params['field'] = 'bodytext'; 1920 $params['returnUrl'] = t3lib_div::linkThisScript(); 1921 $RTEonClick = "window.location.href='".$this->backPath."wizard_rte.php?".t3lib_div::implodeArrayForUrl('',array('P'=>$params))."';return false;"; 1922 $addButton = $this->option_showBigButtons && $this->doEdit ? $GLOBALS['SOBE']->doc->t3Button($RTEonClick,$GLOBALS['LANG']->getLL('editInRTE')) : ''; 1923 1924 return $addButton; 1925 } 1926 1927 /** 1928 * Make selector box for creating new translation in a language 1929 * Displays only languages which are not yet present for the current page. 1930 * 1931 * @param integer Page id for which to create a new language (pages_language_overlay record) 1932 * @return string <select> HTML element (if there were items for the box anyways...) 1933 * @see getTable_tt_content() 1934 */ 1935 function languageSelector($id) { 1936 if ($GLOBALS['BE_USER']->check('tables_modify','pages_language_overlay')) { 1937 1938 // First, select all 1939 $res = $GLOBALS['SOBE']->exec_languageQuery(0); 1940 $langSelItems=array(); 1941 $langSelItems[0]=' 1942 <option value="0"></option>'; 1943 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 1944 if ($GLOBALS['BE_USER']->checkLanguageAccess($row['uid'])) { 1945 $langSelItems[$row['uid']]=' 1946 <option value="'.$row['uid'].'">'.htmlspecialchars($row['title']).'</option>'; 1947 } 1948 } 1949 1950 // Then, subtract the languages which are already on the page: 1951 $res = $GLOBALS['SOBE']->exec_languageQuery($id); 1952 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 1953 unset($langSelItems[$row['uid']]); 1954 } 1955 1956 // If any languages are left, make selector: 1957 if (count($langSelItems)>1) { 1958 $onChangeContent = 'window.location.href=\''.$this->backPath.'alt_doc.php?&edit[pages_language_overlay]['.$id.']=new&overrideVals[pages_language_overlay][sys_language_uid]=\'+this.options[this.selectedIndex].value+\'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')).'\''; 1959 return $GLOBALS['LANG']->getLL('new_language',1).': <select name="createNewLanguage" onchange="'.htmlspecialchars($onChangeContent).'"> 1960 '.implode('',$langSelItems).' 1961 </select><br /><br />'; 1962 } 1963 } 1964 } 1965 1966 /** 1967 * Traverse the result pointer given, adding each record to array and setting some internal values at the same time. 1968 * 1969 * @param pointer SQL result pointer for select query. 1970 * @return array The selected rows returned in this array. 1971 */ 1972 function getResult($result) { 1973 1974 // Initialize: 1975 $editUidList=''; 1976 $recs=Array(); 1977 $nextTree = $this->nextThree; 1978 $c=0; 1979 $output=Array(); 1980 1981 // Traverse the result: 1982 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { 1983 1984 // Add the row to the array: 1985 $output[]=$row; 1986 1987 // Set an internal register: 1988 $recs[$c]=$row['uid']; 1989 1990 // Create the list of the next three ids (for editing links...) 1991 for($a=0;$a<$nextTree;$a++) { 1992 if(isset($recs[$c-$a])) { 1993 $this->tt_contentData['nextThree'][$recs[$c-$a]].=$row['uid'].','; 1994 } 1995 } 1996 1997 // Set next/previous ids: 1998 if (isset($recs[$c-1])) { 1999 if (isset($recs[$c-2])) { 2000 $this->tt_contentData['prev'][$row['uid']]=-$recs[$c-2]; 2001 } else { 2002 $this->tt_contentData['prev'][$row['uid']]=$row['pid']; 2003 } 2004 $this->tt_contentData['next'][$recs[$c-1]]=-$row['uid']; 2005 } 2006 $c++; 2007 } 2008 2009 // Return selected records 2010 return $output; 2011 } 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 /********************************** 2026 * 2027 * Additional functions; Message board items (tt_board) 2028 * 2029 **********************************/ 2030 2031 /** 2032 * Traverses recursively a branch in a message board. 2033 * 2034 * @param array Array of rows (build up recursively) 2035 * @param integer tt_content parent uid 2036 * @param integer Page id 2037 * @param string Additional query part. 2038 * @param string HTML content to prefix items with (to draw the proper tree-graphics) 2039 * @return array $theRows, but with added content 2040 */ 2041 function tt_board_getTree($theRows,$parent,$pid,$qWhere,$treeIcons) { 2042 2043 // Select tt_board elements: 2044 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_board', 'pid='.intval($pid).' AND parent='.intval($parent).$qWhere, '', 'crdate'); 2045 2046 // Traverse the results: 2047 $c=0; 2048 $rc = $GLOBALS['TYPO3_DB']->sql_num_rows($res); 2049 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 2050 $c++; 2051 $row['treeIcons'] = $treeIcons.'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/'.($rc==$c ? 'joinbottom.gif' : 'join.gif'),'width="18" height="16"').' alt="" />'; 2052 $theRows[]=$row; 2053 2054 // Get the branch 2055 $theRows = $this->tt_board_getTree( 2056 $theRows, 2057 $row['uid'], 2058 $row['pid'], 2059 $qWhere, 2060 $treeIcons.'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/'.($rc==$c ? 'blank.gif' : 'line.gif'),'width="18" height="16"').' alt="" />' 2061 ); 2062 } 2063 2064 // Return modified rows: 2065 return $theRows; 2066 } 2067 2068 /** 2069 * Adds an element to the tt_board listing: 2070 * 2071 * @param string Table name 2072 * @param array The record row 2073 * @param string Reply count, if applicable. 2074 * @return string Return content of element (table row) 2075 */ 2076 function tt_board_drawItem($table,$row,$re) { 2077 2078 // Building data-arary with content: 2079 $theData = Array(); 2080 $theData['subject'] = t3lib_div::fixed_lgd_cs(htmlspecialchars($row['subject']),25).' '; 2081 $theData['author'] = t3lib_div::fixed_lgd_cs(htmlspecialchars($row['author']),15).' '; 2082 $theData['date'] = t3lib_div::fixed_lgd_cs(t3lib_BEfunc::datetime($row['crdate']),20).' '; 2083 $theData['age'] = t3lib_BEfunc::calcAge(time()-$row['crdate'], $this->agePrefixes).' '; 2084 if ($re) { 2085 $theData['replys'] = $re; 2086 } 2087 2088 // Subject is built: 2089 $theData['subject'] = 2090 $row['treeIcons']. 2091 $this->getIcon($table,$row). 2092 $theData['subject']; 2093 2094 // Adding element: 2095 return $this->addelement(1,'',$theData); 2096 } 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 /******************************** 2111 * 2112 * Various helper functions 2113 * 2114 ********************************/ 2115 2116 /** 2117 * Counts and returns the number of records on the page with $pid 2118 * 2119 * @param string Table name 2120 * @param integer Page id 2121 * @return integer Number of records. 2122 */ 2123 function numberOfRecords($table,$pid) { 2124 global $TCA; 2125 2126 $c=0; 2127 if ($TCA[$table]) { 2128 $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', $table, 'pid='.intval($pid).t3lib_BEfunc::deleteClause($table).t3lib_BEfunc::versioningPlaceholderClause($table)); 2129 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_row($result)) { 2130 $c=$row[0]; 2131 } 2132 } 2133 return $c; 2134 } 2135 2136 /** 2137 * Processing of larger amounts of text (usually from RTE/bodytext fields) with word wrapping etc. 2138 * 2139 * @param string Input string 2140 * @return string Output string 2141 */ 2142 function renderText($input) { 2143 $input = $this->strip_tags($input, true); 2144 $input = t3lib_div::fixed_lgd_cs($input,1500); 2145 return nl2br(htmlspecialchars(trim($this->wordWrapper($input)))); 2146 } 2147 2148 /** 2149 * Creates the icon image tag for record from table and wraps it in a link which will trigger the click menu. 2150 * 2151 * @param string Table name 2152 * @param array Record array 2153 * @param string Record title (NOT USED) 2154 * @return string HTML for the icon 2155 */ 2156 function getIcon($table,$row) { 2157 2158 // Initialization 2159 $alttext = t3lib_BEfunc::getRecordIconAltText($row,$table); 2160 $iconImg = t3lib_iconWorks::getIconImage($table,$row,$this->backPath,'title="'.$alttext.'"'); 2161 $this->counter++; 2162 2163 // The icon with link 2164 $theIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconImg,$table,$row['uid']); 2165 2166 return $theIcon; 2167 } 2168 2169 /** 2170 * Creates processed values for all fieldnames in $fieldList based on values from $row array. 2171 * The result is 'returned' through $info which is passed as a reference 2172 * 2173 * @param string Table name 2174 * @param string Commalist of fields. 2175 * @param array Record from which to take values for processing. 2176 * @param array Array to which the processed values are added. 2177 * @return void 2178 */ 2179 function getProcessedValue($table,$fieldList,$row,&$info) { 2180 2181 // Splitting values from $fieldList: 2182 $fieldArr = explode(',',$fieldList); 2183 2184 // Traverse fields from $fieldList: 2185 foreach($fieldArr as $field) { 2186 if ($row[$field]) { 2187 $info[]= htmlspecialchars($this->itemLabels[$field]).' '.htmlspecialchars(t3lib_BEfunc::getProcessedValue($table,$field,$row[$field])); 2188 } 2189 } 2190 } 2191 2192 /** 2193 * Returns true, if the record given as parameters is NOT visible based on hidden/starttime/endtime (if available) 2194 * 2195 * @param string Tablename of table to test 2196 * @param array Record row. 2197 * @return boolean Returns true, if disabled. 2198 */ 2199 function isDisabled($table,$row) { 2200 global $TCA; 2201 if ( 2202 ($TCA[$table]['ctrl']['enablecolumns']['disabled'] && $row[$TCA[$table]['ctrl']['enablecolumns']['disabled']]) || 2203 ($TCA[$table]['ctrl']['enablecolumns']['starttime'] && $row[$TCA[$table]['ctrl']['enablecolumns']['starttime']]>time() ) || 2204 ($TCA[$table]['ctrl']['enablecolumns']['endtime'] && $row[$TCA[$table]['ctrl']['enablecolumns']['endtime']] && $row[$TCA[$table]['ctrl']['enablecolumns']['endtime']]<time()) 2205 ) return true; 2206 } 2207 2208 /** 2209 * Will perform "word-wrapping" on the input string. What it does is to split by space or linebreak, then find any word longer than $max and if found, a hyphen is inserted. 2210 * Works well on normal texts, little less well when HTML is involved (since much HTML will have long strings that will be broken). 2211 * 2212 * @param string Content to word-wrap. 2213 * @param integer Max number of chars in a word before it will be wrapped. 2214 * @param string Character to insert when wrapping. 2215 * @return string Processed output. 2216 */ 2217 function wordWrapper($content,$max=50,$char=' -') { 2218 $array = split(' |'.chr(10),$content); 2219 foreach($array as $val) { 2220 if (strlen($val)>$max) { 2221 $content=str_replace($val,substr(chunk_split($val,$max,$char),0,-1),$content); 2222 } 2223 } 2224 return $content; 2225 } 2226 2227 /** 2228 * Returns icon for "no-edit" of a record. 2229 * Basically, the point is to signal that this record could have had an edit link if the circumstances were right. A placeholder for the regular edit icon... 2230 * 2231 * @param string Label key from LOCAL_LANG 2232 * @return string IMG tag for icon. 2233 */ 2234 function noEditIcon($label='noEditItems') { 2235 return '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2_d.gif','width="11" height="12"').' title="'.$GLOBALS['LANG']->getLL($label,1).'" alt="" />'; 2236 } 2237 2238 /** 2239 * Function, which fills in the internal array, $this->allowedTableNames with all tables to which the user has access. Also a set of standard tables (pages, static_template, sys_filemounts, etc...) are filtered out. So what is left is basically all tables which makes sense to list content from. 2240 * 2241 * @return void 2242 */ 2243 function cleanTableNames() { 2244 global $TCA; 2245 2246 // Get all table names: 2247 $tableNames=array_flip(array_keys($TCA)); 2248 2249 // Unset common names: 2250 unset($tableNames['pages']); 2251 unset($tableNames['static_template']); 2252 unset($tableNames['sys_filemounts']); 2253 unset($tableNames['sys_action']); 2254 unset($tableNames['sys_workflows']); 2255 unset($tableNames['be_users']); 2256 unset($tableNames['be_groups']); 2257 2258 $this->allowedTableNames=array(); 2259 2260 // Traverse table names and set them in allowedTableNames array IF they can be read-accessed by the user. 2261 if (is_array($tableNames)) { 2262 foreach($tableNames as $k => $v) { 2263 if ($GLOBALS['BE_USER']->check('tables_select',$k)) { 2264 $this->allowedTableNames['table_'.$k]=$k; 2265 } 2266 } 2267 } 2268 } 2269 2270 /** 2271 * Checking if the RTE is available/enabled for a certain table/field and if so, it returns true. 2272 * Used to determine if the RTE button should be displayed. 2273 * 2274 * @param string Table name 2275 * @param array Record row (needed, if there are RTE dependencies based on other fields in the record) 2276 * @param string Field name 2277 * @return boolean Returns true if the rich text editor would be enabled/available for the field name specified. 2278 */ 2279 function isRTEforField($table,$row,$field){ 2280 $specConf = $this->getSpecConfForField($table,$row,$field); 2281 $p = t3lib_BEfunc::getSpecConfParametersFromArray($specConf['rte_transform']['parameters']); 2282 if (isset($specConf['richtext']) && (!$p['flag'] || !$row[$p['flag']])) { 2283 t3lib_BEfunc::fixVersioningPid($table,$row); 2284 list($tscPID,$thePidValue) = t3lib_BEfunc::getTSCpid($table,$row['uid'],$row['pid']); 2285 if ($thePidValue>=0) { // If the pid-value is not negative (that is, a pid could NOT be fetched) 2286 $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($tscPID)); 2287 $RTEtypeVal = t3lib_BEfunc::getTCAtypeValue($table,$row); 2288 $thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'],$table,$field,$RTEtypeVal); 2289 if (!$thisConfig['disabled']) { 2290 return TRUE; 2291 } 2292 } 2293 } 2294 2295 return FALSE; 2296 } 2297 2298 /** 2299 * Returns "special" configuration from the "types" configuration in TCA for the record given by tablename/fieldname. 2300 * Used by isRTEforField() in the process of finding whether a field has RTE enabled or not. 2301 * 2302 * @param string Table name 2303 * @param array Record array 2304 * @param string Field name 2305 * @return array Spec. conf (if available) 2306 * @access private 2307 * @see isRTEforField() 2308 */ 2309 function getSpecConfForField($table,$row,$field) { 2310 2311 // Get types-configuration for the record: 2312 $types_fieldConfig = t3lib_BEfunc::getTCAtypes($table,$row); 2313 2314 // Find the given field and return the spec key value if found: 2315 if (is_array($types_fieldConfig)) { 2316 foreach($types_fieldConfig as $vconf) { 2317 if ($vconf['field']==$field) return $vconf['spec']; 2318 } 2319 } 2320 } 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 /***************************************** 2334 * 2335 * External renderings 2336 * 2337 *****************************************/ 2338 2339 /** 2340 * Creates an info-box for the current page (identified by input record). 2341 * 2342 * @param array Page record 2343 * @param boolean If set, there will be shown an edit icon, linking to editing of the page properties. 2344 * @return string HTML for the box. 2345 */ 2346 function getPageInfoBox($rec,$edit=0) { 2347 global $LANG; 2348 2349 // If editing of the page properties is allowed: 2350 if ($edit) { 2351 $params='&edit[pages]['.$rec['uid'].']=edit'; 2352 $editIcon='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath)).'">'. 2353 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2.gif','width="11" height="12"').' title="'.$GLOBALS['LANG']->getLL('edit',1).'" alt="" />'. 2354 '</a>'; 2355 } else { 2356 $editIcon=$this->noEditIcon('noEditPage'); 2357 } 2358 2359 // Setting page icon, link, title: 2360 $outPutContent = t3lib_iconWorks::getIconImage('pages',$rec,$this->backPath,'title="'.htmlspecialchars(t3lib_BEfunc::titleAttribForPages($rec)).'"'). 2361 $editIcon. 2362 ' '. 2363 htmlspecialchars($rec['title']); 2364 2365 2366 // Init array where infomation is accumulated as label/value pairs. 2367 $lines=array(); 2368 2369 // Owner user/group: 2370 if ($this->pI_showUser) { 2371 // User: 2372 $users= t3lib_BEfunc::getUserNames('username,usergroup,usergroup_cached_list,uid,realName'); 2373 $groupArray = explode(',',$GLOBALS['BE_USER']->user['usergroup_cached_list']); 2374 $users=t3lib_BEfunc::blindUserNames($users,$groupArray); 2375 $lines[]=array($LANG->getLL('pI_crUser').':',htmlspecialchars($users[$rec['cruser_id']]['username']).' ('.$users[$rec['cruser_id']]['realName'].')'); 2376 } 2377 2378 // Created: 2379 $lines[]=array($LANG->getLL('pI_crDate').':', t3lib_BEfunc::datetime($rec['crdate']).' ('.t3lib_BEfunc::calcAge(time()-$rec['crdate'],$this->agePrefixes).')'); 2380 2381 // Last change: 2382 $lines[]=array($LANG->getLL('pI_lastChange').':', t3lib_BEfunc::datetime($rec['tstamp']).' ('.t3lib_BEfunc::calcAge(time()-$rec['tstamp'],$this->agePrefixes).')'); 2383 2384 // Last change of content: 2385 if ($rec['SYS_LASTCHANGED']) { 2386 $lines[]=array($LANG->getLL('pI_lastChangeContent').':', t3lib_BEfunc::datetime($rec['SYS_LASTCHANGED']).' ('.t3lib_BEfunc::calcAge(time()-$rec['SYS_LASTCHANGED'],$this->agePrefixes).')'); 2387 } 2388 2389 // Spacer: 2390 $lines[]=''; 2391 2392 // Display contents of certain page fields, if any value: 2393 $dfields = explode(',','alias,target,hidden,starttime,endtime,fe_group,no_cache,cache_timeout,newUntil,lastUpdated,subtitle,keywords,description,abstract,author,author_email'); 2394 foreach($dfields as $fV) { 2395 if ($rec[$fV]) { 2396 $lines[]=array($GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel('pages',$fV)), t3lib_BEfunc::getProcessedValue('pages',$fV,$rec[$fV])); 2397 } 2398 } 2399 2400 // Page hits (depends on "sys_stat" extension) 2401 if ($this->pI_showStat && t3lib_extMgm::isLoaded('sys_stat')) { 2402 2403 // Counting total hits: 2404 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'sys_stat', 'page_id='.intval($rec['uid'])); 2405 $rrow = $GLOBALS['TYPO3_DB']->sql_fetch_row($res); 2406 if ($rrow[0]) { 2407 2408 // Get min/max 2409 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('min(tstamp) AS min,max(tstamp) AS max', 'sys_stat', 'page_id='.intval($rec['uid'])); 2410 $rrow2 = $GLOBALS['TYPO3_DB']->sql_fetch_row($res); 2411 2412 $lines[]=''; 2413 $lines[]=array($LANG->getLL('pI_hitsPeriod').':',t3lib_BEfunc::date($rrow2[0]).' - '.t3lib_BEfunc::date($rrow2[1]).' ('.t3lib_BEfunc::calcAge($rrow2[1]-$rrow2[0],$this->agePrefixes).')'); 2414 $lines[]=array($LANG->getLL('pI_hitsTotal').':',$rrow[0]); 2415 2416 2417 // Last 10 days 2418 $nextMidNight = mktime (0,0,0)+1*3600*24; 2419 2420 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*), FLOOR(('.$nextMidNight.'-tstamp)/(24*3600)) AS day', 'sys_stat', 'page_id='.intval($rec['uid']).' AND tstamp>'.($nextMidNight-10*24*3600), 'day'); 2421 $days=array(); 2422 while($rrow = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) { 2423 $days[$rrow[1]] = $rrow[0]; 2424 } 2425 2426 $headerH=array(); 2427 $contentH=array(); 2428 for($a=9;$a>=0;$a--) { 2429 $headerH[]=' 2430 <td class="bgColor5" nowrap="nowrap"> '.date('d',$nextMidNight-($a+1)*24*3600).' </td>'; 2431 $contentH[]=' 2432 <td align="center">'.($days[$a] ? intval($days[$a]) : '-').'</td>'; 2433 } 2434 2435 // Compile first hit-table (last 10 days) 2436 $hitTable=' 2437 <table border="0" cellpadding="0" cellspacing="1" class="typo3-page-hits"> 2438 <tr>'.implode('',$headerH).'</tr> 2439 <tr>'.implode('',$contentH).'</tr> 2440 </table>'; 2441 $lines[]=array($LANG->getLL('pI_hits10days').':',$hitTable,1); 2442 2443 2444 // Last 24 hours 2445 $nextHour = mktime (date('H'),0,0)+3600; 2446 $hours=16; 2447 2448 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*), FLOOR(('.$nextHour.'-tstamp)/3600) AS hours', 'sys_stat', 'page_id='.intval($rec['uid']).' AND tstamp>'.($nextHour-$hours*3600), 'hours'); 2449 $days=array(); 2450 while($rrow = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) { 2451 $days[$rrow[1]]=$rrow[0]; 2452 } 2453 2454 $headerH=array(); 2455 $contentH=array(); 2456 for($a=($hours-1);$a>=0;$a--) { 2457 $headerH[]=' 2458 <td class="bgColor5" nowrap="nowrap"> '.intval(date('H',$nextHour-($a+1)*3600)).' </td>'; 2459 $contentH[]=' 2460 <td align="center">'.($days[$a] ? intval($days[$a]) : '-').'</td>'; 2461 } 2462 2463 // Compile second hit-table (last 24 hours) 2464 $hitTable=' 2465 <table border="0" cellpadding="0" cellspacing="1" class="typo3-page-stat"> 2466 <tr>'.implode('',$headerH).'</tr> 2467 <tr>'.implode('',$contentH).'</tr> 2468 </table>'; 2469 $lines[]=array($LANG->getLL('pI_hits24hours').':',$hitTable,1); 2470 } 2471 } 2472 2473 2474 // Finally, wrap the elements in the $lines array in table cells/rows 2475 foreach($lines as $fV) { 2476 if (is_array($fV)) { 2477 if (!$fV[2]) $fV[1]=htmlspecialchars($fV[1]); 2478 $out.=' 2479 <tr> 2480 <td class="bgColor4" nowrap="nowrap"><strong>'.htmlspecialchars($fV[0]).' </strong></td> 2481 <td class="bgColor4">'.$fV[1].'</td> 2482 </tr>'; 2483 } else { 2484 $out.=' 2485 <tr> 2486 <td colspan="2"><img src="clear.gif" width="1" height="3" alt="" /></td> 2487 </tr>'; 2488 } 2489 } 2490 2491 // Wrap table tags around... 2492 $outPutContent.=' 2493 2494 2495 2496 <!-- 2497 Page info box: 2498 --> 2499 <table border="0" cellpadding="0" cellspacing="1" id="typo3-page-info"> 2500 '.$out.' 2501 </table>'; 2502 2503 // ... and return it. 2504 return $outPutContent; 2505 } 2506 2507 /** 2508 * Creates a menu of the tables that can be listed by this function 2509 * Only tables which has records on the page will be included. 2510 * Notice: The function also fills in the internal variable $this->activeTables with icon/titles. 2511 * 2512 * @param integer Page id from which we are listing records (the function will look up if there are records on the page) 2513 * @return string HTML output. 2514 */ 2515 function getTableMenu($id) { 2516 global $TCA; 2517 2518 // Initialize: 2519 $this->activeTables=array(); 2520 $theTables = explode(',','tt_content,fe_users,tt_address,tt_links,tt_board,tt_guest,tt_calender,tt_products,tt_news'); // NOTICE: This serves double function: Both being tables names (all) and for most others also being extension keys for the extensions they are related to! 2521 2522 // External tables: 2523 if (is_array($this->externalTables)) { 2524 $theTables = array_unique(array_merge($theTables, array_keys($this->externalTables))); 2525 } 2526 2527 // Traverse tables to check: 2528 foreach($theTables as $tName) { 2529 2530 // Check access and whether the proper extensions are loaded: 2531 if ($GLOBALS['BE_USER']->check('tables_select',$tName) && (t3lib_extMgm::isLoaded($tName)||t3lib_div::inList('fe_users,tt_content',$tName) || isset($this->externalTables[$tName]))) { 2532 2533 // Make query to count records from page: 2534 $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', $tName, 'pid='.intval($id).t3lib_BEfunc::deleteClause($tName).t3lib_BEfunc::versioningPlaceholderClause($tName)); 2535 list($c) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result); 2536 2537 // If records were found (or if "tt_content" is the table...): 2538 if ($c || t3lib_div::inList('tt_content',$tName)) { 2539 2540 // Add row to menu: 2541 $out.=' 2542 <td><a href="#'.$tName.'"></a>'. 2543 t3lib_iconWorks::getIconImage($tName,Array(),$this->backPath,'title="'.$GLOBALS['LANG']->sL($TCA[$tName]['ctrl']['title'],1).'"'). 2544 '</td>'; 2545 2546 // ... and to the internal array, activeTables we also add table icon and title (for use elsewhere) 2547 $this->activeTables[$tName]= 2548 t3lib_iconWorks::getIconImage($tName,Array(),$this->backPath,'title="'.$GLOBALS['LANG']->sL($TCA[$tName]['ctrl']['title'],1).': '.$c.' '.$GLOBALS['LANG']->getLL('records',1).'" class="absmiddle"'). 2549 ' '. 2550 $GLOBALS['LANG']->sL($TCA[$tName]['ctrl']['title'],1); 2551 } 2552 } 2553 } 2554 2555 // Wrap cells in table tags: 2556 $out = ' 2557 2558 2559 2560 <!-- 2561 Menu of tables on the page (table menu) 2562 --> 2563 <table border="0" cellpadding="0" cellspacing="0" id="typo3-page-tblMenu"> 2564 <tr>'.$out.' 2565 </tr> 2566 </table>'; 2567 2568 // Return the content: 2569 return $out; 2570 } 2571 2572 /** 2573 * Enhancement for the strip_tags function that provides the feature to fill in empty tags. 2574 * Example <link email@hostname.com></link> is accepted by TYPO3 but would not displayed in the Backend otherwise. 2575 * 2576 * @param string Input string 2577 * @param boolean If true, empty tags will be filled with the first attribute of the tag before. 2578 * @return string Input string with all HTML and PHP tags stripped 2579 */ 2580 function strip_tags($content, $fillEmptyContent=false) { 2581 if($fillEmptyContent && strstr($content, '><')) { 2582 $content = preg_replace('/(<[^ >]* )([^ >]*)([^>]*>)(<\/[^>]*>)/', '$1$2$3$2$4', $content); 2583 } 2584 $content = preg_replace('/<br.?\/?>/', chr(10), $content); 2585 2586 return strip_tags($content); 2587 } 2588 } 2589 2590 2591 2592 2593 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/cms/layout/class.tx_cms_layout.php']) { 2594 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/cms/layout/class.tx_cms_layout.php']); 2595 } 2596 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sun Nov 25 17:13:16 2007 | par Balluche grâce à PHPXref 0.7 |
|