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