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