2 /***************************************************************
5 * (c) 1999-2004 Kasper Skaarhoj (kasper@typo3.com)
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.
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.
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.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
28 * Include file extending db_list.inc for use with the web_layout module
31 * Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj
34 * @author Kasper Skaarhoj <kasper@typo3.com>
37 * [CLASS/FUNCTION INDEX of SCRIPT]
41 * 111: class tx_cms_layout extends recordList
44 * 173: function getTable($table,$id)
45 * 224: function getTable_pages($id)
46 * 358: function getTable_tt_content($id)
47 * 646: function getTable_fe_users($id)
48 * 672: function getTable_sys_note($id)
49 * 763: function getTable_tt_board($id)
50 * 843: function getTable_tt_address($id)
51 * 873: function getTable_tt_links($id)
52 * 899: function getTable_tt_guest($id)
53 * 914: function getTable_tt_news($id)
54 * 935: function getTable_tt_calender($id)
55 * 985: function getTable_tt_products($id)
57 * SECTION: Generic listing of items
58 * 1031: function makeOrdinaryList($table, $id, $fList, $icon=0, $addWhere='')
59 * 1110: function dataFields($fieldArr,$table,$row,$out=array())
60 * 1161: function headerFields($fieldArr,$table,$out=array())
62 * SECTION: Additional functions; Pages
63 * 1203: function pages_getTree($theRows,$pid,$qWhere,$treeIcons,$depth)
64 * 1235: function pages_drawItem($row,$fieldArr)
66 * SECTION: Additional functions; Content Elements
67 * 1345: function tt_content_drawColHeader($colName,$editParams,$newParams)
68 * 1395: function tt_content_drawHeader($row,$space=0)
69 * 1521: function tt_content_drawItem($row)
70 * 1668: function infoGif($infoArr)
71 * 1684: function newContentElementOnClick($id,$colPos,$sys_language)
72 * 1703: function linkEditContent($str,$row,$isRTE=0)
73 * 1736: function languageSelector($id)
74 * 1771: function getResult($result)
76 * SECTION: Additional functions; Message board items (tt_board)
77 * 1840: function tt_board_getTree($theRows,$parent,$pid,$qWhere,$treeIcons)
78 * 1875: function tt_board_drawItem($table,$row,$re)
80 * SECTION: Various helper functions
81 * 1922: function numberOfRecords($table,$pid)
82 * 1941: function renderText($input)
83 * 1955: function getIcon($table,$row)
84 * 1978: function getProcessedValue($table,$fieldList,$row,&$info)
85 * 1998: function isDisabled($table,$row)
86 * 2016: function wordWrapper($content,$max=50,$char=' -')
87 * 2033: function noEditIcon($label='noEditItems')
88 * 2042: function cleanTableNames()
89 * 2078: function isRTEforField($table,$row,$field)
90 * 2107: function getSpecConfForField($table,$row,$field)
92 * SECTION: External renderings
93 * 2144: function getPageInfoBox($rec,$edit=0)
94 * 2313: function getTableMenu($id)
97 * (This index is automatically created/updated by the extension "extdeveval")
105 * Child class for the Web > Page module
107 * @author Kasper Skaarhoj <kasper@typo3.com>
111 class tx_cms_layout
extends recordList
{
113 // External, static: For page statistics:
114 var $stat_select_field='page_id'; // fieldname from sys_stat to select on.
115 var $stat_codes=array(); // eg. "HITS_days:-1"
117 // External, static: Flags of various kinds:
118 var $pI_showUser=0; // If true, users/groups are shown in the page info box.
119 var $pI_showStat=1; // If true, hit statistics are shown in the page info box.
120 var $nextThree = 3; // The number of successive records to edit when showing content elements.
121 var $pages_noEditColumns=0; // If true, disables the edit-column icon for tt_content elements
122 var $option_showBigButtons=1; // If true, shows bit buttons for editing page header, moving, creating elements etc. in the columns view.
123 var $option_newWizard=1; // If true, new-wizards are linked to rather than the regular new-element list.
124 var $ext_function=0; // If set to "1", will link a big button to content element wizard.
125 var $doEdit=1; // If true, elements will have edit icons (probably this is whethere the user has permission to edit the page content). Set externally.
126 var $agePrefixes = ' min| hrs| days| yrs'; // Age prefixes for displaying times. May be set externally to localized values.
127 var $externalTables = array(); // Array of tables which is configured to be listed by the Web > Page module in addition to the default tables.
129 // External, static: Configuration of tt_content element display:
130 var $tt_contentConfig = Array (
131 'showInfo' => 1, // Boolean: Display info-marks or not
132 'showCommands' => 1, // Boolean: Display up/down arrows and edit icons for tt_content records
133 'showCommands_info' => 1, // Boolean: Displays infoGif with the command buttons
134 'single' => 1, // Boolean: If set, the content of column(s) $this->tt_contentConfig['showSingleCol'] is shown in the total width of the page
135 'showSingleCol' => 0, // The column(s) to show if single mode (under each other)
138 'languageColsPointer' => 0,
139 'showHidden' => 1, // Displays hidden records as well
140 'sys_language_uid' => 0, // Which language
141 'cols' => '1,0,2,3' // The order of the rows: Default is left(1), Normal(0), right(2), margin(3)
144 // Internal, dynamic:
145 var $allowedTableNames=array(); // Will contain a list of tables which can be listed by the user.
146 var $activeTables = array(); // Contains icon/title of pages which are listed in the tables menu (see getTableMenu() function )
147 var $tt_contentData = Array(
148 'nextThree' => Array(),
152 var $CType_labels=array(); // Used to store labels for CTypes for tt_content elements
153 var $itemLabels=array(); // Used to store labels for the various fields in tt_content elements
161 /*****************************************
165 *****************************************/
168 * Adds the code of a single table
170 * @param string Table name
171 * @param integer Current page id
172 * @return string HTML for listing.
174 function getTable($table,$id) {
176 // Load full table definition:
177 t3lib_div
::loadTCA($table);
179 if (isset($this->externalTables
[$table])) {
180 $fList = $this->externalTables
[$table][0]['fList']; // eg. "name;title;email;company,image"
181 $icon = $this->externalTables
[$table][0]['icon']; // Boolean,
184 $out = $this->makeOrdinaryList($table, $id, $fList, $icon);
187 // Branch out based on table name:
188 // Notice: Most of these tables belongs to other extensions than 'cms'. Each of these tables can be rendered only if the extensions they belong to is loaded.
191 return $this->getTable_pages($id);
194 return $this->getTable_tt_content($id);
197 return $this->getTable_fe_users($id);
200 return $this->getTable_sys_note($id);
203 return $this->getTable_tt_board($id);
206 return $this->getTable_tt_address($id);
209 return $this->getTable_tt_links($id);
212 return $this->getTable_tt_guest($id);
215 return $this->getTable_tt_news($id);
218 return $this->getTable_tt_calender($id);
221 return $this->getTable_tt_products($id);
228 * Renders records from the pages table from page id
229 * (Used to get information about the page tree content by "Web>Info"!)
231 * @param integer Page id
232 * @return string HTML for the listing
234 function getTable_pages($id) {
239 $delClause = t3lib_BEfunc
::deleteClause('pages').' AND '.$GLOBALS['BE_USER']->getPagePermsClause(1); // Select clause for pages:
241 // Select current page:
243 $row = $GLOBALS['SOBE']->pageinfo
; // The root has a pseudo record in pageinfo...
245 $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'pages', 'uid='.intval($id).$delClause);
246 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result);
249 // If there was found a page:
250 if (is_array($row)) {
252 // Select which fields to show:
253 $pKey = $GLOBALS['SOBE']->MOD_SETTINGS
['function']=='tx_cms_webinfo_hits' ?
'hits' : $GLOBALS['SOBE']->MOD_SETTINGS
['pages'];
256 $this->fieldArray
= explode(',','title,'.implode(',',$this->stat_codes
));
259 $this->cleanTableNames();
260 $tableNames=$this->allowedTableNames
;
261 $this->fieldArray
= explode(',','title,uid,'.implode(',',array_keys($tableNames)));
264 $this->fieldArray
= explode(',','title,uid,lastUpdated,newUntil,no_cache,cache_timeout,php_tree_stop,TSconfig,storage_pid,is_siteroot');
267 $this->fieldArray
= explode(',','title,uid,alias,starttime,endtime,fe_group,target,url,shortcut');
271 // Getting select-depth:
272 $depth=intval($GLOBALS['SOBE']->MOD_SETTINGS
['pages_levels']);
274 // Half line is drawn
276 $theData['subject'] = $this->widthGif
;
277 $out.=$this->addelement(0,'',$theData);
279 // Overriding a few things:
281 $this->oddColumnsTDParams
=' class="bgColor3-20"';
284 $this->eCounter
=$this->firstElementNumber
;
286 // Creating elements:
287 list($flag,$code) = $this->fwd_rwd_nav();
294 $theRows = $this->pages_getTree($theRows,$row['uid'],$delClause,'',$depth);
295 if ($GLOBALS['BE_USER']->doesUserHaveAccess($row,2)) $editUids[]=$row['uid'];
296 $out.=$this->pages_drawItem($row,$this->fieldArray
);
298 // Traverse all pages selected:
299 foreach($theRows as $n => $sRow) {
300 if ($GLOBALS['BE_USER']->doesUserHaveAccess($sRow,2)) $editUids[]=$sRow['uid'];
301 $out.=$this->pages_drawItem($sRow,$this->fieldArray
);
306 // Header line is drawn
308 $editIdList=implode(',',$editUids);
310 // Traverse fields (as set above) in order to create header values:
311 foreach($this->fieldArray
as $field) {
312 if ($editIdList && isset($TCA['pages']['columns'][$field]) && $field!='uid' && !$this->pages_noEditColumns
) {
313 $params='&edit[pages]['.$editIdList.']=edit&columnsOnly='.$field.'&disHelp=1';
314 $iTitle = sprintf($GLOBALS['LANG']->getLL('editThisColumn'),ereg_replace(':$','',trim($GLOBALS['LANG']->sL(t3lib_BEfunc
::getItemLabel('pages',$field)))));
315 $eI= '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc
::editOnClick($params,$this->backPath
,'')).'">'.
316 '<img'.t3lib_iconWorks
::skinImg($this->backPath
,'gfx/edit2.gif','width="11" height="12"').' title="'.htmlspecialchars($iTitle).'" alt="" />'.
321 $theData[$field] = ' <b>'.$GLOBALS['LANG']->sL($TCA['pages']['columns'][$field]['label']).'</b>'.$eI;
324 $theData[$field] = ' <b>ID:</b>';
327 if (substr($field,0,6)=='table_') {
328 $f2 = substr($field,6);
330 $theData[$field] = ' '.t3lib_iconWorks
::getIconImage($f2,array(),$this->backPath
,'title="'.$GLOBALS['LANG']->sL($TCA[$f2]['ctrl']['title'],1).'"');
332 } elseif (substr($field,0,5)=='HITS_') {
333 $fParts = explode(':',substr($field,5));
336 $timespan = mktime (0,0,0)+
intval($fParts[1])*3600*24;
337 $theData[$field]=' '.date('d',$timespan);
340 $theData[$field] = '';
344 $theData[$field] = ' <b>'.$GLOBALS['LANG']->sL($TCA['pages']['columns'][$field]['label'],1).'</b>'.$eI;
351 $this->oddColumnsTDParams
='';
353 <table border="0" cellpadding="0" cellspacing="0" class="typo3-page-pages">
354 '.$this->addelement(1,'',$theData,' class="c-headLine"',20).
358 $this->oddColumnsTDParams
='';
363 * Renders Content Elements from the tt_content table from page id
365 * @param integer Page id
366 * @return string HTML for the listing
368 function getTable_tt_content($id) {
372 $RTE = $GLOBALS['BE_USER']->isRTE();
374 $showHidden = $this->tt_contentConfig
['showHidden']?
'':t3lib_BEfunc
::BEenableFields('tt_content');
375 $pageTitleParamForAltDoc='&recTitle='.rawurlencode(t3lib_BEfunc
::getRecordTitle('pages',t3lib_BEfunc
::getRecord('pages',$id),1));
377 // Get labels for CTypes and tt_content element fields in general:
378 $this->CType_labels
=array();
379 foreach($TCA['tt_content']['columns']['CType']['config']['items'] as $val) {
380 $this->CType_labels
[$val[1]]=$GLOBALS['LANG']->sL($val[0]);
382 $this->itemLabels
=array();
383 foreach($TCA['tt_content']['columns'] as $name => $val) {
384 $this->itemLabels
[$name]=$GLOBALS['LANG']->sL($val['label']);
388 // Select display mode:
389 if (!$this->tt_contentConfig
['single']) { // MULTIPLE column display mode, side by side:
391 // Setting language list:
392 $langList = $this->tt_contentConfig
['sys_language_uid'];
393 if ($this->tt_contentConfig
['languageMode']) {
394 if ($this->tt_contentConfig
['languageColsPointer']) {
395 $langList='0,'.$this->tt_contentConfig
['languageColsPointer'];
397 $langList=implode(',',array_keys($this->tt_contentConfig
['languageCols']));
399 $languageColumn=array();
401 $langListArr = explode(',',$langList);
404 // For EACH languages... :
405 foreach($langListArr as $lP) { // If NOT languageMode, then we'll only be through this once.
406 $showLanguage = ' AND sys_language_uid='.$lP;
407 $cList = explode(',',$this->tt_contentConfig
['cols']);
411 // For EACH column, render the content into a variable:
412 foreach($cList as $key) {
414 // Select content elements from this column/language:
415 $queryParts = $this->makeQueryArray('tt_content', $id, 'AND colPos='.intval($key).$showHidden.$showLanguage);
416 $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
418 // If it turns out that there are not content elements in the column, then display a big button which links directly to the wizard script:
419 if ($this->option_showBigButtons
&& !intval($key) && !$GLOBALS['TYPO3_DB']->sql_num_rows($result)) {
420 $onClick = "document.location='db_new_content_el.php?id=".$id.'&colPos='.intval($key).'&sys_language_uid='.$lP.'&uid_pid='.$id.'&returnUrl='.rawurlencode(t3lib_div
::getIndpEnv('REQUEST_URI'))."';";
421 $theNewButton = $GLOBALS['SOBE']->doc
->t3Button($onClick,$GLOBALS['LANG']->getLL('newPageContent'));
422 $content[$key].= '<img src="clear.gif" width="1" height="5" alt="" /><br />'.$theNewButton;
425 // Traverse any selected elements and render their display code:
426 $rowArr = $this->getResult($result);
427 foreach($rowArr as $row) {
428 $editUidList.= $row['uid'].',';
429 $content[$key].= $this->tt_content_drawHeader($row,$this->tt_contentConfig
['showInfo']?
15:5);
431 $isRTE = $RTE && $this->isRTEforField('tt_content',$row,'bodytext');
432 $content[$key].= $this->tt_content_drawItem($row,$isRTE);
435 // Add new-icon link, header:
436 $newP = $this->newContentElementOnClick($id,$key,$lP);
437 $head[$key].= $this->tt_content_drawColHeader(t3lib_BEfunc
::getProcessedValue('tt_content','colPos',$key), ($this->doEdit
&&count($rowArr)?
'&edit[tt_content]['.$editUidList.']=edit'.$pageTitleParamForAltDoc:''), $newP);
442 // For EACH column, fit the rendered content into a table cell:
444 foreach($cList as $k => $key) {
447 <td><img src="clear.gif" width="'.$lMarg.'" height="1" alt="" /></td>';
450 <td><img src="clear.gif" width="4" height="1" alt="" /></td>
451 <td bgcolor="black"><img src="clear.gif" width="1" height="1" alt="" /></td>
452 <td><img src="clear.gif" width="4" height="1" alt="" /></td>';
455 <td valign="top">'.$head[$key].$content[$key].'</td>';
457 // Storing content for use if languageMode is set:
458 if ($this->tt_contentConfig
['languageMode']) {
459 $languageColumn[$key][$lP] = $head[$key].$content[$key].'<br /><br />';
463 // Wrap the cells into a table row:
465 <table border="0" cellpadding="0" cellspacing="0" width="480" class="typo3-page-cols">
471 // If language mode, then make another presentation:
472 // Notice that THIS presentation will override the value of $out! But it needs the code above to execute since $languageColumn is filled with content we need!
473 if ($this->tt_contentConfig
['languageMode']) {
475 // Get language selector:
476 $languageSelector = $this->languageSelector($id);
478 // Reset out - we will make new content here:
480 // Separator between language columns (black thin line)
482 <td><img src="clear.gif" width="4" height="1" alt="" /></td>
483 <td bgcolor="black"><img src="clear.gif" width="1" height="1" alt="" /></td>
484 <td><img src="clear.gif" width="4" height="1" alt="" /></td>';
486 // Traverse languages found on the page and build up the table displaying them side by side:
489 foreach($langListArr as $lP) {
493 <td valign="top" align="center" class="bgColor6"><strong>'.htmlspecialchars($this->tt_contentConfig
['languageCols'][$lP]).'</strong></td>';
495 // Language overlay page header:
497 list($lpRecord) = t3lib_BEfunc
::getRecordsByField('pages_language_overlay','pid',$id,'AND sys_language_uid='.intval($lP));
498 $params='&edit[pages_language_overlay]['.$lpRecord['uid'].']=edit&overrideVals[pages_language_overlay][sys_language_uid]='.$lP;
499 $lPLabel = '<span class="nobr">'.
500 t3lib_iconWorks
::getIconImage('pages_language_overlay',$lpRecord,$this->backPath
,' class="absmiddle"').
501 '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc
::editOnClick($params,$this->backPath
)).'">'.
502 '<img'.t3lib_iconWorks
::skinImg($this->backPath
,'gfx/edit2.gif','width="11" height="12"').' title="'.$GLOBALS['LANG']->getLL('edit',1).'" class="absmiddle" alt="" />'.
504 htmlspecialchars(t3lib_div
::fixed_lgd($lpRecord['title'],20)).
510 <td>'.$lPLabel.'</td>';
514 <tr>'.implode($midSep,$cCont).'
517 <tr>'.implode($midSep,$sCont).'
520 // Traverse previously built content for the columns:
521 foreach($languageColumn as $cKey => $cCont) {
524 <td valign="top">'.implode('</td>'.$midSep.'
525 <td valign="top">',$cCont).'</td>
529 // Finally, wrap it all in a table and add the language selector on top of it:
530 $out = $languageSelector.'
531 <table border="0" cellpadding="0" cellspacing="0" width="480" class="typo3-page-langMode">
535 } else { // SINGLE column mode (columns shown beneath each other):
538 $showLanguage = ' AND sys_language_uid='.$this->tt_contentConfig
['sys_language_uid'];
539 $cList = explode(',',$this->tt_contentConfig
['showSingleCol']);
543 // Expand the table to some preset dimensions:
546 <td><img src="clear.gif" width="'.$lMarg.'" height="1" alt="" /></td>
547 <td valign="top"><img src="clear.gif" width="150" height="1" alt="" /></td>
548 <td><img src="clear.gif" width="10" height="1" alt="" /></td>
549 <td valign="top"><img src="clear.gif" width="300" height="1" alt="" /></td>
552 // Traverse columns to display top-on-top
553 while(list($counter,$key)=each($cList)) {
555 // Select content elements:
556 $queryParts = $this->makeQueryArray('tt_content', $id, 'AND colPos='.intval($key).$showHidden.$showLanguage);
557 $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
559 $rowArr = $this->getResult($result);
562 // If it turns out that there are not content elements in the column, then display a big button which links directly to the wizard script:
563 if ($this->option_showBigButtons
&& !intval($key) && !$GLOBALS['TYPO3_DB']->sql_num_rows($result)) {
564 $onClick="document.location='db_new_content_el.php?id=".$id.'&colPos='.intval($key).'&sys_language_uid='.$lP.'&uid_pid='.$id.'&returnUrl='.rawurlencode(t3lib_div
::getIndpEnv('REQUEST_URI'))."';";
565 $theNewButton=$GLOBALS['SOBE']->doc
->t3Button($onClick,$GLOBALS['LANG']->getLL('newPageContent'));
566 $theNewButton='<img src="clear.gif" width="1" height="5" alt="" /><br />'.$theNewButton;
567 } else $theNewButton='';
569 // Traverse any selected elements:
570 foreach($rowArr as $row) {
572 $editUidList.=$row['uid'].',';
573 $isRTE=$RTE && $this->isRTEforField('tt_content',$row,'bodytext');
575 // Create row output:
579 <td valign="top">'.$this->tt_content_drawHeader($row).'</td>
581 <td valign="top">'.$this->tt_content_drawItem($row,$isRTE).'</td>
584 // If the element was not the last element, add a divider line:
585 if ($c != $GLOBALS['TYPO3_DB']->sql_num_rows($result)) {
589 <td colspan="3"><img'.t3lib_iconWorks
::skinImg($this->backPath
,'gfx/stiblet_medium2.gif','width="468" height="1"').' class="c-divider" alt="" /></td>
594 // Add spacer between sections in the vertical list
599 <td colspan="3"><br /><br /><br /><br /></td>
603 // Add section header:
604 $newP = $this->newContentElementOnClick($id,$key,$this->tt_contentConfig
['sys_language_uid']);
607 <!-- Column header: -->
610 <td valign="top" colspan="3">'.
611 $this->tt_content_drawColHeader(t3lib_BEfunc
::getProcessedValue('tt_content','colPos',$key), ($this->doEdit
&&count($rowArr)?
'&edit[tt_content]['.$editUidList.']=edit'.$pageTitleParamForAltDoc:''), $newP).
616 // Finally, add the content from the records in this column:
620 // Finally, wrap all table rows in one, big table:
622 <table border="0" cellpadding="0" cellspacing="0" width="400" class="typo3-page-columnsMode">
628 // Add the big buttons to page:
629 if ($this->option_showBigButtons
) {
631 $bArray[0]=$GLOBALS['SOBE']->doc
->t3Button(t3lib_BEfunc
::editOnClick('&edit[pages]['.$id."]=edit",$this->backPath
,''),$GLOBALS['LANG']->getLL('editPageTitle'));
632 $bArray[1]=$GLOBALS['SOBE']->doc
->t3Button("document.location='".$this->backPath
."move_el.php?table=pages&uid=".$id.'&returnUrl='.rawurlencode(t3lib_div
::getIndpEnv('REQUEST_URI'))."';",$GLOBALS['LANG']->getLL('move_page'));
633 $bArray[2]=$GLOBALS['SOBE']->doc
->t3Button("document.location='".$this->backPath
."db_new.php?id=".$id.'&pagesOnly=1&returnUrl='.rawurlencode(t3lib_div
::getIndpEnv('REQUEST_URI'))."';",$GLOBALS['LANG']->getLL('newPage2'));
634 if ($this->ext_function
==1) $bArray[3]=$GLOBALS['SOBE']->doc
->t3Button("document.location='db_new_content_el.php?id=".$id.'&sys_language_uid='.$GLOBALS['SOBE']->current_sys_language
.'&returnUrl='.rawurlencode(t3lib_div
::getIndpEnv('REQUEST_URI'))."';",$GLOBALS['LANG']->getLL('newPageContent2'));
636 <table border="0" cellpadding="4" cellspacing="0" class="typo3-page-buttons">
639 <td>',$bArray).'</td>
642 <img src="clear.gif" width="1" height="5" alt="" /><br />
651 * Renders Frontend Users from the fe_users table from page id
653 * @param integer Page id
654 * @return string HTML for the listing
656 function getTable_fe_users($id) {
658 $this->addElement_tdParams
=array(
659 'username'=>' nowrap="nowrap"',
660 'password'=>' nowrap="nowrap"',
661 'usergroup'=>' nowrap="nowrap"',
662 'name'=>' nowrap="nowrap"',
663 'address'=>' nowrap="nowrap"',
664 'zip'=>' nowrap="nowrap"',
665 'city'=>' nowrap="nowrap"',
666 'email'=>' nowrap="nowrap"',
667 'telephone'=>' nowrap="nowrap"'
669 $fList = 'username,password,usergroup,name,email,telephone,address,zip,city';
670 $out = $this->makeOrdinaryList('fe_users',$id, $fList, 1);
671 $this->addElement_tdParams
=array();
676 * Renders records from the sys_notes table from page id
677 * NOTICE: Requires the sys_note extension to be loaded.
679 * @param integer Page id
680 * @return string HTML for the listing
682 function getTable_sys_note($id) {
685 if (!t3lib_extMgm
::isLoaded('sys_note')) return '';
688 $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
689 $tree = $this->getTreeObject($id,intval($GLOBALS['SOBE']->MOD_SETTINGS
['pages_levels']),$perms_clause);
691 $this->itemLabels
=array();
692 foreach($TCA['sys_note']['columns'] as $name => $val) {
693 $this->itemLabels
[$name]=$GLOBALS['LANG']->sL($val['label']);
696 // If page ids were found, select all sys_notes from the page ids:
698 if (count($tree->ids
)) {
699 $delClause = t3lib_BEfunc
::deleteClause('sys_note');
700 $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_note', 'pid IN ('.implode($tree->ids
,',').') AND (!personal OR cruser='.intval($GLOBALS['BE_USER']->user
['uid']).')'.$delClause);
701 $dbCount = $GLOBALS['TYPO3_DB']->sql_num_rows($result);
703 // If sys_notes were found, render them:
705 $this->fieldArray
= explode(',','__cmds__,info,note');
707 // header line is drawn
709 $theData['__cmds__'] ='';
710 $theData['info'] = '<b>Info</b><br /><img src="clear.gif" height="1" width="220" alt="" />';
711 $theData['note'] = '<b>Note</b>';
712 $out.=$this->addelement(1,'',$theData,' class="c-headLine"',20);
714 // half line is drawn
716 $theData['info'] = $this->widthGif
;
717 $out.=$this->addelement(0,'',$theData);
722 $this->eCounter
=$this->firstElementNumber
;
723 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
724 list($flag,$code) = $this->fwd_rwd_nav();
728 0 => '', // No category
729 1 => ' class="bgColor4"', // Instructions
730 2 => ' class="bgColor2"', // Template
732 4 => ' class="bgColor5"' // To-do
734 $tdparams = $color[$row['category']];
737 $this->getProcessedValue('sys_note','subject,category,author,email,personal',$row,$info);
738 $cont=implode($info,'<br />');
739 $head = '<b>Page:</b> '.t3lib_BEfunc
::getRecordPath($row['pid'],$perms_clause,10).'<br />';
741 $theData['__cmds__']= $this->getIcon('sys_note',$row);
742 $theData['info'] = $head.$cont;
743 $theData['note'] = nl2br($row['message']);
745 $out.=$this->addelement(1,'',$theData,$tdparams,20);
748 // half line is drawn
750 $theData['info'] = $this->widthGif
;
751 $out.=$this->addelement(0,'',$theData);
756 // Wrap it all in a table:
758 <table border="0" cellpadding="1" cellspacing="2" width="480" class="typo3-page-sysnote">
767 * Renders records from the tt_board table from page id
768 * NOTICE: Requires the tt_board extension to be loaded.
770 * @param integer Page id
771 * @return string HTML for the listing
773 function getTable_tt_board($id) {
776 $delClause = t3lib_BEfunc
::deleteClause('tt_board');
777 $queryParts = $this->makeQueryArray('tt_board', $id, 'AND parent=0');
778 $this->setTotalItems($queryParts);
781 // If items were selected, make query:
782 if ($this->totalItems
) {
783 $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
784 $dbCount = $GLOBALS['TYPO3_DB']->sql_num_rows($result);
787 // If results came out of that, render the list:
791 // Setting fields to display first:
792 if ($GLOBALS['SOBE']->MOD_SETTINGS
['tt_board']=='expand') {
793 $this->fieldArray
= explode(',','subject,author,date,age');
795 $this->fieldArray
= explode(',','subject,author,date,age,replys');
798 // Header line is drawn
800 $theData['subject'] = '<b>'.$GLOBALS['LANG']->getLL('tt_board_subject',1).'</b>';
801 $theData['author'] = '<b>'.$GLOBALS['LANG']->getLL('tt_board_author',1).'</b>';
802 $theData['date'] = '<b>'.$GLOBALS['LANG']->getLL('tt_board_date',1).'</b>';
803 $theData['age'] = '<b>'.$GLOBALS['LANG']->getLL('tt_board_age',1).'</b>';
804 if ($GLOBALS['SOBE']->MOD_SETTINGS
['tt_board']!='expand') {
805 $theData['replys'] = '<b>'.$GLOBALS['LANG']->getLL('tt_board_RE',1).'</b>';
807 $out.=$this->addelement(1,'',$theData,' class="c-headLine"',20);
809 // half line is drawn
811 $theData['subject'] = $this->widthGif
;
812 $out.=$this->addelement(0,'',$theData);
815 $this->eCounter
=$this->firstElementNumber
;
816 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
817 list($flag,$code) = $this->fwd_rwd_nav();
823 $theRows = $this->tt_board_getTree ($theRows,$row['uid'],$id,$delClause,'');
824 $out.=$this->tt_board_drawItem('tt_board',$row,count($theRows));
826 if ($GLOBALS['SOBE']->MOD_SETTINGS
['tt_board']=='expand') {
828 while(list($n,$sRow)=each($theRows)) {
829 $out.=$this->tt_board_drawItem('tt_board',$sRow,0);
836 // Wrap it all in a table:
838 <table border="0" cellpadding="0" cellspacing="0" class="typo3-page-listTTboard">
847 * Renders address records from the tt_address table from page id
848 * NOTICE: Requires the tt_address extension to be loaded.
850 * @param integer Page id
851 * @return string HTML for the listing
853 function getTable_tt_address($id) {
855 // Define fieldlist to show:
856 switch($GLOBALS['SOBE']->MOD_SETTINGS
['tt_address']) {
859 $fList = 'name,address,zip,city,country';
863 $fList = 'name;title;email;company,image';
867 $fList = 'name,email,www,phone,fax,mobile';
872 $out = $this->makeOrdinaryList('tt_address',$id, $fList, $icon);
877 * Renders link records from the tt_links table from page id
878 * NOTICE: Requires the tt_links extension to be loaded.
880 * @param integer Page id
881 * @return string HTML for the listing
883 function getTable_tt_links($id) {
885 // Define fieldlist to show:
886 switch($GLOBALS['SOBE']->MOD_SETTINGS
['tt_links']) {
888 $fList = 'title,hidden,url';
891 $fList = 'title;url,note2';
894 $fList = 'title;url,note';
898 $out = $this->makeOrdinaryList('tt_links',$id, $fList,1);
903 * Renders link records from the tt_links table from page id
904 * NOTICE: Requires the tt_links extension to be loaded.
906 * @param integer Page id
907 * @return string HTML for the listing
909 function getTable_tt_guest($id) {
911 // Define fieldlist to show:
912 $fList = 'title;cr_name;cr_email,note';
913 $out = $this->makeOrdinaryList('tt_guest',$id, $fList, 1);
918 * Renders news items from the tt_news table from page id
919 * NOTICE: Requires the tt_news extension to be loaded.
921 * @param integer Page id
922 * @return string HTML for the listing
924 function getTable_tt_news($id) {
926 $this->addElement_tdParams
=array(
927 'title'=>' nowrap="nowrap"',
928 'datetime'=>' nowrap="nowrap"',
929 'starttime'=>' nowrap="nowrap"',
930 'author'=>' nowrap="nowrap"'
932 $fList = 'title,author,author_email,datetime,starttime,category,image';
933 $out = $this->makeOrdinaryList('tt_news',$id, $fList, 1);
934 $this->addElement_tdParams
=array();
939 * Renders calender elements link records from the tt_calender table from page id
940 * NOTICE: Requires the tt_calender extension to be loaded.
942 * @param integer Page id
943 * @return string HTML for the listing
945 function getTable_tt_calender($id) {
947 $type=$GLOBALS['SOBE']->MOD_SETTINGS
['tt_calender'];
951 $fList = 'date,title';
953 $out = $this->makeOrdinaryList('tt_calender',$id, $fList, $icon, ' AND type=0');
958 $fList = 'title;date;time;datetext;link,note';
960 $out = $this->makeOrdinaryList('tt_calender',$id, $fList, $icon, ' AND type=0');
965 $fList = 'title,complete,priority,date';
967 $out = $this->makeOrdinaryList('tt_calender',$id, $fList, $icon, ' AND type=1');
972 $fList = 'title;complete;priority;date;workgroup;responsible;category,note';
974 $out = $this->makeOrdinaryList('tt_calender',$id, $fList, $icon, ' AND type=1');
978 // Overview, both todo and calender
979 $fList = 'title,date,time,week';
981 $out = $this->makeOrdinaryList('tt_calender',$id, $fList, $icon, ' AND type=0');
982 $out.= $this->makeOrdinaryList('tt_calender',$id, $fList, $icon, ' AND type=1');
989 * Renders shopping elements from the tt_products table from page id
990 * NOTICE: Requires the tt_products extension to be loaded.
992 * @param integer Page id
993 * @return string HTML for the listing
995 function getTable_tt_products($id) {
997 $type = $GLOBALS['SOBE']->MOD_SETTINGS
['tt_products'];
1000 $fList = 'title;itemnumber;price;price2;inStock;category,image,note';
1002 $out = $this->makeOrdinaryList('tt_products',$id, $fList, $icon);
1005 $fList = 'title,itemnumber,price,category,image';
1007 $out = $this->makeOrdinaryList('tt_products',$id, $fList, $icon);
1025 /**********************************
1027 * Generic listing of items
1029 **********************************/
1032 * Creates a standard list of elements from a table.
1034 * @param string Table name
1035 * @param integer Page id.
1036 * @param string Comma list of fields to display
1037 * @param boolean If true, icon is shown
1038 * @param string Additional WHERE-clauses.
1039 * @return string HTML table
1041 function makeOrdinaryList($table, $id, $fList, $icon=0, $addWhere='') {
1046 $queryParts = $this->makeQueryArray($table, $id, $addWhere);
1047 $this->setTotalItems($queryParts);
1050 // Make query for records if there were any records found in the count operation:
1051 if ($this->totalItems
) {
1052 $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
1053 $dbCount = $GLOBALS['TYPO3_DB']->sql_num_rows($result);
1056 // If records were found, render the list:
1061 $this->fieldArray
= explode(',','__cmds__,'.$fList);
1063 // Header line is drawn
1065 $theData = $this->headerFields($this->fieldArray
,$table,$theData);
1066 $out.= $this->addelement(1,'',$theData,' class="c-headLine"',15);
1069 $this->eCounter
= $this->firstElementNumber
;
1070 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
1071 list($flag,$code) = $this->fwd_rwd_nav();
1074 $params = '&edit['.$table.']['.$row['uid'].']=edit';
1077 // Setting icons/edit links:
1079 $Nrow['__cmds__']= $this->getIcon($table,$row);
1081 if ($this->doEdit
) {
1082 $Nrow['__cmds__'].= '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc
::editOnClick($params,$this->backPath
)).'">'.
1083 '<img'.t3lib_iconWorks
::skinImg($this->backPath
,'gfx/edit2.gif','width="11" height="12"').' title="'.$GLOBALS['LANG']->getLL('edit',1).'" alt="" />'.
1086 $Nrow['__cmds__'].= $this->noEditIcon();
1090 $Nrow = $this->dataFields($this->fieldArray
,$table,$row,$Nrow);
1091 $tdparams = $this->eCounter%2 ?
' class="bgColor4"' : ' class="bgColor4-20"';
1092 $out.= $this->addelement(1,'',$Nrow,$tdparams);
1097 // Wrap it all in a table:
1101 STANDARD LIST OF "'.$table.'"
1103 <table border="0" cellpadding="1" cellspacing="2" width="480" id="typo3-page-stdlist">
1111 * Adds content to all data fields in $out array
1113 * @param array Array of fields to display. Each field name has a special feature which is that the field name can be specified as more field names. Eg. "field1,field2;field3". Field 2 and 3 will be shown in the same cell of the table separated by <br /> while field1 will have its own cell.
1114 * @param string Table name
1115 * @param array Record array
1116 * @param array Array to which the data is added
1117 * @return array $out array returned after processing.
1118 * @see makeOrdinaryList()
1120 function dataFields($fieldArr,$table,$row,$out=array()) {
1123 // Check table validity:
1125 t3lib_div
::loadTCA($table);
1126 $thumbsCol = $TCA[$table]['ctrl']['thumbnail'];
1129 foreach($fieldArr as $fieldName) {
1131 if ($TCA[$table]['columns'][$fieldName]) { // Each field has its own cell (if configured in TCA)
1132 if ($fieldName==$thumbsCol) { // If the column is a thumbnail column:
1133 $out[$fieldName] = $this->thumbCode($row,$table,$fieldName);
1134 } else { // ... otherwise just render the output:
1135 $out[$fieldName] = nl2br(htmlspecialchars(trim(t3lib_div
::fixed_lgd(t3lib_BEfunc
::getProcessedValue($table,$fieldName,$row[$fieldName]),250))));
1137 } else { // Each field is separated by <br /> and shown in the same cell (If not a TCA field, then explode the field name with ";" and check each value there as a TCA configured field)
1138 $theFields = explode(';',$fieldName);
1140 // Traverse fields, separated by ";" (displayed in a single cell).
1141 foreach($theFields as $fName2) {
1142 if ($TCA[$table]['columns'][$fName2]) {
1143 $out[$fieldName].= '<b>'.$GLOBALS['LANG']->sL($TCA[$table]['columns'][$fName2]['label'],1).'</b>'.
1145 htmlspecialchars(t3lib_div
::fixed_lgd(t3lib_BEfunc
::getProcessedValue($table,$fName2,$row[$fName2]),25)).
1150 // If no value, add a nbsp.
1151 if (!$out[$fieldName]) $out[$fieldName]=' ';
1153 // Wrap in dimmed-span tags if record is "disabled"
1154 if ($this->isDisabled($table,$row)) {
1155 $out[$fieldName] = $GLOBALS['TBE_TEMPLATE']->dfw($out[$fieldName]);
1163 * Header fields made for the listing of records
1165 * @param array Field names
1166 * @param string The table name
1167 * @param array Array to which the headers are added.
1168 * @return array $out returned after addition of the header fields.
1169 * @see makeOrdinaryList()
1171 function headerFields($fieldArr,$table,$out=array()) {
1174 t3lib_div
::loadTCA($table);
1176 foreach($fieldArr as $fieldName) {
1177 $ll = $GLOBALS['LANG']->sL($TCA[$table]['columns'][$fieldName]['label'],1);
1178 $out[$fieldName] = '<b>'.($ll?
$ll:' ').'</b>';
1197 /**********************************
1199 * Additional functions; Pages
1201 **********************************/
1204 * Adds pages-rows to an array, selecting recursively in the page tree.
1206 * @param array Array which will accumulate page rows
1207 * @param integer Pid to select from
1208 * @param string Query-where clause
1209 * @param string Prefixed icon code.
1210 * @param integer Depth (decreasing)
1211 * @return array $theRows, but with added rows.
1213 function pages_getTree($theRows,$pid,$qWhere,$treeIcons,$depth) {
1216 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'pages', 'pid='.intval($pid).$qWhere, '', 'sorting');
1218 $rc = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
1219 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1221 $row['treeIcons'] = $treeIcons.'<img'.t3lib_iconWorks
::skinImg($this->backPath
,'gfx/ol/join'.($rc==$c?
'bottom':'').'.gif','width="18" height="16"').' alt="" />';
1225 $spaceOutIcons = '<img'.t3lib_iconWorks
::skinImg($this->backPath
,'gfx/ol/'.($rc==$c?
'blank.gif':'line.gif'),'width="18" height="16"').' alt="" />';
1226 $theRows = $this->pages_getTree($theRows,$row['uid'],$qWhere,$treeIcons.$spaceOutIcons,$row['php_tree_stop']?
0:$depth);
1229 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'pages', 'pid='.intval($pid).$qWhere);
1230 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
1232 $this->plusPages
[$pid]=$row[0];
1239 * Adds a list item for the pages-rendering
1241 * @param array Record array
1242 * @param array Field list
1243 * @return string HTML for the item
1245 function pages_drawItem($row,$fieldArr) {
1249 $theIcon=$this->getIcon('pages',$row);
1251 // Preparing and getting the data-array
1253 foreach($fieldArr as $field) {
1256 $red = $this->plusPages
[$row['uid']] ?
'<font color="red"><b>+ </b></font>' : '';
1257 $pTitle = htmlspecialchars(t3lib_BEfunc
::getProcessedValue('pages',$field,$row[$field],20));
1259 $pTitle = '<a href="'.htmlspecialchars($this->script
.'?id='.$row['uid']).'">'.$pTitle.'</a>';
1261 $theData[$field]=$row['treeIcons'].$theIcon.$red.$pTitle.' ';
1263 case 'php_tree_stop':
1265 $theData[$field] = $row[$field]?
' <b>x</b>':' ';
1268 if ($GLOBALS['BE_USER']->doesUserHaveAccess($row,2)) {
1269 $params='&edit[pages]['.$row['uid'].']=edit';
1270 $eI= '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc
::editOnClick($params,$this->backPath
,'')).'">'.
1271 '<img'.t3lib_iconWorks
::skinImg($this->backPath
,'gfx/edit2.gif','width="11" height="12"').' title="'.$GLOBALS['LANG']->getLL('editThisPage',1).'" alt="" />'.
1274 $theData[$field] = '<span align="right">'.$row['uid'].$eI.'</span>';
1277 if (substr($field,0,6)=='table_') {
1278 $f2 = substr($field,6);
1280 $c = $this->numberOfRecords($f2,$row['uid']);
1281 $theData[$field] = ' '.($c?
$c:'');
1283 } elseif (substr($field,0,5)=='HITS_') {
1284 if (t3lib_extMgm
::isLoaded('sys_stat')) {
1285 $fParts = explode(':',substr($field,5));
1286 switch($fParts[0]) {
1288 $timespan = mktime (0,0,0)+
intval($fParts[1])*3600*24;
1290 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1293 $this->stat_select_field
.'='.intval($row['uid']).'
1294 AND tstamp>='.intval($timespan).'
1295 AND tstamp<'.intval($timespan+
3600*24)
1297 list($number) = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
1300 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
1303 $this->stat_select_field
.'='.intval($row['uid']).'
1304 AND tstamp>='.intval($timespan).'
1305 AND tstamp<'.intval($timespan+
3600*24).'
1306 AND surecookie!=""',
1309 $scnumber = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
1311 $number.= '/'.$scnumber;
1317 $theData[$field]= ' '.$number;
1319 $theData[$field]= ' ';
1322 $theData[$field]= ' '.htmlspecialchars(t3lib_BEfunc
::getProcessedValue('pages',$field,$row[$field]));
1327 return $this->addelement(1,'',$theData);
1341 /**********************************
1343 * Additional functions; Content Elements
1345 **********************************/
1348 * Draw header for a content element column:
1350 * @param string Column name
1351 * @param string Edit params (Syntax: &edit[...] for alt_doc.php)
1352 * @param string New element params (Syntax: &edit[...] for alt_doc.php)
1353 * @return string HTML table
1355 function tt_content_drawColHeader($colName,$editParams,$newParams) {
1357 // Create header row:
1360 <td class="bgColor2" nowrap="nowrap"><img src="clear.gif" width="1" height="2" alt="" /><br /><div align="center"><b>'.htmlspecialchars(strtoupper($colName)).'</b></div><img src="clear.gif" width="1" height="2" alt="" /></td>
1363 // Create command links:
1364 if ($this->tt_contentConfig
['showCommands']) {
1368 <td class="bgColor5">';
1370 // Edit whole of column:
1372 $out.='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc
::editOnClick($editParams,$this->backPath
)).'">'.
1373 '<img'.t3lib_iconWorks
::skinImg($this->backPath
,'gfx/edit2.gif','width="11" height="12"').' title="'.$GLOBALS['LANG']->getLL('editColumn',1).'" alt="" />'.
1378 $out.='<a href="#" onclick="'.htmlspecialchars($newParams).'">'.
1379 '<img'.t3lib_iconWorks
::skinImg($this->backPath
,'gfx/new_record.gif','width="16" height="12"').' title="'.$GLOBALS['LANG']->getLL('newInColumn',1).'" alt="" />'.
1390 <table border="0" cellpadding="0" cellspacing="0" width="100%" class="typo3-page-colHeader">'.($space?
'
1392 <td><img src="clear.gif" height="'.$space.'" alt="" /></td>
1399 * Draw the header for a single tt_content element
1401 * @param array Record array
1402 * @param integer Amount of pixel space above the header.
1403 * @return string HTML table with the record header.
1405 function tt_content_drawHeader($row,$space=0) {
1408 // Load full table description:
1409 t3lib_div
::loadTCA('tt_content');
1411 // Get record locking status:
1412 if ($lockInfo=t3lib_BEfunc
::isRecordLocked('tt_content',$row['uid'])) {
1413 $lockIcon='<a href="#" onclick="'.htmlspecialchars('alert('.$GLOBALS['LANG']->JScharCode($lockInfo['msg']).');return false;').'">'.
1414 '<img'.t3lib_iconWorks
::skinImg($this->backPath
,'gfx/recordlock_warning3.gif','width="17" height="12"').' title="'.htmlspecialchars($lockInfo['msg']).'" alt="" />'.
1416 } else $lockIcon='';
1418 // Create header with icon/lock-icon/title:
1419 $header = $this->getIcon('tt_content',$row).
1421 ' <b>'.htmlspecialchars($this->CType_labels
[$row['CType']]).'</b>';
1424 <td class="bgColor4">'.$header.'</td>
1427 // If show info is set...;
1428 if ($this->tt_contentConfig
['showInfo']) {
1430 // Get processed values:
1432 $this->getProcessedValue('tt_content','hidden,starttime,endtime,fe_group,spaceBefore,spaceAfter,section_frame,sectionIndex,linkToTop',$row,$info);
1434 // Render control panel for the element:
1435 if ($this->tt_contentConfig
['showCommands'] && $this->doEdit
) {
1437 // Start control cell:
1439 <!-- Control Panel -->
1441 <td class="bgColor5">';
1443 // Edit content element:
1444 $params='&edit[tt_content]['.$this->tt_contentData
['nextThree'][$row['uid']].']=edit';
1445 $out.='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc
::editOnClick($params,$this->backPath
)).'">'.
1446 '<img'.t3lib_iconWorks
::skinImg($this->backPath
,'gfx/edit2.gif','width="11" height="12"').' title="'.htmlspecialchars($this->nextThree
>1?
sprintf($GLOBALS['LANG']->getLL('nextThree'),$this->nextThree
):$GLOBALS['LANG']->getLL('edit')).'" alt="" />'.
1449 // New content element:
1450 if ($this->option_newWizard
) {
1451 $onClick="document.location='db_new_content_el.php?id=".$row['pid'].'&sys_language_uid='.$row['sys_language_uid'].'&colPos='.$row['colPos'].'&uid_pid='.(-$row['uid']).'&returnUrl='.rawurlencode(t3lib_div
::getIndpEnv('REQUEST_URI'))."';";
1453 $params='&edit[tt_content]['.(-$row['uid']).']=new';
1454 $onClick = t3lib_BEfunc
::editOnClick($params,$this->backPath
);
1456 $out.='<a href="#" onclick="'.htmlspecialchars($onClick).'">'.
1457 '<img'.t3lib_iconWorks
::skinImg($this->backPath
,'gfx/new_record.gif','width="16" height="12"').' title="'.$GLOBALS['LANG']->getLL('newAfter',1).'" alt="" />'.
1461 if ($this->tt_contentData
['prev'][$row['uid']]) {
1462 $params='&cmd[tt_content]['.$row['uid'].'][move]='.$this->tt_contentData
['prev'][$row['uid']];
1463 $out.='<a href="'.htmlspecialchars($GLOBALS['SOBE']->doc
->issueCommand($params)).'">'.
1464 '<img'.t3lib_iconWorks
::skinImg($this->backPath
,'gfx/button_up.gif','width="11" height="10"').' title="'.$GLOBALS['LANG']->getLL('moveUp',1).'" alt="" />'.
1467 $out.='<img src="clear.gif" '.t3lib_iconWorks
::skinImg($this->backPath
,'gfx/button_up.gif','width="11" height="10"',2).' alt="" />';
1469 // Move element down:
1470 if ($this->tt_contentData
['next'][$row['uid']]) {
1471 $params='&cmd[tt_content]['.$row['uid'].'][move]='.$this->tt_contentData
['next'][$row['uid']];
1472 $out.='<a href="'.htmlspecialchars($GLOBALS['SOBE']->doc
->issueCommand($params)).'">'.
1473 '<img'.t3lib_iconWorks
::skinImg($this->backPath
,'gfx/button_down.gif','width="11" height="10"').' title="'.$GLOBALS['LANG']->getLL('moveDown',1).'" alt="" />'.
1476 $out.='<img src="clear.gif" '.t3lib_iconWorks
::skinImg($this->backPath
,'gfx/button_down.gif','width="11" height="10"',2).' alt="" />';
1480 $hiddenField = $TCA['tt_content']['ctrl']['enablecolumns']['disabled'];
1481 if ($hiddenField && $TCA['tt_content']['columns'][$hiddenField] && (!$TCA['tt_content']['columns'][$hiddenField]['exclude'] ||
$GLOBALS['BE_USER']->check('non_exclude_fields','tt_content:'.$hiddenField))) {
1482 if ($row[$hiddenField]) {
1483 $params='&data[tt_content]['.$row['uid'].']['.$hiddenField.']=0';
1484 $out.='<a href="'.htmlspecialchars($GLOBALS['SOBE']->doc
->issueCommand($params)).'">'.
1485 '<img'.t3lib_iconWorks
::skinImg($this->backPath
,'gfx/button_unhide.gif','width="11" height="10"').' title="'.$GLOBALS['LANG']->getLL('unHide',1).'" alt="" />'.
1488 $params='&data[tt_content]['.$row['uid'].']['.$hiddenField.']=1';
1489 $out.='<a href="'.htmlspecialchars($GLOBALS['SOBE']->doc
->issueCommand($params)).'">'.
1490 '<img'.t3lib_iconWorks
::skinImg($this->backPath
,'gfx/button_hide.gif','width="11" height="10"').' title="'.$GLOBALS['LANG']->getLL('hide',1).'" alt="" />'.
1496 $params='&cmd[tt_content]['.$row['uid'].'][delete]=1';
1497 $out.='<a href="'.htmlspecialchars($GLOBALS['SOBE']->doc
->issueCommand($params)).'" onclick="'.htmlspecialchars('return confirm('.$GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->getLL('deleteWarning')).');').'">'.
1498 '<img'.t3lib_iconWorks
::skinImg($this->backPath
,'gfx/garbage.gif','width="11" height="12"').' title="'.$GLOBALS['LANG']->getLL('deleteItem',1).'" alt="" />'.
1507 // Display info from records fields:
1511 <td class="bgColor4-20">'.implode($info,'<br />').'</td>
1515 // Wrap the whole header in a table:
1517 <table border="0" cellpadding="0" cellspacing="0" class="typo3-page-ceHeader">'.($space?
'
1519 <td><img src="clear.gif" height="'.$space.'" alt="" /></td>
1526 * Draws the preview content for a content element
1528 * @param string Content element
1529 * @param boolean Set if the RTE link can be created.
1530 * @return string HTML
1532 function tt_content_drawItem($row, $isRTE=FALSE
) {
1539 if ($row['header'] && $row['header_layout']!=100) {
1541 $this->getProcessedValue('tt_content','header_position,header_layout,header_link',$row,$infoArr);
1543 $outHeader= ($row['date'] ?
htmlspecialchars($this->itemLabels
['date'].' '.t3lib_BEfunc
::date($row['date'])).'<br />':'').
1544 $this->infoGif($infoArr).
1545 '<b>'.$this->linkEditContent($this->renderText($row['header']),$row).'</b><br />';
1550 switch($row['CType']) {
1552 if ($row['subheader']) {
1553 $this->getProcessedValue('tt_content','layout',$row,$infoArr);
1554 $out.= $this->infoGif($infoArr).
1555 $this->linkEditContent($this->renderText($row['subheader']),$row).'<br />';
1561 if ($row['CType']=='text' ||
$row['CType']=='textpic') {
1562 if ($row['bodytext']) {
1563 $this->getProcessedValue('tt_content','text_align,text_face,text_size,text_color,text_properties',$row,$infoArr);
1564 $out.= $this->infoGif($infoArr).
1565 $this->linkEditContent($this->renderText($row['bodytext']),$row).'<br />';
1568 if ($row['CType']=='textpic' ||
$row['CType']=='image') {
1569 if ($row['image']) {
1571 $this->getProcessedValue('tt_content','imageorient,imagecols,image_noRows,imageborder,imageheight,image_link,image_zoom,image_compression,image_effects,image_frames',$row,$infoArr);
1572 $out.= $this->infoGif($infoArr).
1573 $this->thumbCode($row,'tt_content','image').'<br />';
1575 if ($row['imagecaption']) {
1577 $this->getProcessedValue('tt_content','imagecaption_position',$row,$infoArr);
1578 $out.= $this->infoGif($infoArr).
1579 $this->linkEditContent($this->renderText($row['imagecaption']),$row).'<br />';
1585 if ($row['bodytext']) {
1586 $this->getProcessedValue('tt_content','layout,text_align,text_face,text_size,text_color,text_properties',$row,$infoArr);
1587 $out.= $this->infoGif($infoArr).
1588 $this->linkEditContent($this->renderText($row['bodytext']),$row).'<br />';
1592 if ($row['bodytext']) {
1593 $this->getProcessedValue('tt_content','table_bgColor,table_border,table_cellspacing,cols,layout,text_align,text_face,text_size,text_color,text_properties',$row,$infoArr);
1594 $out.= $this->infoGif($infoArr).
1595 $this->linkEditContent($this->renderText($row['bodytext']),$row).'<br />';
1599 if ($row['media']) {
1600 $this->getProcessedValue('tt_content','media,select_key,layout,filelink_size,table_bgColor,table_border,table_cellspacing',$row,$infoArr);
1601 $out.= $this->infoGif($infoArr).
1602 $this->linkEditContent($this->renderText($row['bodytext']),$row).'<br />';
1606 if ($row['multimedia']) {
1607 $out.= $this->renderText($row['multimedia']).'<br />';
1608 $out.= $this->renderText($row['parameters']).'<br />';
1612 if ($row['bodytext']) {
1613 $this->getProcessedValue('tt_content','pages,subheader',$row,$infoArr);
1614 $out.= $this->infoGif($infoArr).
1615 $this->linkEditContent($this->renderText($row['bodytext']),$row).'<br />';
1619 if ($row['bodytext']) {
1620 $out.= $this->linkEditContent($this->renderText($row['bodytext']),$row).'<br />';
1622 if ($row['image']) {
1624 $this->getProcessedValue('tt_content','imagewidth',$row,$infoArr);
1625 $out.= $this->infoGif($infoArr).
1626 $this->thumbCode($row,'tt_content','image').'<br />';
1630 if ($row['pages']) {
1631 $this->getProcessedValue('tt_content','menu_type',$row,$infoArr);
1632 $out.= $this->infoGif($infoArr).
1633 $this->linkEditContent($row['pages'],$row).'<br />';
1637 if ($row['records']) {
1638 $this->getProcessedValue('tt_content','layout',$row,$infoArr);
1639 $out.= $this->infoGif($infoArr).
1640 $this->linkEditContent($row['shortcut'],$row).'<br />';
1644 $this->getProcessedValue('tt_content','layout',$row,$infoArr);
1645 $out.= $this->infoGif($infoArr).
1646 $GLOBALS['LANG']->sL(t3lib_BEfunc
::getItemLabel('tt_content','list_type'),1).' '.
1647 $GLOBALS['LANG']->sL(t3lib_BEfunc
::getLabelFromItemlist('tt_content','list_type',$row['list_type']),1).'<br />';
1649 $out.= $GLOBALS['LANG']->sL(t3lib_BEfunc
::getItemLabel('tt_content','select_key'),1).' '.$row['select_key'].'<br />';
1652 $this->getProcessedValue('tt_content','recursive',$row,$infoArr);
1653 $out.= $this->infoGif($infoArr).
1654 $GLOBALS['LANG']->sL(t3lib_BEfunc
::getLabelFromItemlist('tt_content','pages',$row['pages']),1).'<br />';
1657 $out.= $GLOBALS['LANG']->sL(t3lib_BEfunc
::getItemLabel('tt_content','select_key'),1).' '.$row['select_key'].'<br />';
1658 $out.= '<br />'.$this->linkEditContent($this->renderText($row['bodytext']),$row).'<br />';
1659 $out.= '<br />'.$this->linkEditContent($this->renderText($row['imagecaption']),$row).'<br />';
1662 if ($row['bodytext']) {
1663 $out.=$this->linkEditContent($this->renderText($row['bodytext']),$row).'<br />';
1670 <span class="exampleContent">'.$out.'</span>';
1672 $out = $outHeader.$out;
1675 $out.= $this->linkRTEbutton($row);
1679 if ($this->isDisabled('tt_content',$row)) {
1680 return $GLOBALS['TBE_TEMPLATE']->dfw($out);
1687 * Returns an icon, which has its title attribute set to a massive amount of information about the element.
1689 * @param array Array where values are human readable output of field values (not htmlspecialchars()'ed though). The values are imploded by a linebreak.
1690 * @return string HTML img tag if applicable.
1692 function infoGif($infoArr) {
1693 if (count($infoArr) && $this->tt_contentConfig
['showInfo']) {
1694 $out='<img'.t3lib_iconWorks
::skinImg($this->backPath
,'gfx/zoom2.gif','width="12" height="12"').' title="'.htmlspecialchars(implode(chr(10),$infoArr)).'" alt="" /> ';
1700 * Creates onclick-attribute content for a new content element
1702 * @param integer Page id where to create the element.
1703 * @param integer Preset: Column position value
1704 * @param integer Preset: Sys langauge value
1705 * @return string String for onclick attribute.
1706 * @see getTable_tt_content()
1708 function newContentElementOnClick($id,$colPos,$sys_language) {
1709 if ($this->option_newWizard
) {
1710 $onClick="document.location='db_new_content_el.php?id=".$id.'&colPos='.$colPos.'&sys_language_uid='.$sys_language.'&uid_pid='.$id.'&returnUrl='.rawurlencode(t3lib_div
::getIndpEnv('REQUEST_URI'))."';";
1712 $onClick=t3lib_BEfunc
::editOnClick('&edit[tt_content]['.$id.']=new&defVals[tt_content][colPos]='.$colPos.'&defVals[tt_content][sys_language_uid]='.$sys_language,$this->backPath
);
1718 * Will create a link on the input string and possible a big button after the string which links to editing in the RTE
1719 * Used for content element content displayed so the user can click the content / "Edit in Rich Text Editor" button
1721 * @param string String to link. Must be prepared for HTML output.
1722 * @param array The row.
1723 * @return string If the whole thing was editable ($this->doEdit) $str is return with link around. Otherwise just $str.
1724 * @see getTable_tt_content()
1726 function linkEditContent($str,$row) {
1730 if ($this->doEdit
) {
1731 // Setting onclick action for content link:
1732 $onClick=t3lib_BEfunc
::editOnClick('&edit[tt_content]['.$row['uid'].']=edit',$this->backPath
);
1735 return $onClick ?
'<a href="#" onclick="'.htmlspecialchars($onClick).'" title="'.$GLOBALS['LANG']->getLL('edit',1).'">'.$str.'</a>'.$addButton : $str;
1739 * Adds a button to edit the row in RTE wizard
1741 * @param array The row of tt_content element
1742 * @return string Button to click if you want to edit in RTE wizard.
1744 function linkRTEbutton($row) {
1746 $params['table'] = 'tt_content';
1747 $params['uid'] = $row['uid'];
1748 $params['pid'] = $row['pid'];
1749 $params['field'] = 'bodytext';
1750 $params['returnUrl'] = t3lib_div
::linkThisScript();
1751 $RTEonClick = "document.location='".$this->backPath
."wizard_rte.php?".t3lib_div
::implodeArrayForUrl('',array('P'=>$params))."';return false;";
1752 $addButton = $this->option_showBigButtons ?
$GLOBALS['SOBE']->doc
->t3Button($RTEonClick,$GLOBALS['LANG']->getLL('editInRTE')) : '';
1758 * Make selector box for creating new translation in a language
1759 * Displays only languages which are not yet present for the current page.
1761 * @param integer Page id for which to create a new language (pages_language_overlay record)
1762 * @return string <select> HTML element (if there were items for the box anyways...)
1763 * @see getTable_tt_content()
1765 function languageSelector($id) {
1766 if ($GLOBALS['BE_USER']->check('tables_select','pages_language_overlay')) {
1768 // First, select all
1769 $res = $GLOBALS['SOBE']->exec_languageQuery(0);
1770 $langSelItems=array();
1772 <option value="0"></option>';
1773 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1774 $langSelItems[$row['uid']]='
1775 <option value="'.$row['uid'].'">'.htmlspecialchars($row['title']).'</option>';
1778 // Then, subtract the languages which are already on the page:
1779 $res = $GLOBALS['SOBE']->exec_languageQuery($id);
1780 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1781 unset($langSelItems[$row['uid']]);
1784 // If any languages are left, make selector:
1785 if (count($langSelItems)>1) {
1786 $onChangeContent = 'document.location=\''.$this->backPath
.'alt_doc.php?&edit[pages_language_overlay]['.$id.']=new&overrideVals[pages_language_overlay][sys_language_uid]=\'+this.options[this.selectedIndex].value+\'&returnUrl='.rawurlencode(t3lib_div
::getIndpEnv('REQUEST_URI')).'\'';
1787 return $GLOBALS['LANG']->getLL('new_language',1).': <select name="createNewLanguage" onchange="'.htmlspecialchars($onChangeContent).'">
1788 '.implode('',$langSelItems).'
1789 </select><br /><br />';
1795 * Traverse the result pointer given, adding each record to array and setting some internal values at the same time.
1797 * @param pointer SQL result pointer for select query.
1798 * @return array The selected rows returned in this array.
1800 function getResult($result) {
1805 $nextTree = $this->nextThree
;
1809 // Traverse the result:
1810 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
1812 // Add the row to the array:
1815 // Set an internal register:
1816 $recs[$c]=$row['uid'];
1818 // Create the list of the next three ids (for editing links...)
1819 for($a=0;$a<$nextTree;$a++
) {
1820 if(isset($recs[$c-$a])) {
1821 $this->tt_contentData
['nextThree'][$recs[$c-$a]].=$row['uid'].',';
1825 // Set next/previous ids:
1826 if (isset($recs[$c-1])) {
1827 if (isset($recs[$c-2])) {
1828 $this->tt_contentData
['prev'][$row['uid']]=-$recs[$c-2];
1830 $this->tt_contentData
['prev'][$row['uid']]=$row['pid'];
1832 $this->tt_contentData
['next'][$recs[$c-1]]=-$row['uid'];
1837 // Return selected records
1853 /**********************************
1855 * Additional functions; Message board items (tt_board)
1857 **********************************/
1860 * Traverses recursively a branch in a message board.
1862 * @param array Array of rows (build up recursively)
1863 * @param integer tt_content parent uid
1864 * @param integer Page id
1865 * @param string Additional query part.
1866 * @param string HTML content to prefix items with (to draw the proper tree-graphics)
1867 * @return array $theRows, but with added content
1869 function tt_board_getTree($theRows,$parent,$pid,$qWhere,$treeIcons) {
1871 // Select tt_board elements:
1872 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_board', 'pid='.intval($pid).' AND parent='.intval($parent).$qWhere, '', 'crdate');
1874 // Traverse the results:
1876 $rc = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
1877 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1879 $row['treeIcons'] = $treeIcons.'<img'.t3lib_iconWorks
::skinImg($this->backPath
,'gfx/ol/'.($rc==$c ?
'joinbottom.gif' : 'join.gif'),'width="18" height="16"').' alt="" />';
1883 $theRows = $this->tt_board_getTree(
1888 $treeIcons.'<img'.t3lib_iconWorks
::skinImg($this->backPath
,'gfx/ol/'.($rc==$c ?
'blank.gif' : 'line.gif'),'width="18" height="16"').' alt="" />'
1892 // Return modified rows:
1897 * Adds an element to the tt_board listing:
1899 * @param string Table name
1900 * @param array The record row
1901 * @param string Reply count, if applicable.
1902 * @return string Return content of element (table row)
1904 function tt_board_drawItem($table,$row,$re) {
1906 // Building data-arary with content:
1908 $theData['subject'] = t3lib_div
::fixed_lgd(htmlspecialchars($row['subject']),25).' ';
1909 $theData['author'] = t3lib_div
::fixed_lgd(htmlspecialchars($row['author']),15).' ';
1910 $theData['date'] = t3lib_div
::fixed_lgd(t3lib_BEfunc
::datetime($row['crdate']),20).' ';
1911 $theData['age'] = t3lib_BEfunc
::calcAge(time()-$row['crdate'], $this->agePrefixes
).' ';
1913 $theData['replys'] = $re;
1916 // Subject is built:
1917 $theData['subject'] =
1919 $this->getIcon($table,$row).
1920 $theData['subject'];
1923 return $this->addelement(1,'',$theData);
1938 /********************************
1940 * Various helper functions
1942 ********************************/
1945 * Counts and returns the number of records on the page with $pid
1947 * @param string Table name
1948 * @param integer Page id
1949 * @return integer Number of records.
1951 function numberOfRecords($table,$pid) {
1956 $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', $table, 'pid='.intval($pid).t3lib_BEfunc
::deleteClause($table));
1957 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_row($result)) {
1965 * Processing of larger amounts of text (usually from RTE/bodytext fields) with word wrapping etc.
1967 * @param string Input string
1968 * @return string Output string
1970 function renderText($input) {
1971 $input = strip_tags($input);
1972 $input = t3lib_div
::fixed_lgd($input,1500);
1973 return nl2br(htmlspecialchars(trim($this->wordWrapper($input))));
1977 * Creates the icon image tag for record from table and wraps it in a link which will trigger the click menu.
1979 * @param string Table name
1980 * @param array Record array
1981 * @param string Record title (NOT USED)
1982 * @return string HTML for the icon
1984 function getIcon($table,$row) {
1987 $alttext = t3lib_BEfunc
::getRecordIconAltText($row,$table);
1988 $iconImg = t3lib_iconWorks
::getIconImage($table,$row,$this->backPath
,'title="'.$alttext.'"');
1991 // The icon with link
1992 $theIcon = $GLOBALS['SOBE']->doc
->wrapClickMenuOnIcon($iconImg,$table,$row['uid']);
1998 * Creates processed values for all fieldnames in $fieldList based on values from $row array.
1999 * The result is 'returned' through $info which is passed as a reference
2001 * @param string Table name
2002 * @param string Commalist of fields.
2003 * @param array Record from which to take values for processing.
2004 * @param array Array to which the processed values are added.
2007 function getProcessedValue($table,$fieldList,$row,&$info) {
2009 // Splitting values from $fieldList:
2010 $fieldArr = explode(',',$fieldList);
2012 // Traverse fields from $fieldList:
2013 foreach($fieldArr as $field) {
2015 $info[]= htmlspecialchars($this->itemLabels
[$field]).' '.htmlspecialchars(t3lib_BEfunc
::getProcessedValue($table,$field,$row[$field]));
2021 * Returns true, if the record given as parameters is NOT visible based on hidden/starttime/endtime (if available)
2023 * @param string Tablename of table to test
2024 * @param array Record row.
2025 * @return boolean Returns true, if disabled.
2027 function isDisabled($table,$row) {
2030 ($TCA[$table]['ctrl']['enablecolumns']['disabled'] && $row[$TCA[$table]['ctrl']['enablecolumns']['disabled']]) ||
2031 ($TCA[$table]['ctrl']['enablecolumns']['starttime'] && $row[$TCA[$table]['ctrl']['enablecolumns']['starttime']]>time() ) ||
2032 ($TCA[$table]['ctrl']['enablecolumns']['endtime'] && $row[$TCA[$table]['ctrl']['enablecolumns']['endtime']] && $row[$TCA[$table]['ctrl']['enablecolumns']['endtime']]<time())
2037 * Will perform "word-wrapping" on the input string. What it does is to split by space or linebreak, then find any word longer than $max and if found, a hyphen is inserted.
2038 * Works well on normal texts, little less well when HTML is involved (since much HTML will have long strings that will be broken).
2040 * @param string Content to word-wrap.
2041 * @param integer Max number of chars in a word before it will be wrapped.
2042 * @param string Character to insert when wrapping.
2043 * @return string Processed output.
2045 function wordWrapper($content,$max=50,$char=' -') {
2046 $array = split(' |'.chr(10),$content);
2047 foreach($array as $val) {
2048 if (strlen($val)>$max) {
2049 $content=str_replace($val,substr(chunk_split($val,$max,$char),0,-1),$content);
2056 * Returns icon for "no-edit" of a record.
2057 * Basically, the point is to signal that this record could have had an edit link if the circumstances were right. A placeholder for the regular edit icon...
2059 * @param string Label key from LOCAL_LANG
2060 * @return string IMG tag for icon.
2062 function noEditIcon($label='noEditItems') {
2063 return '<img'.t3lib_iconWorks
::skinImg($this->backPath
,'gfx/edit2_d.gif','width="11" height="12"').' title="'.$GLOBALS['LANG']->getLL($label,1).'" alt="" />';
2067 * Function, which fills in the internal array, $this->allowedTableNames with all tables to which the user has access. Also a set of standard tables (pages, static_template, sys_filemounts, etc...) are filtered out. So what is left is basically all tables which makes sense to list content from.
2071 function cleanTableNames() {
2074 // Get all table names:
2075 $tableNames=array_flip(array_keys($TCA));
2077 // Unset common names:
2078 unset($tableNames['pages']);
2079 unset($tableNames['static_template']);
2080 unset($tableNames['sys_filemounts']);
2081 unset($tableNames['sys_action']);
2082 unset($tableNames['sys_workflows']);
2083 unset($tableNames['be_users']);
2084 unset($tableNames['be_groups']);
2086 $this->allowedTableNames
=array();
2088 // Traverse table names and set them in allowedTableNames array IF they can be read-accessed by the user.
2089 if (is_array($tableNames)) {
2090 foreach($tableNames as $k => $v) {
2091 if ($GLOBALS['BE_USER']->check('tables_select',$k)) {
2092 $this->allowedTableNames
['table_'.$k]=$k;
2099 * Checking if the RTE is available/enabled for a certain table/field and if so, it returns true.
2100 * Used to determine if the RTE button should be displayed.
2102 * @param string Table name
2103 * @param array Record row (needed, if there are RTE dependencies based on other fields in the record)
2104 * @param string Field name
2105 * @return boolean Returns true if the rich text editor would be enabled/available for the field name specified.
2107 function isRTEforField($table,$row,$field){
2108 $specConf = $this->getSpecConfForField($table,$row,$field);
2109 $p = t3lib_BEfunc
::getSpecConfParametersFromArray($specConf['rte_transform']['parameters']);
2110 if (isset($specConf['richtext']) && (!$p['flag'] ||
!$row[$p['flag']])) {
2111 list($tscPID,$thePidValue) = t3lib_BEfunc
::getTSCpid($table,$row['uid'],$row['pid']);
2112 if ($thePidValue>=0) { // If the pid-value is not negative (that is, a pid could NOT be fetched)
2113 $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE',t3lib_BEfunc
::getPagesTSconfig($tscPID));
2114 $RTEtypeVal = t3lib_BEfunc
::getTCAtypeValue($table,$row);
2115 $thisConfig = t3lib_BEfunc
::RTEsetup($RTEsetup['properties'],$table,$field,$RTEtypeVal);
2116 if (!$thisConfig['disabled']) {
2126 * Returns "special" configuration from the "types" configuration in TCA for the record given by tablename/fieldname.
2127 * Used by isRTEforField() in the process of finding whether a field has RTE enabled or not.
2129 * @param string Table name
2130 * @param array Record array
2131 * @param string Field name
2132 * @return array Spec. conf (if available)
2134 * @see isRTEforField()
2136 function getSpecConfForField($table,$row,$field) {
2138 // Get types-configuration for the record:
2139 $types_fieldConfig = t3lib_BEfunc
::getTCAtypes($table,$row);
2141 // Find the given field and return the spec key value if found:
2142 if (is_array($types_fieldConfig)) {
2143 foreach($types_fieldConfig as $vconf) {
2144 if ($vconf['field']==$field) return $vconf['spec'];
2160 /*****************************************
2162 * External renderings
2164 *****************************************/
2167 * Creates an info-box for the current page (identified by input record).
2169 * @param array Page record
2170 * @param boolean If set, there will be shown an edit icon, linking to editing of the page header.
2171 * @return string HTML for the box.
2173 function getPageInfoBox($rec,$edit=0) {
2176 // If editing of the page header is allowed:
2178 $params='&edit[pages]['.$rec['uid'].']=edit';
2179 $editIcon='<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc
::editOnClick($params,$this->backPath
)).'">'.
2180 '<img'.t3lib_iconWorks
::skinImg($this->backPath
,'gfx/edit2.gif','width="11" height="12"').' title="'.$GLOBALS['LANG']->getLL('edit',1).'" alt="" />'.
2183 $editIcon=$this->noEditIcon('noEditPage');
2186 // Setting page icon, link, title:
2187 $outPutContent = t3lib_iconWorks
::getIconImage('pages',$rec,$this->backPath
,'title="'.htmlspecialchars(t3lib_BEfunc
::titleAttribForPages($rec)).'"').
2190 htmlspecialchars($rec['title']);
2193 // Init array where infomation is accumulated as label/value pairs.
2196 // Owner user/group:
2197 if ($this->pI_showUser
) {
2199 $users= t3lib_BEfunc
::getUserNames('username,usergroup,usergroup_cached_list,uid,realName');
2200 $groupArray = explode(',',$GLOBALS['BE_USER']->user
['usergroup_cached_list']);
2201 $users=t3lib_BEfunc
::blindUserNames($users,$groupArray);
2202 $lines[]=array($LANG->getLL('pI_crUser').':',htmlspecialchars($users[$rec['cruser_id']]['username']).' ('.$users[$rec['cruser_id']]['realName'].')');
2206 $lines[]=array($LANG->getLL('pI_crDate').':', t3lib_BEfunc
::datetime($rec['crdate']).' ('.t3lib_BEfunc
::calcAge(time()-$rec['crdate'],$this->agePrefixes
).')');
2209 $lines[]=array($LANG->getLL('pI_lastChange').':', t3lib_BEfunc
::datetime($rec['tstamp']).' ('.t3lib_BEfunc
::calcAge(time()-$rec['tstamp'],$this->agePrefixes
).')');
2211 // Last change of content:
2212 if ($rec['SYS_LASTCHANGED']) {
2213 $lines[]=array($LANG->getLL('pI_lastChangeContent').':', t3lib_BEfunc
::datetime($rec['SYS_LASTCHANGED']).' ('.t3lib_BEfunc
::calcAge(time()-$rec['SYS_LASTCHANGED'],$this->agePrefixes
).')');
2219 // Display contents of certain page fields, if any value:
2220 $dfields = explode(',','alias,target,hidden,starttime,endtime,fe_group,no_cache,cache_timeout,newUntil,lastUpdated,subtitle,keywords,description,abstract,author,author_email');
2221 foreach($dfields as $fV) {
2223 $lines[]=array($GLOBALS['LANG']->sL(t3lib_BEfunc
::getItemLabel('pages',$fV)), t3lib_BEfunc
::getProcessedValue('pages',$fV,$rec[$fV]));
2227 // Page hits (depends on "sys_stat" extension)
2228 if ($this->pI_showStat
&& t3lib_extMgm
::isLoaded('sys_stat')) {
2230 // Counting total hits:
2231 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', 'sys_stat', 'page_id='.intval($rec['uid']));
2232 $rrow = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
2236 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('min(tstamp) AS min,max(tstamp) AS max', 'sys_stat', 'page_id='.intval($rec['uid']));
2237 $rrow2 = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
2240 $lines[]=array($LANG->getLL('pI_hitsPeriod').':',t3lib_BEfunc
::date($rrow2[0]).' - '.t3lib_BEfunc
::date($rrow2[1]).' ('.t3lib_BEfunc
::calcAge($rrow2[1]-$rrow2[0],$this->agePrefixes
).')');
2241 $lines[]=array($LANG->getLL('pI_hitsTotal').':',$rrow[0]);
2245 $nextMidNight = mktime (0,0,0)+
1*3600*24;
2247 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*), FLOOR(('.$nextMidNight.'-tstamp)/(24*3600)) AS day', 'sys_stat', 'page_id='.intval($rec['uid']).' AND tstamp>'.($nextMidNight-10*24*3600), 'day');
2249 while($rrow = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) {
2250 $days[$rrow[1]] = $rrow[0];
2255 for($a=9;$a>=0;$a--) {
2257 <td class="bgColor5" nowrap="nowrap"> '.date('d',$nextMidNight-($a+
1)*24*3600).' </td>';
2259 <td align="center">'.($days[$a] ?
intval($days[$a]) : '-').'</td>';
2262 // Compile first hit-table (last 10 days)
2264 <table border="0" cellpadding="0" cellspacing="1" class="typo3-page-hits">
2265 <tr>'.implode('',$headerH).'</tr>
2266 <tr>'.implode('',$contentH).'</tr>
2268 $lines[]=array($LANG->getLL('pI_hits10days').':',$hitTable,1);
2272 $nextHour = mktime (date('H'),0,0)+
3600;
2275 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*), FLOOR(('.$nextHour.'-tstamp)/3600) AS hours', 'sys_stat', 'page_id='.intval($rec['uid']).' AND tstamp>'.($nextHour-$hours*3600), 'hours');
2277 while($rrow = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) {
2278 $days[$rrow[1]]=$rrow[0];
2283 for($a=($hours-1);$a>=0;$a--) {
2285 <td class="bgColor5" nowrap="nowrap"> '.intval(date('H',$nextHour-($a+
1)*3600)).' </td>';
2287 <td align="center">'.($days[$a] ?
intval($days[$a]) : '-').'</td>';
2290 // Compile second hit-table (last 24 hours)
2292 <table border="0" cellpadding="0" cellspacing="1" class="typo3-page-stat">
2293 <tr>'.implode('',$headerH).'</tr>
2294 <tr>'.implode('',$contentH).'</tr>
2296 $lines[]=array($LANG->getLL('pI_hits24hours').':',$hitTable,1);
2301 // Finally, wrap the elements in the $lines array in table cells/rows
2302 foreach($lines as $fV) {
2303 if (is_array($fV)) {
2304 if (!$fV[2]) $fV[1]=htmlspecialchars($fV[1]);
2307 <td class="bgColor4" nowrap="nowrap"><strong>'.htmlspecialchars($fV[0]).' </strong></td>
2308 <td class="bgColor4">'.$fV[1].'</td>
2313 <td colspan="2"><img src="clear.gif" width="1" height="3" alt="" /></td>
2318 // Wrap table tags around...
2326 <table border="0" cellpadding="0" cellspacing="1" id="typo3-page-info">
2330 // ... and return it.
2331 return $outPutContent;
2335 * Creates a menu of the tables that can be listed by this function
2336 * Only tables which has records on the page will be included.
2337 * Notice: The function also fills in the internal variable $this->activeTables with icon/titles.
2339 * @param integer Page id from which we are listing records (the function will look up if there are records on the page)
2340 * @return string HTML output.
2342 function getTableMenu($id) {
2346 $this->activeTables
=array();
2347 $theTables = explode(',','tt_content,fe_users,tt_address,tt_links,tt_board,tt_guest,tt_calender,tt_products,tt_news'); // NOTICE: This serves double function: Both being tables names (all) and for most others also being extension keys for the extensions they are related to!
2350 if (is_array($this->externalTables
)) {
2351 $theTables = array_unique(array_merge($theTables, array_keys($this->externalTables
)));
2354 // Traverse tables to check:
2355 foreach($theTables as $tName) {
2357 // Check access and whether the proper extensions are loaded:
2358 if ($GLOBALS['BE_USER']->check('tables_select',$tName) && (t3lib_extMgm
::isLoaded($tName)||t3lib_div
::inList('fe_users,tt_content',$tName) ||
isset($this->externalTables
[$tName]))) {
2360 // Make query to count records from page:
2361 $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('count(*)', $tName, 'pid='.intval($id).t3lib_BEfunc
::deleteClause($tName));
2362 list($c) = $GLOBALS['TYPO3_DB']->sql_fetch_row($result);
2364 // If records were found (or if "tt_content" is the table...):
2365 if ($c || t3lib_div
::inList('tt_content',$tName)) {
2369 <td><a href="#'.$tName.'"></a>'.
2370 t3lib_iconWorks
::getIconImage($tName,Array(),$this->backPath
,'title="'.$GLOBALS['LANG']->sL($TCA[$tName]['ctrl']['title'],1).'"').
2373 // ... and to the internal array, activeTables we also add table icon and title (for use elsewhere)
2374 $this->activeTables
[$tName]=
2375 t3lib_iconWorks
::getIconImage($tName,Array(),$this->backPath
,'title="'.$GLOBALS['LANG']->sL($TCA[$tName]['ctrl']['title'],1).': '.$c.' '.$GLOBALS['LANG']->getLL('records',1).'" class="absmiddle"').
2377 $GLOBALS['LANG']->sL($TCA[$tName]['ctrl']['title'],1);
2382 // Wrap cells in table tags:
2388 Menu of tables on the page (table menu)
2390 <table border="0" cellpadding="0" cellspacing="0" id="typo3-page-tblMenu">
2395 // Return the content:
2403 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['ext/cms/layout/class.tx_cms_layout.php']) {
2404 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['ext/cms/layout/class.tx_cms_layout.php']);