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