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