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