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