Fixed bug #9798: Don't show fe_users password in page module
[Packages/TYPO3.CMS.git] / typo3 / sysext / cms / layout / class.tx_cms_layout.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2008 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'),ereg_replace(':$','',trim($GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel('pages',$field)))));
322 $eI= '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,'')).'">'.
323 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2.gif','width="11" height="12"').' title="'.htmlspecialchars($iTitle).'" alt="" />'.
324 '</a>';
325 } else $eI='';
326 switch($field) {
327 case 'title':
328 $theData[$field] = '&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 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'pages', 'pid='.intval($pid).$qWhere);
1345 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
1346 if ($row[0]) {
1347 $this->plusPages[$pid]=$row[0];
1348 }
1349 }
1350 return $theRows;
1351 }
1352
1353 /**
1354 * Adds a list item for the pages-rendering
1355 *
1356 * @param array Record array
1357 * @param array Field list
1358 * @return string HTML for the item
1359 */
1360 function pages_drawItem($row,$fieldArr) {
1361 global $TCA;
1362
1363 // Initialization
1364 $theIcon=$this->getIcon('pages',$row);
1365
1366 // Preparing and getting the data-array
1367 $theData = Array();
1368 foreach($fieldArr as $field) {
1369 switch($field) {
1370 case 'title':
1371 $red = $this->plusPages[$row['uid']] ? '<font color="red"><b>+&nbsp;</b></font>' : '';
1372 $pTitle = htmlspecialchars(t3lib_BEfunc::getProcessedValue('pages',$field,$row[$field],20));
1373 if ($red) {
1374 $pTitle = '<a href="'.htmlspecialchars($this->script.'?id='.$row['uid']).'">'.$pTitle.'</a>';
1375 }
1376 $theData[$field]=$row['treeIcons'].$theIcon.$red.$pTitle.'&nbsp;&nbsp;';
1377 break;
1378 case 'php_tree_stop':
1379 case 'TSconfig':
1380 $theData[$field] = $row[$field]?'&nbsp;<b>x</b>':'&nbsp;';
1381 break;
1382 case 'uid':
1383 if ($GLOBALS['BE_USER']->doesUserHaveAccess($row,2)) {
1384 $params='&edit[pages]['.$row['uid'].']=edit';
1385 $eI= '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,'')).'">'.
1386 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2.gif','width="11" height="12"').' title="'.$GLOBALS['LANG']->getLL('editThisPage',1).'" alt="" />'.
1387 '</a>';
1388 } else $eI='';
1389 $theData[$field] = '<span align="right">'.$row['uid'].$eI.'</span>';
1390 break;
1391 default:
1392 if (substr($field,0,6)=='table_') {
1393 $f2 = substr($field,6);
1394 if ($TCA[$f2]) {
1395 $c = $this->numberOfRecords($f2,$row['uid']);
1396 $theData[$field] = '&nbsp;&nbsp;'.($c?$c:'');
1397 }
1398 } elseif (substr($field,0,5)=='HITS_') {
1399 if (t3lib_extMgm::isLoaded('sys_stat')) {
1400 $fParts = explode(':',substr($field,5));
1401 switch($fParts[0]) {
1402 case 'days':
1403 $timespan = mktime (0,0,0)+intval($fParts[1])*3600*24;
1404 // Page hits
1405 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1406 'count(*)',
1407 'sys_stat',
1408 $this->stat_select_field.'='.intval($row['uid']).'
1409 AND tstamp>='.intval($timespan).'
1410 AND tstamp<'.intval($timespan+3600*24)
1411 );
1412 list($number) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
1413 if ($number) {
1414 // Sessions
1415 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1416 'count(*)',
1417 'sys_stat',
1418 $this->stat_select_field.'='.intval($row['uid']).'
1419 AND tstamp>='.intval($timespan).'
1420 AND tstamp<'.intval($timespan+3600*24).'
1421 AND surecookie!=""',
1422 'surecookie'
1423 );
1424 $scnumber = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
1425
1426 $number.= '/'.$scnumber;
1427 } else {
1428 $number='';
1429 }
1430 break;
1431 }
1432 $theData[$field]= '&nbsp;'.$number;
1433 } else {
1434 $theData[$field]= '&nbsp;';
1435 }
1436 } else {
1437 $theData[$field]= '&nbsp;&nbsp;'.htmlspecialchars(t3lib_BEfunc::getProcessedValue('pages',$field,$row[$field]));
1438 }
1439 break;
1440 }
1441 }
1442 $this->addElement_tdParams['title'] = ($row['_CSSCLASS'] ? ' class="'.$row['_CSSCLASS'].'"' : '');
1443 return $this->addelement(1,'',$theData);
1444 }
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457 /**********************************
1458 *
1459 * Additional functions; Content Elements
1460 *
1461 **********************************/
1462
1463 /**
1464 * Draw header for a content element column:
1465 *
1466 * @param string Column name
1467 * @param string Edit params (Syntax: &edit[...] for alt_doc.php)
1468 * @param string New element params (Syntax: &edit[...] for alt_doc.php)
1469 * @return string HTML table
1470 */
1471 function tt_content_drawColHeader($colName,$editParams,$newParams) {
1472
1473 // Create header row:
1474 $out = '
1475 <tr>
1476 <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>
1477 </tr>';
1478
1479 // Create command links:
1480 if ($this->tt_contentConfig['showCommands']) {
1481 // Start cell:
1482 $out.= '
1483 <tr>
1484 <td class="bgColor5">';
1485
1486 // Edit whole of column:
1487 if ($editParams) {
1488 $out.='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($editParams,$this->backPath)).'">'.
1489 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2.gif','width="11" height="12"').' title="'.$GLOBALS['LANG']->getLL('editColumn',1).'" alt="" />'.
1490 '</a>';
1491 }
1492 // New record:
1493 if ($newParams) {
1494 $out.='<a href="#" onclick="'.htmlspecialchars($newParams).'">'.
1495 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/new_record.gif','width="16" height="12"').' title="'.$GLOBALS['LANG']->getLL('newInColumn',1).'" alt="" />'.
1496 '</a>';
1497 }
1498 // End cell:
1499 $out.= '
1500 </td>
1501 </tr>';
1502 }
1503
1504 // Wrap and return:
1505 return '
1506 <table border="0" cellpadding="0" cellspacing="0" width="100%" class="typo3-page-colHeader">'.($space?'
1507 <tr>
1508 <td><img src="clear.gif" height="'.$space.'" alt="" /></td>
1509 </tr>':'').
1510 $out.'
1511 </table>';
1512 }
1513
1514 /**
1515 * Draw the header for a single tt_content element
1516 *
1517 * @param array Record array
1518 * @param integer Amount of pixel space above the header.
1519 * @param boolean If set the buttons for creating new elements and moving up and down are not shown.
1520 * @param boolean If set, we are in language mode and flags will be shown for languages
1521 * @return string HTML table with the record header.
1522 */
1523 function tt_content_drawHeader($row,$space=0,$disableMoveAndNewButtons=FALSE,$langMode=FALSE) {
1524 global $TCA;
1525
1526 // Load full table description:
1527 t3lib_div::loadTCA('tt_content');
1528
1529 // Get record locking status:
1530 if ($lockInfo=t3lib_BEfunc::isRecordLocked('tt_content',$row['uid'])) {
1531 $lockIcon='<a href="#" onclick="'.htmlspecialchars('alert('.$GLOBALS['LANG']->JScharCode($lockInfo['msg']).');return false;').'">'.
1532 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/recordlock_warning3.gif','width="17" height="12"').' title="'.htmlspecialchars($lockInfo['msg']).'" alt="" />'.
1533 '</a>';
1534 } else $lockIcon='';
1535
1536 // Call stats information hook
1537 $stat = '';
1538 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'])) {
1539 $_params = array('tt_content', $row['uid'], &$row);
1540 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'] as $_funcRef) {
1541 $stat.=t3lib_div::callUserFunction($_funcRef,$_params,$this);
1542 }
1543 }
1544
1545 // Create header with icon/lock-icon/title:
1546 $header = $this->getIcon('tt_content',$row).
1547 $lockIcon.
1548 $stat.
1549 ($langMode ? $this->languageFlag($row['sys_language_uid']) : '').
1550 '&nbsp;<b>'.htmlspecialchars($this->CType_labels[$row['CType']]).'</b>';
1551 $out = '
1552 <tr>
1553 <td class="bgColor4">'.$header.'</td>
1554 </tr>';
1555
1556 // If show info is set...;
1557 if ($this->tt_contentConfig['showInfo']) {
1558
1559 // Get processed values:
1560 $info = Array();
1561 $this->getProcessedValue('tt_content','hidden,starttime,endtime,fe_group,spaceBefore,spaceAfter,section_frame,sectionIndex,linkToTop',$row,$info);
1562
1563 // Render control panel for the element:
1564 if ($this->tt_contentConfig['showCommands'] && $this->doEdit) {
1565
1566 // Start control cell:
1567 $out.= '
1568 <!-- Control Panel -->
1569 <tr>
1570 <td class="bgColor5">';
1571
1572 // Edit content element:
1573 $params='&edit[tt_content]['.$this->tt_contentData['nextThree'][$row['uid']].']=edit';
1574 $out.='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath)).'">'.
1575 '<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="" />'.
1576 '</a>';
1577
1578 if (!$disableMoveAndNewButtons) {
1579 // New content element:
1580 if ($this->option_newWizard) {
1581 $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'))."';";
1582 } else {
1583 $params='&edit[tt_content]['.(-$row['uid']).']=new';
1584 $onClick = t3lib_BEfunc::editOnClick($params,$this->backPath);
1585 }
1586 $out.='<a href="#" onclick="'.htmlspecialchars($onClick).'">'.
1587 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/new_record.gif','width="16" height="12"').' title="'.$GLOBALS['LANG']->getLL('newAfter',1).'" alt="" />'.
1588 '</a>';
1589
1590 // Move element up:
1591 if ($this->tt_contentData['prev'][$row['uid']]) {
1592 $params='&cmd[tt_content]['.$row['uid'].'][move]='.$this->tt_contentData['prev'][$row['uid']];
1593 $out.='<a href="'.htmlspecialchars($GLOBALS['SOBE']->doc->issueCommand($params)).'">'.
1594 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_up.gif','width="11" height="10"').' title="'.$GLOBALS['LANG']->getLL('moveUp',1).'" alt="" />'.
1595 '</a>';
1596 } else {
1597 $out.='<img src="clear.gif" '.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_up.gif','width="11" height="10"',2).' alt="" />';
1598 }
1599 // Move element down:
1600 if ($this->tt_contentData['next'][$row['uid']]) {
1601 $params='&cmd[tt_content]['.$row['uid'].'][move]='.$this->tt_contentData['next'][$row['uid']];
1602 $out.='<a href="'.htmlspecialchars($GLOBALS['SOBE']->doc->issueCommand($params)).'">'.
1603 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_down.gif','width="11" height="10"').' title="'.$GLOBALS['LANG']->getLL('moveDown',1).'" alt="" />'.
1604 '</a>';
1605 } else {
1606 $out.='<img src="clear.gif" '.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_down.gif','width="11" height="10"',2).' alt="" />';
1607 }
1608 }
1609
1610 // Hide element:
1611 $hiddenField = $TCA['tt_content']['ctrl']['enablecolumns']['disabled'];
1612 if ($hiddenField && $TCA['tt_content']['columns'][$hiddenField] && (!$TCA['tt_content']['columns'][$hiddenField]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields','tt_content:'.$hiddenField))) {
1613 if ($row[$hiddenField]) {
1614 $params='&data[tt_content]['.($row['_ORIG_uid'] ? $row['_ORIG_uid'] : $row['uid']).']['.$hiddenField.']=0';
1615 $out.='<a href="'.htmlspecialchars($GLOBALS['SOBE']->doc->issueCommand($params)).'">'.
1616 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_unhide.gif','width="11" height="10"').' title="'.$GLOBALS['LANG']->getLL('unHide',1).'" alt="" />'.
1617 '</a>';
1618 } else {
1619 $params='&data[tt_content]['.($row['_ORIG_uid'] ? $row['_ORIG_uid'] : $row['uid']).']['.$hiddenField.']=1';
1620 $out.='<a href="'.htmlspecialchars($GLOBALS['SOBE']->doc->issueCommand($params)).'">'.
1621 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/button_hide.gif','width="11" height="10"').' title="'.$GLOBALS['LANG']->getLL('hide',1).'" alt="" />'.
1622 '</a>';
1623 }
1624 }
1625
1626 // Delete
1627 $params='&cmd[tt_content]['.$row['uid'].'][delete]=1';
1628 $out.='<a href="'.htmlspecialchars($GLOBALS['SOBE']->doc->issueCommand($params)).'" onclick="'.htmlspecialchars('return confirm('.$GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->getLL('deleteWarning')).');').'">'.
1629 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/garbage.gif','width="11" height="12"').' title="'.$GLOBALS['LANG']->getLL('deleteItem',1).'" alt="" />'.
1630 '</a>';
1631
1632 // End cell:
1633 $out.= '
1634 </td>
1635 </tr>';
1636 }
1637
1638 // Display info from records fields:
1639 if (count($info)) {
1640 $out.= '
1641 <tr>
1642 <td class="bgColor4-20">'.implode('<br />',$info).'</td>
1643 </tr>';
1644 }
1645 }
1646 // Wrap the whole header in a table:
1647 return '
1648 <table border="0" cellpadding="0" cellspacing="0" class="typo3-page-ceHeader">'.($space?'
1649 <tr>
1650 <td><img src="clear.gif" height="'.$space.'" alt="" /></td>
1651 </tr>':'').
1652 $out.'
1653 </table>';
1654 }
1655
1656 /**
1657 * Draws the preview content for a content element
1658 *
1659 * @param string Content element
1660 * @param boolean Set if the RTE link can be created.
1661 * @return string HTML
1662 */
1663 function tt_content_drawItem($row, $isRTE=FALSE) {
1664 global $TCA;
1665
1666 $out='';
1667 $outHeader='';
1668
1669 // Make header:
1670 if ($row['header'] && $row['header_layout']!=100) {
1671 $infoArr = Array();
1672 $this->getProcessedValue('tt_content','header_position,header_layout,header_link',$row,$infoArr);
1673
1674 $outHeader= ($row['date'] ? htmlspecialchars($this->itemLabels['date'].' '.t3lib_BEfunc::date($row['date'])).'<br />':'').
1675 $this->infoGif($infoArr).
1676 '<b>'.$this->linkEditContent($this->renderText($row['header']),$row).'</b><br />';
1677 }
1678
1679 // Make content:
1680 $infoArr=Array();
1681 switch($row['CType']) {
1682 case 'header':
1683 if ($row['subheader']) {
1684 $this->getProcessedValue('tt_content','layout',$row,$infoArr);
1685 $out.= $this->infoGif($infoArr).
1686 $this->linkEditContent($this->renderText($row['subheader']),$row).'<br />';
1687 }
1688 break;
1689 case 'text':
1690 case 'textpic':
1691 case 'image':
1692 if ($row['CType']=='text' || $row['CType']=='textpic') {
1693 if ($row['bodytext']) {
1694 $this->getProcessedValue('tt_content','text_align,text_face,text_size,text_color,text_properties',$row,$infoArr);
1695 $out.= $this->infoGif($infoArr).
1696 $this->linkEditContent($this->renderText($row['bodytext']),$row).'<br />';
1697 }
1698 }
1699 if ($row['CType']=='textpic' || $row['CType']=='image') {
1700 if ($row['image']) {
1701 $infoArr=Array();
1702 $this->getProcessedValue('tt_content','imageorient,imagecols,image_noRows,imageborder,imageheight,image_link,image_zoom,image_compression,image_effects,image_frames',$row,$infoArr);
1703 $out.= $this->infoGif($infoArr).
1704 $this->thumbCode($row,'tt_content','image').'<br />';
1705
1706 if ($row['imagecaption']) {
1707 $infoArr=Array();
1708 $this->getProcessedValue('tt_content','imagecaption_position',$row,$infoArr);
1709 $out.= $this->infoGif($infoArr).
1710 $this->linkEditContent($this->renderText($row['imagecaption']),$row).'<br />';
1711 }
1712 }
1713 }
1714 break;
1715 case 'bullets':
1716 if ($row['bodytext']) {
1717 $this->getProcessedValue('tt_content','layout,text_align,text_face,text_size,text_color,text_properties',$row,$infoArr);
1718 $out.= $this->infoGif($infoArr).
1719 $this->linkEditContent($this->renderText($row['bodytext']),$row).'<br />';
1720 }
1721 break;
1722 case 'table':
1723 if ($row['bodytext']) {
1724 $this->getProcessedValue('tt_content','table_bgColor,table_border,table_cellspacing,cols,layout,text_align,text_face,text_size,text_color,text_properties',$row,$infoArr);
1725 $out.= $this->infoGif($infoArr).
1726 $this->linkEditContent($this->renderText($row['bodytext']),$row).'<br />';
1727 }
1728 break;
1729 case 'uploads':
1730 if ($row['media']) {
1731 $this->getProcessedValue('tt_content','media,select_key,layout,filelink_size,table_bgColor,table_border,table_cellspacing',$row,$infoArr);
1732 $out.= $this->infoGif($infoArr).
1733 $this->linkEditContent($this->renderText($row['bodytext']),$row).'<br />';
1734 }
1735 break;
1736 case 'multimedia':
1737 if ($row['multimedia']) {
1738 $out.= $this->renderText($row['multimedia']).'<br />';
1739 $out.= $this->renderText($row['parameters']).'<br />';
1740 }
1741 break;
1742 case 'mailform':
1743 if ($row['bodytext']) {
1744 $this->getProcessedValue('tt_content','pages,subheader',$row,$infoArr);
1745 $out.= $this->infoGif($infoArr).
1746 $this->linkEditContent($this->renderText($row['bodytext']),$row).'<br />';
1747 }
1748 break;
1749 case 'splash':
1750 if ($row['bodytext']) {
1751 $out.= $this->linkEditContent($this->renderText($row['bodytext']),$row).'<br />';
1752 }
1753 if ($row['image']) {
1754 $infoArr=Array();
1755 $this->getProcessedValue('tt_content','imagewidth',$row,$infoArr);
1756 $out.= $this->infoGif($infoArr).
1757 $this->thumbCode($row,'tt_content','image').'<br />';
1758 }
1759 break;
1760 case 'menu':
1761 if ($row['pages']) {
1762 $this->getProcessedValue('tt_content','menu_type',$row,$infoArr);
1763 $out.= $this->infoGif($infoArr).
1764 $this->linkEditContent($row['pages'],$row).'<br />';
1765 }
1766 break;
1767 case 'shortcut':
1768 if ($row['records']) {
1769 $this->getProcessedValue('tt_content','layout',$row,$infoArr);
1770 $out.= $this->infoGif($infoArr).
1771 $this->linkEditContent($row['shortcut'],$row).'<br />';
1772 }
1773 break;
1774 case 'list':
1775 $this->getProcessedValue('tt_content','layout',$row,$infoArr);
1776 $out.= $this->infoGif($infoArr).
1777 $GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel('tt_content','list_type'),1).' '.
1778 $GLOBALS['LANG']->sL(t3lib_BEfunc::getLabelFromItemlist('tt_content','list_type',$row['list_type']),1).'<br />';
1779 $hookArr = array();
1780 $hookOut = '';
1781 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info'][$row['list_type']])) {
1782 $hookArr = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info'][$row['list_type']];
1783 } elseif (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info']['_DEFAULT'])) {
1784 $hookArr = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info']['_DEFAULT'];
1785 }
1786 if (count($hookArr) > 0) {
1787 $_params = array('pObj' => &$this, 'row' => $row, 'infoArr' => $infoArr);
1788 foreach ($hookArr as $_funcRef) {
1789 $hookOut .= t3lib_div::callUserFunction($_funcRef, $_params, $this);
1790 }
1791 }
1792 if (strcmp($hookOut, '')) {
1793 $out .= $hookOut;
1794 } else {
1795 $out.= $GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel('tt_content','select_key'),1).' '.$row['select_key'].'<br />';
1796 }
1797
1798 $infoArr=Array();
1799 $this->getProcessedValue('tt_content','recursive',$row,$infoArr);
1800 $out.= $this->infoGif($infoArr).
1801 $GLOBALS['LANG']->sL(t3lib_BEfunc::getLabelFromItemlist('tt_content','pages',$row['pages']),1).'<br />';
1802 break;
1803 case 'script':
1804 $out.= $GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel('tt_content','select_key'),1).' '.$row['select_key'].'<br />';
1805 $out.= '<br />'.$this->linkEditContent($this->renderText($row['bodytext']),$row).'<br />';
1806 $out.= '<br />'.$this->linkEditContent($this->renderText($row['imagecaption']),$row).'<br />';
1807 break;
1808 default:
1809 if ($row['bodytext']) {
1810 $out.=$this->linkEditContent($this->renderText($row['bodytext']),$row).'<br />';
1811 }
1812 break;
1813 }
1814
1815 // Wrap span-tags:
1816 $out = '
1817 <span class="exampleContent">'.$out.'</span>';
1818 // Add header:
1819 $out = $outHeader.$out;
1820 // Add RTE button:
1821 if ($isRTE) {
1822 $out.= $this->linkRTEbutton($row);
1823 }
1824
1825 // Return values:
1826 if ($this->isDisabled('tt_content',$row)) {
1827 return $GLOBALS['TBE_TEMPLATE']->dfw($out);
1828 } else {
1829 return $out;
1830 }
1831 }
1832
1833 /**
1834 * Filters out all tt_content uids which are already translated so only non-translated uids is left.
1835 * 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 (?)
1836 *
1837 * @param array Numeric array with uids of tt_content elements in the default language
1838 * @param integer Page pid
1839 * @param integer Sys language UID
1840 * @return array Modified $defLanguageCount
1841 */
1842 function getNonTranslatedTTcontentUids($defLanguageCount,$id,$lP) {
1843 if ($lP && count($defLanguageCount)) {
1844
1845 // Select all translations here:
1846 $queryParts = $this->makeQueryArray('tt_content', $id, 'AND sys_language_uid='.intval($lP).' AND l18n_parent IN ('.implode(',',$defLanguageCount).')');
1847 $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
1848
1849 // Flip uids:
1850 $defLanguageCount = array_flip($defLanguageCount);
1851
1852 // Traverse any selected elements and unset original UID if any:
1853 $rowArr = $this->getResult($result);
1854 foreach($rowArr as $row) {
1855 unset($defLanguageCount[$row['l18n_parent']]);
1856 }
1857
1858 // Flip again:
1859 $defLanguageCount = array_keys($defLanguageCount);
1860 }
1861
1862 return $defLanguageCount;
1863 }
1864
1865 /**
1866 * Creates button which is used to create copies of records..
1867 *
1868 * @param array Numeric array with uids of tt_content elements in the default language
1869 * @param integer Sys language UID
1870 * @return string "Copy languages" button, if available.
1871 */
1872 function newLanguageButton($defLanguageCount,$lP) {
1873 if ($this->doEdit && count($defLanguageCount) && $lP) {
1874
1875 $params = '';
1876 foreach($defLanguageCount as $uidVal) {
1877 $params.='&cmd[tt_content]['.$uidVal.'][localize]='.$lP;
1878 }
1879
1880 // Copy for language:
1881 $onClick = "window.location.href='".$GLOBALS['SOBE']->doc->issueCommand($params)."'; return false;";
1882 $theNewButton = $GLOBALS['SOBE']->doc->t3Button($onClick,$GLOBALS['LANG']->getLL('newPageContent_copyForLang').' ['.count($defLanguageCount).']');
1883 return $theNewButton;
1884 }
1885 }
1886
1887 /**
1888 * Returns an icon, which has its title attribute set to a massive amount of information about the element.
1889 *
1890 * @param array Array where values are human readable output of field values (not htmlspecialchars()'ed though). The values are imploded by a linebreak.
1891 * @return string HTML img tag if applicable.
1892 */
1893 function infoGif($infoArr) {
1894 if (count($infoArr) && $this->tt_contentConfig['showInfo']) {
1895 $out='<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/zoom2.gif','width="12" height="12"').' title="'.htmlspecialchars(implode(chr(10),$infoArr)).'" alt="" /> ';
1896 return $out;
1897 }
1898 }
1899
1900 /**
1901 * Creates onclick-attribute content for a new content element
1902 *
1903 * @param integer Page id where to create the element.
1904 * @param integer Preset: Column position value
1905 * @param integer Preset: Sys langauge value
1906 * @return string String for onclick attribute.
1907 * @see getTable_tt_content()
1908 */
1909 function newContentElementOnClick($id,$colPos,$sys_language) {
1910 if ($this->option_newWizard) {
1911 $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'))."';";
1912 } else {
1913 $onClick=t3lib_BEfunc::editOnClick('&edit[tt_content]['.$id.']=new&defVals[tt_content][colPos]='.$colPos.'&defVals[tt_content][sys_language_uid]='.$sys_language,$this->backPath);
1914 }
1915 return $onClick;
1916 }
1917
1918 /**
1919 * Will create a link on the input string and possible a big button after the string which links to editing in the RTE
1920 * Used for content element content displayed so the user can click the content / "Edit in Rich Text Editor" button
1921 *
1922 * @param string String to link. Must be prepared for HTML output.
1923 * @param array The row.
1924 * @return string If the whole thing was editable ($this->doEdit) $str is return with link around. Otherwise just $str.
1925 * @see getTable_tt_content()
1926 */
1927 function linkEditContent($str,$row) {
1928 $addButton='';
1929 $onClick = '';
1930
1931 if ($this->doEdit) {
1932 // Setting onclick action for content link:
1933 $onClick=t3lib_BEfunc::editOnClick('&edit[tt_content]['.$row['uid'].']=edit',$this->backPath);
1934 }
1935 // Return link
1936 return $onClick ? '<a href="#" onclick="'.htmlspecialchars($onClick).'" title="'.$GLOBALS['LANG']->getLL('edit',1).'">'.$str.'</a>'.$addButton : $str;
1937 }
1938
1939 /**
1940 * Adds a button to edit the row in RTE wizard
1941 *
1942 * @param array The row of tt_content element
1943 * @return string Button to click if you want to edit in RTE wizard.
1944 */
1945 function linkRTEbutton($row) {
1946 $params = array();
1947 $params['table'] = 'tt_content';
1948 $params['uid'] = $row['uid'];
1949 $params['pid'] = $row['pid'];
1950 $params['field'] = 'bodytext';
1951 $params['returnUrl'] = t3lib_div::linkThisScript();
1952 $RTEonClick = "window.location.href='".$this->backPath."wizard_rte.php?".t3lib_div::implodeArrayForUrl('',array('P'=>$params))."';return false;";
1953 $addButton = $this->option_showBigButtons && $this->doEdit ? $GLOBALS['SOBE']->doc->t3Button($RTEonClick,$GLOBALS['LANG']->getLL('editInRTE')) : '';
1954
1955 return $addButton;
1956 }
1957
1958 /**
1959 * Make selector box for creating new translation in a language
1960 * Displays only languages which are not yet present for the current page.
1961 *
1962 * @param integer Page id for which to create a new language (pages_language_overlay record)
1963 * @return string <select> HTML element (if there were items for the box anyways...)
1964 * @see getTable_tt_content()
1965 */
1966 function languageSelector($id) {
1967 if ($GLOBALS['BE_USER']->check('tables_modify','pages_language_overlay')) {
1968
1969 // First, select all
1970 $res = $GLOBALS['SOBE']->exec_languageQuery(0);
1971 $langSelItems=array();
1972 $langSelItems[0]='
1973 <option value="0"></option>';
1974 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1975 if ($GLOBALS['BE_USER']->checkLanguageAccess($row['uid'])) {
1976 $langSelItems[$row['uid']]='
1977 <option value="'.$row['uid'].'">'.htmlspecialchars($row['title']).'</option>';
1978 }
1979 }
1980
1981 // Then, subtract the languages which are already on the page:
1982 $res = $GLOBALS['SOBE']->exec_languageQuery($id);
1983 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1984 unset($langSelItems[$row['uid']]);
1985 }
1986 // Remove disallowed languages
1987 if (count($langSelItems) > 1 &&
1988 !$GLOBALS['BE_USER']->user['admin'] &&
1989 strlen($GLOBALS['BE_USER']->groupData['allowed_languages'])) {
1990
1991 $allowed_languages = array_flip(explode(',', $GLOBALS['BE_USER']->groupData['allowed_languages']));
1992
1993 if (count($allowed_languages)) {
1994 foreach($langSelItems as $key => $value) {
1995 if (!isset($allowed_languages[$key]) && $key != 0) {
1996 unset($langSelItems[$key]);
1997 }
1998 }
1999 }
2000 }
2001
2002 // If any languages are left, make selector:
2003 if (count($langSelItems)>1) {
2004 $onChangeContent = 'window.location.href=\''.$this->backPath.'alt_doc.php?&edit[pages_language_overlay]['.$id.']=new&overrideVals[pages_language_overlay][sys_language_uid]=\'+this.options[this.selectedIndex].value+\'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')).'\'';
2005 return $GLOBALS['LANG']->getLL('new_language',1).': <select name="createNewLanguage" onchange="'.htmlspecialchars($onChangeContent).'">
2006 '.implode('',$langSelItems).'
2007 </select><br /><br />';
2008 }
2009 }
2010 }
2011
2012 /**
2013 * Traverse the result pointer given, adding each record to array and setting some internal values at the same time.
2014 *
2015 * @param pointer SQL result pointer for select query.
2016 * @param string Table name defaulting to tt_content
2017 * @return array The selected rows returned in this array.
2018 */
2019 function getResult($result,$table='tt_content') {
2020
2021 // Initialize:
2022 $editUidList='';
2023 $recs=Array();
2024 $nextTree = $this->nextThree;
2025 $c=0;
2026 $output=Array();
2027
2028 // Traverse the result:
2029 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
2030
2031 t3lib_BEfunc::workspaceOL($table, $row, -99, TRUE);
2032
2033 if ($row) {
2034 // Add the row to the array:
2035 $output[]=$row;
2036
2037 // Set an internal register:
2038 $recs[$c]=$row['uid'];
2039
2040 // Create the list of the next three ids (for editing links...)
2041 for($a=0;$a<$nextTree;$a++) {
2042 if(isset($recs[$c-$a])) {
2043 $this->tt_contentData['nextThree'][$recs[$c-$a]].=$row['uid'].',';
2044 }
2045 }
2046
2047 // Set next/previous ids:
2048 if (isset($recs[$c-1])) {
2049 if (isset($recs[$c-2])) {
2050 $this->tt_contentData['prev'][$row['uid']]=-$recs[$c-2];
2051 } else {
2052 $this->tt_contentData['prev'][$row['uid']]=$row['pid'];
2053 }
2054 $this->tt_contentData['next'][$recs[$c-1]]=-$row['uid'];
2055 }
2056 $c++;
2057 }
2058 }
2059
2060 // Return selected records
2061 return $output;
2062 }
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076 /**********************************
2077 *
2078 * Additional functions; Message board items (tt_board)
2079 *
2080 **********************************/
2081
2082 /**
2083 * Traverses recursively a branch in a message board.
2084 *
2085 * @param array Array of rows (build up recursively)
2086 * @param integer tt_content parent uid
2087 * @param integer Page id
2088 * @param string Additional query part.
2089 * @param string HTML content to prefix items with (to draw the proper tree-graphics)
2090 * @return array $theRows, but with added content
2091 */
2092 function tt_board_getTree($theRows,$parent,$pid,$qWhere,$treeIcons) {
2093
2094 // Select tt_board elements:
2095 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_board', 'pid='.intval($pid).' AND parent='.intval($parent).$qWhere, '', 'crdate');
2096
2097 // Traverse the results:
2098 $c=0;
2099 $rc = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
2100 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
2101 $c++;
2102 $row['treeIcons'] = $treeIcons.'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/'.($rc==$c ? 'joinbottom.gif' : 'join.gif'),'width="18" height="16"').' alt="" />';
2103 $theRows[]=$row;
2104
2105 // Get the branch
2106 $theRows = $this->tt_board_getTree(
2107 $theRows,
2108 $row['uid'],
2109 $row['pid'],
2110 $qWhere,
2111 $treeIcons.'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/ol/'.($rc==$c ? 'blank.gif' : 'line.gif'),'width="18" height="16"').' alt="" />'
2112 );
2113 }
2114
2115 // Return modified rows:
2116 return $theRows;
2117 }
2118
2119 /**
2120 * Adds an element to the tt_board listing:
2121 *
2122 * @param string Table name
2123 * @param array The record row
2124 * @param string Reply count, if applicable.
2125 * @return string Return content of element (table row)
2126 */
2127 function tt_board_drawItem($table,$row,$re) {
2128
2129 // Building data-arary with content:
2130 $theData = Array();
2131 $theData['subject'] = t3lib_div::fixed_lgd_cs(htmlspecialchars($row['subject']),25).'&nbsp; &nbsp;';
2132 $theData['author'] = t3lib_div::fixed_lgd_cs(htmlspecialchars($row['author']),15).'&nbsp; &nbsp;';
2133 $theData['date'] = t3lib_div::fixed_lgd_cs(t3lib_BEfunc::datetime($row['crdate']),20).'&nbsp; &nbsp;';
2134 $theData['age'] = t3lib_BEfunc::calcAge(time()-$row['crdate'], $this->agePrefixes).'&nbsp; &nbsp;';
2135 if ($re) {
2136 $theData['replys'] = $re;
2137 }
2138
2139 // Subject is built:
2140 $theData['subject'] =
2141 $row['treeIcons'].
2142 $this->getIcon($table,$row).
2143 $theData['subject'];
2144
2145 // Adding element:
2146 return $this->addelement(1,'',$theData);
2147 }
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161 /********************************
2162 *
2163 * Various helper functions
2164 *
2165 ********************************/
2166
2167 /**
2168 * Counts and returns the number of records on the page with $pid
2169 *
2170 * @param string Table name
2171 * @param integer Page id
2172 * @return integer Number of records.
2173 */
2174 function numberOfRecords($table,$pid) {
2175 global $TCA;
2176
2177 $c=0;
2178 if ($TCA[$table]) {
2179 $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', $table, 'pid='.intval($pid).t3lib_BEfunc::deleteClause($table).t3lib_BEfunc::versioningPlaceholderClause($table));
2180 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_row($result)) {
2181 $c=$row[0];
2182 }
2183 }
2184 return $c;
2185 }
2186
2187 /**
2188 * Processing of larger amounts of text (usually from RTE/bodytext fields) with word wrapping etc.
2189 *
2190 * @param string Input string
2191 * @return string Output string
2192 */
2193 function renderText($input) {
2194 $input = $this->strip_tags($input, true);
2195 $input = t3lib_div::fixed_lgd_cs($input,1500);
2196 return nl2br(htmlspecialchars(trim($this->wordWrapper($input))));
2197 }
2198
2199 /**
2200 * Creates the icon image tag for record from table and wraps it in a link which will trigger the click menu.
2201 *
2202 * @param string Table name
2203 * @param array Record array
2204 * @param string Record title (NOT USED)
2205 * @return string HTML for the icon
2206 */
2207 function getIcon($table,$row) {
2208
2209 // Initialization
2210 $alttext = t3lib_BEfunc::getRecordIconAltText($row,$table);
2211 $iconImg = t3lib_iconWorks::getIconImage($table,$row,$this->backPath,'title="'.$alttext.'"');
2212 $this->counter++;
2213
2214 // The icon with link
2215 $theIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconImg,$table,$row['uid']);
2216
2217 return $theIcon;
2218 }
2219
2220 /**
2221 * Creates processed values for all fieldnames in $fieldList based on values from $row array.
2222 * The result is 'returned' through $info which is passed as a reference
2223 *
2224 * @param string Table name
2225 * @param string Commalist of fields.
2226 * @param array Record from which to take values for processing.
2227 * @param array Array to which the processed values are added.
2228 * @return void
2229 */
2230 function getProcessedValue($table,$fieldList,$row,&$info) {
2231
2232 // Splitting values from $fieldList:
2233 $fieldArr = explode(',',$fieldList);
2234
2235 // Traverse fields from $fieldList:
2236 foreach($fieldArr as $field) {
2237 if ($row[$field]) {
2238 $info[]= htmlspecialchars($this->itemLabels[$field]).' '.htmlspecialchars(t3lib_BEfunc::getProcessedValue($table,$field,$row[$field]));
2239 }
2240 }
2241 }
2242
2243 /**
2244 * Returns true, if the record given as parameters is NOT visible based on hidden/starttime/endtime (if available)
2245 *
2246 * @param string Tablename of table to test
2247 * @param array Record row.
2248 * @return boolean Returns true, if disabled.
2249 */
2250 function isDisabled($table,$row) {
2251 global $TCA;
2252 if (
2253 ($TCA[$table]['ctrl']['enablecolumns']['disabled'] && $row[$TCA[$table]['ctrl']['enablecolumns']['disabled']]) ||
2254 ($TCA[$table]['ctrl']['enablecolumns']['starttime'] && $row[$TCA[$table]['ctrl']['enablecolumns']['starttime']]>time() ) ||
2255 ($TCA[$table]['ctrl']['enablecolumns']['endtime'] && $row[$TCA[$table]['ctrl']['enablecolumns']['endtime']] && $row[$TCA[$table]['ctrl']['enablecolumns']['endtime']]<time())
2256 ) return true;
2257 }
2258
2259 /**
2260 * 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.
2261 * Works well on normal texts, little less well when HTML is involved (since much HTML will have long strings that will be broken).
2262 *
2263 * @param string Content to word-wrap.
2264 * @param integer Max number of chars in a word before it will be wrapped.
2265 * @param string Character to insert when wrapping.
2266 * @return string Processed output.
2267 */
2268 function wordWrapper($content,$max=50,$char=' -') {
2269 $array = split(' |'.chr(10),$content);
2270 foreach($array as $val) {
2271 if (strlen($val)>$max) {
2272 $content=str_replace($val,substr(chunk_split($val,$max,$char),0,-1),$content);
2273 }
2274 }
2275 return $content;
2276 }
2277
2278 /**
2279 * Returns icon for "no-edit" of a record.
2280 * 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...
2281 *
2282 * @param string Label key from LOCAL_LANG
2283 * @return string IMG tag for icon.
2284 */
2285 function noEditIcon($label='noEditItems') {
2286 return '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2_d.gif','width="11" height="12"').' title="'.$GLOBALS['LANG']->getLL($label,1).'" alt="" />';
2287 }
2288
2289 /**
2290 * 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.
2291 *
2292 * @return void
2293 */
2294 function cleanTableNames() {
2295 global $TCA;
2296
2297 // Get all table names:
2298 $tableNames=array_flip(array_keys($TCA));
2299
2300 // Unset common names:
2301 unset($tableNames['pages']);
2302 unset($tableNames['static_template']);
2303 unset($tableNames['sys_filemounts']);
2304 unset($tableNames['sys_action']);
2305 unset($tableNames['sys_workflows']);
2306 unset($tableNames['be_users']);
2307 unset($tableNames['be_groups']);
2308
2309 $this->allowedTableNames=array();
2310
2311 // Traverse table names and set them in allowedTableNames array IF they can be read-accessed by the user.
2312 if (is_array($tableNames)) {
2313 foreach($tableNames as $k => $v) {
2314 if ($GLOBALS['BE_USER']->check('tables_select',$k)) {
2315 $this->allowedTableNames['table_'.$k]=$k;
2316 }
2317 }
2318 }
2319 }
2320
2321 /**
2322 * Checking if the RTE is available/enabled for a certain table/field and if so, it returns true.
2323 * Used to determine if the RTE button should be displayed.
2324 *
2325 * @param string Table name
2326 * @param array Record row (needed, if there are RTE dependencies based on other fields in the record)
2327 * @param string Field name
2328 * @return boolean Returns true if the rich text editor would be enabled/available for the field name specified.
2329 */
2330 function isRTEforField($table,$row,$field){
2331 $specConf = $this->getSpecConfForField($table,$row,$field);
2332 $p = t3lib_BEfunc::getSpecConfParametersFromArray($specConf['rte_transform']['parameters']);
2333 if (isset($specConf['richtext']) && (!$p['flag'] || !$row[$p['flag']])) {
2334 t3lib_BEfunc::fixVersioningPid($table,$row);
2335 list($tscPID,$thePidValue) = t3lib_BEfunc::getTSCpid($table,$row['uid'],$row['pid']);
2336 if ($thePidValue>=0) { // If the pid-value is not negative (that is, a pid could NOT be fetched)
2337 $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE',t3lib_BEfunc::getPagesTSconfig($tscPID));
2338 $RTEtypeVal = t3lib_BEfunc::getTCAtypeValue($table,$row);
2339 $thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'],$table,$field,$RTEtypeVal);
2340 if (!$thisConfig['disabled']) {
2341 return TRUE;
2342 }
2343 }
2344 }
2345
2346 return FALSE;
2347 }
2348
2349 /**
2350 * Returns "special" configuration from the "types" configuration in TCA for the record given by tablename/fieldname.
2351 * Used by isRTEforField() in the process of finding whether a field has RTE enabled or not.
2352 *
2353 * @param string Table name
2354 * @param array Record array
2355 * @param string Field name
2356 * @return array Spec. conf (if available)
2357 * @access private
2358 * @see isRTEforField()
2359 */
2360 function getSpecConfForField($table,$row,$field) {
2361
2362 // Get types-configuration for the record:
2363 $types_fieldConfig = t3lib_BEfunc::getTCAtypes($table,$row);
2364
2365 // Find the given field and return the spec key value if found:
2366 if (is_array($types_fieldConfig)) {
2367 foreach($types_fieldConfig as $vconf) {
2368 if ($vconf['field']==$field) return $vconf['spec'];
2369 }
2370 }
2371 }
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384 /*****************************************
2385 *
2386 * External renderings
2387 *
2388 *****************************************/
2389
2390 /**
2391 * Creates an info-box for the current page (identified by input record).
2392 *
2393 * @param array Page record
2394 * @param boolean If set, there will be shown an edit icon, linking to editing of the page properties.
2395 * @return string HTML for the box.
2396 */
2397 function getPageInfoBox($rec,$edit=0) {
2398 global $LANG;
2399
2400 // If editing of the page properties is allowed:
2401 if ($edit) {
2402 $params='&edit[pages]['.$rec['uid'].']=edit';
2403 $editIcon='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath)).'">'.
2404 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/edit2.gif','width="11" height="12"').' title="'.$GLOBALS['LANG']->getLL('edit',1).'" alt="" />'.
2405 '</a>';
2406 } else {
2407 $editIcon=$this->noEditIcon('noEditPage');
2408 }
2409
2410 // Setting page icon, link, title:
2411 $outPutContent = t3lib_iconWorks::getIconImage('pages',$rec,$this->backPath,'title="'.htmlspecialchars(t3lib_BEfunc::titleAttribForPages($rec)).'"').
2412 $editIcon.
2413 '&nbsp;'.
2414 htmlspecialchars($rec['title']);
2415
2416
2417 // Init array where infomation is accumulated as label/value pairs.
2418 $lines=array();
2419
2420 // Owner user/group:
2421 if ($this->pI_showUser) {
2422 // User:
2423 $users= t3lib_BEfunc::getUserNames('username,usergroup,usergroup_cached_list,uid,realName');
2424 $groupArray = explode(',',$GLOBALS['BE_USER']->user['usergroup_cached_list']);
2425 $users=t3lib_BEfunc::blindUserNames($users,$groupArray);
2426 $lines[]=array($LANG->getLL('pI_crUser').':',htmlspecialchars($users[$rec['cruser_id']]['username']).' ('.$users[$rec['cruser_id']]['realName'].')');
2427 }
2428
2429 // Created:
2430 $lines[]=array($LANG->getLL('pI_crDate').':', t3lib_BEfunc::datetime($rec['crdate']).' ('.t3lib_BEfunc::calcAge(time()-$rec['crdate'],$this->agePrefixes).')');
2431
2432 // Last change:
2433 $lines[]=array($LANG->getLL('pI_lastChange').':', t3lib_BEfunc::datetime($rec['tstamp']).' ('.t3lib_BEfunc::calcAge(time()-$rec['tstamp'],$this->agePrefixes).')');
2434
2435 // Last change of content:
2436 if ($rec['SYS_LASTCHANGED']) {
2437 $lines[]=array($LANG->getLL('pI_lastChangeContent').':', t3lib_BEfunc::datetime($rec['SYS_LASTCHANGED']).' ('.t3lib_BEfunc::calcAge(time()-$rec['SYS_LASTCHANGED'],$this->agePrefixes).')');
2438 }
2439
2440 // Spacer:
2441 $lines[]='';
2442
2443 // Display contents of certain page fields, if any value:
2444 $dfields = explode(',','alias,target,hidden,starttime,endtime,fe_group,no_cache,cache_timeout,newUntil,lastUpdated,subtitle,keywords,description,abstract,author,author_email');
2445 foreach($dfields as $fV) {
2446 if ($rec[$fV]) {
2447 $lines[]=array($GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel('pages',$fV)), t3lib_BEfunc::getProcessedValue('pages',$fV,$rec[$fV]));
2448 }
2449 }
2450
2451 // Page hits (depends on "sys_stat" extension)
2452 if ($this->pI_showStat && t3lib_extMgm::isLoaded('sys_stat')) {
2453
2454 // Counting total hits:
2455 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'sys_stat', 'page_id='.intval($rec['uid']));
2456 $rrow = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
2457 if ($rrow[0]) {
2458
2459 // Get min/max
2460 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('min(tstamp) AS min,max(tstamp) AS max', 'sys_stat', 'page_id='.intval($rec['uid']));
2461 $rrow2 = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
2462
2463 $lines[]='';
2464 $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).')');
2465 $lines[]=array($LANG->getLL('pI_hitsTotal').':',$rrow[0]);
2466
2467
2468 // Last 10 days
2469 $nextMidNight = mktime (0,0,0)+1*3600*24;
2470
2471 $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');
2472 $days=array();
2473 while($rrow = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) {
2474 $days[$rrow[1]] = $rrow[0];
2475 }
2476
2477 $headerH=array();
2478 $contentH=array();
2479 for($a=9;$a>=0;$a--) {
2480 $headerH[]='
2481 <td class="bgColor5" nowrap="nowrap">&nbsp;'.date('d',$nextMidNight-($a+1)*24*3600).'&nbsp;</td>';
2482 $contentH[]='
2483 <td align="center">'.($days[$a] ? intval($days[$a]) : '-').'</td>';
2484 }
2485
2486 // Compile first hit-table (last 10 days)
2487 $hitTable='
2488 <table border="0" cellpadding="0" cellspacing="1" class="typo3-page-hits">
2489 <tr>'.implode('',$headerH).'</tr>
2490 <tr>'.implode('',$contentH).'</tr>
2491 </table>';
2492 $lines[]=array($LANG->getLL('pI_hits10days').':',$hitTable,1);
2493
2494
2495 // Last 24 hours
2496 $nextHour = mktime (date('H'),0,0)+3600;
2497 $hours=16;
2498
2499 $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');
2500 $days=array();
2501 while($rrow = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) {
2502 $days[$rrow[1]]=$rrow[0];
2503 }
2504
2505 $headerH=array();
2506 $contentH=array();
2507 for($a=($hours-1);$a>=0;$a--) {
2508 $headerH[]='
2509 <td class="bgColor5" nowrap="nowrap">&nbsp;'.intval(date('H',$nextHour-($a+1)*3600)).'&nbsp;</td>';
2510 $contentH[]='
2511 <td align="center">'.($days[$a] ? intval($days[$a]) : '-').'</td>';
2512 }
2513
2514 // Compile second hit-table (last 24 hours)
2515 $hitTable='
2516 <table border="0" cellpadding="0" cellspacing="1" class="typo3-page-stat">
2517 <tr>'.implode('',$headerH).'</tr>
2518 <tr>'.implode('',$contentH).'</tr>
2519 </table>';
2520 $lines[]=array($LANG->getLL('pI_hits24hours').':',$hitTable,1);
2521 }
2522 }
2523
2524
2525 // Finally, wrap the elements in the $lines array in table cells/rows
2526 foreach($lines as $fV) {
2527 if (is_array($fV)) {
2528 if (!$fV[2]) $fV[1]=htmlspecialchars($fV[1]);
2529 $out.='
2530 <tr>
2531 <td class="bgColor4" nowrap="nowrap"><strong>'.htmlspecialchars($fV[0]).'&nbsp;&nbsp;</strong></td>
2532 <td class="bgColor4">'.$fV[1].'</td>
2533 </tr>';
2534 } else {
2535 $out.='
2536 <tr>
2537 <td colspan="2"><img src="clear.gif" width="1" height="3" alt="" /></td>
2538 </tr>';
2539 }
2540 }
2541
2542 // Wrap table tags around...
2543 $outPutContent.='
2544
2545
2546
2547 <!--
2548 Page info box:
2549 -->
2550 <table border="0" cellpadding="0" cellspacing="1" id="typo3-page-info">
2551 '.$out.'
2552 </table>';
2553
2554 // ... and return it.
2555 return $outPutContent;
2556 }
2557
2558 /**
2559 * Creates a menu of the tables that can be listed by this function
2560 * Only tables which has records on the page will be included.
2561 * Notice: The function also fills in the internal variable $this->activeTables with icon/titles.
2562 *
2563 * @param integer Page id from which we are listing records (the function will look up if there are records on the page)
2564 * @return string HTML output.
2565 */
2566 function getTableMenu($id) {
2567 global $TCA;
2568
2569 // Initialize:
2570 $this->activeTables=array();
2571 $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!
2572
2573 // External tables:
2574 if (is_array($this->externalTables)) {
2575 $theTables = array_unique(array_merge($theTables, array_keys($this->externalTables)));
2576 }
2577
2578 // Traverse tables to check:
2579 foreach($theTables as $tName) {
2580
2581 // Check access and whether the proper extensions are loaded:
2582 if ($GLOBALS['BE_USER']->check('tables_select',$tName) && (t3lib_extMgm::isLoaded($tName)||t3lib_div::inList('fe_users,tt_content',$tName) || isset($this->externalTables[$tName]))) {
2583
2584 // Make query to count records from page:
2585 $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', $tName, 'pid='.intval($id).t3lib_BEfunc::deleteClause($tName).t3lib_BEfunc::versioningPlaceholderClause($tName));
2586 list($c) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result);
2587
2588 // If records were found (or if "tt_content" is the table...):
2589 if ($c || t3lib_div::inList('tt_content',$tName)) {
2590
2591 // Add row to menu:
2592 $out.='
2593 <td><a href="#'.$tName.'"></a>'.
2594 t3lib_iconWorks::getIconImage($tName,Array(),$this->backPath,'title="'.$GLOBALS['LANG']->sL($TCA[$tName]['ctrl']['title'],1).'"').
2595 '</td>';
2596
2597 // ... and to the internal array, activeTables we also add table icon and title (for use elsewhere)
2598 $this->activeTables[$tName]=
2599 t3lib_iconWorks::getIconImage($tName,Array(),$this->backPath,'title="'.$GLOBALS['LANG']->sL($TCA[$tName]['ctrl']['title'],1).': '.$c.' '.$GLOBALS['LANG']->getLL('records',1).'" class="absmiddle"').
2600 '&nbsp;'.
2601 $GLOBALS['LANG']->sL($TCA[$tName]['ctrl']['title'],1);
2602 }
2603 }
2604 }
2605
2606 // Wrap cells in table tags:
2607 $out = '
2608
2609
2610
2611 <!--
2612 Menu of tables on the page (table menu)
2613 -->
2614 <table border="0" cellpadding="0" cellspacing="0" id="typo3-page-tblMenu">
2615 <tr>'.$out.'
2616 </tr>
2617 </table>';
2618
2619 // Return the content:
2620 return $out;
2621 }
2622
2623 /**
2624 * Enhancement for the strip_tags function that provides the feature to fill in empty tags.
2625 * Example <link email@hostname.com></link> is accepted by TYPO3 but would not displayed in the Backend otherwise.
2626 *
2627 * @param string Input string
2628 * @param boolean If true, empty tags will be filled with the first attribute of the tag before.
2629 * @return string Input string with all HTML and PHP tags stripped
2630 */
2631 function strip_tags($content, $fillEmptyContent=false) {
2632 if($fillEmptyContent && strstr($content, '><')) {
2633 $content = preg_replace('/(<[^ >]* )([^ >]*)([^>]*>)(<\/[^>]*>)/', '$1$2$3$2$4', $content);
2634 }
2635 $content = preg_replace('/<br.?\/?>/', chr(10), $content);
2636
2637 return strip_tags($content);
2638 }
2639 }
2640
2641
2642
2643
2644 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/cms/layout/class.tx_cms_layout.php']) {
2645 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/cms/layout/class.tx_cms_layout.php']);
2646 }
2647
2648 ?>