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