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