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