Fixed #11430: Performance improvement: use $GLOBALS['EXEC_TIME'] instead of time...
[Packages/TYPO3.CMS.git] / typo3 / sysext / cms / layout / class.tx_cms_layout.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2009 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$
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->oddColumnsCssClass = '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'),rtrim(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] = '&nbsp;<b>'.$GLOBALS['LANG']->sL($TCA['pages']['columns'][$field]['label']).'</b>'.$eI;
329 break;
330 case 'uid':
331 $theData[$field] = '&nbsp;<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] = '&nbsp;'.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]='&nbsp;'.date('d',$timespan);
345 break;
346 default:
347 $theData[$field] = '';
348 break;
349 }
350 } else {
351 $theData[$field] = '&nbsp;&nbsp;<b>'.$GLOBALS['LANG']->sL($TCA['pages']['columns'][$field]['label'],1).'</b>'.$eI;
352 }
353 break;
354 }
355 }
356
357 // Start table:
358 $this->oddColumnsCssClass = '';
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->oddColumnsCssClass = '';
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
444 if (is_array($row) && (int)$row['t3ver_state']!=2) {
445 $singleElementHTML = '';
446 if (!$lP) $defLanguageCount[$key][] = $row['uid'];
447
448 $editUidList.= $row['uid'].',';
449 $singleElementHTML.= $this->tt_content_drawHeader($row,$this->tt_contentConfig['showInfo']?15:5, $this->defLangBinding && $lP>0, TRUE);
450
451 $isRTE = $RTE && $this->isRTEforField('tt_content',$row,'bodytext');
452 $singleElementHTML.= '<div '.($row['_ORIG_uid'] ? ' class="ver-element"' :'').'>'.$this->tt_content_drawItem($row,$isRTE).'</div>';
453
454 if ($this->defLangBinding && $this->tt_contentConfig['languageMode']) {
455 $defLangBinding[$key][$lP][$row[($lP ? 'l18n_parent' : 'uid')]] = $singleElementHTML;
456 } else {
457 $content[$key].= $singleElementHTML;
458 }
459 } else { unset($rowArr[$rKey]); }
460 }
461
462 // Add new-icon link, header:
463 $newP = $this->newContentElementOnClick($id,$key,$lP);
464 $head[$key].= $this->tt_content_drawColHeader(t3lib_BEfunc::getProcessedValue('tt_content','colPos',$key), ($this->doEdit&&count($rowArr)?'&edit[tt_content]['.$editUidList.']=edit'.$pageTitleParamForAltDoc:''), $newP);
465 $editUidList = '';
466 }
467
468 // For EACH column, fit the rendered content into a table cell:
469 $out='';
470 foreach($cList as $k => $key) {
471 if (!$k) {
472 $out.= '
473 <td><img src="clear.gif" width="'.$lMarg.'" height="1" alt="" /></td>';
474 } else {
475 $out.= '
476 <td><img src="clear.gif" width="4" height="1" alt="" /></td>
477 <td bgcolor="black"><img src="clear.gif" width="1" height="1" alt="" /></td>
478 <td><img src="clear.gif" width="4" height="1" alt="" /></td>';
479 }
480 $out.= '
481 <td valign="top">'.$head[$key].$content[$key].'</td>';
482
483 // Storing content for use if languageMode is set:
484 if ($this->tt_contentConfig['languageMode']) {
485 $languageColumn[$key][$lP] = $head[$key].$content[$key];
486 if (!$this->defLangBinding) {
487 $languageColumn[$key][$lP].='<br /><br />'.$this->newLanguageButton($this->getNonTranslatedTTcontentUids($defLanguageCount[$key],$id,$lP),$lP);
488 }
489 }
490 }
491
492 // Wrap the cells into a table row:
493 $out = '
494 <table border="0" cellpadding="0" cellspacing="0" width="480" class="typo3-page-cols">
495 <tr>'.$out.'
496 </tr>
497 </table>';
498
499 // CSH:
500 $out.= t3lib_BEfunc::cshItem($this->descrTable,'columns_multi',$GLOBALS['BACK_PATH']);
501 }
502
503 // If language mode, then make another presentation:
504 // 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!
505 if ($this->tt_contentConfig['languageMode']) {
506
507 // Get language selector:
508 $languageSelector = $this->languageSelector($id);
509
510 // Reset out - we will make new content here:
511 $out='';
512 // Separator between language columns (black thin line)
513 $midSep = '
514 <td><img src="clear.gif" width="4" height="1" alt="" /></td>
515 <td bgcolor="black"><img src="clear.gif" width="1" height="1" alt="" /></td>
516 <td><img src="clear.gif" width="4" height="1" alt="" /></td>';
517
518 // Traverse languages found on the page and build up the table displaying them side by side:
519 $cCont=array();
520 $sCont=array();
521 foreach($langListArr as $lP) {
522
523 // Header:
524 $cCont[$lP]='
525 <td valign="top" align="center" class="bgColor6"><strong>'.htmlspecialchars($this->tt_contentConfig['languageCols'][$lP]).'</strong></td>';
526
527 // "View page" icon is added:
528 $viewLink = '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::viewOnClick($this->id,$this->backPath,t3lib_BEfunc::BEgetRootLine($this->id),'','','&L='.$lP)).'">'.
529 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/zoom.gif','width="12" height="12"').' class="absmiddle" title="" alt="" />'.
530 '</a>';
531
532 // Language overlay page header:
533 if ($lP) {
534
535 list($lpRecord) = t3lib_BEfunc::getRecordsByField('pages_language_overlay','pid',$id,'AND sys_language_uid='.intval($lP));
536 t3lib_BEfunc::workspaceOL('pages_language_overlay',$lpRecord);
537 $params='&edit[pages_language_overlay]['.$lpRecord['uid'].']=edit&overrideVals[pages_language_overlay][sys_language_uid]='.$lP;
538 $lPLabel = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon(t3lib_iconWorks::getIconImage('pages_language_overlay',$lpRecord,$this->backPath,' class="absmiddle"'),'pages_language_overlay',$lpRecord['uid']).
539 $viewLink.
540 ($GLOBALS['BE_USER']->check('tables_modify','pages_language_overlay') ? '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath)).'">'.
541 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2.gif','width="11" height="12"').' title="'.$GLOBALS['LANG']->getLL('edit',1).'" class="absmiddle" alt="" />'.
542 '</a>' : '').
543 htmlspecialchars(t3lib_div::fixed_lgd_cs($lpRecord['title'],20));
544 } else {
545 $lPLabel = $viewLink;
546 }
547 $sCont[$lP]='
548 <td nowrap="nowrap">'.$lPLabel.'</td>';
549 }
550 // Add headers:
551 $out.='
552 <tr class="bgColor5">'.implode($midSep,$cCont).'
553 </tr>';
554 $out.='
555 <tr class="bgColor5">'.implode($midSep,$sCont).'
556 </tr>';
557
558 // Traverse previously built content for the columns:
559 foreach($languageColumn as $cKey => $cCont) {
560 $out.='
561 <tr>
562 <td valign="top">'.implode('</td>'.$midSep.'
563 <td valign="top">',$cCont).'</td>
564 </tr>';
565
566 if ($this->defLangBinding) {
567 // "defLangBinding" mode
568 foreach($defLanguageCount[$cKey] as $defUid) {
569 $cCont=array();
570 foreach($langListArr as $lP) {
571 $cCont[] = $defLangBinding[$cKey][$lP][$defUid].
572 '<br/>'.$this->newLanguageButton($this->getNonTranslatedTTcontentUids(array($defUid),$id,$lP),$lP);
573 }
574 $out.='
575 <tr>
576 <td valign="top">'.implode('</td>'.$midSep.'
577 <td valign="top">',$cCont).'</td>
578 </tr>';
579 }
580
581 // Create spacer:
582 $cCont=array();
583 foreach($langListArr as $lP) {
584 $cCont[] = '&nbsp;';
585 }
586 $out.='
587 <tr>
588 <td valign="top">'.implode('</td>'.$midSep.'
589 <td valign="top">',$cCont).'</td>
590 </tr>';
591 }
592 }
593
594 // Finally, wrap it all in a table and add the language selector on top of it:
595 $out = $languageSelector.'
596 <table border="0" cellpadding="0" cellspacing="0" width="480" class="typo3-page-langMode">
597 '.$out.'
598 </table>';
599
600 // CSH:
601 $out.= t3lib_BEfunc::cshItem($this->descrTable,'language_list',$GLOBALS['BACK_PATH']);
602 }
603 } else { // SINGLE column mode (columns shown beneath each other):
604 #debug('single column');
605 if ($this->tt_contentConfig['sys_language_uid']==0 || !$this->defLangBinding) {
606
607 // Initialize:
608 if ($this->defLangBinding && $this->tt_contentConfig['sys_language_uid']==0) {
609 $showLanguage = ' AND sys_language_uid IN (0,-1)';
610 $lP = 0;
611 } else {
612 $showLanguage = ' AND sys_language_uid='.$this->tt_contentConfig['sys_language_uid'];
613 $lP = $this->tt_contentConfig['sys_language_uid'];
614 }
615
616 $cList = explode(',',$this->tt_contentConfig['showSingleCol']);
617 $content=array();
618 $out='';
619
620 // Expand the table to some preset dimensions:
621 $out.='
622 <tr>
623 <td><img src="clear.gif" width="'.$lMarg.'" height="1" alt="" /></td>
624 <td valign="top"><img src="clear.gif" width="150" height="1" alt="" /></td>
625 <td><img src="clear.gif" width="10" height="1" alt="" /></td>
626 <td valign="top"><img src="clear.gif" width="300" height="1" alt="" /></td>
627 </tr>';
628
629 // Traverse columns to display top-on-top
630 while(list($counter,$key)=each($cList)) {
631
632 // Select content elements:
633 $queryParts = $this->makeQueryArray('tt_content', $id, 'AND colPos='.intval($key).$showHidden.$showLanguage);
634 $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
635 $c = 0;
636 $rowArr = $this->getResult($result);
637 $rowOut = '';
638
639 // 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:
640 if ($this->doEdit && $this->option_showBigButtons && !intval($key) && !$GLOBALS['TYPO3_DB']->sql_num_rows($result)) {
641 $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'))."';";
642 $theNewButton=$GLOBALS['SOBE']->doc->t3Button($onClick,$GLOBALS['LANG']->getLL('newPageContent'));
643 $theNewButton='<img src="clear.gif" width="1" height="5" alt="" /><br />'.$theNewButton;
644 } else $theNewButton='';
645
646 // Traverse any selected elements:
647 foreach($rowArr as $rKey => $row) {
648
649 if (is_array($row) && (int)$row['t3ver_state']!=2) {
650
651 $c++;
652 $editUidList.=$row['uid'].',';
653 $isRTE=$RTE && $this->isRTEforField('tt_content',$row,'bodytext');
654
655 // Create row output:
656 $rowOut.='
657 <tr>
658 <td></td>
659 <td valign="top">'.$this->tt_content_drawHeader($row).'</td>
660 <td>&nbsp;</td>
661 <td'.($row['_ORIG_uid'] ? ' class="ver-element"' :'').' valign="top">'.$this->tt_content_drawItem($row,$isRTE).'</td>
662 </tr>';
663
664 // If the element was not the last element, add a divider line:
665 if ($c != $GLOBALS['TYPO3_DB']->sql_num_rows($result)) {
666 $rowOut.='
667 <tr>
668 <td></td>
669 <td colspan="3"><img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/stiblet_medium2.gif','width="468" height="1"').' class="c-divider" alt="" /></td>
670 </tr>';
671 }
672 } else { unset($rowArr[$rKey]); }
673 }
674
675 // Add spacer between sections in the vertical list
676 if ($counter) {
677 $out.='
678 <tr>
679 <td></td>
680 <td colspan="3"><br /><br /><br /><br /></td>
681 </tr>';
682 }
683
684 // Add section header:
685 $newP = $this->newContentElementOnClick($id,$key,$this->tt_contentConfig['sys_language_uid']);
686 $out.='
687
688 <!-- Column header: -->
689 <tr>
690 <td></td>
691 <td valign="top" colspan="3">'.
692 $this->tt_content_drawColHeader(t3lib_BEfunc::getProcessedValue('tt_content','colPos',$key), ($this->doEdit&&count($rowArr)?'&edit[tt_content]['.$editUidList.']=edit'.$pageTitleParamForAltDoc:''), $newP).
693 $theNewButton.
694 '<br /></td>
695 </tr>';
696
697 // Finally, add the content from the records in this column:
698 $out.=$rowOut;
699 }
700
701 // Finally, wrap all table rows in one, big table:
702 $out = '
703 <table border="0" cellpadding="0" cellspacing="0" width="400" class="typo3-page-columnsMode">
704 '.$out.'
705 </table>';
706
707 // CSH:
708 $out.= t3lib_BEfunc::cshItem($this->descrTable,'columns_single',$GLOBALS['BACK_PATH']);
709 } else {
710 $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/>';
711 }
712 }
713
714
715 // Add the big buttons to page:
716 if ($this->option_showBigButtons) {
717 $bArray=array();
718
719 if (!$GLOBALS['SOBE']->current_sys_language) {
720 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'));
721 } else {
722 if ($this->doEdit && $GLOBALS['BE_USER']->check('tables_modify','pages_language_overlay')) {
723 list($languageOverlayRecord) = t3lib_BEfunc::getRecordsByField('pages_language_overlay','pid',$id,'AND sys_language_uid='.intval($GLOBALS['SOBE']->current_sys_language));
724 $bArray[0]=$GLOBALS['SOBE']->doc->t3Button(t3lib_BEfunc::editOnClick('&edit[pages_language_overlay]['.$languageOverlayRecord['uid']."]=edit",$this->backPath,''),$GLOBALS['LANG']->getLL('editPageProperties_curLang'));
725 }
726 }
727 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'));
728 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'));
729 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'));
730 $out = '
731 <table border="0" cellpadding="4" cellspacing="0" class="typo3-page-buttons">
732 <tr>
733 <td>'.implode('</td>
734 <td>',$bArray).'</td>
735 </tr>
736 </table>
737 <img src="clear.gif" width="1" height="5" alt="" /><br />
738 '.t3lib_BEfunc::cshItem($this->descrTable,'button_panel',$GLOBALS['BACK_PATH']). // CSH
739 $out;
740 }
741
742 // Return content:
743 return $out;
744 }
745
746 /**
747 * Renders Frontend Users from the fe_users table from page id
748 *
749 * @param integer Page id
750 * @return string HTML for the listing
751 */
752 function getTable_fe_users($id) {
753
754 $this->addElement_tdParams=array(
755 'username'=>' nowrap="nowrap"',
756 'usergroup'=>' nowrap="nowrap"',
757 'name'=>' nowrap="nowrap"',
758 'address'=>' nowrap="nowrap"',
759 'zip'=>' nowrap="nowrap"',
760 'city'=>' nowrap="nowrap"',
761 'email'=>' nowrap="nowrap"',
762 'telephone'=>' nowrap="nowrap"'
763 );
764 $fList = 'username,usergroup,name,email,telephone,address,zip,city';
765 $out = $this->makeOrdinaryList('fe_users',$id, $fList, 1);
766 $this->addElement_tdParams=array();
767 return $out;
768 }
769
770 /**
771 * Renders records from the sys_notes table from page id
772 * NOTICE: Requires the sys_note extension to be loaded.
773 *
774 * @param integer Page id
775 * @return string HTML for the listing
776 */
777 function getTable_sys_note($id) {
778 global $TCA;
779
780 if (!t3lib_extMgm::isLoaded('sys_note')) return '';
781
782 // INIT:
783 $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
784 $tree = $this->getTreeObject($id,intval($GLOBALS['SOBE']->MOD_SETTINGS['pages_levels']),$perms_clause);
785
786 $this->itemLabels =array();
787 foreach($TCA['sys_note']['columns'] as $name => $val) {
788 $this->itemLabels[$name]=$GLOBALS['LANG']->sL($val['label']);
789 }
790
791 // If page ids were found, select all sys_notes from the page ids:
792 $out='';
793 if (count($tree->ids)) {
794 $delClause = t3lib_BEfunc::deleteClause('sys_note').t3lib_BEfunc::versioningPlaceholderClause('sys_note');
795 $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);
796 $dbCount = $GLOBALS['TYPO3_DB']->sql_num_rows($result);
797
798 // If sys_notes were found, render them:
799 if ($dbCount) {
800 $this->fieldArray = explode(',','__cmds__,info,note');
801
802 // header line is drawn
803 $theData = Array();
804 $theData['__cmds__'] ='';
805 $theData['info'] = '<b>Info</b><br /><img src="clear.gif" height="1" width="220" alt="" />';
806 $theData['note'] = '<b>Note</b>';
807 $out.=$this->addelement(1,'',$theData,' class="c-headLine"',20);
808
809 // half line is drawn
810 $theData = Array();
811 $theData['info'] = $this->widthGif;
812 $out.=$this->addelement(0,'',$theData);
813
814 $this->no_noWrap=1;
815
816 // Items
817 $this->eCounter=$this->firstElementNumber;
818 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
819 t3lib_BEfunc::workspaceOL('sys_note', $row);
820
821 if (is_array($row)) {
822 list($flag,$code) = $this->fwd_rwd_nav();
823 $out.=$code;
824 if ($flag) {
825 $color = Array (
826 0 => '', // No category
827 1 => ' class="bgColor4"', // Instructions
828 2 => ' class="bgColor2"', // Template
829 3 => '', // Notes
830 4 => ' class="bgColor5"' // To-do
831 );
832 $tdparams = $color[$row['category']];
833 $info = Array();;
834 $theData = Array();
835 $this->getProcessedValue('sys_note','subject,category,author,email,personal',$row,$info);
836 $cont=implode('<br />',$info);
837 $head = '<b>Page:</b> '.t3lib_BEfunc::getRecordPath($row['pid'],$perms_clause,10).'<br />';
838
839 $theData['__cmds__']= $this->getIcon('sys_note',$row);
840 $theData['info'] = $head.$cont;
841 $theData['note'] = nl2br($row['message']);
842
843 $out.=$this->addelement(1,'',$theData,$tdparams,20);
844
845
846 // half line is drawn
847 $theData = Array();
848 $theData['info'] = $this->widthGif;
849 $out.=$this->addelement(0,'',$theData);
850 }
851 $this->eCounter++;
852 }
853 }
854
855 // Wrap it all in a table:
856 $out='
857 <table border="0" cellpadding="1" cellspacing="2" width="480" class="typo3-page-sysnote">
858 '.$out.'
859 </table>';
860 }
861 }
862 return $out;
863 }
864
865 /**
866 * Renders records from the tt_board table from page id
867 * NOTICE: Requires the tt_board extension to be loaded.
868 *
869 * @param integer Page id
870 * @return string HTML for the listing
871 */
872 function getTable_tt_board($id) {
873
874 // Initialize:
875 $delClause = t3lib_BEfunc::deleteClause('tt_board').t3lib_BEfunc::versioningPlaceholderClause('tt_board');
876 $queryParts = $this->makeQueryArray('tt_board', $id, 'AND parent=0');
877 $this->setTotalItems($queryParts);
878 $dbCount = 0;
879
880 // If items were selected, make query:
881 if ($this->totalItems) {
882 $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
883 $dbCount = $GLOBALS['TYPO3_DB']->sql_num_rows($result);
884 }
885
886 // If results came out of that, render the list:
887 $out='';
888 if ($dbCount) {
889
890 // Setting fields to display first:
891 if ($GLOBALS['SOBE']->MOD_SETTINGS['tt_board']=='expand') {
892 $this->fieldArray = explode(',','subject,author,date,age');
893 } else {
894 $this->fieldArray = explode(',','subject,author,date,age,replys');
895 }
896
897 // Header line is drawn
898 $theData = Array();
899 $theData['subject'] = '<b>'.$GLOBALS['LANG']->getLL('tt_board_subject',1).'</b>';
900 $theData['author'] = '<b>'.$GLOBALS['LANG']->getLL('tt_board_author',1).'</b>';
901 $theData['date'] = '<b>'.$GLOBALS['LANG']->getLL('tt_board_date',1).'</b>';
902 $theData['age'] = '<b>'.$GLOBALS['LANG']->getLL('tt_board_age',1).'</b>';
903 if ($GLOBALS['SOBE']->MOD_SETTINGS['tt_board']!='expand') {
904 $theData['replys'] = '<b>'.$GLOBALS['LANG']->getLL('tt_board_RE',1).'</b>';
905 }
906 $out.=$this->addelement(1,'',$theData,' class="c-headLine"',20);
907
908 // half line is drawn
909 $theData = Array();
910 $theData['subject'] = $this->widthGif;
911 $out.=$this->addelement(0,'',$theData);
912
913 // Items
914 $this->eCounter=$this->firstElementNumber;
915 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
916 t3lib_BEfunc::workspaceOL('tt_board', $row);
917
918 if (is_array($row)) {
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
939 // Wrap it all in a table:
940 $out='
941 <table border="0" cellpadding="0" cellspacing="0" class="typo3-page-listTTboard">
942 '.$out.'
943 </table>';
944 }
945
946 return $out;
947 }
948
949 /**
950 * Renders address records from the tt_address table from page id
951 * NOTICE: Requires the tt_address extension to be loaded.
952 *
953 * @param integer Page id
954 * @return string HTML for the listing
955 */
956 function getTable_tt_address($id) {
957
958 // Define fieldlist to show:
959 switch($GLOBALS['SOBE']->MOD_SETTINGS['tt_address']) {
960 case 1:
961 $icon = 0;
962 $fList = 'name,address,zip,city,country';
963 break;
964 case 2:
965 $icon = 1;
966 $fList = 'name;title;email;company,image';
967 break;
968 default:
969 $icon = 0;
970 $fList = 'name,email,www,phone,fax,mobile';
971 break;
972 }
973
974 // Create listing
975 $out = $this->makeOrdinaryList('tt_address',$id, $fList, $icon);
976 return $out;
977 }
978
979 /**
980 * Renders link records from the tt_links table from page id
981 * NOTICE: Requires the tt_links extension to be loaded.
982 *
983 * @param integer Page id
984 * @return string HTML for the listing
985 */
986 function getTable_tt_links($id) {
987
988 // Define fieldlist to show:
989 switch($GLOBALS['SOBE']->MOD_SETTINGS['tt_links']) {
990 case 1:
991 $fList = 'title,hidden,url';
992 break;
993 case 2:
994 $fList = 'title;url,note2';
995 break;
996 default:
997 $fList = 'title;url,note';
998 break;
999 }
1000
1001 $out = $this->makeOrdinaryList('tt_links',$id, $fList,1);
1002 return $out;
1003 }
1004
1005 /**
1006 * Renders link records from the tt_links table from page id
1007 * NOTICE: Requires the tt_links extension to be loaded.
1008 *
1009 * @param integer Page id
1010 * @return string HTML for the listing
1011 */
1012 function getTable_tt_guest($id) {
1013
1014 // Define fieldlist to show:
1015 $fList = 'title;cr_name;cr_email,note';
1016 $out = $this->makeOrdinaryList('tt_guest',$id, $fList, 1);
1017 return $out;
1018 }
1019
1020 /**
1021 * Renders news items from the tt_news table from page id
1022 * NOTICE: Requires the tt_news extension to be loaded.
1023 *
1024 * @param integer Page id
1025 * @return string HTML for the listing
1026 */
1027 function getTable_tt_news($id) {
1028
1029 $this->addElement_tdParams=array(
1030 'title'=>' nowrap="nowrap"',
1031 'datetime'=>' nowrap="nowrap"',
1032 'starttime'=>' nowrap="nowrap"',
1033 'author'=>' nowrap="nowrap"'
1034 );
1035 $fList = 'title,author,author_email,datetime,starttime,category,image';
1036 $out = $this->makeOrdinaryList('tt_news',$id, $fList, 1);
1037 $this->addElement_tdParams=array();
1038 return $out;
1039 }
1040
1041 /**
1042 * Renders calender elements link records from the tt_calender table from page id
1043 * NOTICE: Requires the tt_calender extension to be loaded.
1044 *
1045 * @param integer Page id
1046 * @return string HTML for the listing
1047 */
1048 function getTable_tt_calender($id) {
1049
1050 $type=$GLOBALS['SOBE']->MOD_SETTINGS['tt_calender'];
1051 switch($type) {
1052 case 'date':
1053 // Date default
1054 $fList = 'date,title';
1055 $icon=0;
1056 $out = $this->makeOrdinaryList('tt_calender',$id, $fList, $icon, ' AND type=0');
1057 return $out;
1058 break;
1059 case 'date_ext':
1060 // Date extended
1061 $fList = 'title;date;time;datetext;link,note';
1062 $icon=1;
1063 $out = $this->makeOrdinaryList('tt_calender',$id, $fList, $icon, ' AND type=0');
1064 return $out;
1065 break;
1066 case 'todo':
1067 // Todo default
1068 $fList = 'title,complete,priority,date';
1069 $icon=0;
1070 $out = $this->makeOrdinaryList('tt_calender',$id, $fList, $icon, ' AND type=1');
1071 return $out;
1072 break;
1073 case 'todo_ext':
1074 // Todo extended
1075 $fList = 'title;complete;priority;date;workgroup;responsible;category,note';
1076 $icon=1;
1077 $out = $this->makeOrdinaryList('tt_calender',$id, $fList, $icon, ' AND type=1');
1078 return $out;
1079 break;
1080 default:
1081 // Overview, both todo and calender
1082 $fList = 'title,date,time,week';
1083 $icon=1;
1084 $out = $this->makeOrdinaryList('tt_calender',$id, $fList, $icon, ' AND type=0');
1085 $out.= $this->makeOrdinaryList('tt_calender',$id, $fList, $icon, ' AND type=1');
1086 return $out;
1087 break;
1088 }
1089 }
1090
1091 /**
1092 * Renders shopping elements from the tt_products table from page id
1093 * NOTICE: Requires the tt_products extension to be loaded.
1094 *
1095 * @param integer Page id
1096 * @return string HTML for the listing
1097 */
1098 function getTable_tt_products($id) {
1099
1100 $type = $GLOBALS['SOBE']->MOD_SETTINGS['tt_products'];
1101 switch($type) {
1102 case 'ext':
1103 $fList = 'title;itemnumber;price;price2;inStock;category,image,note';
1104 $icon=1;
1105 $out = $this->makeOrdinaryList('tt_products',$id, $fList, $icon);
1106 break;
1107 default:
1108 $fList = 'title,itemnumber,price,category,image';
1109 $icon=1;
1110 $out = $this->makeOrdinaryList('tt_products',$id, $fList, $icon);
1111 break;
1112 }
1113
1114 return $out;
1115 }
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128 /**********************************
1129 *
1130 * Generic listing of items
1131 *
1132 **********************************/
1133
1134 /**
1135 * Creates a standard list of elements from a table.
1136 *
1137 * @param string Table name
1138 * @param integer Page id.
1139 * @param string Comma list of fields to display
1140 * @param boolean If true, icon is shown
1141 * @param string Additional WHERE-clauses.
1142 * @return string HTML table
1143 */
1144 function makeOrdinaryList($table, $id, $fList, $icon=0, $addWhere='') {
1145 global $TCA;
1146
1147 // Initialize:
1148 $out = '';
1149 $queryParts = $this->makeQueryArray($table, $id, $addWhere);
1150 $this->setTotalItems($queryParts);
1151 $dbCount = 0;
1152
1153 // Make query for records if there were any records found in the count operation:
1154 if ($this->totalItems) {
1155 $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
1156 $dbCount = $GLOBALS['TYPO3_DB']->sql_num_rows($result);
1157 }
1158
1159 // If records were found, render the list:
1160 $out = '';
1161 if ($dbCount) {
1162
1163 // Set fields
1164 $this->fieldArray = explode(',','__cmds__,'.$fList);
1165
1166 // Header line is drawn
1167 $theData = array();
1168 $theData = $this->headerFields($this->fieldArray,$table,$theData);
1169 if ($this->doEdit) {
1170 $theData['__cmds__'] = '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick('&edit['.$table.']['.$this->id.']=new',$this->backPath)).'">'.
1171 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/new_el.gif').' title="'.$GLOBALS['LANG']->getLL('new',1).'" alt="" />'.
1172 '</a>';
1173 }
1174 $out.= $this->addelement(1,'',$theData,' class="c-headLine"',15);
1175
1176 // Render Items
1177 $this->eCounter = $this->firstElementNumber;
1178 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
1179 t3lib_BEfunc::workspaceOL($table, $row);
1180
1181 if (is_array($row)) {
1182 list($flag,$code) = $this->fwd_rwd_nav();
1183 $out.= $code;
1184 if ($flag) {
1185 $params = '&edit['.$table.']['.$row['uid'].']=edit';
1186 $Nrow = array();
1187
1188 // Setting icons/edit links:
1189 if ($icon) {
1190 $Nrow['__cmds__']= $this->getIcon($table,$row);
1191 }
1192 if ($this->doEdit) {
1193 $Nrow['__cmds__'].= '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath)).'">'.
1194 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2.gif','width="11" height="12"').' title="'.$GLOBALS['LANG']->getLL('edit',1).'" alt="" />'.
1195 '</a>';
1196 } else {
1197 $Nrow['__cmds__'].= $this->noEditIcon();
1198 }
1199
1200 // Get values:
1201 $Nrow = $this->dataFields($this->fieldArray,$table,$row,$Nrow);
1202 $tdparams = $this->eCounter%2 ? ' class="bgColor4"' : ' class="bgColor4-20"';
1203 $out.= $this->addelement(1,'',$Nrow,$tdparams);
1204 }
1205 $this->eCounter++;
1206 }
1207 }
1208
1209 // Wrap it all in a table:
1210 $out='
1211
1212 <!--
1213 STANDARD LIST OF "'.$table.'"
1214 -->
1215 <table border="0" cellpadding="1" cellspacing="2" width="480" class="typo3-page-stdlist">
1216 '.$out.'
1217 </table>';
1218 }
1219 return $out;
1220 }
1221
1222 /**
1223 * Adds content to all data fields in $out array
1224 *
1225 * @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.
1226 * @param string Table name
1227 * @param array Record array
1228 * @param array Array to which the data is added
1229 * @return array $out array returned after processing.
1230 * @see makeOrdinaryList()
1231 */
1232 function dataFields($fieldArr,$table,$row,$out=array()) {
1233 global $TCA;
1234
1235 // Check table validity:
1236 if ($TCA[$table]) {
1237 t3lib_div::loadTCA($table);
1238 $thumbsCol = $TCA[$table]['ctrl']['thumbnail'];
1239
1240 // Traverse fields:
1241 foreach($fieldArr as $fieldName) {
1242
1243 if ($TCA[$table]['columns'][$fieldName]) { // Each field has its own cell (if configured in TCA)
1244 if ($fieldName==$thumbsCol) { // If the column is a thumbnail column:
1245 $out[$fieldName] = $this->thumbCode($row,$table,$fieldName);
1246 } else { // ... otherwise just render the output:
1247 $out[$fieldName] = nl2br(htmlspecialchars(trim(t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getProcessedValue($table,$fieldName,$row[$fieldName],0,0,0,$row['uid']),250))));
1248 }
1249 } 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)
1250 $theFields = explode(';',$fieldName);
1251
1252 // Traverse fields, separated by ";" (displayed in a single cell).
1253 foreach($theFields as $fName2) {
1254 if ($TCA[$table]['columns'][$fName2]) {
1255 $out[$fieldName].= '<b>'.$GLOBALS['LANG']->sL($TCA[$table]['columns'][$fName2]['label'],1).'</b>'.
1256 '&nbsp;&nbsp;'.
1257 htmlspecialchars(t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getProcessedValue($table,$fName2,$row[$fName2],0,0,0,$row['uid']),25)).
1258 '<br />';
1259 }
1260 }
1261 }
1262 // If no value, add a nbsp.
1263 if (!$out[$fieldName]) $out[$fieldName]='&nbsp;';
1264
1265 // Wrap in dimmed-span tags if record is "disabled"
1266 if ($this->isDisabled($table,$row)) {
1267 $out[$fieldName] = $GLOBALS['TBE_TEMPLATE']->dfw($out[$fieldName]);
1268 }
1269 }
1270 }
1271 return $out;
1272 }
1273
1274 /**
1275 * Header fields made for the listing of records
1276 *
1277 * @param array Field names
1278 * @param string The table name
1279 * @param array Array to which the headers are added.
1280 * @return array $out returned after addition of the header fields.
1281 * @see makeOrdinaryList()
1282 */
1283 function headerFields($fieldArr,$table,$out=array()) {
1284 global $TCA;
1285
1286 t3lib_div::loadTCA($table);
1287
1288 foreach($fieldArr as $fieldName) {
1289 $ll = $GLOBALS['LANG']->sL($TCA[$table]['columns'][$fieldName]['label'],1);
1290 $out[$fieldName] = '<b>'.($ll?$ll:'&nbsp;').'</b>';
1291 }
1292 return $out;
1293 }
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309 /**********************************
1310 *
1311 * Additional functions; Pages
1312 *
1313 **********************************/
1314
1315 /**
1316 * Adds pages-rows to an array, selecting recursively in the page tree.
1317 *
1318 * @param array Array which will accumulate page rows
1319 * @param integer Pid to select from
1320 * @param string Query-where clause
1321 * @param string Prefixed icon code.
1322 * @param integer Depth (decreasing)
1323 * @return array $theRows, but with added rows.
1324 */
1325 function pages_getTree($theRows,$pid,$qWhere,$treeIcons,$depth) {
1326 $depth--;
1327 if ($depth>=0) {
1328 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'pages', 'pid='.intval($pid).$qWhere, '', 'sorting');
1329 $c=0;
1330 $rc = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
1331 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1332 t3lib_BEfunc::workspaceOL('pages', $row);
1333 if (is_array($row)) {
1334 $c++;
1335 $row['treeIcons'] = $treeIcons.'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/join'.($rc==$c?'bottom':'').'.gif','width="18" height="16"').' alt="" />';
1336 $theRows[]=$row;
1337
1338 // Get the branch
1339 $spaceOutIcons = '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/'.($rc==$c?'blank.gif':'line.gif'),'width="18" height="16"').' alt="" />';
1340 $theRows = $this->pages_getTree($theRows,$row['uid'],$qWhere,$treeIcons.$spaceOutIcons,$row['php_tree_stop']?0:$depth);
1341 }
1342 }
1343 } else {
1344 $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('uid', 'pages', 'pid=' . intval($pid) . $qWhere);
1345 if ($count) {
1346 $this->plusPages[$pid] = $count;
1347 }
1348 }
1349 return $theRows;
1350 }
1351
1352 /**
1353 * Adds a list item for the pages-rendering
1354 *
1355 * @param array Record array
1356 * @param array Field list
1357 * @return string HTML for the item
1358 */
1359 function pages_drawItem($row,$fieldArr) {
1360 global $TCA;
1361
1362 // Initialization
1363 $theIcon=$this->getIcon('pages',$row);
1364
1365 // Preparing and getting the data-array
1366 $theData = Array();
1367 foreach($fieldArr as $field) {
1368 switch($field) {
1369 case 'title':
1370 $red = $this->plusPages[$row['uid']] ? '<font color="red"><b>+&nbsp;</b></font>' : '';
1371 $pTitle = htmlspecialchars(t3lib_BEfunc::getProcessedValue('pages',$field,$row[$field],20));
1372 if ($red) {
1373 $pTitle = '<a href="'.htmlspecialchars($this->script.'?id='.$row['uid']).'">'.$pTitle.'</a>';
1374 }
1375 $theData[$field]=$row['treeIcons'].$theIcon.$red.$pTitle.'&nbsp;&nbsp;';
1376 break;
1377 case 'php_tree_stop':
1378 case 'TSconfig':
1379 $theData[$field] = $row[$field]?'&nbsp;<b>x</b>':'&nbsp;';
1380 break;
1381 case 'uid':
1382 if ($GLOBALS['BE_USER']->doesUserHaveAccess($row,2)) {
1383 $params='&edit[pages]['.$row['uid'].']=edit';
1384 $eI= '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,'')).'">'.
1385 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2.gif','width="11" height="12"').' title="'.$GLOBALS['LANG']->getLL('editThisPage',1).'" alt="" />'.
1386 '</a>';
1387 } else $eI='';
1388 $theData[$field] = '<span align="right">'.$row['uid'].$eI.'</span>';
1389 break;
1390 default:
1391 if (substr($field,0,6)=='table_') {
1392 $f2 = substr($field,6);
1393 if ($TCA[$f2]) {
1394 $c = $this->numberOfRecords($f2,$row['uid']);
1395 $theData[$field] = '&nbsp;&nbsp;'.($c?$c:'');
1396 }
1397 } elseif (substr($field,0,5)=='HITS_') {
1398 if (t3lib_extMgm::isLoaded('sys_stat')) {
1399 $fParts = explode(':',substr($field,5));
1400 switch($fParts[0]) {
1401 case 'days':
1402 $timespan = mktime (0,0,0)+intval($fParts[1])*3600*24;
1403 // Page hits
1404 $number = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
1405 '*',
1406 'sys_stat',
1407 $this->stat_select_field . '=' . intval($row['uid']) .
1408 ' AND tstamp >=' . intval($timespan) .
1409 ' AND tstamp <' . intval($timespan + 3600 * 24)
1410 );
1411 if ($number) {
1412 // Sessions
1413 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1414 'count(*)',
1415 'sys_stat',
1416 $this->stat_select_field.'='.intval($row['uid']).'
1417 AND tstamp>='.intval($timespan).'
1418 AND tstamp<'.intval($timespan+3600*24).'
1419 AND surecookie!=""',
1420 'surecookie'
1421 );
1422 $scnumber = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
1423
1424 $number.= '/'.$scnumber;
1425 } else {
1426 $number='';
1427 }
1428 break;
1429 }
1430 $theData[$field]= '&nbsp;'.$number;
1431 } else {
1432 $theData[$field]= '&nbsp;';
1433 }
1434 } else {
1435 $theData[$field]= '&nbsp;&nbsp;'.htmlspecialchars(t3lib_BEfunc::getProcessedValue('pages',$field,$row[$field]));
1436 }
1437 break;
1438 }
1439 }
1440 $this->addElement_tdParams['title'] = ($row['_CSSCLASS'] ? ' class="'.$row['_CSSCLASS'].'"' : '');
1441 return $this->addelement(1,'',$theData);
1442 }
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455 /**********************************
1456 *
1457 * Additional functions; Content Elements
1458 *
1459 **********************************/
1460
1461 /**
1462 * Draw header for a content element column:
1463 *
1464 * @param string Column name
1465 * @param string Edit params (Syntax: &edit[...] for alt_doc.php)
1466 * @param string New element params (Syntax: &edit[...] for alt_doc.php)
1467 * @return string HTML table
1468 */
1469 function tt_content_drawColHeader($colName,$editParams,$newParams) {
1470
1471 // Create header row:
1472 $out = '
1473 <tr>
1474 <td class="bgColor2" nowrap="nowrap"><img src="clear.gif" width="1" height="2" alt="" /><br /><div align="center"><b>' . htmlspecialchars($GLOBALS['LANG']->csConvObj->conv_case($GLOBALS['LANG']->charSet, $colName, 'toUpper')) . '</b></div><img src="clear.gif" width="1" height="2" alt="" /></td>
1475 </tr>';
1476
1477 // Create command links:
1478 if ($this->tt_contentConfig['showCommands']) {
1479 // Start cell:
1480 $out.= '
1481 <tr>
1482 <td class="bgColor5">';
1483
1484 // Edit whole of column:
1485 if ($editParams) {
1486 $out.='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($editParams,$this->backPath)).'">'.
1487 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2.gif','width="11" height="12"').' title="'.$GLOBALS['LANG']->getLL('editColumn',1).'" alt="" />'.
1488 '</a>';
1489 }
1490 // New record:
1491 if ($newParams) {
1492 $out.='<a href="#" onclick="'.htmlspecialchars($newParams).'">'.
1493 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/new_record.gif','width="16" height="12"').' title="'.$GLOBALS['LANG']->getLL('newInColumn',1).'" alt="" />'.
1494 '</a>';
1495 }
1496 // End cell:
1497 $out.= '
1498 </td>
1499 </tr>';
1500 }
1501
1502 // Wrap and return:
1503 return '
1504 <table border="0" cellpadding="0" cellspacing="0" width="100%" class="typo3-page-colHeader">'.($space?'
1505 <tr>
1506 <td><img src="clear.gif" height="'.$space.'" alt="" /></td>
1507 </tr>':'').
1508 $out.'
1509 </table>';
1510 }
1511
1512 /**
1513 * Draw the header for a single tt_content element
1514 *
1515 * @param array Record array
1516 * @param integer Amount of pixel space above the header.
1517 * @param boolean If set the buttons for creating new elements and moving up and down are not shown.
1518 * @param boolean If set, we are in language mode and flags will be shown for languages
1519 * @return string HTML table with the record header.
1520 */
1521 function tt_content_drawHeader($row,$space=0,$disableMoveAndNewButtons=FALSE,$langMode=FALSE) {
1522 global $TCA;
1523
1524 // Load full table description:
1525 t3lib_div::loadTCA('tt_content');
1526
1527 // Get record locking status:
1528 if ($lockInfo=t3lib_BEfunc::isRecordLocked('tt_content',$row['uid'])) {
1529 $lockIcon='<a href="#" onclick="'.htmlspecialchars('alert('.$GLOBALS['LANG']->JScharCode($lockInfo['msg']).');return false;').'">'.
1530 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/recordlock_warning3.gif','width="17" height="12"').' title="'.htmlspecialchars($lockInfo['msg']).'" alt="" />'.
1531 '</a>';
1532 } else $lockIcon='';
1533
1534 // Call stats information hook
1535 $stat = '';
1536 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'])) {
1537 $_params = array('tt_content', $row['uid'], &$row);
1538 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'] as $_funcRef) {
1539 $stat.=t3lib_div::callUserFunction($_funcRef,$_params,$this);
1540 }
1541 }
1542
1543 // Create header with icon/lock-icon/title:
1544 $header = $this->getIcon('tt_content',$row).
1545 $lockIcon.
1546 $stat.
1547 ($langMode ? $this->languageFlag($row['sys_language_uid']) : '').
1548 '&nbsp;<b>'.htmlspecialchars($this->CType_labels[$row['CType']]).'</b>';
1549 $out = '
1550 <tr>
1551 <td class="bgColor4">'.$header.'</td>
1552 </tr>';
1553
1554 // If show info is set...;
1555 if ($this->tt_contentConfig['showInfo']) {
1556
1557 // Get processed values:
1558 $info = Array();
1559 $this->getProcessedValue('tt_content','hidden,starttime,endtime,fe_group,spaceBefore,spaceAfter,section_frame,sectionIndex,linkToTop',$row,$info);
1560
1561 // Render control panel for the element:
1562 if ($this->tt_contentConfig['showCommands'] && $this->doEdit) {
1563
1564 // Start control cell:
1565 $out.= '
1566 <!-- Control Panel -->
1567 <tr>
1568 <td class="bgColor5">';
1569
1570 // Edit content element:
1571 $params='&edit[tt_content]['.$this->tt_contentData['nextThree'][$row['uid']].']=edit';
1572 $out.='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath)).'">'.
1573 '<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="" />'.
1574 '</a>';
1575
1576 if (!$disableMoveAndNewButtons) {
1577 // New content element:
1578 if ($this->option_newWizard) {
1579 $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'))."';";
1580 } else {
1581 $params='&edit[tt_content]['.(-$row['uid']).']=new';
1582 $onClick = t3lib_BEfunc::editOnClick($params,$this->backPath);
1583 }
1584 $out.='<a href="#" onclick="'.htmlspecialchars($onClick).'">'.
1585 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/new_record.gif','width="16" height="12"').' title="'.$GLOBALS['LANG']->getLL('newAfter',1).'" alt="" />'.
1586 '</a>';
1587
1588 // Move element up:
1589 if ($this->tt_contentData['prev'][$row['uid']]) {
1590 $params='&cmd[tt_content]['.$row['uid'].'][move]='.$this->tt_contentData['prev'][$row['uid']];
1591 $out.='<a href="'.htmlspecialchars($GLOBALS['SOBE']->doc->issueCommand($params)).'">'.
1592 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_up.gif','width="11" height="10"').' title="'.$GLOBALS['LANG']->getLL('moveUp',1).'" alt="" />'.
1593 '</a>';
1594 } else {
1595 $out.='<img src="clear.gif" '.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_up.gif','width="11" height="10"',2).' alt="" />';
1596 }
1597 // Move element down:
1598 if ($this->tt_contentData['next'][$row['uid']]) {
1599 $params='&cmd[tt_content]['.$row['uid'].'][move]='.$this->tt_contentData['next'][$row['uid']];
1600 $out.='<a href="'.htmlspecialchars($GLOBALS['SOBE']->doc->issueCommand($params)).'">'.
1601 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_down.gif','width="11" height="10"').' title="'.$GLOBALS['LANG']->getLL('moveDown',1).'" alt="" />'.
1602 '</a>';
1603 } else {
1604 $out.='<img src="clear.gif" '.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_down.gif','width="11" height="10"',2).' alt="" />';
1605 }
1606 }
1607
1608 // Hide element:
1609 $hiddenField = $TCA['tt_content']['ctrl']['enablecolumns']['disabled'];
1610 if ($hiddenField && $TCA['tt_content']['columns'][$hiddenField] && (!$TCA['tt_content']['columns'][$hiddenField]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields','tt_content:'.$hiddenField))) {
1611 if ($row[$hiddenField]) {
1612 $params='&data[tt_content]['.($row['_ORIG_uid'] ? $row['_ORIG_uid'] : $row['uid']).']['.$hiddenField.']=0';
1613 $out.='<a href="'.htmlspecialchars($GLOBALS['SOBE']->doc->issueCommand($params)).'">'.
1614 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_unhide.gif','width="11" height="10"').' title="'.$GLOBALS['LANG']->getLL('unHide',1).'" alt="" />'.
1615 '</a>';
1616 } else {
1617 $params='&data[tt_content]['.($row['_ORIG_uid'] ? $row['_ORIG_uid'] : $row['uid']).']['.$hiddenField.']=1';
1618 $out.='<a href="'.htmlspecialchars($GLOBALS['SOBE']->doc->issueCommand($params)).'">'.
1619 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_hide.gif','width="11" height="10"').' title="'.$GLOBALS['LANG']->getLL('hide',1).'" alt="" />'.
1620 '</a>';
1621 }
1622 }
1623
1624 // Delete
1625 $params='&cmd[tt_content]['.$row['uid'].'][delete]=1';
1626 $out.='<a href="'.htmlspecialchars($GLOBALS['SOBE']->doc->issueCommand($params)).'" onclick="'.htmlspecialchars('return confirm('.$GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->getLL('deleteWarning')).');').'">'.
1627 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/garbage.gif','width="11" height="12"').' title="'.$GLOBALS['LANG']->getLL('deleteItem',1).'" alt="" />'.
1628 '</a>';
1629
1630 // End cell:
1631 $out.= '
1632 </td>
1633 </tr>';
1634 }
1635
1636 // Display info from records fields:
1637 if (count($info)) {
1638 $out.= '
1639 <tr>
1640 <td class="bgColor4-20">'.implode('<br />',$info).'</td>
1641 </tr>';
1642 }
1643 }
1644 // Wrap the whole header in a table:
1645 return '
1646 <table border="0" cellpadding="0" cellspacing="0" class="typo3-page-ceHeader">'.($space?'
1647 <tr>
1648 <td><img src="clear.gif" height="'.$space.'" alt="" /></td>
1649 </tr>':'').
1650 $out.'
1651 </table>';
1652 }
1653
1654 /**
1655 * Draws the preview content for a content element
1656 *
1657 * @param string Content element
1658 * @param boolean Set if the RTE link can be created.
1659 * @return string HTML
1660 */
1661 function tt_content_drawItem($row, $isRTE=FALSE) {
1662 global $TCA;
1663
1664 $out='';
1665 $outHeader='';
1666
1667 // Make header:
1668 if ($row['header']) {
1669 $infoArr = Array();
1670 $this->getProcessedValue('tt_content','header_position,header_layout,header_link',$row,$infoArr);
1671
1672 // If header layout is set to 'hidden', display an accordant note:
1673 if ($row['header_layout'] == 100) {
1674 $hiddenHeaderNote = ' <em>[' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.hidden', true) . ']</em>';
1675 }
1676 $outHeader= ($row['date'] ? htmlspecialchars($this->itemLabels['date'].' '.t3lib_BEfunc::date($row['date'])).'<br />':'').
1677 $this->infoGif($infoArr).
1678 '<b>' . $this->linkEditContent($this->renderText($row['header']), $row) . $hiddenHeaderNote . '</b><br />';
1679 }
1680
1681 // Make content:
1682 $infoArr = array();
1683 $drawItem = true;
1684
1685 // Hook: Render an own preview of a record
1686 $drawItemHooks =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem'];
1687
1688 if (is_array($drawItemHooks)) {
1689 foreach($drawItemHooks as $hookClass) {
1690 $hookObject = &t3lib_div::getUserObj($hookClass);
1691
1692 if(!($hookObject instanceof tx_cms_layout_tt_content_drawItemHook)) {
1693 throw new UnexpectedValueException('$hookObject must implement interface tx_cms_layout_tt_content_drawItemHook', 1218547409);
1694 }
1695
1696 $hookObject->preProcess($this, $drawItem, $outHeader, $out, $row);
1697 }
1698 }
1699
1700 // Draw preview of the item depending on its CType (if not disabled by previous hook):
1701 if ($drawItem) {
1702 switch($row['CType']) {
1703 case 'header':
1704 if ($row['subheader']) {
1705 $this->getProcessedValue('tt_content','layout',$row,$infoArr);
1706 $out.= $this->infoGif($infoArr).
1707 $this->linkEditContent($this->renderText($row['subheader']),$row).'<br />';
1708 }
1709 break;
1710 case 'text':
1711 case 'textpic':
1712 case 'image':
1713 if ($row['CType']=='text' || $row['CType']=='textpic') {
1714 if ($row['bodytext']) {
1715 $this->getProcessedValue('tt_content','text_align,text_face,text_size,text_color,text_properties',$row,$infoArr);
1716 $out.= $this->infoGif($infoArr).
1717 $this->linkEditContent($this->renderText($row['bodytext']),$row).'<br />';
1718 }
1719 }
1720 if ($row['CType']=='textpic' || $row['CType']=='image') {
1721 if ($row['image']) {
1722 $infoArr=Array();
1723 $this->getProcessedValue('tt_content','imageorient,imagecols,image_noRows,imageborder,imageheight,image_link,image_zoom,image_compression,image_effects,image_frames',$row,$infoArr);
1724 $out.= $this->infoGif($infoArr).
1725 $this->thumbCode($row,'tt_content','image').'<br />';
1726
1727 if ($row['imagecaption']) {
1728 $infoArr=Array();
1729 $this->getProcessedValue('tt_content','imagecaption_position',$row,$infoArr);
1730 $out.= $this->infoGif($infoArr).
1731 $this->linkEditContent($this->renderText($row['imagecaption']),$row).'<br />';
1732 }
1733 }
1734 }
1735 break;
1736 case 'bullets':
1737 if ($row['bodytext']) {
1738 $this->getProcessedValue('tt_content','layout,text_align,text_face,text_size,text_color,text_properties',$row,$infoArr);
1739 $out.= $this->infoGif($infoArr).
1740 $this->linkEditContent($this->renderText($row['bodytext']),$row).'<br />';
1741 }
1742 break;
1743 case 'table':
1744 if ($row['bodytext']) {
1745 $this->getProcessedValue('tt_content','table_bgColor,table_border,table_cellspacing,cols,layout,text_align,text_face,text_size,text_color,text_properties',$row,$infoArr);
1746 $out.= $this->infoGif($infoArr).
1747 $this->linkEditContent($this->renderText($row['bodytext']),$row).'<br />';
1748 }
1749 break;
1750 case 'uploads':
1751 if ($row['media']) {
1752 $this->getProcessedValue('tt_content','media,select_key,layout,filelink_size,table_bgColor,table_border,table_cellspacing',$row,$infoArr);
1753 $out.= $this->infoGif($infoArr).
1754 $this->linkEditContent($this->renderText($row['bodytext']),$row).'<br />';
1755 }
1756 break;
1757 case 'multimedia':
1758 if ($row['multimedia']) {
1759 $out.= $this->renderText($row['multimedia']).'<br />';
1760 $out.= $this->renderText($row['parameters']).'<br />';
1761 }
1762 break;
1763 case 'mailform':
1764 if ($row['bodytext']) {
1765 $this->getProcessedValue('tt_content','pages,subheader',$row,$infoArr);
1766 $out.= $this->infoGif($infoArr).
1767 $this->linkEditContent($this->renderText($row['bodytext']),$row).'<br />';
1768 }
1769 break;
1770 case 'splash':
1771 if ($row['bodytext']) {
1772 $out.= $this->linkEditContent($this->renderText($row['bodytext']),$row).'<br />';
1773 }
1774 if ($row['image']) {
1775 $infoArr=Array();
1776 $this->getProcessedValue('tt_content','imagewidth',$row,$infoArr);
1777 $out.= $this->infoGif($infoArr).
1778 $this->thumbCode($row,'tt_content','image').'<br />';
1779 }
1780 break;
1781 case 'menu':
1782 if ($row['pages']) {
1783 $this->getProcessedValue('tt_content','menu_type',$row,$infoArr);
1784 $out.= $this->infoGif($infoArr).
1785 $this->linkEditContent($row['pages'],$row).'<br />';
1786 }
1787 break;
1788 case 'shortcut':
1789 if ($row['records']) {
1790 $this->getProcessedValue('tt_content','layout',$row,$infoArr);
1791 $out.= $this->infoGif($infoArr).
1792 $this->linkEditContent($row['shortcut'],$row).'<br />';
1793 }
1794 break;
1795 case 'list':
1796 $this->getProcessedValue('tt_content','layout',$row,$infoArr);
1797 $out.= $this->infoGif($infoArr).
1798 $GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel('tt_content','list_type'),1).' '.
1799 $GLOBALS['LANG']->sL(t3lib_BEfunc::getLabelFromItemlist('tt_content','list_type',$row['list_type']),1).'<br />';
1800 $hookArr = array();
1801 $hookOut = '';
1802 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info'][$row['list_type']])) {
1803 $hookArr = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info'][$row['list_type']];
1804 } elseif (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info']['_DEFAULT'])) {
1805 $hookArr = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info']['_DEFAULT'];
1806 }
1807 if (count($hookArr) > 0) {
1808 $_params = array('pObj' => &$this, 'row' => $row, 'infoArr' => $infoArr);
1809 foreach ($hookArr as $_funcRef) {
1810 $hookOut .= t3lib_div::callUserFunction($_funcRef, $_params, $this);
1811 }
1812 }
1813 if (strcmp($hookOut, '')) {
1814 $out .= $hookOut;
1815 } else {
1816 $out.= $GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel('tt_content','select_key'),1).' '.$row['select_key'].'<br />';
1817 }
1818
1819 $infoArr=Array();
1820 $this->getProcessedValue('tt_content','recursive',$row,$infoArr);
1821 $out.= $this->infoGif($infoArr).
1822 $GLOBALS['LANG']->sL(t3lib_BEfunc::getLabelFromItemlist('tt_content','pages',$row['pages']),1).'<br />';
1823 break;
1824 case 'script':
1825 $out.= $GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel('tt_content','select_key'),1).' '.$row['select_key'].'<br />';
1826 $out.= '<br />'.$this->linkEditContent($this->renderText($row['bodytext']),$row).'<br />';
1827 $out.= '<br />'.$this->linkEditContent($this->renderText($row['imagecaption']),$row).'<br />';
1828 break;
1829 default:
1830 if ($row['bodytext']) {
1831 $out.=$this->linkEditContent($this->renderText($row['bodytext']),$row).'<br />';
1832 }
1833 break;
1834 }
1835 }
1836
1837 // Wrap span-tags:
1838 $out = '
1839 <span class="exampleContent">'.$out.'</span>';
1840 // Add header:
1841 $out = $outHeader.$out;
1842 // Add RTE button:
1843 if ($isRTE) {
1844 $out.= $this->linkRTEbutton($row);
1845 }
1846
1847 // Return values:
1848 if ($this->isDisabled('tt_content',$row)) {
1849 return $GLOBALS['TBE_TEMPLATE']->dfw($out);
1850 } else {
1851 return $out;
1852 }
1853 }
1854
1855 /**
1856 * Filters out all tt_content uids which are already translated so only non-translated uids is left.
1857 * 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 (?)
1858 *
1859 * @param array Numeric array with uids of tt_content elements in the default language
1860 * @param integer Page pid
1861 * @param integer Sys language UID
1862 * @return array Modified $defLanguageCount
1863 */
1864 function getNonTranslatedTTcontentUids($defLanguageCount,$id,$lP) {
1865 if ($lP && count($defLanguageCount)) {
1866
1867 // Select all translations here:
1868 $queryParts = $this->makeQueryArray('tt_content', $id, 'AND sys_language_uid='.intval($lP).' AND l18n_parent IN ('.implode(',',$defLanguageCount).')');
1869 $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
1870
1871 // Flip uids:
1872 $defLanguageCount = array_flip($defLanguageCount);
1873
1874 // Traverse any selected elements and unset original UID if any:
1875 $rowArr = $this->getResult($result);
1876 foreach($rowArr as $row) {
1877 unset($defLanguageCount[$row['l18n_parent']]);
1878 }
1879
1880 // Flip again:
1881 $defLanguageCount = array_keys($defLanguageCount);
1882 }
1883
1884 return $defLanguageCount;
1885 }
1886
1887 /**
1888 * Creates button which is used to create copies of records..
1889 *
1890 * @param array Numeric array with uids of tt_content elements in the default language
1891 * @param integer Sys language UID
1892 * @return string "Copy languages" button, if available.
1893 */
1894 function newLanguageButton($defLanguageCount,$lP) {
1895 if ($this->doEdit && count($defLanguageCount) && $lP) {
1896
1897 $params = '';
1898 foreach($defLanguageCount as $uidVal) {
1899 $params.='&cmd[tt_content]['.$uidVal.'][localize]='.$lP;
1900 }
1901
1902 // Copy for language:
1903 $onClick = "window.location.href='".$GLOBALS['SOBE']->doc->issueCommand($params)."'; return false;";
1904 $theNewButton = $GLOBALS['SOBE']->doc->t3Button($onClick,$GLOBALS['LANG']->getLL('newPageContent_copyForLang').' ['.count($defLanguageCount).']');
1905 return $theNewButton;
1906 }
1907 }
1908
1909 /**
1910 * Returns an icon, which has its title attribute set to a massive amount of information about the element.
1911 *
1912 * @param array Array where values are human readable output of field values (not htmlspecialchars()'ed though). The values are imploded by a linebreak.
1913 * @return string HTML img tag if applicable.
1914 */
1915 function infoGif($infoArr) {
1916 if (count($infoArr) && $this->tt_contentConfig['showInfo']) {
1917 $out='<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/zoom2.gif','width="12" height="12"').' title="'.htmlspecialchars(implode(chr(10),$infoArr)).'" alt="" /> ';
1918 return $out;
1919 }
1920 }
1921
1922 /**
1923 * Creates onclick-attribute content for a new content element
1924 *
1925 * @param integer Page id where to create the element.
1926 * @param integer Preset: Column position value
1927 * @param integer Preset: Sys langauge value
1928 * @return string String for onclick attribute.
1929 * @see getTable_tt_content()
1930 */
1931 function newContentElementOnClick($id,$colPos,$sys_language) {
1932 if ($this->option_newWizard) {
1933 $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'))."';";
1934 } else {
1935 $onClick=t3lib_BEfunc::editOnClick('&edit[tt_content]['.$id.']=new&defVals[tt_content][colPos]='.$colPos.'&defVals[tt_content][sys_language_uid]='.$sys_language,$this->backPath);
1936 }
1937 return $onClick;
1938 }
1939
1940 /**
1941 * Will create a link on the input string and possible a big button after the string which links to editing in the RTE
1942 * Used for content element content displayed so the user can click the content / "Edit in Rich Text Editor" button
1943 *
1944 * @param string String to link. Must be prepared for HTML output.
1945 * @param array The row.
1946 * @return string If the whole thing was editable ($this->doEdit) $str is return with link around. Otherwise just $str.
1947 * @see getTable_tt_content()
1948 */
1949 function linkEditContent($str,$row) {
1950 $addButton='';
1951 $onClick = '';
1952
1953 if ($this->doEdit) {
1954 // Setting onclick action for content link:
1955 $onClick=t3lib_BEfunc::editOnClick('&edit[tt_content]['.$row['uid'].']=edit',$this->backPath);
1956 }
1957 // Return link
1958 return $onClick ? '<a href="#" onclick="'.htmlspecialchars($onClick).'" title="'.$GLOBALS['LANG']->getLL('edit',1).'">'.$str.'</a>'.$addButton : $str;
1959 }
1960
1961 /**
1962 * Adds a button to edit the row in RTE wizard
1963 *
1964 * @param array The row of tt_content element
1965 * @return string Button to click if you want to edit in RTE wizard.
1966 */
1967 function linkRTEbutton($row) {
1968 $params = array();
1969 $params['table'] = 'tt_content';
1970 $params['uid'] = $row['uid'];
1971 $params['pid'] = $row['pid'];
1972 $params['field'] = 'bodytext';
1973 $params['returnUrl'] = t3lib_div::linkThisScript();
1974 $RTEonClick = "window.location.href='".$this->backPath."wizard_rte.php?".t3lib_div::implodeArrayForUrl('',array('P'=>$params))."';return false;";
1975 $addButton = $this->option_showBigButtons && $this->doEdit ? $GLOBALS['SOBE']->doc->t3Button($RTEonClick,$GLOBALS['LANG']->getLL('editInRTE')) : '';
1976
1977 return $addButton;
1978 }
1979
1980 /**
1981 * Make selector box for creating new translation in a language
1982 * Displays only languages which are not yet present for the current page and
1983 * that are not disabled with page TS.
1984 *
1985 * @param integer Page id for which to create a new language (pages_language_overlay record)
1986 * @return string <select> HTML element (if there were items for the box anyways...)
1987 * @see getTable_tt_content()
1988 */
1989 function languageSelector($id) {
1990 if ($GLOBALS['BE_USER']->check('tables_modify','pages_language_overlay')) {
1991
1992 // First, select all
1993 $res = $GLOBALS['SOBE']->exec_languageQuery(0);
1994 $langSelItems=array();
1995 $langSelItems[0]='
1996 <option value="0"></option>';
1997 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1998 if ($GLOBALS['BE_USER']->checkLanguageAccess($row['uid'])) {
1999 $langSelItems[$row['uid']]='
2000 <option value="'.$row['uid'].'">'.htmlspecialchars($row['title']).'</option>';
2001 }
2002 }
2003
2004 // Then, subtract the languages which are already on the page:
2005 $res = $GLOBALS['SOBE']->exec_languageQuery($id);
2006 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
2007 unset($langSelItems[$row['uid']]);
2008 }
2009 // Remove disallowed languages
2010 if (count($langSelItems) > 1 &&
2011 !$GLOBALS['BE_USER']->user['admin'] &&
2012 strlen($GLOBALS['BE_USER']->groupData['allowed_languages'])) {
2013
2014 $allowed_languages = array_flip(explode(',', $GLOBALS['BE_USER']->groupData['allowed_languages']));
2015
2016 if (count($allowed_languages)) {
2017 foreach($langSelItems as $key => $value) {
2018 if (!isset($allowed_languages[$key]) && $key != 0) {
2019 unset($langSelItems[$key]);
2020 }
2021 }
2022 }
2023 }
2024 // Remove disabled languages
2025 $modSharedTSconfig = t3lib_BEfunc::getModTSconfig($id, 'mod.SHARED');
2026 $disableLanguages = isset($modSharedTSconfig['properties']['disableLanguages']) ? t3lib_div::trimExplode(',', $modSharedTSconfig['properties']['disableLanguages'], 1) : array();
2027 if (count($langSelItems) && count($disableLanguages)) {
2028 foreach ($disableLanguages as $language) {
2029 if ($language != 0 && isset($langSelItems[$language])) {
2030 unset($langSelItems[$language]);
2031 }
2032 }
2033 }
2034
2035 // If any languages are left, make selector:
2036 if (count($langSelItems)>1) {
2037 $onChangeContent = 'window.location.href=\''.$this->backPath.'alt_doc.php?&edit[pages_language_overlay]['.$id.']=new&overrideVals[pages_language_overlay][doktype]=' . (int) $this->pageRecord['doktype'] . '&overrideVals[pages_language_overlay][sys_language_uid]=\'+this.options[this.selectedIndex].value+\'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')).'\'';
2038 return $GLOBALS['LANG']->getLL('new_language',1).': <select name="createNewLanguage" onchange="'.htmlspecialchars($onChangeContent).'">
2039 '.implode('',$langSelItems).'
2040 </select><br /><br />';
2041 }
2042 }
2043 }
2044
2045 /**
2046 * Traverse the result pointer given, adding each record to array and setting some internal values at the same time.
2047 *
2048 * @param pointer SQL result pointer for select query.
2049 * @param string Table name defaulting to tt_content
2050 * @return array The selected rows returned in this array.
2051 */
2052 function getResult($result,$table='tt_content') {
2053
2054 // Initialize:
2055 $editUidList='';
2056 $recs=Array();
2057 $nextTree = $this->nextThree;
2058 $c=0;
2059 $output=Array();
2060
2061 // Traverse the result:
2062 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
2063
2064 t3lib_BEfunc::workspaceOL($table, $row, -99, TRUE);
2065
2066 if ($row) {
2067 // Add the row to the array:
2068 $output[]=$row;
2069
2070 // Set an internal register:
2071 $recs[$c]=$row['uid'];
2072
2073 // Create the list of the next three ids (for editing links...)
2074 for($a=0;$a<$nextTree;$a++) {
2075 if(isset($recs[$c-$a])) {
2076 $this->tt_contentData['nextThree'][$recs[$c-$a]].=$row['uid'].',';
2077 }
2078 }
2079
2080 // Set next/previous ids:
2081 if (isset($recs[$c-1])) {
2082 if (isset($recs[$c-2])) {
2083 $this->tt_contentData['prev'][$row['uid']]=-$recs[$c-2];
2084 } else {
2085 $this->tt_contentData['prev'][$row['uid']]=$row['pid'];
2086 }
2087 $this->tt_contentData['next'][$recs[$c-1]]=-$row['uid'];
2088 }
2089 $c++;
2090 }
2091 }
2092
2093 // Return selected records
2094 return $output;
2095 }
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109 /**********************************
2110 *
2111 * Additional functions; Message board items (tt_board)
2112 *
2113 **********************************/
2114
2115 /**
2116 * Traverses recursively a branch in a message board.
2117 *
2118 * @param array Array of rows (build up recursively)
2119 * @param integer tt_content parent uid
2120 * @param integer Page id
2121 * @param string Additional query part.
2122 * @param string HTML content to prefix items with (to draw the proper tree-graphics)
2123 * @return array $theRows, but with added content
2124 */
2125 function tt_board_getTree($theRows,$parent,$pid,$qWhere,$treeIcons) {
2126
2127 // Select tt_board elements:
2128 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_board', 'pid='.intval($pid).' AND parent='.intval($parent).$qWhere, '', 'crdate');
2129
2130 // Traverse the results:
2131 $c=0;
2132 $rc = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
2133 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
2134 $c++;
2135 $row['treeIcons'] = $treeIcons.'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/'.($rc==$c ? 'joinbottom.gif' : 'join.gif'),'width="18" height="16"').' alt="" />';
2136 $theRows[]=$row;
2137
2138 // Get the branch
2139 $theRows = $this->tt_board_getTree(
2140 $theRows,
2141 $row['uid'],
2142 $row['pid'],
2143 $qWhere,
2144 $treeIcons.'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/'.($rc==$c ? 'blank.gif' : 'line.gif'),'width="18" height="16"').' alt="" />'
2145 );
2146 }
2147
2148 // Return modified rows:
2149 return $theRows;
2150 }
2151
2152 /**
2153 * Adds an element to the tt_board listing:
2154 *
2155 * @param string Table name
2156 * @param array The record row
2157 * @param string Reply count, if applicable.
2158 * @return string Return content of element (table row)
2159 */
2160 function tt_board_drawItem($table,$row,$re) {
2161
2162 // Building data-arary with content:
2163 $theData = Array();
2164 $theData['subject'] = t3lib_div::fixed_lgd_cs(htmlspecialchars($row['subject']),25).'&nbsp; &nbsp;';
2165 $theData['author'] = t3lib_div::fixed_lgd_cs(htmlspecialchars($row['author']),15).'&nbsp; &nbsp;';
2166 $theData['date'] = t3lib_div::fixed_lgd_cs(t3lib_BEfunc::datetime($row['crdate']),20).'&nbsp; &nbsp;';
2167 $theData['age'] = t3lib_BEfunc::calcAge($GLOBALS['EXEC_TIME'] - $row['crdate'], $this->agePrefixes) . '&nbsp; &nbsp;';
2168 if ($re) {
2169 $theData['replys'] = $re;
2170 }
2171
2172 // Subject is built:
2173 $theData['subject'] =
2174 $row['treeIcons'].
2175 $this->getIcon($table,$row).
2176 $theData['subject'];
2177
2178 // Adding element:
2179 return $this->addelement(1,'',$theData);
2180 }
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194 /********************************
2195 *
2196 * Various helper functions
2197 *
2198 ********************************/
2199
2200 /**
2201 * Counts and returns the number of records on the page with $pid
2202 *
2203 * @param string Table name
2204 * @param integer Page id
2205 * @return integer Number of records.
2206 */
2207 function numberOfRecords($table,$pid) {
2208 if ($GLOBALS['TCA'][$table]) {
2209 $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
2210 'uid',
2211 $table,
2212 'pid=' . intval($pid) .
2213 t3lib_BEfunc::deleteClause($table) .
2214 t3lib_BEfunc::versioningPlaceholderClause($table)
2215 );
2216 }
2217 return intval($count);
2218 }
2219
2220 /**
2221 * Processing of larger amounts of text (usually from RTE/bodytext fields) with word wrapping etc.
2222 *
2223 * @param string Input string
2224 * @return string Output string
2225 */
2226 function renderText($input) {
2227 $input = $this->strip_tags($input, true);
2228 $input = t3lib_div::fixed_lgd_cs($input,1500);
2229 return nl2br(htmlspecialchars(trim($this->wordWrapper($input))));
2230 }
2231
2232 /**
2233 * Creates the icon image tag for record from table and wraps it in a link which will trigger the click menu.
2234 *
2235 * @param string Table name
2236 * @param array Record array
2237 * @param string Record title (NOT USED)
2238 * @return string HTML for the icon
2239 */
2240 function getIcon($table,$row) {
2241
2242 // Initialization
2243 $alttext = t3lib_BEfunc::getRecordIconAltText($row,$table);
2244 $iconImg = t3lib_iconWorks::getIconImage($table,$row,$this->backPath,'title="'.$alttext.'"');
2245 $this->counter++;
2246
2247 // The icon with link
2248 $theIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconImg,$table,$row['uid']);
2249
2250 return $theIcon;
2251 }
2252
2253 /**
2254 * Creates processed values for all fieldnames in $fieldList based on values from $row array.
2255 * The result is 'returned' through $info which is passed as a reference
2256 *
2257 * @param string Table name
2258 * @param string Commalist of fields.
2259 * @param array Record from which to take values for processing.
2260 * @param array Array to which the processed values are added.
2261 * @return void
2262 */
2263 function getProcessedValue($table,$fieldList,$row,&$info) {
2264
2265 // Splitting values from $fieldList:
2266 $fieldArr = explode(',',$fieldList);
2267
2268 // Traverse fields from $fieldList:
2269 foreach($fieldArr as $field) {
2270 if ($row[$field]) {
2271 $info[]= htmlspecialchars($this->itemLabels[$field]).' '.htmlspecialchars(t3lib_BEfunc::getProcessedValue($table,$field,$row[$field]));
2272 }
2273 }
2274 }
2275
2276 /**
2277 * Returns true, if the record given as parameters is NOT visible based on hidden/starttime/endtime (if available)
2278 *
2279 * @param string Tablename of table to test
2280 * @param array Record row.
2281 * @return boolean Returns true, if disabled.
2282 */
2283 function isDisabled($table,$row) {
2284 global $TCA;
2285 if (
2286 ($TCA[$table]['ctrl']['enablecolumns']['disabled'] && $row[$TCA[$table]['ctrl']['enablecolumns']['disabled']]) ||
2287 ($TCA[$table]['ctrl']['enablecolumns']['starttime'] && $row[$TCA[$table]['ctrl']['enablecolumns']['starttime']] > $GLOBALS['EXEC_TIME']) ||
2288 ($TCA[$table]['ctrl']['enablecolumns']['endtime'] && $row[$TCA[$table]['ctrl']['enablecolumns']['endtime']] && $row[$TCA[$table]['ctrl']['enablecolumns']['endtime']] < $GLOBALS['EXEC_TIME'])
2289 ) return true;
2290 }
2291
2292 /**
2293 * 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.
2294 * Works well on normal texts, little less well when HTML is involved (since much HTML will have long strings that will be broken).
2295 *
2296 * @param string Content to word-wrap.
2297 * @param integer Max number of chars in a word before it will be wrapped.
2298 * @param string Character to insert when wrapping.
2299 * @return string Processed output.
2300 */
2301 function wordWrapper($content,$max=50,$char=' -') {
2302 $array = preg_split('/[ ' . chr(10) . ']/', $content);
2303 foreach($array as $val) {
2304 if (strlen($val)>$max) {
2305 $content=str_replace($val,substr(chunk_split($val,$max,$char),0,-1),$content);
2306 }
2307 }
2308 return $content;
2309 }
2310
2311 /**
2312 * Returns icon for "no-edit" of a record.
2313 * 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...
2314 *
2315 * @param string Label key from LOCAL_LANG
2316 * @return string IMG tag for icon.
2317 */
2318 function noEditIcon($label='noEditItems') {
2319 return '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2_d.gif','width="11" height="12"').' title="'.$GLOBALS['LANG']->getLL($label,1).'" alt="" />';
2320 }
2321
2322 /**
2323 * 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.
2324 *
2325 * @return void
2326 */
2327 function cleanTableNames() {
2328 global $TCA;
2329
2330 // Get all table names:
2331 $tableNames=array_flip(array_keys($TCA));
2332
2333 // Unset common names:
2334 unset($tableNames['pages']);
2335 unset($tableNames['static_template']);
2336 unset($tableNames['sys_filemounts']);
2337 unset($tableNames['sys_action']);
2338 unset($tableNames['sys_workflows']);
2339 unset($tableNames['be_users']);
2340 unset($tableNames['be_groups']);
2341
2342 $this->allowedTableNames=array();
2343
2344 // Traverse table names and set them in allowedTableNames array IF they can be read-accessed by the user.
2345 if (is_array($tableNames)) {
2346 foreach($tableNames as $k => $v) {
2347 if ($GLOBALS['BE_USER']->check('tables_select',$k)) {
2348 $this->allowedTableNames['table_'.$k]=$k;
2349 }
2350 }
2351 }
2352 }
2353
2354 /**
2355 * Checking if the RTE is available/enabled for a certain table/field and if so, it returns true.
2356 * Used to determine if the RTE button should be displayed.
2357 *
2358 * @param string Table name
2359 * @param array Record row (needed, if there are RTE dependencies based on other fields in the record)
2360 * @param string Field name
2361 * @return boolean Returns true if the rich text editor would be enabled/available for the field name specified.
2362 */
2363 function isRTEforField($table,$row,$field){
2364 $specConf = $this->getSpecConfForField($table,$row,$field);
2365 $p = t3lib_BEfunc::getSpecConfParametersFromArray($specConf['rte_transform']['parameters']);
2366 if (isset($specConf['richtext']) && (!$p['flag'] || !$row[$p['flag']])) {
2367 t3lib_BEfunc::fixVersioningPid($table,$row);
2368 list($tscPID,$thePidValue) = t3lib_BEfunc::getTSCpid($table,$row['uid'],$row['pid']);
2369 if ($thePidValue>=0) { // If the pid-value is not negative (that is, a pid could NOT be fetched)
2370 $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($tscPID));
2371 $RTEtypeVal = t3lib_BEfunc::getTCAtypeValue($table,$row);
2372 $thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'],$table,$field,$RTEtypeVal);
2373 if (!$thisConfig['disabled']) {
2374 return TRUE;
2375 }
2376 }
2377 }
2378
2379 return FALSE;
2380 }
2381
2382 /**
2383 * Returns "special" configuration from the "types" configuration in TCA for the record given by tablename/fieldname.
2384 * Used by isRTEforField() in the process of finding whether a field has RTE enabled or not.
2385 *
2386 * @param string Table name
2387 * @param array Record array
2388 * @param string Field name
2389 * @return array Spec. conf (if available)
2390 * @access private
2391 * @see isRTEforField()
2392 */
2393 function getSpecConfForField($table,$row,$field) {
2394
2395 // Get types-configuration for the record:
2396 $types_fieldConfig = t3lib_BEfunc::getTCAtypes($table,$row);
2397
2398 // Find the given field and return the spec key value if found:
2399 if (is_array($types_fieldConfig)) {
2400 foreach($types_fieldConfig as $vconf) {
2401 if ($vconf['field']==$field) return $vconf['spec'];
2402 }
2403 }
2404 }
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417 /*****************************************
2418 *
2419 * External renderings
2420 *
2421 *****************************************/
2422
2423 /**
2424 * Creates an info-box for the current page (identified by input record).
2425 *
2426 * @param array Page record
2427 * @param boolean If set, there will be shown an edit icon, linking to editing of the page properties.
2428 * @return string HTML for the box.
2429 */
2430 function getPageInfoBox($rec,$edit=0) {
2431 global $LANG;
2432
2433 // If editing of the page properties is allowed:
2434 if ($edit) {
2435 $params='&edit[pages]['.$rec['uid'].']=edit';
2436 $editIcon='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath)).'">'.
2437 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2.gif','width="11" height="12"').' title="'.$GLOBALS['LANG']->getLL('edit',1).'" alt="" />'.
2438 '</a>';
2439 } else {
2440 $editIcon=$this->noEditIcon('noEditPage');
2441 }
2442
2443 // Setting page icon, link, title:
2444 $outPutContent = t3lib_iconWorks::getIconImage('pages',$rec,$this->backPath,'title="'.htmlspecialchars(t3lib_BEfunc::titleAttribForPages($rec)).'"').
2445 $editIcon.
2446 '&nbsp;'.
2447 htmlspecialchars($rec['title']);
2448
2449
2450 // Init array where infomation is accumulated as label/value pairs.
2451 $lines=array();
2452
2453 // Owner user/group:
2454 if ($this->pI_showUser) {
2455 // User:
2456 $users= t3lib_BEfunc::getUserNames('username,usergroup,usergroup_cached_list,uid,realName');
2457 $groupArray = explode(',',$GLOBALS['BE_USER']->user['usergroup_cached_list']);
2458 $users=t3lib_BEfunc::blindUserNames($users,$groupArray);
2459 $lines[]=array($LANG->getLL('pI_crUser').':',htmlspecialchars($users[$rec['cruser_id']]['username']).' ('.$users[$rec['cruser_id']]['realName'].')');
2460 }
2461
2462 // Created:
2463 $lines[] = array(
2464 $LANG->getLL('pI_crDate') . ':',
2465 t3lib_BEfunc::datetime($rec['crdate']) . ' (' . t3lib_BEfunc::calcAge($GLOBALS['EXEC_TIME'] - $rec['crdate'], $this->agePrefixes) . ')',
2466 );
2467
2468 // Last change:
2469 $lines[] = array(
2470 $LANG->getLL('pI_lastChange') . ':',
2471 t3lib_BEfunc::datetime($rec['tstamp']) . ' (' . t3lib_BEfunc::calcAge($GLOBALS['EXEC_TIME'] - $rec['tstamp'],$this->agePrefixes) . ')',
2472 );
2473
2474 // Last change of content:
2475 if ($rec['SYS_LASTCHANGED']) {
2476 $lines[] = array(
2477 $LANG->getLL('pI_lastChangeContent') . ':',
2478 t3lib_BEfunc::datetime($rec['SYS_LASTCHANGED']) . ' (' . t3lib_BEfunc::calcAge($GLOBALS['EXEC_TIME'] - $rec['SYS_LASTCHANGED'], $this->agePrefixes) . ')',
2479 );
2480 }
2481
2482 // Spacer:
2483 $lines[]='';
2484
2485 // Display contents of certain page fields, if any value:
2486 $dfields = explode(',','alias,target,hidden,starttime,endtime,fe_group,no_cache,cache_timeout,newUntil,lastUpdated,subtitle,keywords,description,abstract,author,author_email');
2487 foreach($dfields as $fV) {
2488 if ($rec[$fV]) {
2489 $lines[]=array($GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel('pages',$fV)), t3lib_BEfunc::getProcessedValue('pages',$fV,$rec[$fV]));
2490 }
2491 }
2492
2493 // Page hits (depends on "sys_stat" extension)
2494 if ($this->pI_showStat && t3lib_extMgm::isLoaded('sys_stat')) {
2495
2496 // Counting total hits:
2497 $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', 'sys_stat', 'page_id=' . intval($rec['uid']));
2498 if ($count) {
2499
2500 // Get min/max
2501 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('min(tstamp) AS min,max(tstamp) AS max', 'sys_stat', 'page_id='.intval($rec['uid']));
2502 $rrow2 = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
2503
2504 $lines[]='';
2505 $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).')');
2506 $lines[]=array($LANG->getLL('pI_hitsTotal').':',$rrow[0]);
2507
2508
2509 // Last 10 days
2510 $nextMidNight = mktime (0,0,0)+1*3600*24;
2511
2512 $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');
2513 $days=array();
2514 while($rrow = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) {
2515 $days[$rrow[1]] = $rrow[0];
2516 }
2517
2518 $headerH=array();
2519 $contentH=array();
2520 for($a=9;$a>=0;$a--) {
2521 $headerH[]='
2522 <td class="bgColor5" nowrap="nowrap">&nbsp;'.date('d',$nextMidNight-($a+1)*24*3600).'&nbsp;</td>';
2523 $contentH[]='
2524 <td align="center">'.($days[$a] ? intval($days[$a]) : '-').'</td>';
2525 }
2526
2527 // Compile first hit-table (last 10 days)
2528 $hitTable='
2529 <table border="0" cellpadding="0" cellspacing="1" class="typo3-page-hits">
2530 <tr>'.implode('',$headerH).'</tr>
2531 <tr>'.implode('',$contentH).'</tr>
2532 </table>';
2533 $lines[]=array($LANG->getLL('pI_hits10days').':',$hitTable,1);
2534
2535
2536 // Last 24 hours
2537 $nextHour = mktime (date('H'),0,0)+3600;
2538 $hours=16;
2539
2540 $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');
2541 $days=array();
2542 while($rrow = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) {
2543 $days[$rrow[1]]=$rrow[0];
2544 }
2545
2546 $headerH=array();
2547 $contentH=array();
2548 for($a=($hours-1);$a>=0;$a--) {
2549 $headerH[]='
2550 <td class="bgColor5" nowrap="nowrap">&nbsp;'.intval(date('H',$nextHour-($a+1)*3600)).'&nbsp;</td>';
2551 $contentH[]='
2552 <td align="center">'.($days[$a] ? intval($days[$a]) : '-').'</td>';
2553 }
2554
2555 // Compile second hit-table (last 24 hours)
2556 $hitTable='
2557 <table border="0" cellpadding="0" cellspacing="1" class="typo3-page-stat">
2558 <tr>'.implode('',$headerH).'</tr>
2559 <tr>'.implode('',$contentH).'</tr>
2560 </table>';
2561 $lines[]=array($LANG->getLL('pI_hits24hours').':',$hitTable,1);
2562 }
2563 }
2564
2565
2566 // Finally, wrap the elements in the $lines array in table cells/rows
2567 foreach($lines as $fV) {
2568 if (is_array($fV)) {
2569 if (!$fV[2]) $fV[1]=htmlspecialchars($fV[1]);
2570 $out.='
2571 <tr>
2572 <td class="bgColor4" nowrap="nowrap"><strong>'.htmlspecialchars($fV[0]).'&nbsp;&nbsp;</strong></td>
2573 <td class="bgColor4">'.$fV[1].'</td>
2574 </tr>';
2575 } else {
2576 $out.='
2577 <tr>
2578 <td colspan="2"><img src="clear.gif" width="1" height="3" alt="" /></td>
2579 </tr>';
2580 }
2581 }
2582
2583 // Wrap table tags around...
2584 $outPutContent.='
2585
2586
2587
2588 <!--
2589 Page info box:
2590 -->
2591 <table border="0" cellpadding="0" cellspacing="1" id="typo3-page-info">
2592 '.$out.'
2593 </table>';
2594
2595 // ... and return it.
2596 return $outPutContent;
2597 }
2598
2599 /**
2600 * Creates a menu of the tables that can be listed by this function
2601 * Only tables which has records on the page will be included.
2602 * Notice: The function also fills in the internal variable $this->activeTables with icon/titles.
2603 *
2604 * @param integer Page id from which we are listing records (the function will look up if there are records on the page)
2605 * @return string HTML output.
2606 */
2607 function getTableMenu($id) {
2608 global $TCA;
2609
2610 // Initialize:
2611 $this->activeTables=array();
2612 $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!
2613
2614 // External tables:
2615 if (is_array($this->externalTables)) {
2616 $theTables = array_unique(array_merge($theTables, array_keys($this->externalTables)));
2617 }
2618
2619 // Traverse tables to check:
2620 foreach($theTables as $tName) {
2621
2622 // Check access and whether the proper extensions are loaded:
2623 if ($GLOBALS['BE_USER']->check('tables_select',$tName) && (t3lib_extMgm::isLoaded($tName)||t3lib_div::inList('fe_users,tt_content',$tName) || isset($this->externalTables[$tName]))) {
2624
2625 // Make query to count records from page:
2626 $c = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
2627 'uid',
2628 $tName,
2629 'pid=' . intval($id) .
2630 t3lib_BEfunc::deleteClause($tName) .
2631 t3lib_BEfunc::versioningPlaceholderClause($tName)
2632 );
2633
2634 // If records were found (or if "tt_content" is the table...):
2635 if ($c || t3lib_div::inList('tt_content',$tName)) {
2636
2637 // Add row to menu:
2638 $out.='
2639 <td><a href="#'.$tName.'"></a>'.
2640 t3lib_iconWorks::getIconImage($tName,Array(),$this->backPath,'title="'.$GLOBALS['LANG']->sL($TCA[$tName]['ctrl']['title'],1).'"').
2641 '</td>';
2642
2643 // ... and to the internal array, activeTables we also add table icon and title (for use elsewhere)
2644 $this->activeTables[$tName]=
2645 t3lib_iconWorks::getIconImage($tName,Array(),$this->backPath,'title="'.$GLOBALS['LANG']->sL($TCA[$tName]['ctrl']['title'],1).': '.$c.' '.$GLOBALS['LANG']->getLL('records',1).'" class="absmiddle"').
2646 '&nbsp;'.
2647 $GLOBALS['LANG']->sL($TCA[$tName]['ctrl']['title'],1);
2648 }
2649 }
2650 }
2651
2652 // Wrap cells in table tags:
2653 $out = '
2654
2655
2656
2657 <!--
2658 Menu of tables on the page (table menu)
2659 -->
2660 <table border="0" cellpadding="0" cellspacing="0" id="typo3-page-tblMenu">
2661 <tr>'.$out.'
2662 </tr>
2663 </table>';
2664
2665 // Return the content:
2666 return $out;
2667 }
2668
2669 /**
2670 * Enhancement for the strip_tags function that provides the feature to fill in empty tags.
2671 * Example <link email@hostname.com></link> is accepted by TYPO3 but would not displayed in the Backend otherwise.
2672 *
2673 * @param string Input string
2674 * @param boolean If true, empty tags will be filled with the first attribute of the tag before.
2675 * @return string Input string with all HTML and PHP tags stripped
2676 */
2677 function strip_tags($content, $fillEmptyContent=false) {
2678 if($fillEmptyContent && strstr($content, '><')) {
2679 $content = preg_replace('/(<[^ >]* )([^ >]*)([^>]*>)(<\/[^>]*>)/', '$1$2$3$2$4', $content);
2680 }
2681 $content = preg_replace('/<br.?\/?>/', chr(10), $content);
2682
2683 return strip_tags($content);
2684 }
2685 }
2686
2687
2688
2689
2690 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/cms/layout/class.tx_cms_layout.php']) {
2691 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/cms/layout/class.tx_cms_layout.php']);
2692 }
2693
2694 ?>