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