[TASK] Add logDeprecatedFunction() to two methods
[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 = $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 (!empty($row['records'])) {
1430 $shortcutContent = array();
1431
1432 $recordList = explode(',', $row['records']);
1433 foreach ($recordList as $recordIdentifier) {
1434 $split = t3lib_BEfunc::splitTable_Uid($recordIdentifier);
1435 $tableName = empty($split[0]) ? 'tt_content' : $split[0];
1436
1437 $shortcutRecord = t3lib_BEfunc::getRecord($tableName, $split[1]);
1438
1439 if (is_array($shortcutRecord)) {
1440 $icon = t3lib_iconWorks::getSpriteIconForRecord($tableName, $shortcutRecord);
1441 $onClick = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon(
1442 $icon, $tableName, $shortcutRecord['uid'], 1, '', '+copy,info,edit,view', TRUE);
1443
1444 $shortcutContent[] = '<a href="#" onclick="' . htmlspecialchars($onClick) . '">' . $icon . '</a>' .
1445 htmlspecialchars(t3lib_BEfunc::getRecordTitle($tableName, $shortcutRecord));
1446 }
1447 }
1448 $out .= implode('<br />', $shortcutContent) . '<br />';
1449 }
1450 break;
1451 case 'list':
1452
1453 $hookArr = array();
1454 $hookOut = '';
1455 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info'][$row['list_type']])) {
1456 $hookArr = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info'][$row['list_type']];
1457 } elseif (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info']['_DEFAULT'])) {
1458 $hookArr = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info']['_DEFAULT'];
1459 }
1460 if (count($hookArr) > 0) {
1461 $_params = array('pObj' => &$this, 'row' => $row, 'infoArr' => $infoArr);
1462 foreach ($hookArr as $_funcRef) {
1463 $hookOut .= t3lib_div::callUserFunction($_funcRef, $_params, $this);
1464 }
1465 }
1466 if (strcmp($hookOut, '')) {
1467 $out .= $hookOut;
1468 } elseif (!empty($row['select_key'])) {
1469 $out .= $GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel('tt_content', 'select_key'), 1) . ' ' . $row['select_key'] . '<br />';
1470 }
1471
1472 $out .= $GLOBALS['LANG']->sL(t3lib_BEfunc::getLabelFromItemlist('tt_content', 'pages', $row['pages']), 1) . '<br />';
1473 break;
1474 case 'script':
1475 $out .= $GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel('tt_content', 'select_key'), 1) . ' ' . $row['select_key'] . '<br />';
1476 $out .= '<br />' . $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />';
1477 $out .= '<br />' . $this->linkEditContent($this->renderText($row['imagecaption']), $row) . '<br />';
1478 break;
1479 default:
1480 if ($row['bodytext']) {
1481 $out .= $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />';
1482 }
1483 break;
1484 }
1485 }
1486
1487 // Wrap span-tags:
1488 $out = '
1489 <span class="exampleContent">' . $out . '</span>';
1490 // Add header:
1491 $out = $outHeader . $out;
1492 // Add RTE button:
1493 if ($isRTE) {
1494 $out .= $this->linkRTEbutton($row);
1495 }
1496
1497 // Return values:
1498 if ($this->isDisabled('tt_content', $row)) {
1499 return $GLOBALS['TBE_TEMPLATE']->dfw($out);
1500 } else {
1501 return $out;
1502 }
1503 }
1504
1505 /**
1506 * Filters out all tt_content uids which are already translated so only non-translated uids is left.
1507 * 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 (?)
1508 *
1509 * @param array Numeric array with uids of tt_content elements in the default language
1510 * @param integer Page pid
1511 * @param integer Sys language UID
1512 * @return array Modified $defLanguageCount
1513 */
1514 function getNonTranslatedTTcontentUids($defLanguageCount, $id, $lP) {
1515 if ($lP && count($defLanguageCount)) {
1516
1517 // Select all translations here:
1518 $queryParts = $this->makeQueryArray('tt_content', $id, 'AND sys_language_uid=' . intval($lP) . ' AND l18n_parent IN (' . implode(',', $defLanguageCount) . ')');
1519 $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
1520
1521 // Flip uids:
1522 $defLanguageCount = array_flip($defLanguageCount);
1523
1524 // Traverse any selected elements and unset original UID if any:
1525 $rowArr = $this->getResult($result);
1526 foreach ($rowArr as $row) {
1527 unset($defLanguageCount[$row['l18n_parent']]);
1528 }
1529
1530 // Flip again:
1531 $defLanguageCount = array_keys($defLanguageCount);
1532 }
1533
1534 return $defLanguageCount;
1535 }
1536
1537 /**
1538 * Creates button which is used to create copies of records..
1539 *
1540 * @param array Numeric array with uids of tt_content elements in the default language
1541 * @param integer Sys language UID
1542 * @return string "Copy languages" button, if available.
1543 */
1544 function newLanguageButton($defLanguageCount, $lP) {
1545 if ($this->doEdit && count($defLanguageCount) && $lP) {
1546
1547 $params = '';
1548 foreach ($defLanguageCount as $uidVal) {
1549 $params .= '&cmd[tt_content][' . $uidVal . '][localize]=' . $lP;
1550 }
1551
1552 // Copy for language:
1553 $onClick = "window.location.href='" . $GLOBALS['SOBE']->doc->issueCommand($params) . "'; return false;";
1554 $theNewButton = $GLOBALS['SOBE']->doc->t3Button($onClick, $GLOBALS['LANG']->getLL('newPageContent_copyForLang') . ' [' . count($defLanguageCount) . ']');
1555 return $theNewButton;
1556 }
1557 }
1558
1559 /**
1560 * Creates onclick-attribute content for a new content element
1561 *
1562 * @param integer Page id where to create the element.
1563 * @param integer Preset: Column position value
1564 * @param integer Preset: Sys langauge value
1565 * @return string String for onclick attribute.
1566 * @see getTable_tt_content()
1567 */
1568 function newContentElementOnClick($id, $colPos, $sys_language) {
1569 if ($this->option_newWizard) {
1570 $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')) . "';";
1571 } else {
1572 $onClick = t3lib_BEfunc::editOnClick('&edit[tt_content][' . $id . ']=new&defVals[tt_content][colPos]=' . $colPos . '&defVals[tt_content][sys_language_uid]=' . $sys_language, $this->backPath);
1573 }
1574 return $onClick;
1575 }
1576
1577 /**
1578 * Will create a link on the input string and possible a big button after the string which links to editing in the RTE
1579 * Used for content element content displayed so the user can click the content / "Edit in Rich Text Editor" button
1580 *
1581 * @param string String to link. Must be prepared for HTML output.
1582 * @param array The row.
1583 * @return string If the whole thing was editable ($this->doEdit) $str is return with link around. Otherwise just $str.
1584 * @see getTable_tt_content()
1585 */
1586 function linkEditContent($str, $row) {
1587 $addButton = '';
1588 $onClick = '';
1589
1590 if ($this->doEdit) {
1591 // Setting onclick action for content link:
1592 $onClick = t3lib_BEfunc::editOnClick('&edit[tt_content][' . $row['uid'] . ']=edit', $this->backPath);
1593 }
1594 // Return link
1595 return $onClick ? '<a href="#" onclick="' . htmlspecialchars($onClick) . '" title="' . $GLOBALS['LANG']->getLL('edit', 1) . '">' . $str . '</a>' . $addButton : $str;
1596 }
1597
1598 /**
1599 * Adds a button to edit the row in RTE wizard
1600 *
1601 * @param array The row of tt_content element
1602 * @return string Button to click if you want to edit in RTE wizard.
1603 */
1604 function linkRTEbutton($row) {
1605 $params = array();
1606 $params['table'] = 'tt_content';
1607 $params['uid'] = $row['uid'];
1608 $params['pid'] = $row['pid'];
1609 $params['field'] = 'bodytext';
1610 $params['returnUrl'] = t3lib_div::linkThisScript();
1611 $RTEonClick = "window.location.href='" . $this->backPath . "wizard_rte.php?" . t3lib_div::implodeArrayForUrl('', array('P' => $params)) . "';return false;";
1612 $addButton = $this->option_showBigButtons && $this->doEdit ? $GLOBALS['SOBE']->doc->t3Button($RTEonClick, $GLOBALS['LANG']->getLL('editInRTE')) : '';
1613
1614 return $addButton;
1615 }
1616
1617 /**
1618 * Make selector box for creating new translation in a language
1619 * Displays only languages which are not yet present for the current page and
1620 * that are not disabled with page TS.
1621 *
1622 * @param integer Page id for which to create a new language (pages_language_overlay record)
1623 * @return string <select> HTML element (if there were items for the box anyways...)
1624 * @see getTable_tt_content()
1625 */
1626 function languageSelector($id) {
1627 if ($GLOBALS['BE_USER']->check('tables_modify', 'pages_language_overlay')) {
1628
1629 // First, select all
1630 $res = $GLOBALS['SOBE']->exec_languageQuery(0);
1631 $langSelItems = array();
1632 $langSelItems[0] = '
1633 <option value="0"></option>';
1634 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1635 if ($GLOBALS['BE_USER']->checkLanguageAccess($row['uid'])) {
1636 $langSelItems[$row['uid']] = '
1637 <option value="' . $row['uid'] . '">' . htmlspecialchars($row['title']) . '</option>';
1638 }
1639 }
1640
1641 // Then, subtract the languages which are already on the page:
1642 $res = $GLOBALS['SOBE']->exec_languageQuery($id);
1643 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1644 unset($langSelItems[$row['uid']]);
1645 }
1646 // Remove disallowed languages
1647 if (count($langSelItems) > 1 &&
1648 !$GLOBALS['BE_USER']->user['admin'] &&
1649 strlen($GLOBALS['BE_USER']->groupData['allowed_languages'])) {
1650
1651 $allowed_languages = array_flip(explode(',', $GLOBALS['BE_USER']->groupData['allowed_languages']));
1652
1653 if (count($allowed_languages)) {
1654 foreach ($langSelItems as $key => $value) {
1655 if (!isset($allowed_languages[$key]) && $key != 0) {
1656 unset($langSelItems[$key]);
1657 }
1658 }
1659 }
1660 }
1661 // Remove disabled languages
1662 $modSharedTSconfig = t3lib_BEfunc::getModTSconfig($id, 'mod.SHARED');
1663 $disableLanguages = isset($modSharedTSconfig['properties']['disableLanguages']) ? t3lib_div::trimExplode(',', $modSharedTSconfig['properties']['disableLanguages'], 1) : array();
1664 if (count($langSelItems) && count($disableLanguages)) {
1665 foreach ($disableLanguages as $language) {
1666 if ($language != 0 && isset($langSelItems[$language])) {
1667 unset($langSelItems[$language]);
1668 }
1669 }
1670 }
1671
1672 // If any languages are left, make selector:
1673 if (count($langSelItems) > 1) {
1674 $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')) . '\'';
1675 return $GLOBALS['LANG']->getLL('new_language', 1) . ': <select name="createNewLanguage" onchange="' . htmlspecialchars($onChangeContent) . '">
1676 ' . implode('', $langSelItems) . '
1677 </select><br /><br />';
1678 }
1679 }
1680 }
1681
1682 /**
1683 * Traverse the result pointer given, adding each record to array and setting some internal values at the same time.
1684 *
1685 * @param pointer SQL result pointer for select query.
1686 * @param string Table name defaulting to tt_content
1687 * @return array The selected rows returned in this array.
1688 */
1689 function getResult($result, $table = 'tt_content') {
1690
1691 // Initialize:
1692 $editUidList = '';
1693 $recs = Array();
1694 $nextTree = $this->nextThree;
1695 $c = 0;
1696 $output = Array();
1697
1698 // Traverse the result:
1699 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
1700
1701 t3lib_BEfunc::workspaceOL($table, $row, -99, TRUE);
1702
1703 if ($row) {
1704 // Add the row to the array:
1705 $output[] = $row;
1706
1707 // Set an internal register:
1708 $recs[$c] = $row['uid'];
1709
1710 // Create the list of the next three ids (for editing links...)
1711 for ($a = 0; $a < $nextTree; $a++) {
1712 if (isset($recs[$c - $a])) {
1713 $this->tt_contentData['nextThree'][$recs[$c - $a]] .= $row['uid'] . ',';
1714 }
1715 }
1716
1717 // Set next/previous ids:
1718 if (isset($recs[$c - 1])) {
1719 if (isset($recs[$c - 2])) {
1720 $this->tt_contentData['prev'][$row['uid']] = -$recs[$c - 2];
1721 } else {
1722 $this->tt_contentData['prev'][$row['uid']] = $row['pid'];
1723 }
1724 $this->tt_contentData['next'][$recs[$c - 1]] = -$row['uid'];
1725 }
1726 $c++;
1727 }
1728 }
1729
1730 // Return selected records
1731 return $output;
1732 }
1733
1734
1735 /********************************
1736 *
1737 * Various helper functions
1738 *
1739 ********************************/
1740
1741 /**
1742 * Counts and returns the number of records on the page with $pid
1743 *
1744 * @param string Table name
1745 * @param integer Page id
1746 * @return integer Number of records.
1747 */
1748 function numberOfRecords($table, $pid) {
1749 if ($GLOBALS['TCA'][$table]) {
1750 $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
1751 'uid',
1752 $table,
1753 'pid=' . intval($pid) .
1754 t3lib_BEfunc::deleteClause($table) .
1755 t3lib_BEfunc::versioningPlaceholderClause($table)
1756 );
1757 }
1758 return intval($count);
1759 }
1760
1761 /**
1762 * Processing of larger amounts of text (usually from RTE/bodytext fields) with word wrapping etc.
1763 *
1764 * @param string Input string
1765 * @return string Output string
1766 */
1767 function renderText($input) {
1768 $input = strip_tags($input);
1769 $input = t3lib_div::fixed_lgd_cs($input, 1500);
1770 return nl2br(htmlspecialchars(trim($this->wordWrapper($input))));
1771 }
1772
1773 /**
1774 * Creates the icon image tag for record from table and wraps it in a link which will trigger the click menu.
1775 *
1776 * @param string Table name
1777 * @param array Record array
1778 * @param string Record title (NOT USED)
1779 * @return string HTML for the icon
1780 */
1781 function getIcon($table, $row) {
1782
1783 // Initialization
1784 $alttext = t3lib_BEfunc::getRecordIconAltText($row, $table);
1785 $iconImg = t3lib_iconWorks::getSpriteIconForRecord($table, $row, array('title' => $alttext));
1786 $this->counter++;
1787
1788 // The icon with link
1789 $theIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconImg, $table, $row['uid']);
1790
1791 return $theIcon;
1792 }
1793
1794 /**
1795 * Creates processed values for all fieldnames in $fieldList based on values from $row array.
1796 * The result is 'returned' through $info which is passed as a reference
1797 *
1798 * @param string Table name
1799 * @param string Commalist of fields.
1800 * @param array Record from which to take values for processing.
1801 * @param array Array to which the processed values are added.
1802 * @return void
1803 */
1804 function getProcessedValue($table, $fieldList, array $row, array &$info) {
1805 // Splitting values from $fieldList
1806 $fieldArr = explode(',', $fieldList);
1807
1808 // Traverse fields from $fieldList
1809 foreach ($fieldArr as $field) {
1810 if ($row[$field]) {
1811 $info[] = '<strong>' . htmlspecialchars($this->itemLabels[$field]) . '</strong> ' . htmlspecialchars(t3lib_BEfunc::getProcessedValue($table, $field, $row[$field]));
1812 }
1813 }
1814 }
1815
1816 /**
1817 * Returns TRUE, if the record given as parameters is NOT visible based on hidden/starttime/endtime (if available)
1818 *
1819 * @param string Tablename of table to test
1820 * @param array Record row.
1821 * @return boolean Returns TRUE, if disabled.
1822 */
1823 function isDisabled($table, $row) {
1824 if (
1825 ($GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled']
1826 && $row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled']])
1827 || ($GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['starttime']
1828 && $row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['starttime']] > $GLOBALS['EXEC_TIME'])
1829 || ($GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['endtime']
1830 && $row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['endtime']]
1831 && $row[$GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['endtime']] < $GLOBALS['EXEC_TIME'])
1832 ) {
1833 return TRUE;
1834 }
1835 }
1836
1837 /**
1838 * 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.
1839 * Works well on normal texts, little less well when HTML is involved (since much HTML will have long strings that will be broken).
1840 *
1841 * @param string Content to word-wrap.
1842 * @param integer Max number of chars in a word before it will be wrapped.
1843 * @param string Character to insert when wrapping.
1844 * @return string Processed output.
1845 */
1846 function wordWrapper($content, $max = 50, $char = ' -') {
1847 $array = preg_split('/[ ' . LF . ']/', $content);
1848 foreach ($array as $val) {
1849 if (strlen($val) > $max) {
1850 $content = str_replace($val, substr(chunk_split($val, $max, $char), 0, -1), $content);
1851 }
1852 }
1853 return $content;
1854 }
1855
1856 /**
1857 * Returns icon for "no-edit" of a record.
1858 * 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...
1859 *
1860 * @param string Label key from LOCAL_LANG
1861 * @return string IMG tag for icon.
1862 */
1863 function noEditIcon($label = 'noEditItems') {
1864 return t3lib_iconWorks::getSpriteIcon('status-edit-read-only', array('title' => $GLOBALS['LANG']->getLL($label, TRUE)));
1865 }
1866
1867 /**
1868 * 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.
1869 *
1870 * @return void
1871 */
1872 function cleanTableNames() {
1873
1874 // Get all table names:
1875 $tableNames = array_flip(array_keys($GLOBALS['TCA']));
1876
1877 // Unset common names:
1878 unset($tableNames['pages']);
1879 unset($tableNames['static_template']);
1880 unset($tableNames['sys_filemounts']);
1881 unset($tableNames['sys_action']);
1882 unset($tableNames['sys_workflows']);
1883 unset($tableNames['be_users']);
1884 unset($tableNames['be_groups']);
1885
1886 $this->allowedTableNames = array();
1887
1888 // Traverse table names and set them in allowedTableNames array IF they can be read-accessed by the user.
1889 if (is_array($tableNames)) {
1890 foreach ($tableNames as $k => $v) {
1891 if ($GLOBALS['BE_USER']->check('tables_select', $k)) {
1892 $this->allowedTableNames['table_' . $k] = $k;
1893 }
1894 }
1895 }
1896 }
1897
1898 /**
1899 * Checking if the RTE is available/enabled for a certain table/field and if so, it returns TRUE.
1900 * Used to determine if the RTE button should be displayed.
1901 *
1902 * @param string Table name
1903 * @param array Record row (needed, if there are RTE dependencies based on other fields in the record)
1904 * @param string Field name
1905 * @return boolean Returns TRUE if the rich text editor would be enabled/available for the field name specified.
1906 */
1907 function isRTEforField($table, $row, $field) {
1908 $specConf = $this->getSpecConfForField($table, $row, $field);
1909 $p = t3lib_BEfunc::getSpecConfParametersFromArray($specConf['rte_transform']['parameters']);
1910 if (isset($specConf['richtext']) && (!$p['flag'] || !$row[$p['flag']])) {
1911 t3lib_BEfunc::fixVersioningPid($table, $row);
1912 list($tscPID, $thePidValue) = t3lib_BEfunc::getTSCpid($table, $row['uid'], $row['pid']);
1913 if ($thePidValue >= 0) { // If the pid-value is not negative (that is, a pid could NOT be fetched)
1914 $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE', t3lib_BEfunc::getPagesTSconfig($tscPID));
1915 $RTEtypeVal = t3lib_BEfunc::getTCAtypeValue($table, $row);
1916 $thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'], $table, $field, $RTEtypeVal);
1917 if (!$thisConfig['disabled']) {
1918 return TRUE;
1919 }
1920 }
1921 }
1922
1923 return FALSE;
1924 }
1925
1926 /**
1927 * Returns "special" configuration from the "types" configuration in TCA for the record given by tablename/fieldname.
1928 * Used by isRTEforField() in the process of finding whether a field has RTE enabled or not.
1929 *
1930 * @param string Table name
1931 * @param array Record array
1932 * @param string Field name
1933 * @return array Spec. conf (if available)
1934 * @access private
1935 * @see isRTEforField()
1936 */
1937 function getSpecConfForField($table, $row, $field) {
1938
1939 // Get types-configuration for the record:
1940 $types_fieldConfig = t3lib_BEfunc::getTCAtypes($table, $row);
1941
1942 // Find the given field and return the spec key value if found:
1943 if (is_array($types_fieldConfig)) {
1944 foreach ($types_fieldConfig as $vconf) {
1945 if ($vconf['field'] == $field) {
1946 return $vconf['spec'];
1947 }
1948 }
1949 }
1950 }
1951
1952
1953 /*****************************************
1954 *
1955 * External renderings
1956 *
1957 *****************************************/
1958
1959 /**
1960 * Creates an info-box for the current page (identified by input record).
1961 *
1962 * @param array Page record
1963 * @param boolean If set, there will be shown an edit icon, linking to editing of the page properties.
1964 * @return string HTML for the box.
1965 */
1966 function getPageInfoBox($rec, $edit = 0) {
1967 // If editing of the page properties is allowed:
1968 if ($edit) {
1969 $params = '&edit[pages][' . $rec['uid'] . ']=edit';
1970 $editIcon = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::editOnClick($params, $this->backPath)) . '" title="' . $GLOBALS['LANG']->getLL('edit', TRUE) . '">' .
1971 t3lib_iconWorks::getSpriteIcon('actions-document-open') .
1972 '</a>';
1973 } else {
1974 $editIcon = $this->noEditIcon('noEditPage');
1975 }
1976
1977 // Setting page icon, link, title:
1978 $outPutContent = t3lib_iconWorks::getSpriteIconForRecord('pages', $rec, array('title' => t3lib_BEfunc::titleAttribForPages($rec))) .
1979 $editIcon .
1980 '&nbsp;' .
1981 htmlspecialchars($rec['title']);
1982
1983
1984 // Init array where infomation is accumulated as label/value pairs.
1985 $lines = array();
1986
1987 // Owner user/group:
1988 if ($this->pI_showUser) {
1989 // User:
1990 $users = t3lib_BEfunc::getUserNames('username,usergroup,usergroup_cached_list,uid,realName');
1991 $groupArray = explode(',', $GLOBALS['BE_USER']->user['usergroup_cached_list']);
1992 $users = t3lib_BEfunc::blindUserNames($users, $groupArray);
1993 $lines[] = array($GLOBALS['LANG']->getLL('pI_crUser') . ':', htmlspecialchars($users[$rec['cruser_id']]['username']) .
1994 ' (' . $users[$rec['cruser_id']]['realName'] . ')');
1995 }
1996
1997 // Created:
1998 $lines[] = array(
1999 $GLOBALS['LANG']->getLL('pI_crDate') . ':',
2000 t3lib_BEfunc::datetime($rec['crdate']) . ' (' . t3lib_BEfunc::calcAge($GLOBALS['EXEC_TIME'] - $rec['crdate'], $this->agePrefixes) . ')',
2001 );
2002
2003 // Last change:
2004 $lines[] = array(
2005 $GLOBALS['LANG']->getLL('pI_lastChange') . ':',
2006 t3lib_BEfunc::datetime($rec['tstamp']) . ' (' . t3lib_BEfunc::calcAge($GLOBALS['EXEC_TIME'] - $rec['tstamp'], $this->agePrefixes) . ')',
2007 );
2008
2009 // Last change of content:
2010 if ($rec['SYS_LASTCHANGED']) {
2011 $lines[] = array(
2012 $GLOBALS['LANG']->getLL('pI_lastChangeContent') . ':',
2013 t3lib_BEfunc::datetime($rec['SYS_LASTCHANGED']) . ' (' . t3lib_BEfunc::calcAge($GLOBALS['EXEC_TIME'] - $rec['SYS_LASTCHANGED'], $this->agePrefixes) . ')',
2014 );
2015 }
2016
2017 // Spacer:
2018 $lines[] = '';
2019
2020 // Display contents of certain page fields, if any value:
2021 $dfields = explode(',', 'alias,target,hidden,starttime,endtime,fe_group,no_cache,cache_timeout,newUntil,lastUpdated,subtitle,keywords,description,abstract,author,author_email');
2022 foreach ($dfields as $fV) {
2023 if ($rec[$fV]) {
2024 $lines[] = array($GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel('pages', $fV)), t3lib_BEfunc::getProcessedValue('pages', $fV, $rec[$fV]));
2025 }
2026 }
2027
2028 // Page hits (depends on "sys_stat" extension)
2029 if ($this->pI_showStat && t3lib_extMgm::isLoaded('sys_stat')) {
2030
2031 // Counting total hits:
2032 $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', 'sys_stat', 'page_id=' . intval($rec['uid']));
2033 if ($count) {
2034
2035 // Get min/max
2036 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('min(tstamp) AS min,max(tstamp) AS max', 'sys_stat', 'page_id=' . intval($rec['uid']));
2037 $rrow2 = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
2038
2039 $lines[] = '';
2040 $lines[] = array($GLOBALS['LANG']->getLL('pI_hitsPeriod') . ':', t3lib_BEfunc::date($rrow2[0]) . ' - ' .
2041 t3lib_BEfunc::date($rrow2[1]) . ' (' . t3lib_BEfunc::calcAge($rrow2[1] - $rrow2[0], $this->agePrefixes) . ')');
2042 $lines[] = array($GLOBALS['LANG']->getLL('pI_hitsTotal') . ':', $rrow2[0]);
2043
2044
2045 // Last 10 days
2046 $nextMidNight = mktime(0, 0, 0) + 1 * 3600 * 24;
2047
2048 $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');
2049 $days = array();
2050 while ($rrow = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) {
2051 $days[$rrow[1]] = $rrow[0];
2052 }
2053
2054 $headerH = array();
2055 $contentH = array();
2056 for ($a = 9; $a >= 0; $a--) {
2057 $headerH[] = '
2058 <td class="bgColor5" nowrap="nowrap">&nbsp;' . date('d', $nextMidNight - ($a + 1) * 24 * 3600) . '&nbsp;</td>';
2059 $contentH[] = '
2060 <td align="center">' . ($days[$a] ? intval($days[$a]) : '-') . '</td>';
2061 }
2062
2063 // Compile first hit-table (last 10 days)
2064 $hitTable = '
2065 <table border="0" cellpadding="0" cellspacing="1" class="typo3-page-hits">
2066 <tr>' . implode('', $headerH) . '</tr>
2067 <tr>' . implode('', $contentH) . '</tr>
2068 </table>';
2069 $lines[] = array($GLOBALS['LANG']->getLL('pI_hits10days') . ':', $hitTable, 1);
2070
2071
2072 // Last 24 hours
2073 $nextHour = mktime(date('H'), 0, 0) + 3600;
2074 $hours = 16;
2075
2076 $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');
2077 $days = array();
2078 while ($rrow = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) {
2079 $days[$rrow[1]] = $rrow[0];
2080 }
2081
2082 $headerH = array();
2083 $contentH = array();
2084 for ($a = ($hours - 1); $a >= 0; $a--) {
2085 $headerH[] = '
2086 <td class="bgColor5" nowrap="nowrap">&nbsp;' . intval(date('H', $nextHour - ($a + 1) * 3600)) . '&nbsp;</td>';
2087 $contentH[] = '
2088 <td align="center">' . ($days[$a] ? intval($days[$a]) : '-') . '</td>';
2089 }
2090
2091 // Compile second hit-table (last 24 hours)
2092 $hitTable = '
2093 <table border="0" cellpadding="0" cellspacing="1" class="typo3-page-stat">
2094 <tr>' . implode('', $headerH) . '</tr>
2095 <tr>' . implode('', $contentH) . '</tr>
2096 </table>';
2097 $lines[] = array($GLOBALS['LANG']->getLL('pI_hits24hours') . ':', $hitTable, 1);
2098 }
2099 }
2100
2101
2102 // Finally, wrap the elements in the $lines array in table cells/rows
2103 foreach ($lines as $fV) {
2104 if (is_array($fV)) {
2105 if (!$fV[2]) {
2106 $fV[1] = htmlspecialchars($fV[1]);
2107 }
2108 $out .= '
2109 <tr>
2110 <td class="bgColor4" nowrap="nowrap"><strong>' . htmlspecialchars($fV[0]) . '&nbsp;&nbsp;</strong></td>
2111 <td class="bgColor4">' . $fV[1] . '</td>
2112 </tr>';
2113 } else {
2114 $out .= '
2115 <tr>
2116 <td colspan="2"><img src="clear.gif" width="1" height="3" alt="" /></td>
2117 </tr>';
2118 }
2119 }
2120
2121 // Wrap table tags around...
2122 $outPutContent .= '
2123
2124
2125
2126 <!--
2127 Page info box:
2128 -->
2129 <table border="0" cellpadding="0" cellspacing="1" id="typo3-page-info">
2130 ' . $out . '
2131 </table>';
2132
2133 // ... and return it.
2134 return $outPutContent;
2135 }
2136
2137 /**
2138 * Creates a menu of the tables that can be listed by this function
2139 * Only tables which has records on the page will be included.
2140 * Notice: The function also fills in the internal variable $this->activeTables with icon/titles.
2141 *
2142 * @param integer Page id from which we are listing records (the function will look up if there are records on the page)
2143 * @return string HTML output.
2144 */
2145 function getTableMenu($id) {
2146
2147 // Initialize:
2148 $this->activeTables = array();
2149 $theTables = array('tt_content');
2150
2151 // External tables:
2152 if (is_array($this->externalTables)) {
2153 $theTables = array_unique(array_merge($theTables, array_keys($this->externalTables)));
2154 }
2155
2156 // Traverse tables to check:
2157 foreach ($theTables as $tName) {
2158
2159 // Check access and whether the proper extensions are loaded:
2160 if ($GLOBALS['BE_USER']->check('tables_select', $tName) && (t3lib_extMgm::isLoaded($tName) || t3lib_div::inList('fe_users,tt_content', $tName) || isset($this->externalTables[$tName]))) {
2161
2162 // Make query to count records from page:
2163 $c = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
2164 'uid',
2165 $tName,
2166 'pid=' . intval($id) .
2167 t3lib_BEfunc::deleteClause($tName) .
2168 t3lib_BEfunc::versioningPlaceholderClause($tName)
2169 );
2170
2171 // If records were found (or if "tt_content" is the table...):
2172 if ($c || t3lib_div::inList('tt_content', $tName)) {
2173
2174 // Add row to menu:
2175 $out .= '
2176 <td><a href="#' . $tName . '"></a>' .
2177 t3lib_iconWorks::getSpriteIconForRecord(
2178 $tName,
2179 array(),
2180 array('title' => $GLOBALS['LANG']->sL($GLOBALS['TCA'][$tName]['ctrl']['title'], 1))
2181 ) . '</td>';
2182
2183 // ... and to the internal array, activeTables we also add table icon and title (for use elsewhere)
2184 $this->activeTables[$tName] =
2185 t3lib_iconWorks::getSpriteIconForRecord(
2186 $tName,
2187 array(),
2188 array('title' => $GLOBALS['LANG']->sL($GLOBALS['TCA'][$tName]['ctrl']['title'], 1) . ': ' . $c . ' ' . $GLOBALS['LANG']->getLL('records', 1))
2189 ) .
2190 '&nbsp;' . $GLOBALS['LANG']->sL($GLOBALS['TCA'][$tName]['ctrl']['title'], 1);
2191 }
2192 }
2193 }
2194
2195 // Wrap cells in table tags:
2196 $out = '
2197 <!--
2198 Menu of tables on the page (table menu)
2199 -->
2200 <table border="0" cellpadding="0" cellspacing="0" id="typo3-page-tblMenu">
2201 <tr>' . $out . '
2202 </tr>
2203 </table>';
2204
2205 // Return the content:
2206 return $out;
2207 }
2208
2209 /**
2210 * Enhancement for the strip_tags function that provides the feature to fill in empty tags.
2211 * Example <link email@hostname.com></link> is accepted by TYPO3 but would not displayed in the Backend otherwise.
2212 *
2213 * @param string Input string
2214 * @param boolean If TRUE, empty tags will be filled with the first attribute of the tag before.
2215 * @return string Input string with all HTML and PHP tags stripped
2216 * @deprecated since TYPO3 4.6, deprecationLog since 6.0, will be removed two versions later - use php-function strip_tags instead
2217 */
2218 function strip_tags($content, $fillEmptyContent = FALSE) {
2219 t3lib_div::logDeprecatedFunction();
2220 if ($fillEmptyContent && strstr($content, '><')) {
2221 $content = preg_replace('/(<[^ >]* )([^ >]*)([^>]*>)(<\/[^>]*>)/', '$1$2$3$2$4', $content);
2222 }
2223 $content = preg_replace('/<br.?\/?>/', LF, $content);
2224
2225 return strip_tags($content);
2226 }
2227 }
2228
2229
2230 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/cms/layout/class.tx_cms_layout.php'])) {
2231 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/cms/layout/class.tx_cms_layout.php']);
2232 }
2233
2234 ?>