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