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