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