[FEATURE] Improve rendering of CE in page module
[Packages/TYPO3.CMS.git] / typo3 / sysext / cms / layout / class.tx_cms_layout.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-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 $disableMoveAndNewButtons = ($this->defLangBinding && $lP > 0);
416 $singleElementHTML .= $this->tt_content_drawHeader($row, $this->tt_contentConfig['showInfo'] ? 15 : 5, $disableMoveAndNewButtons, TRUE);
417
418 $isRTE = $RTE && $this->isRTEforField('tt_content', $row, 'bodytext');
419 $innerContent = '<div ' . ($row['_ORIG_uid'] ? ' class="ver-element"' : '') . '>' . $this->tt_content_drawItem($row, $isRTE) . '</div>';
420
421 $singleElementHTML .= '<div class="t3-page-ce-body-inner">' .
422 $innerContent .
423 '</div>' .
424 $this->tt_content_drawFooter($row);
425
426 // NOTE: this is the end tag for <div class="t3-page-ce-body">
427 // because of bad (historic) conception, starting tag has to be placed inside tt_content_drawHeader()
428 $singleElementHTML .= '</div>';
429
430
431 $statusHidden = ($this->isDisabled('tt_content', $row) ? ' t3-page-ce-hidden' : '');
432 $singleElementHTML = '<div class="t3-page-ce' . $statusHidden . '">' . $singleElementHTML . '</div>';
433
434 // Add icon "new content element below"
435 if (!$disableMoveAndNewButtons) {
436 // New content element:
437 if ($this->option_newWizard) {
438 $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')) . "';";
439 } else {
440 $params = '&edit[tt_content][' . (-$row['uid']) . ']=new';
441 $onClick = t3lib_BEfunc::editOnClick($params, $this->backPath);
442 }
443 $singleElementHTML .= '<div style="margin-bottom:7px;margin-left:5px;"><a href="#" onclick="' . htmlspecialchars($onClick) . '" title="' . $GLOBALS['LANG']->getLL('newRecordHere', 1) . '">' .
444 t3lib_iconWorks::getSpriteIcon('actions-document-new') .
445 '</a></div>';
446 }
447
448 if ($this->defLangBinding && $this->tt_contentConfig['languageMode']) {
449 $defLangBinding[$key][$lP][$row[($lP ? 'l18n_parent' : 'uid')]] = $singleElementHTML;
450 } else {
451 $content[$key] .= $singleElementHTML;
452 }
453 } else {
454 unset($rowArr[$rKey]);
455 }
456 }
457
458 // Add new-icon link, header:
459 $newP = $this->newContentElementOnClick($id, $key, $lP);
460 $colTitle = t3lib_BEfunc::getProcessedValue('tt_content', 'colPos', $key);
461
462 $tcaItems = t3lib_div::callUserFunction('EXT:cms/classes/class.tx_cms_backendlayout.php:tx_cms_BackendLayout->getColPosListItemsParsed', $id, $this);
463 foreach ($tcaItems as $item) {
464 if ($item[1] == $key) {
465 $colTitle = $GLOBALS['LANG']->sL($item[0]);
466 }
467 }
468 $head[$key] .= $this->tt_content_drawColHeader($colTitle, ($this->doEdit && count($rowArr) ? '&edit[tt_content][' . $editUidList . ']=edit' . $pageTitleParamForAltDoc : ''), $newP);
469 $editUidList = '';
470 }
471
472 // For EACH column, fit the rendered content into a table cell:
473 $out = '';
474
475 $backendLayoutUid = $this->getSelectedBackendLayoutUid($id);
476 $backendLayoutRecord = t3lib_BEfunc::getRecord('backend_layout', intval($backendLayoutUid));
477 $this->tt_contentConfig['showAsGrid'] = !empty($backendLayoutRecord['config']) && !$this->tt_contentConfig['languageMode'];
478
479 if (!$this->tt_contentConfig['showAsGrid']) {
480 foreach ($cList as $k => $key) {
481
482 if (!$k) {
483 $out .= '
484 <td><img src="clear.gif" width="' . $lMarg . '" height="1" alt="" /></td>';
485 } else {
486 $out .= '
487 <td><img src="clear.gif" width="4" height="1" alt="" /></td>
488 <td class="t3-page-border"><img src="clear.gif" width="1" height="1" alt="" /></td>
489 <td><img src="clear.gif" width="4" height="1" alt="" /></td>';
490 }
491 $out .= '
492 <td class="t3-page-column t3-page-column-' . $key . '">' . $head[$key] . $content[$key] . '</td>';
493
494 // Storing content for use if languageMode is set:
495 if ($this->tt_contentConfig['languageMode']) {
496 $languageColumn[$key][$lP] = $head[$key] . $content[$key];
497 if (!$this->defLangBinding) {
498 $languageColumn[$key][$lP] .= '<br /><br />' . $this->newLanguageButton($this->getNonTranslatedTTcontentUids($defLanguageCount[$key], $id, $lP), $lP);
499 }
500 }
501 }
502
503 // Wrap the cells into a table row:
504 $out = '
505 <table border="0" cellpadding="0" cellspacing="0" class="t3-page-columns">
506 <tr>' . $out . '
507 </tr>
508 </table>';
509
510 } else {
511 // GRID VIEW:
512
513 // initialize TS parser to parse config to array
514 $parser = t3lib_div::makeInstance('t3lib_TSparser');
515 $parser->parse($backendLayoutRecord['config']);
516
517 $grid .= '<div class="t3-gridContainer"><table border="0" cellspacing="1" cellpadding="4" width="100%" height="100%" class="t3-page-columns t3-gridTable">';
518
519 // add colgroups
520 $colCount = intval($parser->setup['backend_layout.']['colCount']);
521 $rowCount = intval($parser->setup['backend_layout.']['rowCount']);
522
523 $grid .= '<colgroup>';
524 for ($i = 0; $i < $colCount; $i++) {
525 $grid .= '<col style="width:' . (100 / $colCount) . '%"></col>';
526 }
527 $grid .= '</colgroup>';
528
529 // cycle through rows
530 for ($row = 1; $row <= $rowCount; $row++) {
531 $rowConfig = $parser->setup['backend_layout.']['rows.'][$row . '.'];
532 if (!isset($rowConfig)) {
533 continue;
534 }
535
536 $grid .= '<tr>';
537
538 for ($col = 1; $col <= $colCount; $col++) {
539 $columnConfig = $rowConfig['columns.'][$col . '.'];
540
541 if (!isset($columnConfig)) {
542 continue;
543 }
544
545 // which tt_content colPos should be displayed inside this cell
546 $columnKey = intval($columnConfig['colPos']);
547
548 // render the grid cell
549 $colSpan = intval($columnConfig['colspan']);
550 $rowSpan = intval($columnConfig['rowspan']);
551
552 $grid .= '<td valign="top"' .
553 ($colSpan > 0 ? ' colspan="' . $colSpan . '"' : '') .
554 ($rowSpan > 0 ? ' rowspan="' . $rowSpan . '"' : '') .
555 ' class="t3-gridCell t3-page-column t3-page-column-' . $columnKey .
556 (!isset($columnConfig['colPos']) ? ' t3-gridCell-unassigned' : '') .
557 ((isset($columnConfig['colPos']) && ! $head[$columnKey]) ? ' t3-gridCell-restricted' : '') .
558 ($colSpan > 0 ? ' t3-gridCell-width' . $colSpan : '') .
559 ($rowSpan > 0 ? ' t3-gridCell-height' . $rowSpan : '') . '">';
560
561 // Draw the pre-generated header with edit and new buttons if a colPos is assigned.
562 // If not, a new header without any buttons will be generated.
563 if (isset($columnConfig['colPos']) && $head[$columnKey]) {
564 $grid .= $head[$columnKey] . $content[$columnKey];
565 } elseif ($columnConfig['colPos']) {
566 $grid .= $this->tt_content_drawColHeader($GLOBALS['LANG']->getLL('noAccess'), '', '');
567 } else {
568 $grid .= $this->tt_content_drawColHeader($GLOBALS['LANG']->getLL('notAssigned'), '', '');
569 }
570
571 $grid .= '</td>';
572 }
573 $grid .= '</tr>';
574 }
575 $out .= $grid . '</table></div>';
576 }
577
578 // CSH:
579 $out .= t3lib_BEfunc::cshItem($this->descrTable, 'columns_multi', $GLOBALS['BACK_PATH']);
580 }
581
582 // If language mode, then make another presentation:
583 // 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!
584 if ($this->tt_contentConfig['languageMode']) {
585
586 // Get language selector:
587 $languageSelector = $this->languageSelector($id);
588
589 // Reset out - we will make new content here:
590 $out = '';
591 // Separator between language columns (black thin line)
592 $midSep = '
593 <td><img src="clear.gif" width="4" height="1" alt="" /></td>
594 <td class="t3-page-border"><img src="clear.gif" width="1" height="1" alt="" /></td>
595 <td><img src="clear.gif" width="4" height="1" alt="" /></td>';
596
597 // Traverse languages found on the page and build up the table displaying them side by side:
598 $cCont = array();
599 $sCont = array();
600 foreach ($langListArr as $lP) {
601
602 // Header:
603 $cCont[$lP] = '
604 <td valign="top" align="center" class="bgColor6"><strong>' . htmlspecialchars($this->tt_contentConfig['languageCols'][$lP]) . '</strong></td>';
605
606 // "View page" icon is added:
607 $viewLink = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::viewOnClick($this->id, $this->backPath, t3lib_BEfunc::BEgetRootLine($this->id), '', '', '&L=' . $lP)) . '">' .
608 t3lib_iconWorks::getSpriteIcon('actions-document-view') .
609 '</a>';
610
611 // Language overlay page header:
612 if ($lP) {
613
614 list($lpRecord) = t3lib_BEfunc::getRecordsByField('pages_language_overlay', 'pid', $id, 'AND sys_language_uid=' . intval($lP));
615 t3lib_BEfunc::workspaceOL('pages_language_overlay', $lpRecord);
616 $params = '&edit[pages_language_overlay][' . $lpRecord['uid'] . ']=edit&overrideVals[pages_language_overlay][sys_language_uid]=' . $lP;
617 $lPLabel = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon(t3lib_iconWorks::getSpriteIconForRecord('pages_language_overlay', $lpRecord), 'pages_language_overlay', $lpRecord['uid']) .
618 $viewLink .
619 ($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) . '">' .
620 t3lib_iconWorks::getSpriteIcon('actions-document-open') .
621 '</a>' : '') .
622 htmlspecialchars(t3lib_div::fixed_lgd_cs($lpRecord['title'], 20));
623 } else {
624 $lPLabel = $viewLink;
625 }
626 $sCont[$lP] = '
627 <td nowrap="nowrap">' . $lPLabel . '</td>';
628 }
629
630 // Add headers:
631 $out .= '<tr>' . implode($midSep, $cCont) . '</tr>';
632 $out .= '<tr class="bgColor5">' . implode($midSep, $sCont) . '</tr>';
633
634 // Traverse previously built content for the columns:
635 foreach ($languageColumn as $cKey => $cCont) {
636 $out .= '
637 <tr>
638 <td valign="top">' . implode('</td>' . $midSep . '
639 <td valign="top">', $cCont) . '</td>
640 </tr>';
641
642 if ($this->defLangBinding) {
643 // "defLangBinding" mode
644 foreach ($defLanguageCount[$cKey] as $defUid) {
645 $cCont = array();
646 foreach ($langListArr as $lP) {
647 $cCont[] = $defLangBinding[$cKey][$lP][$defUid] .
648 '<br/>' . $this->newLanguageButton($this->getNonTranslatedTTcontentUids(array($defUid), $id, $lP), $lP);
649 }
650 $out .= '
651 <tr>
652 <td valign="top">' . implode('</td>' . $midSep . '
653 <td valign="top">', $cCont) . '</td>
654 </tr>';
655 }
656
657 // Create spacer:
658 $cCont = array();
659 foreach ($langListArr as $lP) {
660 $cCont[] = '&nbsp;';
661 }
662 $out .= '
663 <tr>
664 <td valign="top">' . implode('</td>' . $midSep . '
665 <td valign="top">', $cCont) . '</td>
666 </tr>';
667 }
668 }
669
670 // Finally, wrap it all in a table and add the language selector on top of it:
671 $out = $languageSelector . '
672 <table cellpadding="0" cellspacing="0" class="t3-page-langMode">
673 ' . $out . '
674 </table>';
675
676 // CSH:
677 $out .= t3lib_BEfunc::cshItem($this->descrTable, 'language_list', $GLOBALS['BACK_PATH']);
678 }
679 } else { // SINGLE column mode (columns shown beneath each other):
680 #debug('single column');
681 if ($this->tt_contentConfig['sys_language_uid'] == 0 || !$this->defLangBinding) {
682
683 // Initialize:
684 if ($this->defLangBinding && $this->tt_contentConfig['sys_language_uid'] == 0) {
685 $showLanguage = ' AND sys_language_uid IN (0,-1)';
686 $lP = 0;
687 } else {
688 $showLanguage = ' AND sys_language_uid=' . $this->tt_contentConfig['sys_language_uid'];
689 $lP = $this->tt_contentConfig['sys_language_uid'];
690 }
691
692 $cList = explode(',', $this->tt_contentConfig['showSingleCol']);
693 $content = array();
694 $out = '';
695
696 // Expand the table to some preset dimensions:
697 $out .= '
698 <tr>
699 <td><img src="clear.gif" width="' . $lMarg . '" height="1" alt="" /></td>
700 <td valign="top"><img src="clear.gif" width="150" height="1" alt="" /></td>
701 <td><img src="clear.gif" width="10" height="1" alt="" /></td>
702 <td valign="top"><img src="clear.gif" width="300" height="1" alt="" /></td>
703 </tr>';
704
705 // Traverse columns to display top-on-top
706 foreach ($cList as $counter => $key) {
707
708 // Select content elements:
709 $queryParts = $this->makeQueryArray('tt_content', $id, 'AND colPos=' . intval($key) . $showHidden . $showLanguage);
710 $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
711 $c = 0;
712 $rowArr = $this->getResult($result);
713 $rowOut = '';
714
715 // 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:
716 if ($this->doEdit && $this->option_showBigButtons && !intval($key) && !$GLOBALS['TYPO3_DB']->sql_num_rows($result)) {
717 $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')) . "';";
718 $theNewButton = $GLOBALS['SOBE']->doc->t3Button($onClick, $GLOBALS['LANG']->getLL('newPageContent'));
719 $theNewButton = '<img src="clear.gif" width="1" height="5" alt="" /><br />' . $theNewButton;
720 } else {
721 $theNewButton = '';
722 }
723
724 // Traverse any selected elements:
725 foreach ($rowArr as $rKey => $row) {
726
727 if (is_array($row) && (int) $row['t3ver_state'] != 2) {
728
729 $c++;
730 $editUidList .= $row['uid'] . ',';
731 $isRTE = $RTE && $this->isRTEforField('tt_content', $row, 'bodytext');
732
733 // Create row output:
734 $rowOut .= '
735 <tr>
736 <td></td>
737 <td valign="top">' . $this->tt_content_drawHeader($row) . '</td>
738 <td>&nbsp;</td>
739 <td' . ($row['_ORIG_uid'] ? ' class="ver-element"' : '') . ' valign="top">' . $this->tt_content_drawItem($row, $isRTE) . '</td>
740 </tr>';
741
742 // If the element was not the last element, add a divider line:
743 if ($c != $GLOBALS['TYPO3_DB']->sql_num_rows($result)) {
744 $rowOut .= '
745 <tr>
746 <td></td>
747 <td colspan="3"><img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/stiblet_medium2.gif', 'width="468" height="1"') . ' class="c-divider" alt="" /></td>
748 </tr>';
749 }
750 } else {
751 unset($rowArr[$rKey]);
752 }
753 }
754
755 // Add spacer between sections in the vertical list
756 if ($counter) {
757 $out .= '
758 <tr>
759 <td></td>
760 <td colspan="3"><br /><br /><br /><br /></td>
761 </tr>';
762 }
763
764 // Add section header:
765 $newP = $this->newContentElementOnClick($id, $key, $this->tt_contentConfig['sys_language_uid']);
766 $out .= '
767
768 <!-- Column header: -->
769 <tr>
770 <td></td>
771 <td valign="top" colspan="3">' .
772 $this->tt_content_drawColHeader(t3lib_BEfunc::getProcessedValue('tt_content', 'colPos', $key), ($this->doEdit && count($rowArr) ? '&edit[tt_content][' . $editUidList . ']=edit' . $pageTitleParamForAltDoc : ''), $newP) .
773 $theNewButton .
774 '<br /></td>
775 </tr>';
776
777 // Finally, add the content from the records in this column:
778 $out .= $rowOut;
779 }
780
781 // Finally, wrap all table rows in one, big table:
782 $out = '
783 <table border="0" cellpadding="0" cellspacing="0" width="400" class="typo3-page-columnsMode">
784 ' . $out . '
785 </table>';
786
787 // CSH:
788 $out .= t3lib_BEfunc::cshItem($this->descrTable, 'columns_single', $GLOBALS['BACK_PATH']);
789 } else {
790 $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/>';
791 }
792 }
793
794
795 // Add the big buttons to page:
796 if ($this->option_showBigButtons) {
797 $bArray = array();
798
799 if (!$GLOBALS['SOBE']->current_sys_language) {
800 if ($this->ext_CALC_PERMS & 2) {
801 $bArray[0] = $GLOBALS['SOBE']->doc->t3Button(t3lib_BEfunc::editOnClick('&edit[pages][' . $id . "]=edit", $this->backPath, ''), $GLOBALS['LANG']->getLL('editPageProperties'));
802 }
803 } else {
804 if ($this->doEdit && $GLOBALS['BE_USER']->check('tables_modify', 'pages_language_overlay')) {
805 list($languageOverlayRecord) = t3lib_BEfunc::getRecordsByField('pages_language_overlay', 'pid', $id, 'AND sys_language_uid=' . intval($GLOBALS['SOBE']->current_sys_language));
806 $bArray[0] = $GLOBALS['SOBE']->doc->t3Button(t3lib_BEfunc::editOnClick('&edit[pages_language_overlay][' . $languageOverlayRecord['uid'] . "]=edit", $this->backPath, ''), $GLOBALS['LANG']->getLL('editPageProperties_curLang'));
807 }
808 }
809 if ($this->ext_CALC_PERMS & 4 || $this->ext_CALC_PERMS & 2) {
810 $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'));
811 }
812 if ($this->ext_CALC_PERMS & 8) {
813 $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'));
814 }
815 if ($this->doEdit && $this->ext_function == 1) {
816 $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'));
817 }
818 $out = '
819 <table border="0" cellpadding="4" cellspacing="0" class="typo3-page-buttons">
820 <tr>
821 <td>' . implode('</td>
822 <td>', $bArray) . '</td>
823 <td>' . t3lib_BEfunc::cshItem($this->descrTable, 'button_panel', $GLOBALS['BACK_PATH']) . '</td>
824 </tr>
825 </table>
826 <br />
827 ' . $out;
828 }
829
830 // Return content:
831 return $out;
832 }
833
834
835 /**********************************
836 *
837 * Generic listing of items
838 *
839 **********************************/
840
841 /**
842 * Creates a standard list of elements from a table.
843 *
844 * @param string Table name
845 * @param integer Page id.
846 * @param string Comma list of fields to display
847 * @param boolean If TRUE, icon is shown
848 * @param string Additional WHERE-clauses.
849 * @return string HTML table
850 */
851 function makeOrdinaryList($table, $id, $fList, $icon = 0, $addWhere = '') {
852
853 // Initialize:
854 $out = '';
855 $queryParts = $this->makeQueryArray($table, $id, $addWhere);
856 $this->setTotalItems($queryParts);
857 $dbCount = 0;
858
859 // Make query for records if there were any records found in the count operation:
860 if ($this->totalItems) {
861 $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
862 $dbCount = $GLOBALS['TYPO3_DB']->sql_num_rows($result);
863 }
864
865 // If records were found, render the list:
866 $out = '';
867 if ($dbCount) {
868
869 // Set fields
870 $this->fieldArray = t3lib_div::trimExplode(',', '__cmds__,' . $fList, TRUE);
871
872 // Header line is drawn
873 $theData = array();
874 $theData = $this->headerFields($this->fieldArray, $table, $theData);
875 if ($this->doEdit) {
876 $theData['__cmds__'] = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::editOnClick('&edit[' . $table . '][' . $this->id . ']=new', $this->backPath)) . '" title="' . $GLOBALS['LANG']->getLL('new', TRUE) . '">' .
877 t3lib_iconWorks::getSpriteIcon('actions-document-new') .
878 '</a>';
879 }
880 $out .= $this->addelement(1, '', $theData, ' class="c-headLine"', 15);
881
882 // Render Items
883 $this->eCounter = $this->firstElementNumber;
884 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
885 t3lib_BEfunc::workspaceOL($table, $row);
886
887 if (is_array($row)) {
888 list($flag, $code) = $this->fwd_rwd_nav();
889 $out .= $code;
890 if ($flag) {
891 $params = '&edit[' . $table . '][' . $row['uid'] . ']=edit';
892 $Nrow = array();
893
894 // Setting icons/edit links:
895 if ($icon) {
896 $Nrow['__cmds__'] = $this->getIcon($table, $row);
897 }
898 if ($this->doEdit) {
899 $Nrow['__cmds__'] .= '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::editOnClick($params, $this->backPath)) . '" title="' . $GLOBALS['LANG']->getLL('edit', TRUE) . '">' .
900 t3lib_iconWorks::getSpriteIcon('actions-document-open') .
901 '</a>';
902 } else {
903 $Nrow['__cmds__'] .= $this->noEditIcon();
904 }
905
906 // Get values:
907 $Nrow = $this->dataFields($this->fieldArray, $table, $row, $Nrow);
908 $tdparams = $this->eCounter % 2 ? ' class="bgColor4"' : ' class="bgColor4-20"';
909 $out .= $this->addelement(1, '', $Nrow, $tdparams);
910 }
911 $this->eCounter++;
912 }
913 }
914
915 // Wrap it all in a table:
916 $out = '
917
918 <!--
919 STANDARD LIST OF "' . $table . '"
920 -->
921 <table border="0" cellpadding="1" cellspacing="2" width="480" class="typo3-page-stdlist">
922 ' . $out . '
923 </table>';
924 }
925 return $out;
926 }
927
928 /**
929 * Adds content to all data fields in $out array
930 *
931 * @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.
932 * @param string Table name
933 * @param array Record array
934 * @param array Array to which the data is added
935 * @return array $out array returned after processing.
936 * @see makeOrdinaryList()
937 */
938 function dataFields($fieldArr, $table, $row, $out = array()) {
939
940 // Check table validity:
941 if ($GLOBALS['TCA'][$table]) {
942 t3lib_div::loadTCA($table);
943 $thumbsCol = $GLOBALS['TCA'][$table]['ctrl']['thumbnail'];
944
945 // Traverse fields:
946 foreach ($fieldArr as $fieldName) {
947
948 if ($GLOBALS['TCA'][$table]['columns'][$fieldName]) {
949 // Each field has its own cell (if configured in TCA)
950 if ($fieldName == $thumbsCol) { // If the column is a thumbnail column:
951 $out[$fieldName] = $this->thumbCode($row, $table, $fieldName);
952 } else { // ... otherwise just render the output:
953 $out[$fieldName] = nl2br(htmlspecialchars(trim(t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getProcessedValue($table, $fieldName, $row[$fieldName], 0, 0, 0, $row['uid']), 250))));
954 }
955 } 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)
956 $theFields = explode(';', $fieldName);
957
958 // Traverse fields, separated by ";" (displayed in a single cell).
959 foreach ($theFields as $fName2) {
960 if ($GLOBALS['TCA'][$table]['columns'][$fName2]) {
961 $out[$fieldName] .= '<strong>' . $GLOBALS['LANG']->sL($GLOBALS['TCA'][$table]['columns'][$fName2]['label'], 1) . '</strong>' .
962 '&nbsp;&nbsp;' .
963 htmlspecialchars(t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getProcessedValue($table, $fName2, $row[$fName2], 0, 0, 0, $row['uid']), 25)) .
964 '<br />';
965 }
966 }
967 }
968 // If no value, add a nbsp.
969 if (!$out[$fieldName]) {
970 $out[$fieldName] = '&nbsp;';
971 }
972
973 // Wrap in dimmed-span tags if record is "disabled"
974 if ($this->isDisabled($table, $row)) {
975 $out[$fieldName] = $GLOBALS['TBE_TEMPLATE']->dfw($out[$fieldName]);
976 }
977 }
978 }
979 return $out;
980 }
981
982 /**
983 * Header fields made for the listing of records
984 *
985 * @param array Field names
986 * @param string The table name
987 * @param array Array to which the headers are added.
988 * @return array $out returned after addition of the header fields.
989 * @see makeOrdinaryList()
990 */
991 function headerFields($fieldArr, $table, $out = array()) {
992 t3lib_div::loadTCA($table);
993
994 foreach ($fieldArr as $fieldName) {
995 $ll = $GLOBALS['LANG']->sL($GLOBALS['TCA'][$table]['columns'][$fieldName]['label'], 1);
996 $out[$fieldName] = '<strong>' . ($ll ? $ll : '&nbsp;') . '</strong>';
997 }
998 return $out;
999 }
1000
1001
1002 /**********************************
1003 *
1004 * Additional functions; Pages
1005 *
1006 **********************************/
1007
1008 /**
1009 * Adds pages-rows to an array, selecting recursively in the page tree.
1010 *
1011 * @param array Array which will accumulate page rows
1012 * @param integer Pid to select from
1013 * @param string Query-where clause
1014 * @param string Prefixed icon code.
1015 * @param integer Depth (decreasing)
1016 * @return array $theRows, but with added rows.
1017 */
1018 function pages_getTree($theRows, $pid, $qWhere, $treeIcons, $depth) {
1019 $depth--;
1020 if ($depth >= 0) {
1021 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'pages', 'pid=' . intval($pid) . $qWhere, '', 'sorting');
1022 $c = 0;
1023 $rc = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
1024 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1025 t3lib_BEfunc::workspaceOL('pages', $row);
1026 if (is_array($row)) {
1027 $c++;
1028 $row['treeIcons'] = $treeIcons . '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/ol/join' . ($rc == $c ? 'bottom' : '') . '.gif', 'width="18" height="16"') . ' alt="" />';
1029 $theRows[] = $row;
1030
1031 // Get the branch
1032 $spaceOutIcons = '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/ol/' . ($rc == $c ? 'blank.gif' : 'line.gif'), 'width="18" height="16"') . ' alt="" />';
1033 $theRows = $this->pages_getTree($theRows, $row['uid'], $qWhere, $treeIcons . $spaceOutIcons, $row['php_tree_stop'] ? 0 : $depth);
1034 }
1035 }
1036 } else {
1037 $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('uid', 'pages', 'pid=' . intval($pid) . $qWhere);
1038 if ($count) {
1039 $this->plusPages[$pid] = $count;
1040 }
1041 }
1042 return $theRows;
1043 }
1044
1045 /**
1046 * Adds a list item for the pages-rendering
1047 *
1048 * @param array Record array
1049 * @param array Field list
1050 * @return string HTML for the item
1051 */
1052 function pages_drawItem($row, $fieldArr) {
1053
1054 // Initialization
1055 $theIcon = $this->getIcon('pages', $row);
1056
1057 // Preparing and getting the data-array
1058 $theData = Array();
1059 foreach ($fieldArr as $field) {
1060 switch ($field) {
1061 case 'title':
1062 $red = $this->plusPages[$row['uid']] ? '<font color="red"><strong>+&nbsp;</strong></font>' : '';
1063 $pTitle = htmlspecialchars(t3lib_BEfunc::getProcessedValue('pages', $field, $row[$field], 20));
1064 if ($red) {
1065 $pTitle = '<a href="' . htmlspecialchars($this->script . '?id=' . $row['uid']) . '">' . $pTitle . '</a>';
1066 }
1067 $theData[$field] = $row['treeIcons'] . $theIcon . $red . $pTitle . '&nbsp;&nbsp;';
1068 break;
1069 case 'php_tree_stop':
1070 case 'TSconfig':
1071 $theData[$field] = $row[$field] ? '&nbsp;<strong>x</strong>' : '&nbsp;';
1072 break;
1073 case 'uid':
1074 if ($GLOBALS['BE_USER']->doesUserHaveAccess($row, 2)) {
1075 $params = '&edit[pages][' . $row['uid'] . ']=edit';
1076 $eI = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::editOnClick($params, $this->backPath, '')) . '" title="' . $GLOBALS['LANG']->getLL('editThisPage', TRUE) . '">' .
1077 t3lib_iconWorks::getSpriteIcon('actions-document-open') .
1078 '</a>';
1079 } else {
1080 $eI = '';
1081 }
1082 $theData[$field] = '<span align="right">' . $row['uid'] . $eI . '</span>';
1083 break;
1084 default:
1085 if (substr($field, 0, 6) == 'table_') {
1086 $f2 = substr($field, 6);
1087 if ($GLOBALS['TCA'][$f2]) {
1088 $c = $this->numberOfRecords($f2, $row['uid']);
1089 $theData[$field] = '&nbsp;&nbsp;' . ($c ? $c : '');
1090 }
1091 } elseif (substr($field, 0, 5) == 'HITS_') {
1092 if (t3lib_extMgm::isLoaded('sys_stat')) {
1093 $fParts = explode(':', substr($field, 5));
1094 switch ($fParts[0]) {
1095 case 'days':
1096 $timespan = mktime(0, 0, 0) + intval($fParts[1]) * 3600 * 24;
1097 // Page hits
1098 $number = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
1099 '*',
1100 'sys_stat',
1101 $this->stat_select_field . '=' . intval($row['uid']) .
1102 ' AND tstamp >=' . intval($timespan) .
1103 ' AND tstamp <' . intval($timespan + 3600 * 24)
1104 );
1105 if ($number) {
1106 // Sessions
1107 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1108 'count(*)',
1109 'sys_stat',
1110 $this->stat_select_field . '=' . intval($row['uid']) . '
1111 AND tstamp>=' . intval($timespan) . '
1112 AND tstamp<' . intval($timespan + 3600 * 24) . '
1113 AND surecookie<>\'\'',
1114 'surecookie'
1115 );
1116 $scnumber = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
1117
1118 $number .= '/' . $scnumber;
1119 } else {
1120 $number = '';
1121 }
1122 break;
1123 }
1124 $theData[$field] = '&nbsp;' . $number;
1125 } else {
1126 $theData[$field] = '&nbsp;';
1127 }
1128 } else {
1129 $theData[$field] = '&nbsp;&nbsp;' . htmlspecialchars(t3lib_BEfunc::getProcessedValue('pages', $field, $row[$field]));
1130 }
1131 break;
1132 }
1133 }
1134 $this->addElement_tdParams['title'] = ($row['_CSSCLASS'] ? ' class="' . $row['_CSSCLASS'] . '"' : '');
1135 return $this->addelement(1, '', $theData);
1136 }
1137
1138
1139 /**********************************
1140 *
1141 * Additional functions; Content Elements
1142 *
1143 **********************************/
1144
1145 /**
1146 * Draw header for a content element column:
1147 *
1148 * @param string Column name
1149 * @param string Edit params (Syntax: &edit[...] for alt_doc.php)
1150 * @param string New element params (Syntax: &edit[...] for alt_doc.php)
1151 * @return string HTML table
1152 */
1153 function tt_content_drawColHeader($colName, $editParams, $newParams) {
1154
1155 $icons = '';
1156 // Create command links:
1157 if ($this->tt_contentConfig['showCommands']) {
1158 // New record:
1159 if ($newParams) {
1160 $icons .= '<a href="#" onclick="' . htmlspecialchars($newParams) . '" title="' . $GLOBALS['LANG']->getLL('newInColumn', TRUE) . '">' .
1161 t3lib_iconWorks::getSpriteIcon('actions-document-new') .
1162 '</a>';
1163 }
1164 // Edit whole of column:
1165 if ($editParams) {
1166 $icons .= '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::editOnClick($editParams, $this->backPath)) . '" title="' . $GLOBALS['LANG']->getLL('editColumn', TRUE) . '">' .
1167 t3lib_iconWorks::getSpriteIcon('actions-document-open') .
1168 '</a>';
1169 }
1170 }
1171 if (strlen($icons)) {
1172 $icons = '<div class="t3-page-colHeader-icons">' . $icons . '</div>';
1173 }
1174
1175 // Create header row:
1176 $out = '<div class="t3-page-colHeader t3-row-header">
1177 ' . $icons . '
1178 <div class="t3-page-colHeader-label">' . htmlspecialchars($colName) . '</div>
1179 </div>';
1180 return $out;
1181 }
1182
1183 /**
1184 * Draw the footer for a single tt_content element
1185 *
1186 * @param array Record array
1187 * @return string HTML of the footer
1188 */
1189 protected function tt_content_drawFooter(array $row) {
1190 $content = '';
1191
1192 // Get processed values:
1193 $info = array();
1194 $this->getProcessedValue('tt_content', 'hidden,starttime,endtime,fe_group,spaceBefore,spaceAfter', $row, $info);
1195
1196 // Display info from records fields:
1197 if (count($info)) {
1198 $content = '<div class="t3-page-ce-info">
1199 ' . implode('<br />', $info) . '
1200 </div>';
1201 }
1202
1203 // Wrap it
1204 if (!empty($content)) {
1205 $content = '<div class="t3-page-ce-footer">' . $content . '</div>';
1206 }
1207
1208 return $content;
1209 }
1210
1211 /**
1212 * Draw the header for a single tt_content element
1213 *
1214 * @param array Record array
1215 * @param integer Amount of pixel space above the header.
1216 * @param boolean If set the buttons for creating new elements and moving up and down are not shown.
1217 * @param boolean If set, we are in language mode and flags will be shown for languages
1218 * @return string HTML table with the record header.
1219 */
1220 function tt_content_drawHeader($row, $space = 0, $disableMoveAndNewButtons = FALSE, $langMode = FALSE) {
1221
1222 // Load full table description:
1223 t3lib_div::loadTCA('tt_content');
1224
1225 // If show info is set...;
1226 if ($this->tt_contentConfig['showInfo']) {
1227
1228 // Render control panel for the element:
1229 if ($this->tt_contentConfig['showCommands'] && $this->doEdit) {
1230
1231 // Edit content element:
1232 $params = '&edit[tt_content][' . $this->tt_contentData['nextThree'][$row['uid']] . ']=edit';
1233 $out .= '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::editOnClick($params, $this->backPath)) . '" title="' .
1234 htmlspecialchars($this->nextThree > 1 ? sprintf($GLOBALS['LANG']->getLL('nextThree'), $this->nextThree) : $GLOBALS['LANG']->getLL('edit')) . '">' .
1235 t3lib_iconWorks::getSpriteIcon('actions-document-open') .
1236 '</a>';
1237
1238 // Hide element:
1239 $hiddenField = $GLOBALS['TCA']['tt_content']['ctrl']['enablecolumns']['disabled'];
1240 if ($hiddenField && $GLOBALS['TCA']['tt_content']['columns'][$hiddenField]
1241 && (!$GLOBALS['TCA']['tt_content']['columns'][$hiddenField]['exclude']
1242 || $GLOBALS['BE_USER']->check('non_exclude_fields', 'tt_content:' . $hiddenField))) {
1243 if ($row[$hiddenField]) {
1244 $params = '&data[tt_content][' . ($row['_ORIG_uid'] ? $row['_ORIG_uid'] : $row['uid']) . '][' . $hiddenField . ']=0';
1245 $out .= '<a href="' . htmlspecialchars($GLOBALS['SOBE']->doc->issueCommand($params)) . '" title="' . $GLOBALS['LANG']->getLL('unHide', TRUE) . '">' .
1246 t3lib_iconWorks::getSpriteIcon('actions-edit-unhide') .
1247 '</a>';
1248 } else {
1249 $params = '&data[tt_content][' . ($row['_ORIG_uid'] ? $row['_ORIG_uid'] : $row['uid']) . '][' . $hiddenField . ']=1';
1250 $out .= '<a href="' . htmlspecialchars($GLOBALS['SOBE']->doc->issueCommand($params)) . '" title="' . $GLOBALS['LANG']->getLL('hide', TRUE) . '">' .
1251 t3lib_iconWorks::getSpriteIcon('actions-edit-hide') .
1252 '</a>';
1253 }
1254 }
1255
1256 // Delete
1257 $params = '&cmd[tt_content][' . $row['uid'] . '][delete]=1';
1258 $confirm = $GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->getLL('deleteWarning') .
1259 t3lib_BEfunc::translationCount('tt_content', $row['uid'], ' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.translationsOfRecord')));
1260 $out .= '<a href="' . htmlspecialchars($GLOBALS['SOBE']->doc->issueCommand($params)) . '" onclick="' . htmlspecialchars('return confirm(' . $confirm . ');') . '" title="' . $GLOBALS['LANG']->getLL('deleteItem', TRUE) . '">' .
1261 t3lib_iconWorks::getSpriteIcon('actions-edit-delete') .
1262 '</a>';
1263
1264 if (!$disableMoveAndNewButtons) {
1265 $moveButtonContent = '';
1266 $displayMoveButtons = FALSE;
1267
1268 // Move element up:
1269 if ($this->tt_contentData['prev'][$row['uid']]) {
1270 $params = '&cmd[tt_content][' . $row['uid'] . '][move]=' . $this->tt_contentData['prev'][$row['uid']];
1271 $moveButtonContent .= '<a href="' . htmlspecialchars($GLOBALS['SOBE']->doc->issueCommand($params)) . '" title="' . $GLOBALS['LANG']->getLL('moveUp', TRUE) . '">' .
1272 t3lib_iconWorks::getSpriteIcon('actions-move-up') .
1273 '</a>';
1274 $displayMoveButtons = TRUE;
1275 } else {
1276 $moveButtonContent .= t3lib_iconWorks::getSpriteIcon('empty-empty');
1277 }
1278 // Move element down:
1279 if ($this->tt_contentData['next'][$row['uid']]) {
1280 $params = '&cmd[tt_content][' . $row['uid'] . '][move]= ' . $this->tt_contentData['next'][$row['uid']];
1281 $moveButtonContent .= '<a href="' . htmlspecialchars($GLOBALS['SOBE']->doc->issueCommand($params)) . '" title="' . $GLOBALS['LANG']->getLL('moveDown', TRUE) . '">' .
1282 t3lib_iconWorks::getSpriteIcon('actions-move-down') .
1283 '</a>';
1284 $displayMoveButtons = TRUE;
1285 } else {
1286 $moveButtonContent .= t3lib_iconWorks::getSpriteIcon('empty-empty');
1287 }
1288
1289 if ($displayMoveButtons) {
1290 $out .= '<span class="t3-page-ce-icons-move">' . $moveButtonContent . '</span>';
1291 }
1292 }
1293 }
1294
1295 }
1296
1297 $additionalIcons = array();
1298 $additionalIcons[] = $this->getIcon('tt_content', $row) . ' ';
1299 $additionalIcons[] = ($langMode ? $this->languageFlag($row['sys_language_uid'], FALSE) : '');
1300
1301 // Get record locking status:
1302 if ($lockInfo = t3lib_BEfunc::isRecordLocked('tt_content', $row['uid'])) {
1303 $additionalIcons[] = '<a href="#" onclick="' . htmlspecialchars('alert(' . $GLOBALS['LANG']->JScharCode($lockInfo['msg']) . ');return false;') . '" title="' . htmlspecialchars($lockInfo['msg']) . '">' .
1304 t3lib_iconWorks::getSpriteIcon('status-warning-in-use') .
1305 '</a>';
1306 }
1307
1308 // Call stats information hook
1309 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'])) {
1310 $_params = array('tt_content', $row['uid'], &$row);
1311 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'] as $_funcRef) {
1312 $additionalIcons[] = t3lib_div::callUserFunction($_funcRef, $_params, $this);
1313 }
1314 }
1315
1316 // Wrap the whole header
1317 // NOTE: end-tag for <div class="t3-page-ce-body"> is in getTable_tt_content()
1318 return '<h4 class="t3-page-ce-header">
1319 <div class="t3-row-header">
1320 <span class="ce-icons-left">' . implode('', $additionalIcons) . '</span>
1321 <span class="ce-icons">
1322 ' . $out . '
1323 </span></div>
1324 </h4>
1325 <div class="t3-page-ce-body">';
1326 }
1327
1328 /**
1329 * Draws the preview content for a content element
1330 *
1331 * @param string Content element
1332 * @param boolean Set if the RTE link can be created.
1333 * @return string HTML
1334 */
1335 function tt_content_drawItem($row, $isRTE = FALSE) {
1336 $out = '';
1337 $outHeader = '';
1338
1339 // Make header:
1340 if ($row['header']) {
1341 $infoArr = Array();
1342 $this->getProcessedValue('tt_content', 'header_position,header_layout,header_link', $row, $infoArr);
1343
1344 // If header layout is set to 'hidden', display an accordant note:
1345 if ($row['header_layout'] == 100) {
1346 $hiddenHeaderNote = ' <em>[' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.hidden', TRUE) . ']</em>';
1347 }
1348 $outHeader = ($row['date'] ? htmlspecialchars($this->itemLabels['date'] . ' ' . t3lib_BEfunc::date($row['date'])) . '<br />' : '') .
1349 '<strong>' . $this->linkEditContent($this->renderText($row['header']), $row) . $hiddenHeaderNote . '</strong><br />';
1350 }
1351
1352 // Make content:
1353 $infoArr = array();
1354 $drawItem = TRUE;
1355
1356 // Hook: Render an own preview of a record
1357 $drawItemHooks =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem'];
1358
1359 if (is_array($drawItemHooks)) {
1360 foreach ($drawItemHooks as $hookClass) {
1361 $hookObject = t3lib_div::getUserObj($hookClass);
1362
1363 if (!($hookObject instanceof tx_cms_layout_tt_content_drawItemHook)) {
1364 throw new UnexpectedValueException('$hookObject must implement interface tx_cms_layout_tt_content_drawItemHook', 1218547409);
1365 }
1366
1367 $hookObject->preProcess($this, $drawItem, $outHeader, $out, $row);
1368 }
1369 }
1370
1371 // Draw preview of the item depending on its CType (if not disabled by previous hook):
1372 if ($drawItem) {
1373 switch ($row['CType']) {
1374 case 'header':
1375 if ($row['subheader']) {
1376 $out .= $this->linkEditContent($this->renderText($row['subheader']), $row) . '<br />';
1377 }
1378 break;
1379 case 'text':
1380 case 'textpic':
1381 case 'image':
1382 if ($row['CType'] == 'text' || $row['CType'] == 'textpic') {
1383 if ($row['bodytext']) {
1384 $this->getProcessedValue('tt_content', 'text_align,text_face,text_size,text_color,text_properties', $row, $infoArr);
1385 $out .= $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />';
1386 }
1387 }
1388 if ($row['CType'] == 'textpic' || $row['CType'] == 'image') {
1389 if ($row['image']) {
1390 $out .= $this->thumbCode($row, 'tt_content', 'image') . '<br />';
1391 if ($row['imagecaption']) {
1392 $out .= $this->linkEditContent($this->renderText($row['imagecaption']), $row) . '<br />';
1393 }
1394 }
1395 }
1396 break;
1397 case 'bullets':
1398 case 'table':
1399 case 'mailform':
1400 if ($row['bodytext']) {
1401 $out .= $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />';
1402 }
1403 break;
1404 case 'uploads':
1405 if ($row['media']) {
1406 $out .= $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />';
1407 }
1408 break;
1409 case 'multimedia':
1410 if ($row['multimedia']) {
1411 $out .= $this->renderText($row['multimedia']) . '<br />';
1412 $out .= $this->renderText($row['parameters']) . '<br />';
1413 }
1414 break;
1415 case 'splash':
1416 if ($row['bodytext']) {
1417 $out .= $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />';
1418 }
1419 if ($row['image']) {
1420 $out .= $this->thumbCode($row, 'tt_content', 'image') . '<br />';
1421 }
1422 break;
1423 case 'menu':
1424 if ($row['pages']) {
1425 $out .= $this->linkEditContent($row['pages'], $row) . '<br />';
1426 }
1427 break;
1428 case 'shortcut':
1429 if ($row['records']) {
1430 $out .= $this->linkEditContent($row['shortcut'], $row) . '<br />';
1431 }
1432 break;
1433 case 'list':
1434
1435 $hookArr = array();
1436 $hookOut = '';
1437 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info'][$row['list_type']])) {
1438 $hookArr = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info'][$row['list_type']];
1439 } elseif (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info']['_DEFAULT'])) {
1440 $hookArr = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info']['_DEFAULT'];
1441 }
1442 if (count($hookArr) > 0) {
1443 $_params = array('pObj' => &$this, 'row' => $row, 'infoArr' => $infoArr);
1444 foreach ($hookArr as $_funcRef) {
1445 $hookOut .= t3lib_div::callUserFunction($_funcRef, $_params, $this);
1446 }
1447 }
1448 if (strcmp($hookOut, '')) {
1449 $out .= $hookOut;
1450 } elseif (!empty($row['select_key'])) {
1451 $out .= $GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel('tt_content', 'select_key'), 1) . ' ' . $row['select_key'] . '<br />';
1452 }
1453
1454 $out .= $GLOBALS['LANG']->sL(t3lib_BEfunc::getLabelFromItemlist('tt_content', 'pages', $row['pages']), 1) . '<br />';
1455 break;
1456 case 'script':
1457 $out .= $GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel('tt_content', 'select_key'), 1) . ' ' . $row['select_key'] . '<br />';
1458 $out .= '<br />' . $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />';
1459 $out .= '<br />' . $this->linkEditContent($this->renderText($row['imagecaption']), $row) . '<br />';
1460 break;
1461 default:
1462 if ($row['bodytext']) {
1463 $out .= $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />';
1464 }
1465 break;
1466 }
1467 }
1468
1469 // Wrap span-tags:
1470 $out = '
1471 <span class="exampleContent">' . $out . '</span>';
1472 // Add header:
1473 $out = $outHeader . $out;
1474 // Add RTE button:
1475 if ($isRTE) {
1476 $out .= $this->linkRTEbutton($row);
1477 }
1478
1479 // Return values:
1480 if ($this->isDisabled('tt_content', $row)) {
1481 return $GLOBALS['TBE_TEMPLATE']->dfw($out);
1482 } else {
1483 return $out;
1484 }
1485 }
1486
1487 /**
1488 * Filters out all tt_content uids which are already translated so only non-translated uids is left.
1489 * 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 (?)
1490 *
1491 * @param array Numeric array with uids of tt_content elements in the default language
1492 * @param integer Page pid
1493 * @param integer Sys language UID
1494 * @return array Modified $defLanguageCount
1495 */
1496 function getNonTranslatedTTcontentUids($defLanguageCount, $id, $lP) {
1497 if ($lP && count($defLanguageCount)) {
1498
1499 // Select all translations here:
1500 $queryParts = $this->makeQueryArray('tt_content', $id, 'AND sys_language_uid=' . intval($lP) . ' AND l18n_parent IN (' . implode(',', $defLanguageCount) . ')');
1501 $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
1502
1503 // Flip uids:
1504 $defLanguageCount = array_flip($defLanguageCount);
1505
1506 // Traverse any selected elements and unset original UID if any:
1507 $rowArr = $this->getResult($result);
1508 foreach ($rowArr as $row) {
1509 unset($defLanguageCount[$row['l18n_parent']]);
1510 }
1511
1512 // Flip again:
1513 $defLanguageCount = array_keys($defLanguageCount);
1514 }
1515
1516 return $defLanguageCount;
1517 }
1518
1519 /**
1520 * Creates button which is used to create copies of records..
1521 *
1522 * @param array Numeric array with uids of tt_content elements in the default language
1523 * @param integer Sys language UID
1524 * @return string "Copy languages" button, if available.
1525 */
1526 function newLanguageButton($defLanguageCount, $lP) {
1527 if ($this->doEdit && count($defLanguageCount) && $lP) {
1528
1529 $params = '';
1530 foreach ($defLanguageCount as $uidVal) {
1531 $params .= '&cmd[tt_content][' . $uidVal . '][localize]=' . $lP;
1532 }
1533
1534 // Copy for language:
1535 $onClick = "window.location.href='" . $GLOBALS['SOBE']->doc->issueCommand($params) . "'; return false;";
1536 $theNewButton = $GLOBALS['SOBE']->doc->t3Button($onClick, $GLOBALS['LANG']->getLL('newPageContent_copyForLang') . ' [' . count($defLanguageCount) . ']');
1537 return $theNewButton;
1538 }
1539 }
1540
1541 /**
1542 * Creates onclick-attribute content for a new content element
1543 *
1544 * @param integer Page id where to create the element.
1545 * @param integer Preset: Column position value
1546 * @param integer Preset: Sys langauge value
1547 * @return string String for onclick attribute.
1548 * @see getTable_tt_content()
1549 */
1550 function newContentElementOnClick($id, $colPos, $sys_language) {
1551 if ($this->option_newWizard) {
1552 $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')) . "';";
1553 } else {
1554 $onClick = t3lib_BEfunc::editOnClick('&edit[tt_content][' . $id . ']=new&defVals[tt_content][colPos]=' . $colPos . '&defVals[tt_content][sys_language_uid]=' . $sys_language, $this->backPath);
1555 }
1556 return $onClick;
1557 }
1558
1559 /**
1560 * Will create a link on the input string and possible a big button after the string which links to editing in the RTE
1561 * Used for content element content displayed so the user can click the content / "Edit in Rich Text Editor" button
1562 *
1563 * @param string String to link. Must be prepared for HTML output.
1564 * @param array The row.
1565 * @return string If the whole thing was editable ($this->doEdit) $str is return with link around. Otherwise just $str.
1566 * @see getTable_tt_content()
1567 */
1568 function linkEditContent($str, $row) {
1569 $addButton = '';
1570 $onClick = '';
1571
1572 if ($this->doEdit) {
1573 // Setting onclick action for content link:
1574 $onClick = t3lib_BEfunc::editOnClick('&edit[tt_content][' . $row['uid'] . ']=edit', $this->backPath);
1575 }
1576 // Return link
1577 return $onClick ? '<a href="#" onclick="' . htmlspecialchars($onClick) . '" title="' . $GLOBALS['LANG']->getLL('edit', 1) . '">' . $str . '</a>' . $addButton : $str;
1578 }
1579
1580 /**
1581 * Adds a button to edit the row in RTE wizard
1582 *
1583 * @param array The row of tt_content element
1584 * @return string Button to click if you want to edit in RTE wizard.
1585 */
1586 function linkRTEbutton($row) {
1587 $params = array();
1588 $params['table'] = 'tt_content';
1589 $params['uid'] = $row['uid'];
1590 $params['pid'] = $row['pid'];
1591 $params['field'] = 'bodytext';
1592 $params['returnUrl'] = t3lib_div::linkThisScript();
1593 $RTEonClick = "window.location.href='" . $this->backPath . "wizard_rte.php?" . t3lib_div::implodeArrayForUrl('', array('P' => $params)) . "';return false;";
1594 $addButton = $this->option_showBigButtons && $this->doEdit ? $GLOBALS['SOBE']->doc->t3Button($RTEonClick, $GLOBALS['LANG']->getLL('editInRTE')) : '';
1595
1596 return $addButton;
1597 }
1598
1599 /**
1600 * Make selector box for creating new translation in a language
1601 * Displays only languages which are not yet present for the current page and
1602 * that are not disabled with page TS.
1603 *
1604 * @param integer Page id for which to create a new language (pages_language_overlay record)
1605 * @return string <select> HTML element (if there were items for the box anyways...)
1606 * @see getTable_tt_content()
1607 */
1608 function languageSelector($id) {
1609 if ($GLOBALS['BE_USER']->check('tables_modify', 'pages_language_overlay')) {
1610
1611 // First, select all
1612 $res = $GLOBALS['SOBE']->exec_languageQuery(0);
1613 $langSelItems = array();
1614 $langSelItems[0] = '
1615 <option value="0"></option>';
1616 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1617 if ($GLOBALS['BE_USER']->checkLanguageAccess($row['uid'])) {
1618 $langSelItems[$row['uid']] = '
1619 <option value="' . $row['uid'] . '">' . htmlspecialchars($row['title']) . '</option>';
1620 }
1621 }
1622
1623 // Then, subtract the languages which are already on the page:
1624 $res = $GLOBALS['SOBE']->exec_languageQuery($id);
1625 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1626 unset($langSelItems[$row['uid']]);
1627 }
1628 // Remove disallowed languages
1629 if (count($langSelItems) > 1 &&
1630 !$GLOBALS['BE_USER']->user['admin'] &&
1631 strlen($GLOBALS['BE_USER']->groupData['allowed_languages'])) {
1632
1633 $allowed_languages = array_flip(explode(',', $GLOBALS['BE_USER']->groupData['allowed_languages']));
1634
1635 if (count($allowed_languages)) {
1636 foreach ($langSelItems as $key => $value) {
1637 if (!isset($allowed_languages[$key]) && $key != 0) {
1638 unset($langSelItems[$key]);
1639 }
1640 }
1641 }
1642 }
1643 // Remove disabled languages
1644 $modSharedTSconfig = t3lib_BEfunc::getModTSconfig($id, 'mod.SHARED');
1645 $disableLanguages = isset($modSharedTSconfig['properties']['disableLanguages']) ? t3lib_div::trimExplode(',', $modSharedTSconfig['properties']['disableLanguages'], 1) : array();
1646 if (count($langSelItems) && count($disableLanguages)) {
1647 foreach ($disableLanguages as $language) {
1648 if ($language != 0 && isset($langSelItems[$language])) {
1649 unset($langSelItems[$language]);
1650 }
1651 }
1652 }
1653
1654 // If any languages are left, make selector:
1655 if (count($langSelItems) > 1) {
1656 $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')) . '\'';
1657 return $GLOBALS['LANG']->getLL('new_language', 1) . ': <select name="createNewLanguage" onchange="' . htmlspecialchars($onChangeContent) . '">
1658 ' . implode('', $langSelItems) . '
1659 </select><br /><br />';
1660 }
1661 }
1662 }
1663
1664 /**
1665 * Traverse the result pointer given, adding each record to array and setting some internal values at the same time.
1666 *
1667 * @param pointer SQL result pointer for select query.
1668 * @param string Table name defaulting to tt_content
1669 * @return array The selected rows returned in this array.
1670 */
1671 function getResult($result, $table = 'tt_content') {
1672
1673 // Initialize:
1674 $editUidList = '';
1675 $recs = Array();
1676 $nextTree = $this->nextThree;
1677 $c = 0;
1678 $output = Array();
1679
1680 // Traverse the result:
1681 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
1682
1683 t3lib_BEfunc::workspaceOL($table, $row, -99, TRUE);
1684
1685 if ($row) {
1686 // Add the row to the array:
1687 $output[] = $row;
1688
1689 // Set an internal register:
1690 $recs[$c] = $row['uid'];
1691
1692 // Create the list of the next three ids (for editing links...)
1693 for ($a = 0; $a < $nextTree; $a++) {
1694 if (isset($recs[$c - $a])) {
1695 $this->tt_contentData['nextThree'][$recs[$c - $a]] .= $row['uid'] . ',';
1696 }
1697 }
1698
1699 // Set next/previous ids:
1700 if (isset($recs[$c - 1])) {
1701 if (isset($recs[$c - 2])) {
1702 $this->tt_contentData['prev'][$row['uid']] = -$recs[$c - 2];
1703 } else {
1704 $this->tt_contentData['prev'][$row['uid']] = $row['pid'];
1705 }
1706 $this->tt_contentData['next'][$recs[$c - 1]] = -$row['uid'];
1707 }
1708 $c++;
1709 }
1710 }
1711
1712 // Return selected records
1713 return $output;
1714 }
1715
1716
1717 /********************************
1718 *
1719 * Various helper functions
1720 *
1721 ********************************/
1722
1723 /**
1724 * Counts and returns the number of records on the page with $pid
1725 *
1726 * @param string Table name
1727 * @param integer Page id
1728 * @return integer Number of records.
1729 */
1730 function numberOfRecords($table, $pid) {
1731 if ($GLOBALS['TCA'][$table]) {
1732 $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
1733 'uid',
1734 $table,
1735 'pid=' . intval($pid) .
1736 t3lib_BEfunc::deleteClause($table) .
1737 t3lib_BEfunc::versioningPlaceholderClause($table)
1738 );
1739 }
1740 return intval($count);
1741 }
1742
1743 /**
1744 * Processing of larger amounts of text (usually from RTE/bodytext fields) with word wrapping etc.
1745 *
1746 * @param string Input string
1747 * @return string Output string
1748 */
1749 function renderText($input) {
1750 $input = strip_tags($input);
1751 $input = t3lib_div::fixed_lgd_cs($input, 1500);
1752 return nl2br(htmlspecialchars(trim($this->wordWrapper($input))));
1753 }
1754
1755 /**
1756 * Creates the icon image tag for record from table and wraps it in a link which will trigger the click menu.
1757 *
1758 * @param string Table name
1759 * @param array Record array
1760 * @param string Record title (NOT USED)
1761 * @return string HTML for the icon
1762 */
1763 function getIcon($table, $row) {
1764
1765 // Initialization
1766 $alttext = t3lib_BEfunc::getRecordIconAltText($row, $table);
1767 $iconImg = t3lib_iconWorks::getSpriteIconForRecord($table, $row, array('title' => $alttext));
1768 $this->counter++;
1769
1770 // The icon with link
1771 $theIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconImg, $table, $row['uid']);
1772
1773 return $theIcon;
1774 }
1775
1776 /**
1777 * Creates processed values for all fieldnames in $fieldList based on values from $row array.
1778 * The result is 'returned' through $info which is passed as a reference
1779 *
1780 * @param string Table name
1781 * @param string Commalist of fields.
1782 * @param array Record from which to take values for processing.
1783 * @param array Array to which the processed values are added.
1784 * @return void
1785 */
1786 function getProcessedValue($table, $fieldList, array $row, array &$info) {
1787 // Splitting values from $fieldList
1788 $fieldArr = explode(',', $fieldList);
1789
1790 // Traverse fields from $fieldList
1791 foreach ($fieldArr as $field) {
1792 if ($row[$field]) {
1793 $info[] = '<strong>' . htmlspecialchars($this->itemLabels[$field]) . '</strong> ' . htmlspecialchars(t3lib_BEfunc::getProcessedValue($table, $field, $row[$field]));
1794 }
1795 }
1796 }
1797
1798 /**
1799 * Returns TRUE, if the record given as parameters is NOT visible based on hidden/starttime/endtime (if available)
1800 *
1801 * @param string Tablename of table to test
1802 * @param array Record row.
1803 * @return boolean Returns TRUE, if disabled.
1804 */
1805 function isDisabled($table, $row) {
1806 if (
1807 ($GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled']
1808 && $row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled']])
1809 || ($GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['starttime']
1810 && $row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['starttime']] > $GLOBALS['EXEC_TIME'])
1811 || ($GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['endtime']
1812 && $row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['endtime']]
1813 && $row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['endtime']] < $GLOBALS['EXEC_TIME'])
1814 ) {
1815 return TRUE;
1816 }
1817 }
1818
1819 /**
1820 * 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.
1821 * Works well on normal texts, little less well when HTML is involved (since much HTML will have long strings that will be broken).
1822 *
1823 * @param string Content to word-wrap.
1824 * @param integer Max number of chars in a word before it will be wrapped.
1825 * @param string Character to insert when wrapping.
1826 * @return string Processed output.
1827 */
1828 function wordWrapper($content, $max = 50, $char = ' -') {
1829 $array = preg_split('/[ ' . LF . ']/', $content);
1830 foreach ($array as $val) {
1831 if (strlen($val) > $max) {
1832 $content = str_replace($val, substr(chunk_split($val, $max, $char), 0, -1), $content);
1833 }
1834 }
1835 return $content;
1836 }
1837
1838 /**
1839 * Returns icon for "no-edit" of a record.
1840 * 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...
1841 *
1842 * @param string Label key from LOCAL_LANG
1843 * @return string IMG tag for icon.
1844 */
1845 function noEditIcon($label = 'noEditItems') {
1846 return t3lib_iconWorks::getSpriteIcon('status-edit-read-only', array('title' => $GLOBALS['LANG']->getLL($label, TRUE)));
1847 }
1848
1849 /**
1850 * 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.
1851 *
1852 * @return void
1853 */
1854 function cleanTableNames() {
1855
1856 // Get all table names:
1857 $tableNames = array_flip(array_keys($GLOBALS['TCA']));
1858
1859 // Unset common names:
1860 unset($tableNames['pages']);
1861 unset($tableNames['static_template']);
1862 unset($tableNames['sys_filemounts']);
1863 unset($tableNames['sys_action']);
1864 unset($tableNames['sys_workflows']);
1865 unset($tableNames['be_users']);
1866 unset($tableNames['be_groups']);
1867
1868 $this->allowedTableNames = array();
1869
1870 // Traverse table names and set them in allowedTableNames array IF they can be read-accessed by the user.
1871 if (is_array($tableNames)) {
1872 foreach ($tableNames as $k => $v) {
1873 if ($GLOBALS['BE_USER']->check('tables_select', $k)) {
1874 $this->allowedTableNames['table_' . $k] = $k;
1875 }
1876 }
1877 }
1878 }
1879
1880 /**
1881 * Checking if the RTE is available/enabled for a certain table/field and if so, it returns TRUE.
1882 * Used to determine if the RTE button should be displayed.
1883 *
1884 * @param string Table name
1885 * @param array Record row (needed, if there are RTE dependencies based on other fields in the record)
1886 * @param string Field name
1887 * @return boolean Returns TRUE if the rich text editor would be enabled/available for the field name specified.
1888 */
1889 function isRTEforField($table, $row, $field) {
1890 $specConf = $this->getSpecConfForField($table, $row, $field);
1891 $p = t3lib_BEfunc::getSpecConfParametersFromArray($specConf['rte_transform']['parameters']);
1892 if (isset($specConf['richtext']) && (!$p['flag'] || !$row[$p['flag']])) {
1893 t3lib_BEfunc::fixVersioningPid($table, $row);
1894 list($tscPID, $thePidValue) = t3lib_BEfunc::getTSCpid($table, $row['uid'], $row['pid']);
1895 if ($thePidValue >= 0) { // If the pid-value is not negative (that is, a pid could NOT be fetched)
1896 $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE', t3lib_BEfunc::getPagesTSconfig($tscPID));
1897 $RTEtypeVal = t3lib_BEfunc::getTCAtypeValue($table, $row);
1898 $thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'], $table, $field, $RTEtypeVal);
1899 if (!$thisConfig['disabled']) {
1900 return TRUE;
1901 }
1902 }
1903 }
1904
1905 return FALSE;
1906 }
1907
1908 /**
1909 * Returns "special" configuration from the "types" configuration in TCA for the record given by tablename/fieldname.
1910 * Used by isRTEforField() in the process of finding whether a field has RTE enabled or not.
1911 *
1912 * @param string Table name
1913 * @param array Record array
1914 * @param string Field name
1915 * @return array Spec. conf (if available)
1916 * @access private
1917 * @see isRTEforField()
1918 */
1919 function getSpecConfForField($table, $row, $field) {
1920
1921 // Get types-configuration for the record:
1922 $types_fieldConfig = t3lib_BEfunc::getTCAtypes($table, $row);
1923
1924 // Find the given field and return the spec key value if found:
1925 if (is_array($types_fieldConfig)) {
1926 foreach ($types_fieldConfig as $vconf) {
1927 if ($vconf['field'] == $field) {
1928 return $vconf['spec'];
1929 }
1930 }
1931 }
1932 }
1933
1934
1935 /*****************************************
1936 *
1937 * External renderings
1938 *
1939 *****************************************/
1940
1941 /**
1942 * Creates an info-box for the current page (identified by input record).
1943 *
1944 * @param array Page record
1945 * @param boolean If set, there will be shown an edit icon, linking to editing of the page properties.
1946 * @return string HTML for the box.
1947 */
1948 function getPageInfoBox($rec, $edit = 0) {
1949 // If editing of the page properties is allowed:
1950 if ($edit) {
1951 $params = '&edit[pages][' . $rec['uid'] . ']=edit';
1952 $editIcon = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::editOnClick($params, $this->backPath)) . '" title="' . $GLOBALS['LANG']->getLL('edit', TRUE) . '">' .
1953 t3lib_iconWorks::getSpriteIcon('actions-document-open') .
1954 '</a>';
1955 } else {
1956 $editIcon = $this->noEditIcon('noEditPage');
1957 }
1958
1959 // Setting page icon, link, title:
1960 $outPutContent = t3lib_iconWorks::getSpriteIconForRecord('pages', $rec, array('title' => t3lib_BEfunc::titleAttribForPages($rec))) .
1961 $editIcon .
1962 '&nbsp;' .
1963 htmlspecialchars($rec['title']);
1964
1965
1966 // Init array where infomation is accumulated as label/value pairs.
1967 $lines = array();
1968
1969 // Owner user/group:
1970 if ($this->pI_showUser) {
1971 // User:
1972 $users = t3lib_BEfunc::getUserNames('username,usergroup,usergroup_cached_list,uid,realName');
1973 $groupArray = explode(',', $GLOBALS['BE_USER']->user['usergroup_cached_list']);
1974 $users = t3lib_BEfunc::blindUserNames($users, $groupArray);
1975 $lines[] = array($GLOBALS['LANG']->getLL('pI_crUser') . ':', htmlspecialchars($users[$rec['cruser_id']]['username']) .
1976 ' (' . $users[$rec['cruser_id']]['realName'] . ')');
1977 }
1978
1979 // Created:
1980 $lines[] = array(
1981 $GLOBALS['LANG']->getLL('pI_crDate') . ':',
1982 t3lib_BEfunc::datetime($rec['crdate']) . ' (' . t3lib_BEfunc::calcAge($GLOBALS['EXEC_TIME'] - $rec['crdate'], $this->agePrefixes) . ')',
1983 );
1984
1985 // Last change:
1986 $lines[] = array(
1987 $GLOBALS['LANG']->getLL('pI_lastChange') . ':',
1988 t3lib_BEfunc::datetime($rec['tstamp']) . ' (' . t3lib_BEfunc::calcAge($GLOBALS['EXEC_TIME'] - $rec['tstamp'], $this->agePrefixes) . ')',
1989 );
1990
1991 // Last change of content:
1992 if ($rec['SYS_LASTCHANGED']) {
1993 $lines[] = array(
1994 $GLOBALS['LANG']->getLL('pI_lastChangeContent') . ':',
1995 t3lib_BEfunc::datetime($rec['SYS_LASTCHANGED']) . ' (' . t3lib_BEfunc::calcAge($GLOBALS['EXEC_TIME'] - $rec['SYS_LASTCHANGED'], $this->agePrefixes) . ')',
1996 );
1997 }
1998
1999 // Spacer:
2000 $lines[] = '';
2001
2002 // Display contents of certain page fields, if any value:
2003 $dfields = explode(',', 'alias,target,hidden,starttime,endtime,fe_group,no_cache,cache_timeout,newUntil,lastUpdated,subtitle,keywords,description,abstract,author,author_email');
2004 foreach ($dfields as $fV) {
2005 if ($rec[$fV]) {
2006 $lines[] = array($GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel('pages', $fV)), t3lib_BEfunc::getProcessedValue('pages', $fV, $rec[$fV]));
2007 }
2008 }
2009
2010 // Page hits (depends on "sys_stat" extension)
2011 if ($this->pI_showStat && t3lib_extMgm::isLoaded('sys_stat')) {
2012
2013 // Counting total hits:
2014 $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', 'sys_stat', 'page_id=' . intval($rec['uid']));
2015 if ($count) {
2016
2017 // Get min/max
2018 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('min(tstamp) AS min,max(tstamp) AS max', 'sys_stat', 'page_id=' . intval($rec['uid']));
2019 $rrow2 = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
2020
2021 $lines[] = '';
2022 $lines[] = array($GLOBALS['LANG']->getLL('pI_hitsPeriod') . ':', t3lib_BEfunc::date($rrow2[0]) . ' - ' .
2023 t3lib_BEfunc::date($rrow2[1]) . ' (' . t3lib_BEfunc::calcAge($rrow2[1] - $rrow2[0], $this->agePrefixes) . ')');
2024 $lines[] = array($GLOBALS['LANG']->getLL('pI_hitsTotal') . ':', $rrow2[0]);
2025
2026
2027 // Last 10 days
2028 $nextMidNight = mktime(0, 0, 0) + 1 * 3600 * 24;
2029
2030 $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');
2031 $days = array();
2032 while ($rrow = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) {
2033 $days[$rrow[1]] = $rrow[0];
2034 }
2035
2036 $headerH = array();
2037 $contentH = array();
2038 for ($a = 9; $a >= 0; $a--) {
2039 $headerH[] = '
2040 <td class="bgColor5" nowrap="nowrap">&nbsp;' . date('d', $nextMidNight - ($a + 1) * 24 * 3600) . '&nbsp;</td>';
2041 $contentH[] = '
2042 <td align="center">' . ($days[$a] ? intval($days[$a]) : '-') . '</td>';
2043 }
2044
2045 // Compile first hit-table (last 10 days)
2046 $hitTable = '
2047 <table border="0" cellpadding="0" cellspacing="1" class="typo3-page-hits">
2048 <tr>' . implode('', $headerH) . '</tr>
2049 <tr>' . implode('', $contentH) . '</tr>
2050 </table>';
2051 $lines[] = array($GLOBALS['LANG']->getLL('pI_hits10days') . ':', $hitTable, 1);
2052
2053
2054 // Last 24 hours
2055 $nextHour = mktime(date('H'), 0, 0) + 3600;
2056 $hours = 16;
2057
2058 $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');
2059 $days = array();
2060 while ($rrow = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) {
2061 $days[$rrow[1]] = $rrow[0];
2062 }
2063
2064 $headerH = array();
2065 $contentH = array();
2066 for ($a = ($hours - 1); $a >= 0; $a--) {
2067 $headerH[] = '
2068 <td class="bgColor5" nowrap="nowrap">&nbsp;' . intval(date('H', $nextHour - ($a + 1) * 3600)) . '&nbsp;</td>';
2069 $contentH[] = '
2070 <td align="center">' . ($days[$a] ? intval($days[$a]) : '-') . '</td>';
2071 }
2072
2073 // Compile second hit-table (last 24 hours)
2074 $hitTable = '
2075 <table border="0" cellpadding="0" cellspacing="1" class="typo3-page-stat">
2076 <tr>' . implode('', $headerH) . '</tr>
2077 <tr>' . implode('', $contentH) . '</tr>
2078 </table>';
2079 $lines[] = array($GLOBALS['LANG']->getLL('pI_hits24hours') . ':', $hitTable, 1);
2080 }
2081 }
2082
2083
2084 // Finally, wrap the elements in the $lines array in table cells/rows
2085 foreach ($lines as $fV) {
2086 if (is_array($fV)) {
2087 if (!$fV[2]) {
2088 $fV[1] = htmlspecialchars($fV[1]);
2089 }
2090 $out .= '
2091 <tr>
2092 <td class="bgColor4" nowrap="nowrap"><strong>' . htmlspecialchars($fV[0]) . '&nbsp;&nbsp;</strong></td>
2093 <td class="bgColor4">' . $fV[1] . '</td>
2094 </tr>';
2095 } else {
2096 $out .= '
2097 <tr>
2098 <td colspan="2"><img src="clear.gif" width="1" height="3" alt="" /></td>
2099 </tr>';
2100 }
2101 }
2102
2103 // Wrap table tags around...
2104 $outPutContent .= '
2105
2106
2107
2108 <!--
2109 Page info box:
2110 -->
2111 <table border="0" cellpadding="0" cellspacing="1" id="typo3-page-info">
2112 ' . $out . '
2113 </table>';
2114
2115 // ... and return it.
2116 return $outPutContent;
2117 }
2118
2119 /**
2120 * Creates a menu of the tables that can be listed by this function
2121 * Only tables which has records on the page will be included.
2122 * Notice: The function also fills in the internal variable $this->activeTables with icon/titles.
2123 *
2124 * @param integer Page id from which we are listing records (the function will look up if there are records on the page)
2125 * @return string HTML output.
2126 */
2127 function getTableMenu($id) {
2128
2129 // Initialize:
2130 $this->activeTables = array();
2131 $theTables = array('tt_content');
2132
2133 // External tables:
2134 if (is_array($this->externalTables)) {
2135 $theTables = array_unique(array_merge($theTables, array_keys($this->externalTables)));
2136 }
2137
2138 // Traverse tables to check:
2139 foreach ($theTables as $tName) {
2140
2141 // Check access and whether the proper extensions are loaded:
2142 if ($GLOBALS['BE_USER']->check('tables_select', $tName) && (t3lib_extMgm::isLoaded($tName) || t3lib_div::inList('fe_users,tt_content', $tName) || isset($this->externalTables[$tName]))) {
2143
2144 // Make query to count records from page:
2145 $c = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
2146 'uid',
2147 $tName,
2148 'pid=' . intval($id) .
2149 t3lib_BEfunc::deleteClause($tName) .
2150 t3lib_BEfunc::versioningPlaceholderClause($tName)
2151 );
2152
2153 // If records were found (or if "tt_content" is the table...):
2154 if ($c || t3lib_div::inList('tt_content', $tName)) {
2155
2156 // Add row to menu:
2157 $out .= '
2158 <td><a href="#' . $tName . '"></a>' .
2159 t3lib_iconWorks::getSpriteIconForRecord(
2160 $tName,
2161 array(),
2162 array('title' => $GLOBALS['LANG']->sL($GLOBALS['TCA'][$tName]['ctrl']['title'], 1))
2163 ) . '</td>';
2164
2165 // ... and to the internal array, activeTables we also add table icon and title (for use elsewhere)
2166 $this->activeTables[$tName] =
2167 t3lib_iconWorks::getSpriteIconForRecord(
2168 $tName,
2169 array(),
2170 array('title' => $GLOBALS['LANG']->sL($GLOBALS['TCA'][$tName]['ctrl']['title'], 1) . ': ' . $c . ' ' . $GLOBALS['LANG']->getLL('records', 1))
2171 ) .
2172 '&nbsp;' . $GLOBALS['LANG']->sL($GLOBALS['TCA'][$tName]['ctrl']['title'], 1);
2173 }
2174 }
2175 }
2176
2177 // Wrap cells in table tags:
2178 $out = '
2179 <!--
2180 Menu of tables on the page (table menu)
2181 -->
2182 <table border="0" cellpadding="0" cellspacing="0" id="typo3-page-tblMenu">
2183 <tr>' . $out . '
2184 </tr>
2185 </table>';
2186
2187 // Return the content:
2188 return $out;
2189 }
2190
2191 /**
2192 * Enhancement for the strip_tags function that provides the feature to fill in empty tags.
2193 * Example <link email@hostname.com></link> is accepted by TYPO3 but would not displayed in the Backend otherwise.
2194 *
2195 * @param string Input string
2196 * @param boolean If TRUE, empty tags will be filled with the first attribute of the tag before.
2197 * @return string Input string with all HTML and PHP tags stripped
2198 * @deprecated since TYPO3 4.6, will be removed in 4.8 - using php-function strip_tags now
2199 */
2200 function strip_tags($content, $fillEmptyContent = FALSE) {
2201 if ($fillEmptyContent && strstr($content, '><')) {
2202 $content = preg_replace('/(<[^ >]* )([^ >]*)([^>]*>)(<\/[^>]*>)/', '$1$2$3$2$4', $content);
2203 }
2204 $content = preg_replace('/<br.?\/?>/', LF, $content);
2205
2206 return strip_tags($content);
2207 }
2208 }
2209
2210
2211 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/cms/layout/class.tx_cms_layout.php'])) {
2212 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/cms/layout/class.tx_cms_layout.php']);
2213 }
2214
2215 ?>