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