|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com) 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * A copy is found in the textfile GPL.txt and important notices to the license 00017 * from the author is found in LICENSE.txt distributed with these scripts. 00018 * 00019 * 00020 * This script is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * This copyright notice MUST APPEAR in all copies of the script! 00026 ***************************************************************/ 00027 /** 00028 * Include file extending db_list.inc for use with the web_layout module 00029 * 00030 * $Id: class.tx_cms_layout.php 10547 2011-02-22 20:03:57Z lolli $ 00031 * Revised for TYPO3 3.6 November/2003 by Kasper Skårhøj 00032 * XHTML compliant 00033 * 00034 * @author Kasper Skårhøj <kasperYYYY@typo3.com> 00035 */ 00036 00037 /** 00038 * [CLASS/FUNCTION INDEX of SCRIPT] 00039 * 00040 * 00041 * 00042 * 115: class tx_cms_layout extends recordList 00043 * 00044 * SECTION: Renderings 00045 * 180: function getTable($table,$id) 00046 * 240: function getTable_pages($id) 00047 * 378: function getTable_tt_content($id) 00048 * 754: function getTable_fe_users($id) 00049 * 780: function getTable_sys_note($id) 00050 * 873: function getTable_tt_board($id) 00051 * 955: function getTable_tt_address($id) 00052 * 985: function getTable_tt_links($id) 00053 * 1011: function getTable_tt_guest($id) 00054 * 1026: function getTable_tt_news($id) 00055 * 1047: function getTable_tt_calender($id) 00056 * 1097: function getTable_tt_products($id) 00057 * 00058 * SECTION: Generic listing of items 00059 * 1143: function makeOrdinaryList($table, $id, $fList, $icon=0, $addWhere='') 00060 * 1224: function dataFields($fieldArr,$table,$row,$out=array()) 00061 * 1275: function headerFields($fieldArr,$table,$out=array()) 00062 * 00063 * SECTION: Additional functions; Pages 00064 * 1317: function pages_getTree($theRows,$pid,$qWhere,$treeIcons,$depth) 00065 * 1350: function pages_drawItem($row,$fieldArr) 00066 * 00067 * SECTION: Additional functions; Content Elements 00068 * 1461: function tt_content_drawColHeader($colName,$editParams,$newParams) 00069 * 1513: function tt_content_drawHeader($row,$space=0,$disableMoveAndNewButtons=FALSE,$langMode=FALSE) 00070 * 1643: function tt_content_drawItem($row, $isRTE=FALSE) 00071 * 1806: function getNonTranslatedTTcontentUids($defLanguageCount,$id,$lP) 00072 * 1836: function newLanguageButton($defLanguageCount,$lP) 00073 * 1857: function infoGif($infoArr) 00074 * 1873: function newContentElementOnClick($id,$colPos,$sys_language) 00075 * 1891: function linkEditContent($str,$row) 00076 * 1909: function linkRTEbutton($row) 00077 * 1930: function languageSelector($id) 00078 * 1967: function getResult($result) 00079 * 00080 * SECTION: Additional functions; Message board items (tt_board) 00081 * 2036: function tt_board_getTree($theRows,$parent,$pid,$qWhere,$treeIcons) 00082 * 2071: function tt_board_drawItem($table,$row,$re) 00083 * 00084 * SECTION: Various helper functions 00085 * 2118: function numberOfRecords($table,$pid) 00086 * 2137: function renderText($input) 00087 * 2151: function getIcon($table,$row) 00088 * 2174: function getProcessedValue($table,$fieldList,$row,&$info) 00089 * 2194: function isDisabled($table,$row) 00090 * 2212: function wordWrapper($content,$max=50,$char=' -') 00091 * 2229: function noEditIcon($label='noEditItems') 00092 * 2238: function cleanTableNames() 00093 * 2274: function isRTEforField($table,$row,$field) 00094 * 2304: function getSpecConfForField($table,$row,$field) 00095 * 00096 * SECTION: External renderings 00097 * 2341: function getPageInfoBox($rec,$edit=0) 00098 * 2510: function getTableMenu($id) 00099 * 2575: function strip_tags($content, $fillEmptyContent=false) 00100 * 00101 * TOTAL FUNCTIONS: 43 00102 * (This index is automatically created/updated by the extension "extdeveval") 00103 * 00104 */ 00105 00106 00107 /** 00108 * Child class for the Web > Page module 00109 * 00110 * @author Kasper Skårhøj <kasperYYYY@typo3.com> 00111 * @package TYPO3 00112 * @subpackage core 00113 */ 00114 class tx_cms_layout extends recordList { 00115 00116 // External, static: For page statistics: 00117 var $stat_select_field = 'page_id'; // fieldname from sys_stat to select on. 00118 var $stat_codes = array(); // eg. "HITS_days:-1" 00119 00120 // External, static: Flags of various kinds: 00121 var $pI_showUser = 0; // If true, users/groups are shown in the page info box. 00122 var $pI_showStat = 1; // If true, hit statistics are shown in the page info box. 00123 var $nextThree = 3; // The number of successive records to edit when showing content elements. 00124 var $pages_noEditColumns = 0; // If true, disables the edit-column icon for tt_content elements 00125 var $option_showBigButtons = 1; // If true, shows big buttons for editing page properties, moving, creating elements etc. in the columns view. 00126 var $option_newWizard = 1; // If true, new-wizards are linked to rather than the regular new-element list. 00127 var $ext_function = 0; // If set to "1", will link a big button to content element wizard. 00128 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. 00129 var $agePrefixes = ' min| hrs| days| yrs'; // Age prefixes for displaying times. May be set externally to localized values. 00130 var $externalTables = array(); // Array of tables to be listed by the Web > Page module in addition to the default tables. 00131 var $descrTable; // "Pseudo" Description -table name 00132 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! 00133 00134 // External, static: Configuration of tt_content element display: 00135 var $tt_contentConfig = Array( 00136 'showInfo' => 1, // Boolean: Display info-marks or not 00137 'showCommands' => 1, // Boolean: Display up/down arrows and edit icons for tt_content records 00138 'single' => 1, // Boolean: If set, the content of column(s) $this->tt_contentConfig['showSingleCol'] is shown in the total width of the page 00139 'showAsGrid' => 0, // Boolean: If set, the content of columns is shown in grid 00140 'showSingleCol' => 0, // The column(s) to show if single mode (under each other) 00141 'languageCols' => 0, 00142 'languageMode' => 0, 00143 'languageColsPointer' => 0, 00144 'showHidden' => 1, // Displays hidden records as well 00145 'sys_language_uid' => 0, // Which language 00146 'cols' => '1,0,2,3' // The order of the rows: Default is left(1), Normal(0), right(2), margin(3) 00147 ); 00148 00149 // Internal, dynamic: 00150 var $allowedTableNames = array(); // Will contain a list of tables which can be listed by the user. 00151 var $activeTables = array(); // Contains icon/title of pages which are listed in the tables menu (see getTableMenu() function ) 00152 var $tt_contentData = Array( 00153 'nextThree' => Array(), 00154 'prev' => Array(), 00155 'next' => Array() 00156 ); 00157 var $CType_labels = array(); // Used to store labels for CTypes for tt_content elements 00158 var $itemLabels = array(); // Used to store labels for the various fields in tt_content elements 00159 00160 00161 /***************************************** 00162 * 00163 * Renderings 00164 * 00165 *****************************************/ 00166 00167 /** 00168 * Adds the code of a single table 00169 * 00170 * @param string Table name 00171 * @param integer Current page id 00172 * @return string HTML for listing. 00173 */ 00174 function getTable($table, $id) { 00175 00176 // Load full table definition: 00177 t3lib_div::loadTCA($table); 00178 00179 if (isset($this->externalTables[$table])) { 00180 return $this->getExternalTables($id, $table); 00181 } else { 00182 // Branch out based on table name: 00183 // 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. 00184 switch ($table) { 00185 case 'pages': 00186 return $this->getTable_pages($id); 00187 break; 00188 case 'tt_content': 00189 return $this->getTable_tt_content($id); 00190 break; 00191 case 'fe_users': 00192 return $this->getTable_fe_users($id); 00193 break; 00194 case 'sys_note': 00195 return $this->getTable_sys_note($id); 00196 break; 00197 case 'tt_board': 00198 return $this->getTable_tt_board($id); 00199 break; 00200 case 'tt_address': 00201 return $this->getTable_tt_address($id); 00202 break; 00203 case 'tt_links': 00204 return $this->getTable_tt_links($id); 00205 break; 00206 case 'tt_guest': 00207 return $this->getTable_tt_guest($id); 00208 break; 00209 case 'tt_news': 00210 return $this->getTable_tt_news($id); 00211 break; 00212 case 'tt_calender': 00213 return $this->getTable_tt_calender($id); 00214 break; 00215 case 'tt_products': 00216 return $this->getTable_tt_products($id); 00217 break; 00218 } 00219 } 00220 } 00221 00222 00223 /** 00224 * Renders an external table from page id 00225 * 00226 * @param integer Page id 00227 * @param string name of the table 00228 * @return string HTML for the listing 00229 */ 00230 function getExternalTables($id, $table) { 00231 00232 $type = $GLOBALS['SOBE']->MOD_SETTINGS[$table]; 00233 if (!isset($type)) { 00234 $type = 0; 00235 } 00236 00237 $fList = $this->externalTables[$table][$type]['fList']; // eg. "name;title;email;company,image" 00238 // The columns are separeted by comma ','. 00239 // Values separated by semicolon ';' are shown in the same column. 00240 $icon = $this->externalTables[$table][$type]['icon']; 00241 $addWhere = $this->externalTables[$table][$type]['addWhere']; 00242 00243 // Create listing 00244 $out = $this->makeOrdinaryList($table, $id, $fList, $icon, $addWhere); 00245 return $out; 00246 } 00247 00248 00249 /** 00250 * Renders records from the pages table from page id 00251 * (Used to get information about the page tree content by "Web>Info"!) 00252 * 00253 * @param integer Page id 00254 * @return string HTML for the listing 00255 */ 00256 function getTable_pages($id) { 00257 global $TCA; 00258 00259 // Initializing: 00260 $out = ''; 00261 $delClause = t3lib_BEfunc::deleteClause('pages') . ' AND ' . $GLOBALS['BE_USER']->getPagePermsClause(1); // Select clause for pages: 00262 00263 // Select current page: 00264 if (!$id) { 00265 $row = $GLOBALS['SOBE']->pageinfo; // The root has a pseudo record in pageinfo... 00266 } else { 00267 $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'pages', 'uid=' . intval($id) . $delClause); 00268 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result); 00269 t3lib_BEfunc::workspaceOL('pages', $row); 00270 } 00271 00272 // If there was found a page: 00273 if (is_array($row)) { 00274 00275 // Select which fields to show: 00276 $pKey = $GLOBALS['SOBE']->MOD_SETTINGS['function'] == 'tx_cms_webinfo_hits' ? 'hits' : $GLOBALS['SOBE']->MOD_SETTINGS['pages']; 00277 switch ($pKey) { 00278 case 'hits': 00279 $this->fieldArray = explode(',', 'title,' . implode(',', $this->stat_codes)); 00280 break; 00281 case 1: 00282 $this->cleanTableNames(); 00283 $tableNames = $this->allowedTableNames; 00284 $this->fieldArray = explode(',', 'title,uid,' . implode(',', array_keys($tableNames))); 00285 break; 00286 case 2: 00287 $this->fieldArray = explode(',', 'title,uid,lastUpdated,newUntil,no_cache,cache_timeout,php_tree_stop,TSconfig,storage_pid,is_siteroot,fe_login_mode'); 00288 break; 00289 default: 00290 $this->fieldArray = explode(',', 'title,uid,alias,starttime,endtime,fe_group,target,url,shortcut,shortcut_mode'); 00291 break; 00292 } 00293 00294 // Getting select-depth: 00295 $depth = intval($GLOBALS['SOBE']->MOD_SETTINGS['pages_levels']); 00296 00297 // Half line is drawn 00298 $theData = Array(); 00299 $theData['subject'] = $this->widthGif; 00300 $out .= $this->addelement(0, '', $theData); 00301 00302 // Overriding a few things: 00303 $this->no_noWrap = 0; 00304 $this->oddColumnsCssClass = 'bgColor3-20'; 00305 00306 // Items 00307 $this->eCounter = $this->firstElementNumber; 00308 00309 // Creating elements: 00310 list($flag, $code) = $this->fwd_rwd_nav(); 00311 $out .= $code; 00312 $editUids = array(); 00313 if ($flag) { 00314 00315 // Getting children: 00316 $theRows = Array(); 00317 $theRows = $this->pages_getTree($theRows, $row['uid'], $delClause . t3lib_BEfunc::versioningPlaceholderClause('pages'), '', $depth); 00318 if ($GLOBALS['BE_USER']->doesUserHaveAccess($row, 2)) { 00319 $editUids[] = $row['uid']; 00320 } 00321 $out .= $this->pages_drawItem($row, $this->fieldArray); 00322 00323 // Traverse all pages selected: 00324 foreach ($theRows as $n => $sRow) { 00325 if ($GLOBALS['BE_USER']->doesUserHaveAccess($sRow, 2)) { 00326 $editUids[] = $sRow['uid']; 00327 } 00328 $out .= $this->pages_drawItem($sRow, $this->fieldArray); 00329 } 00330 $this->eCounter++; 00331 } 00332 00333 // Header line is drawn 00334 $theData = Array(); 00335 $editIdList = implode(',', $editUids); 00336 00337 // Traverse fields (as set above) in order to create header values: 00338 foreach ($this->fieldArray as $field) { 00339 if ($editIdList && isset($TCA['pages']['columns'][$field]) && $field != 'uid' && !$this->pages_noEditColumns) { 00340 $params = '&edit[pages][' . $editIdList . ']=edit&columnsOnly=' . $field . '&disHelp=1'; 00341 $iTitle = sprintf($GLOBALS['LANG']->getLL('editThisColumn'), rtrim(trim($GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel('pages', $field))), ':')); 00342 $eI = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::editOnClick($params, $this->backPath, '')) . '" title="' . htmlspecialchars($iTitle) . '">' . 00343 t3lib_iconWorks::getSpriteIcon('actions-document-open') . 00344 '</a>'; 00345 } else { 00346 $eI = ''; 00347 } 00348 switch ($field) { 00349 case 'title': 00350 $theData[$field] = ' <strong>' . $GLOBALS['LANG']->sL($TCA['pages']['columns'][$field]['label']) . '</strong>' . $eI; 00351 break; 00352 case 'uid': 00353 $theData[$field] = ' <strong>ID:</strong>'; 00354 break; 00355 default: 00356 if (substr($field, 0, 6) == 'table_') { 00357 $f2 = substr($field, 6); 00358 if ($TCA[$f2]) { 00359 $theData[$field] = ' ' . t3lib_iconWorks::getSpriteIconForRecord($f2, array(), array('title' => $GLOBALS['LANG']->sL($TCA[$f2]['ctrl']['title'], 1))); 00360 } 00361 } elseif (substr($field, 0, 5) == 'HITS_') { 00362 $fParts = explode(':', substr($field, 5)); 00363 switch ($fParts[0]) { 00364 case 'days': 00365 $timespan = mktime(0, 0, 0) + intval($fParts[1]) * 3600 * 24; 00366 $theData[$field] = ' ' . date('d', $timespan); 00367 break; 00368 default: 00369 $theData[$field] = ''; 00370 break; 00371 } 00372 } else { 00373 $theData[$field] = ' <strong>' . $GLOBALS['LANG']->sL($TCA['pages']['columns'][$field]['label'], 1) . '</strong>' . $eI; 00374 } 00375 break; 00376 } 00377 } 00378 00379 // Start table: 00380 $this->oddColumnsCssClass = ''; 00381 00382 // CSH: 00383 $out = t3lib_BEfunc::cshItem($this->descrTable, 'func_' . $pKey, $GLOBALS['BACK_PATH']) . 00384 ' 00385 <table border="0" cellpadding="0" cellspacing="0" class="typo3-page-pages"> 00386 ' . $this->addelement(1, '', $theData, ' class="t3-row-header"', 20) . 00387 $out . ' 00388 </table>'; 00389 } 00390 $this->oddColumnsCssClass = ''; 00391 return $out; 00392 } 00393 00394 /** 00395 * Returns the backend layout which should be used for this page. 00396 * 00397 * @param integer $id: Uid of the current page 00398 * @return mixed Uid of the backend layout record or NULL if no layout should be used 00399 */ 00400 function getSelectedBackendLayoutUid($id) { 00401 $page = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('backend_layout', 'pages', 'uid=' . $id); 00402 $backendLayoutUid = intval($page['backend_layout']); 00403 if ($backendLayoutUid == -1) { 00404 // if it is set to "none" - don't use any 00405 $backendLayoutUid = NULL; 00406 } else if ($backendLayoutUid == 0) { 00407 // if it not set check the rootline for a layout on next level and use this 00408 $rootline = t3lib_BEfunc::BEgetRootLine($id); 00409 for ($i = count($rootline) - 2; $i > 0; $i--) { 00410 $backendLayoutUid = intval($rootline[$i]['backend_layout_next_level']); 00411 if ($backendLayoutUid > 0) { 00412 // stop searching if a layout for "next level" is set 00413 break; 00414 } else if ($backendLayoutUid == -1){ 00415 // if layout for "next level" is set to "none" - don't use any and stop searching 00416 $backendLayoutUid = NULL; 00417 break; 00418 } 00419 } 00420 } 00421 // if it is set to a positive value use this 00422 return $backendLayoutUid; 00423 } 00424 00425 /** 00426 * Renders Content Elements from the tt_content table from page id 00427 * 00428 * @param integer Page id 00429 * @return string HTML for the listing 00430 */ 00431 function getTable_tt_content($id) { 00432 global $TCA; 00433 00434 $this->initializeLanguages(); 00435 00436 // Initialize: 00437 $RTE = $GLOBALS['BE_USER']->isRTE(); 00438 $lMarg = 1; 00439 $showHidden = $this->tt_contentConfig['showHidden'] ? '' : t3lib_BEfunc::BEenableFields('tt_content'); 00440 $pageTitleParamForAltDoc = '&recTitle=' . rawurlencode(t3lib_BEfunc::getRecordTitle('pages', t3lib_BEfunc::getRecordWSOL('pages', $id), TRUE)); 00441 $GLOBALS['SOBE']->doc->getPageRenderer()->loadExtJs(); 00442 $GLOBALS['SOBE']->doc->getPageRenderer()->addJsFile($GLOBALS['BACK_PATH'] . 'sysext/cms/layout/js/typo3pageModule.js'); 00443 00444 // Get labels for CTypes and tt_content element fields in general: 00445 $this->CType_labels = array(); 00446 foreach ($TCA['tt_content']['columns']['CType']['config']['items'] as $val) { 00447 $this->CType_labels[$val[1]] = $GLOBALS['LANG']->sL($val[0]); 00448 } 00449 $this->itemLabels = array(); 00450 foreach ($TCA['tt_content']['columns'] as $name => $val) { 00451 $this->itemLabels[$name] = $GLOBALS['LANG']->sL($val['label']); 00452 } 00453 00454 // Select display mode: 00455 if (!$this->tt_contentConfig['single']) { // MULTIPLE column display mode, side by side: 00456 00457 // Setting language list: 00458 $langList = $this->tt_contentConfig['sys_language_uid']; 00459 if ($this->tt_contentConfig['languageMode']) { 00460 if ($this->tt_contentConfig['languageColsPointer']) { 00461 $langList = '0,' . $this->tt_contentConfig['languageColsPointer']; 00462 } else { 00463 $langList = implode(',', array_keys($this->tt_contentConfig['languageCols'])); 00464 } 00465 $languageColumn = array(); 00466 } 00467 $langListArr = explode(',', $langList); 00468 $defLanguageCount = array(); 00469 $defLangBinding = array(); 00470 00471 // For EACH languages... : 00472 foreach ($langListArr as $lP) { // If NOT languageMode, then we'll only be through this once. 00473 $showLanguage = $this->defLangBinding && $lP == 0 ? ' AND sys_language_uid IN (0,-1)' : ' AND sys_language_uid=' . $lP; 00474 $cList = explode(',', $this->tt_contentConfig['cols']); 00475 $content = array(); 00476 $head = array(); 00477 00478 // For EACH column, render the content into a variable: 00479 foreach ($cList as $key) { 00480 if (!$lP) { 00481 $defLanguageCount[$key] = array(); 00482 } 00483 00484 // Select content elements from this column/language: 00485 $queryParts = $this->makeQueryArray('tt_content', $id, 'AND colPos=' . intval($key) . $showHidden . $showLanguage); 00486 $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts); 00487 00488 // 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: 00489 if ($this->doEdit && $this->option_showBigButtons && !intval($key) && !$GLOBALS['TYPO3_DB']->sql_num_rows($result)) { 00490 $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')) . "';"; 00491 $theNewButton = $GLOBALS['SOBE']->doc->t3Button($onClick, $GLOBALS['LANG']->getLL('newPageContent')); 00492 $content[$key] .= '<img src="clear.gif" width="1" height="5" alt="" /><br />' . $theNewButton; 00493 } 00494 00495 // Traverse any selected elements and render their display code: 00496 $rowArr = $this->getResult($result); 00497 00498 foreach ($rowArr as $rKey => $row) { 00499 00500 if (is_array($row) && (int) $row['t3ver_state'] != 2) { 00501 $singleElementHTML = ''; 00502 if (!$lP) { 00503 $defLanguageCount[$key][] = $row['uid']; 00504 } 00505 00506 $editUidList .= $row['uid'] . ','; 00507 $singleElementHTML .= $this->tt_content_drawHeader($row, $this->tt_contentConfig['showInfo'] ? 15 : 5, $this->defLangBinding && $lP > 0, TRUE); 00508 00509 $isRTE = $RTE && $this->isRTEforField('tt_content', $row, 'bodytext'); 00510 $singleElementHTML .= '<div ' . ($row['_ORIG_uid'] ? ' class="ver-element"' : '') . '>' . $this->tt_content_drawItem($row, $isRTE) . '</div>'; 00511 00512 // NOTE: this is the end tag for <div class="t3-page-ce-body"> 00513 // because of bad (historic) conception, starting tag has to be placed inside tt_content_drawHeader() 00514 $singleElementHTML .= '</div>'; 00515 00516 00517 $statusHidden = ($this->isDisabled('tt_content', $row) ? ' t3-page-ce-hidden' : ''); 00518 $singleElementHTML = '<div class="t3-page-ce' . $statusHidden . '">' . $singleElementHTML . '</div>'; 00519 00520 if ($this->defLangBinding && $this->tt_contentConfig['languageMode']) { 00521 $defLangBinding[$key][$lP][$row[($lP ? 'l18n_parent' : 'uid')]] = $singleElementHTML; 00522 } else { 00523 $content[$key] .= $singleElementHTML; 00524 } 00525 } else { 00526 unset($rowArr[$rKey]); 00527 } 00528 } 00529 00530 // Add new-icon link, header: 00531 $newP = $this->newContentElementOnClick($id, $key, $lP); 00532 $colTitle = t3lib_BEfunc::getProcessedValue('tt_content', 'colPos', $key); 00533 00534 $tcaItems = t3lib_div::callUserFunction('EXT:cms/classes/class.tx_cms_backendlayout.php:tx_cms_BackendLayout->getColPosListItemsParsed', $id, $this); 00535 foreach ($tcaItems as $item) { 00536 if ($item[1] == $key) { 00537 $colTitle = $GLOBALS['LANG']->sL($item[0]); 00538 } 00539 } 00540 $head[$key] .= $this->tt_content_drawColHeader($colTitle, ($this->doEdit && count($rowArr) ? '&edit[tt_content][' . $editUidList . ']=edit' . $pageTitleParamForAltDoc : ''), $newP); 00541 $editUidList = ''; 00542 } 00543 00544 // For EACH column, fit the rendered content into a table cell: 00545 $out = ''; 00546 00547 $backendLayoutUid = $this->getSelectedBackendLayoutUid($id); 00548 $backendLayoutRecord = t3lib_BEfunc::getRecord('backend_layout', intval($backendLayoutUid)); 00549 $this->tt_contentConfig['showAsGrid'] = !empty($backendLayoutRecord['config']) && !$this->tt_contentConfig['languageMode']; 00550 00551 if (!$this->tt_contentConfig['showAsGrid']) { 00552 foreach ($cList as $k => $key) { 00553 00554 if (!$k) { 00555 $out .= ' 00556 <td><img src="clear.gif" width="' . $lMarg . '" height="1" alt="" /></td>'; 00557 } else { 00558 $out .= ' 00559 <td><img src="clear.gif" width="4" height="1" alt="" /></td> 00560 <td bgcolor="#cfcfcf"><img src="clear.gif" width="1" height="1" alt="" /></td> 00561 <td><img src="clear.gif" width="4" height="1" alt="" /></td>'; 00562 } 00563 $out .= ' 00564 <td class="t3-page-column t3-page-column-' . $key . '">' . $head[$key] . $content[$key] . '</td>'; 00565 00566 // Storing content for use if languageMode is set: 00567 if ($this->tt_contentConfig['languageMode']) { 00568 $languageColumn[$key][$lP] = $head[$key] . $content[$key]; 00569 if (!$this->defLangBinding) { 00570 $languageColumn[$key][$lP] .= '<br /><br />' . $this->newLanguageButton($this->getNonTranslatedTTcontentUids($defLanguageCount[$key], $id, $lP), $lP); 00571 } 00572 } 00573 } 00574 00575 // Wrap the cells into a table row: 00576 $out = ' 00577 <table border="0" cellpadding="0" cellspacing="0" class="t3-page-columns" width="100%"> 00578 <tr>' . $out . ' 00579 </tr> 00580 </table>'; 00581 00582 } else { 00583 // GRID VIEW: 00584 00585 // initialize TS parser to parse config to array 00586 $parser = t3lib_div::makeInstance('t3lib_TSparser'); 00587 $parser->parse($backendLayoutRecord['config']); 00588 00589 $grid .= '<div class="t3-gridContainer"><table border="0" cellspacing="1" cellpadding="4" width="100%" height="100%" class="t3-page-columns t3-gridTable">'; 00590 00591 // add colgroups 00592 $colCount = intval($parser->setup['backend_layout.']['colCount']); 00593 $rowCount = intval($parser->setup['backend_layout.']['rowCount']); 00594 00595 $grid .= '<colgroup>'; 00596 for ($i = 0; $i < $colCount; $i++) { 00597 $grid .= '<col style="width:' . (100 / $colCount) . '%"></col>'; 00598 } 00599 $grid .= '</colgroup>'; 00600 00601 // cycle through rows 00602 for ($row = 1; $row <= $rowCount; $row++) { 00603 $rowConfig = $parser->setup['backend_layout.']['rows.'][$row . '.']; 00604 if (!isset($rowConfig)) { 00605 continue; 00606 } 00607 00608 $grid .= '<tr>'; 00609 00610 for ($col = 1; $col <= $colCount; $col++) { 00611 $columnConfig = $rowConfig['columns.'][$col . '.']; 00612 00613 if (!isset($columnConfig)) { 00614 continue; 00615 } 00616 00617 // which tt_content colPos should be displayed inside this cell 00618 $columnKey = intval($columnConfig['colPos']); 00619 00620 // render the grid cell 00621 $grid .= '<td valign="top"' . 00622 (isset($columnConfig['colspan']) ? ' colspan="' . $columnConfig['colspan'] . '"' : '') . 00623 (isset($columnConfig['rowspan']) ? ' rowspan="' . $columnConfig['rowspan'] . '"' : '') . 00624 ' class="t3-gridCell t3-page-column t3-page-column-' . $columnKey . 00625 (!isset($columnConfig['colPos']) ? ' t3-gridCell-unassigned' : '') . 00626 ((isset($columnConfig['colPos']) && ! $head[$columnKey]) ? ' t3-gridCell-restricted' : '') . 00627 (isset($columnConfig['colspan']) ? ' t3-gridCell-width' . $columnConfig['colspan'] : '') . 00628 (isset($columnConfig['rowspan']) ? ' t3-gridCell-height' . $columnConfig['rowspan'] : '') . '">'; 00629 00630 // Draw the pre-generated header with edit and new buttons if a colPos is assigned. 00631 // If not, a new header without any buttons will be generated. 00632 if (isset($columnConfig['colPos']) && $head[$columnKey]) { 00633 $grid .= $head[$columnKey] . $content[$columnKey]; 00634 } else if ($columnConfig['colPos']) { 00635 $grid .= $this->tt_content_drawColHeader($GLOBALS['LANG']->getLL('noAccess'), '', ''); 00636 } else { 00637 $grid .= $this->tt_content_drawColHeader($GLOBALS['LANG']->getLL('notAssigned'), '', ''); 00638 } 00639 00640 $grid .= '</td>'; 00641 } 00642 $grid .= '</tr>'; 00643 } 00644 $out .= $grid . '</table></div>'; 00645 } 00646 00647 // CSH: 00648 $out .= t3lib_BEfunc::cshItem($this->descrTable, 'columns_multi', $GLOBALS['BACK_PATH']); 00649 } 00650 00651 // If language mode, then make another presentation: 00652 // 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! 00653 if ($this->tt_contentConfig['languageMode']) { 00654 00655 // Get language selector: 00656 $languageSelector = $this->languageSelector($id); 00657 00658 // Reset out - we will make new content here: 00659 $out = ''; 00660 // Separator between language columns (black thin line) 00661 $midSep = ' 00662 <td><img src="clear.gif" width="4" height="1" alt="" /></td> 00663 <td bgcolor="black"><img src="clear.gif" width="1" height="1" alt="" /></td> 00664 <td><img src="clear.gif" width="4" height="1" alt="" /></td>'; 00665 00666 // Traverse languages found on the page and build up the table displaying them side by side: 00667 $cCont = array(); 00668 $sCont = array(); 00669 foreach ($langListArr as $lP) { 00670 00671 // Header: 00672 $cCont[$lP] = ' 00673 <td valign="top" align="center" class="bgColor6"><strong>' . htmlspecialchars($this->tt_contentConfig['languageCols'][$lP]) . '</strong></td>'; 00674 00675 // "View page" icon is added: 00676 $viewLink = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::viewOnClick($this->id, $this->backPath, t3lib_BEfunc::BEgetRootLine($this->id), '', '', '&L=' . $lP)) . '">' . 00677 t3lib_iconWorks::getSpriteIcon('actions-document-view') . 00678 '</a>'; 00679 00680 // Language overlay page header: 00681 if ($lP) { 00682 00683 list($lpRecord) = t3lib_BEfunc::getRecordsByField('pages_language_overlay', 'pid', $id, 'AND sys_language_uid=' . intval($lP)); 00684 t3lib_BEfunc::workspaceOL('pages_language_overlay', $lpRecord); 00685 $params = '&edit[pages_language_overlay][' . $lpRecord['uid'] . ']=edit&overrideVals[pages_language_overlay][sys_language_uid]=' . $lP; 00686 $lPLabel = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon(t3lib_iconWorks::getSpriteIconForRecord('pages_language_overlay', $lpRecord), $lpRecord['uid']) . 00687 $viewLink . 00688 ($GLOBALS['BE_USER']->check('tables_modify', 'pages_language_overlay') ? '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::editOnClick($params, $this->backPath)) . '" title="' . $GLOBALS['LANG']->getLL('edit', TRUE) . '">' . 00689 t3lib_iconWorks::getSpriteIcon('actions-document-open') . 00690 '</a>' : '') . 00691 htmlspecialchars(t3lib_div::fixed_lgd_cs($lpRecord['title'], 20)); 00692 } else { 00693 $lPLabel = $viewLink; 00694 } 00695 $sCont[$lP] = ' 00696 <td nowrap="nowrap">' . $lPLabel . '</td>'; 00697 } 00698 // Add headers: 00699 $out .= ' 00700 <tr class="bgColor5">' . implode($midSep, $cCont) . ' 00701 </tr>'; 00702 $out .= ' 00703 <tr class="bgColor5">' . implode($midSep, $sCont) . ' 00704 </tr>'; 00705 00706 // Traverse previously built content for the columns: 00707 foreach ($languageColumn as $cKey => $cCont) { 00708 $out .= ' 00709 <tr> 00710 <td valign="top">' . implode('</td>' . $midSep . ' 00711 <td valign="top">', $cCont) . '</td> 00712 </tr>'; 00713 00714 if ($this->defLangBinding) { 00715 // "defLangBinding" mode 00716 foreach ($defLanguageCount[$cKey] as $defUid) { 00717 $cCont = array(); 00718 foreach ($langListArr as $lP) { 00719 $cCont[] = $defLangBinding[$cKey][$lP][$defUid] . 00720 '<br/>' . $this->newLanguageButton($this->getNonTranslatedTTcontentUids(array($defUid), $id, $lP), $lP); 00721 } 00722 $out .= ' 00723 <tr> 00724 <td valign="top">' . implode('</td>' . $midSep . ' 00725 <td valign="top">', $cCont) . '</td> 00726 </tr>'; 00727 } 00728 00729 // Create spacer: 00730 $cCont = array(); 00731 foreach ($langListArr as $lP) { 00732 $cCont[] = ' '; 00733 } 00734 $out .= ' 00735 <tr> 00736 <td valign="top">' . implode('</td>' . $midSep . ' 00737 <td valign="top">', $cCont) . '</td> 00738 </tr>'; 00739 } 00740 } 00741 00742 // Finally, wrap it all in a table and add the language selector on top of it: 00743 $out = $languageSelector . ' 00744 <table border="0" cellpadding="0" cellspacing="0" width="480" class="typo3-page-langMode"> 00745 ' . $out . ' 00746 </table>'; 00747 00748 // CSH: 00749 $out .= t3lib_BEfunc::cshItem($this->descrTable, 'language_list', $GLOBALS['BACK_PATH']); 00750 } 00751 } else { // SINGLE column mode (columns shown beneath each other): 00752 #debug('single column'); 00753 if ($this->tt_contentConfig['sys_language_uid'] == 0 || !$this->defLangBinding) { 00754 00755 // Initialize: 00756 if ($this->defLangBinding && $this->tt_contentConfig['sys_language_uid'] == 0) { 00757 $showLanguage = ' AND sys_language_uid IN (0,-1)'; 00758 $lP = 0; 00759 } else { 00760 $showLanguage = ' AND sys_language_uid=' . $this->tt_contentConfig['sys_language_uid']; 00761 $lP = $this->tt_contentConfig['sys_language_uid']; 00762 } 00763 00764 $cList = explode(',', $this->tt_contentConfig['showSingleCol']); 00765 $content = array(); 00766 $out = ''; 00767 00768 // Expand the table to some preset dimensions: 00769 $out .= ' 00770 <tr> 00771 <td><img src="clear.gif" width="' . $lMarg . '" height="1" alt="" /></td> 00772 <td valign="top"><img src="clear.gif" width="150" height="1" alt="" /></td> 00773 <td><img src="clear.gif" width="10" height="1" alt="" /></td> 00774 <td valign="top"><img src="clear.gif" width="300" height="1" alt="" /></td> 00775 </tr>'; 00776 00777 // Traverse columns to display top-on-top 00778 foreach ($cList as $counter => $key) { 00779 00780 // Select content elements: 00781 $queryParts = $this->makeQueryArray('tt_content', $id, 'AND colPos=' . intval($key) . $showHidden . $showLanguage); 00782 $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts); 00783 $c = 0; 00784 $rowArr = $this->getResult($result); 00785 $rowOut = ''; 00786 00787 // 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: 00788 if ($this->doEdit && $this->option_showBigButtons && !intval($key) && !$GLOBALS['TYPO3_DB']->sql_num_rows($result)) { 00789 $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')) . "';"; 00790 $theNewButton = $GLOBALS['SOBE']->doc->t3Button($onClick, $GLOBALS['LANG']->getLL('newPageContent')); 00791 $theNewButton = '<img src="clear.gif" width="1" height="5" alt="" /><br />' . $theNewButton; 00792 } else { 00793 $theNewButton = ''; 00794 } 00795 00796 // Traverse any selected elements: 00797 foreach ($rowArr as $rKey => $row) { 00798 00799 if (is_array($row) && (int) $row['t3ver_state'] != 2) { 00800 00801 $c++; 00802 $editUidList .= $row['uid'] . ','; 00803 $isRTE = $RTE && $this->isRTEforField('tt_content', $row, 'bodytext'); 00804 00805 // Create row output: 00806 $rowOut .= ' 00807 <tr> 00808 <td></td> 00809 <td valign="top">' . $this->tt_content_drawHeader($row) . '</td> 00810 <td> </td> 00811 <td' . ($row['_ORIG_uid'] ? ' class="ver-element"' : '') . ' valign="top">' . $this->tt_content_drawItem($row, $isRTE) . '</td> 00812 </tr>'; 00813 00814 // If the element was not the last element, add a divider line: 00815 if ($c != $GLOBALS['TYPO3_DB']->sql_num_rows($result)) { 00816 $rowOut .= ' 00817 <tr> 00818 <td></td> 00819 <td colspan="3"><img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/stiblet_medium2.gif', 'width="468" height="1"') . ' class="c-divider" alt="" /></td> 00820 </tr>'; 00821 } 00822 } else { 00823 unset($rowArr[$rKey]); 00824 } 00825 } 00826 00827 // Add spacer between sections in the vertical list 00828 if ($counter) { 00829 $out .= ' 00830 <tr> 00831 <td></td> 00832 <td colspan="3"><br /><br /><br /><br /></td> 00833 </tr>'; 00834 } 00835 00836 // Add section header: 00837 $newP = $this->newContentElementOnClick($id, $key, $this->tt_contentConfig['sys_language_uid']); 00838 $out .= ' 00839 00840 <!-- Column header: --> 00841 <tr> 00842 <td></td> 00843 <td valign="top" colspan="3">' . 00844 $this->tt_content_drawColHeader(t3lib_BEfunc::getProcessedValue('tt_content', 'colPos', $key), ($this->doEdit && count($rowArr) ? '&edit[tt_content][' . $editUidList . ']=edit' . $pageTitleParamForAltDoc : ''), $newP) . 00845 $theNewButton . 00846 '<br /></td> 00847 </tr>'; 00848 00849 // Finally, add the content from the records in this column: 00850 $out .= $rowOut; 00851 } 00852 00853 // Finally, wrap all table rows in one, big table: 00854 $out = ' 00855 <table border="0" cellpadding="0" cellspacing="0" width="400" class="typo3-page-columnsMode"> 00856 ' . $out . ' 00857 </table>'; 00858 00859 // CSH: 00860 $out .= t3lib_BEfunc::cshItem($this->descrTable, 'columns_single', $GLOBALS['BACK_PATH']); 00861 } else { 00862 $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/>'; 00863 } 00864 } 00865 00866 00867 // Add the big buttons to page: 00868 if ($this->option_showBigButtons) { 00869 $bArray = array(); 00870 00871 if (!$GLOBALS['SOBE']->current_sys_language) { 00872 if ($this->ext_CALC_PERMS & 2) { 00873 $bArray[0] = $GLOBALS['SOBE']->doc->t3Button(t3lib_BEfunc::editOnClick('&edit[pages][' . $id . "]=edit", $this->backPath, ''), $GLOBALS['LANG']->getLL('editPageProperties')); 00874 } 00875 } else { 00876 if ($this->doEdit && $GLOBALS['BE_USER']->check('tables_modify', 'pages_language_overlay')) { 00877 list($languageOverlayRecord) = t3lib_BEfunc::getRecordsByField('pages_language_overlay', 'pid', $id, 'AND sys_language_uid=' . intval($GLOBALS['SOBE']->current_sys_language)); 00878 $bArray[0] = $GLOBALS['SOBE']->doc->t3Button(t3lib_BEfunc::editOnClick('&edit[pages_language_overlay][' . $languageOverlayRecord['uid'] . "]=edit", $this->backPath, ''), $GLOBALS['LANG']->getLL('editPageProperties_curLang')); 00879 } 00880 } 00881 if ($this->ext_CALC_PERMS & 4 || $this->ext_CALC_PERMS & 2) { 00882 $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')); 00883 } 00884 if ($this->ext_CALC_PERMS & 8) { 00885 $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')); 00886 } 00887 if ($this->doEdit && $this->ext_function == 1) { 00888 $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')); 00889 } 00890 $out = ' 00891 <table border="0" cellpadding="4" cellspacing="0" class="typo3-page-buttons"> 00892 <tr> 00893 <td>' . implode('</td> 00894 <td>', $bArray) . '</td> 00895 <td>' . t3lib_BEfunc::cshItem($this->descrTable, 'button_panel', $GLOBALS['BACK_PATH']) . '</td> 00896 </tr> 00897 </table> 00898 <br /> 00899 ' . $out; 00900 } 00901 00902 // Return content: 00903 return $out; 00904 } 00905 00906 /** 00907 * Renders Frontend Users from the fe_users table from page id 00908 * 00909 * @param integer Page id 00910 * @return string HTML for the listing 00911 */ 00912 function getTable_fe_users($id) { 00913 00914 $this->addElement_tdParams = array( 00915 'username' => ' nowrap="nowrap"', 00916 'usergroup' => ' nowrap="nowrap"', 00917 'name' => ' nowrap="nowrap"', 00918 'address' => ' nowrap="nowrap"', 00919 'zip' => ' nowrap="nowrap"', 00920 'city' => ' nowrap="nowrap"', 00921 'email' => ' nowrap="nowrap"', 00922 'telephone' => ' nowrap="nowrap"' 00923 ); 00924 $fList = 'username,usergroup,name,email,telephone,address,zip,city'; 00925 $out = $this->makeOrdinaryList('fe_users', $id, $fList, 1); 00926 $this->addElement_tdParams = array(); 00927 return $out; 00928 } 00929 00930 /** 00931 * Renders records from the sys_notes table from page id 00932 * NOTICE: Requires the sys_note extension to be loaded. 00933 * 00934 * @param integer Page id 00935 * @return string HTML for the listing 00936 */ 00937 function getTable_sys_note($id) { 00938 global $TCA; 00939 00940 if (!t3lib_extMgm::isLoaded('sys_note')) { 00941 return ''; 00942 } 00943 00944 // INIT: 00945 $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1); 00946 $tree = $this->getTreeObject($id, intval($GLOBALS['SOBE']->MOD_SETTINGS['pages_levels']), $perms_clause); 00947 00948 $this->itemLabels = array(); 00949 foreach ($TCA['sys_note']['columns'] as $name => $val) { 00950 $this->itemLabels[$name] = $GLOBALS['LANG']->sL($val['label']); 00951 } 00952 00953 // If page ids were found, select all sys_notes from the page ids: 00954 $out = ''; 00955 if (count($tree->ids)) { 00956 $delClause = t3lib_BEfunc::deleteClause('sys_note') . t3lib_BEfunc::versioningPlaceholderClause('sys_note'); 00957 $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); 00958 $dbCount = $GLOBALS['TYPO3_DB']->sql_num_rows($result); 00959 00960 // If sys_notes were found, render them: 00961 if ($dbCount) { 00962 $this->fieldArray = explode(',', '__cmds__,info,note'); 00963 00964 // header line is drawn 00965 $theData = Array(); 00966 $theData['__cmds__'] = ''; 00967 $theData['info'] = '<strong>Info</strong><br /><img src="clear.gif" height="1" width="220" alt="" />'; 00968 $theData['note'] = '<strong>Note</strong>'; 00969 $out .= $this->addelement(1, '', $theData, ' class="t3-row-header"', 20); 00970 00971 // half line is drawn 00972 $theData = Array(); 00973 $theData['info'] = $this->widthGif; 00974 $out .= $this->addelement(0, '', $theData); 00975 00976 $this->no_noWrap = 1; 00977 00978 // Items 00979 $this->eCounter = $this->firstElementNumber; 00980 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { 00981 t3lib_BEfunc::workspaceOL('sys_note', $row); 00982 00983 if (is_array($row)) { 00984 list($flag, $code) = $this->fwd_rwd_nav(); 00985 $out .= $code; 00986 if ($flag) { 00987 $color = Array( 00988 0 => '', // No category 00989 1 => ' class="bgColor4"', // Instructions 00990 2 => ' class="bgColor2"', // Template 00991 3 => '', // Notes 00992 4 => ' class="bgColor5"' // To-do 00993 ); 00994 $tdparams = $color[$row['category']]; 00995 $info = Array(); 00996 ; 00997 $theData = Array(); 00998 $this->getProcessedValue('sys_note', 'subject,category,author,email,personal', $row, $info); 00999 $cont = implode('<br />', $info); 01000 $head = '<strong>Page:</strong> ' . t3lib_BEfunc::getRecordPath($row['pid'], $perms_clause, 10) . '<br />'; 01001 01002 $theData['__cmds__'] = $this->getIcon('sys_note', $row); 01003 $theData['info'] = $head . $cont; 01004 $theData['note'] = nl2br($row['message']); 01005 01006 $out .= $this->addelement(1, '', $theData, $tdparams, 20); 01007 01008 01009 // half line is drawn 01010 $theData = Array(); 01011 $theData['info'] = $this->widthGif; 01012 $out .= $this->addelement(0, '', $theData); 01013 } 01014 $this->eCounter++; 01015 } 01016 } 01017 01018 // Wrap it all in a table: 01019 $out = ' 01020 <table border="0" cellpadding="1" cellspacing="2" width="480" class="typo3-page-sysnote"> 01021 ' . $out . ' 01022 </table>'; 01023 } 01024 } 01025 return $out; 01026 } 01027 01028 /** 01029 * Renders records from the tt_board table from page id 01030 * NOTICE: Requires the tt_board extension to be loaded. 01031 * 01032 * @param integer Page id 01033 * @return string HTML for the listing 01034 */ 01035 function getTable_tt_board($id) { 01036 01037 // Initialize: 01038 $delClause = t3lib_BEfunc::deleteClause('tt_board') . t3lib_BEfunc::versioningPlaceholderClause('tt_board'); 01039 $queryParts = $this->makeQueryArray('tt_board', $id, 'AND parent=0'); 01040 $this->setTotalItems($queryParts); 01041 $dbCount = 0; 01042 01043 // If items were selected, make query: 01044 if ($this->totalItems) { 01045 $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts); 01046 $dbCount = $GLOBALS['TYPO3_DB']->sql_num_rows($result); 01047 } 01048 01049 // If results came out of that, render the list: 01050 $out = ''; 01051 if ($dbCount) { 01052 01053 // Setting fields to display first: 01054 if ($GLOBALS['SOBE']->MOD_SETTINGS['tt_board'] == 'expand') { 01055 $this->fieldArray = explode(',', 'subject,author,date,age'); 01056 } else { 01057 $this->fieldArray = explode(',', 'subject,author,date,age,replys'); 01058 } 01059 01060 // Header line is drawn 01061 $theData = Array(); 01062 $theData['subject'] = '<strong>' . $GLOBALS['LANG']->getLL('tt_board_subject', 1) . '</strong>'; 01063 $theData['author'] = '<strong>' . $GLOBALS['LANG']->getLL('tt_board_author', 1) . '</strong>'; 01064 $theData['date'] = '<strong>' . $GLOBALS['LANG']->getLL('tt_board_date', 1) . '</strong>'; 01065 $theData['age'] = '<strong>' . $GLOBALS['LANG']->getLL('tt_board_age', 1) . '</strong>'; 01066 if ($GLOBALS['SOBE']->MOD_SETTINGS['tt_board'] != 'expand') { 01067 $theData['replys'] = '<strong>' . $GLOBALS['LANG']->getLL('tt_board_RE', 1) . '</strong>'; 01068 } 01069 $out .= $this->addelement(1, '', $theData, ' class="t3-row-header"', 20); 01070 01071 // half line is drawn 01072 $theData = Array(); 01073 $theData['subject'] = $this->widthGif; 01074 $out .= $this->addelement(0, '', $theData); 01075 01076 // Items 01077 $this->eCounter = $this->firstElementNumber; 01078 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { 01079 t3lib_BEfunc::workspaceOL('tt_board', $row); 01080 01081 if (is_array($row)) { 01082 list($flag, $code) = $this->fwd_rwd_nav(); 01083 $out .= $code; 01084 01085 if ($flag) { 01086 01087 $theRows = Array(); 01088 $theRows = $this->tt_board_getTree($theRows, $row['uid'], $id, $delClause, ''); 01089 $out .= $this->tt_board_drawItem('tt_board', $row, count($theRows)); 01090 01091 if ($GLOBALS['SOBE']->MOD_SETTINGS['tt_board'] == 'expand') { 01092 foreach ($theRows as $n => $sRow) { 01093 $out .= $this->tt_board_drawItem('tt_board', $sRow, 0); 01094 } 01095 } 01096 } 01097 $this->eCounter++; 01098 } 01099 } 01100 01101 // Wrap it all in a table: 01102 $out = ' 01103 <table border="0" cellpadding="0" cellspacing="0" class="typo3-page-listTTboard"> 01104 ' . $out . ' 01105 </table>'; 01106 } 01107 01108 return $out; 01109 } 01110 01111 /** 01112 * Renders address records from the tt_address table from page id 01113 * NOTICE: Requires the tt_address extension to be loaded. 01114 * 01115 * @param integer Page id 01116 * @return string HTML for the listing 01117 */ 01118 function getTable_tt_address($id) { 01119 01120 // Define fieldlist to show: 01121 switch ($GLOBALS['SOBE']->MOD_SETTINGS['tt_address']) { 01122 case 1: 01123 $icon = 0; 01124 $fList = 'name,address,zip,city,country'; 01125 break; 01126 case 2: 01127 $icon = 1; 01128 $fList = 'name;title;email;company,image'; 01129 break; 01130 default: 01131 $icon = 0; 01132 $fList = 'name,email,www,phone,fax,mobile'; 01133 break; 01134 } 01135 01136 // Create listing 01137 $out = $this->makeOrdinaryList('tt_address', $id, $fList, $icon); 01138 return $out; 01139 } 01140 01141 /** 01142 * Renders link records from the tt_links table from page id 01143 * NOTICE: Requires the tt_links extension to be loaded. 01144 * 01145 * @param integer Page id 01146 * @return string HTML for the listing 01147 */ 01148 function getTable_tt_links($id) { 01149 01150 // Define fieldlist to show: 01151 switch ($GLOBALS['SOBE']->MOD_SETTINGS['tt_links']) { 01152 case 1: 01153 $fList = 'title,hidden,url'; 01154 break; 01155 case 2: 01156 $fList = 'title;url,note2'; 01157 break; 01158 default: 01159 $fList = 'title;url,note'; 01160 break; 01161 } 01162 01163 $out = $this->makeOrdinaryList('tt_links', $id, $fList, 1); 01164 return $out; 01165 } 01166 01167 /** 01168 * Renders link records from the tt_links table from page id 01169 * NOTICE: Requires the tt_links extension to be loaded. 01170 * 01171 * @param integer Page id 01172 * @return string HTML for the listing 01173 */ 01174 function getTable_tt_guest($id) { 01175 01176 // Define fieldlist to show: 01177 $fList = 'title;cr_name;cr_email,note'; 01178 $out = $this->makeOrdinaryList('tt_guest', $id, $fList, 1); 01179 return $out; 01180 } 01181 01182 /** 01183 * Renders news items from the tt_news table from page id 01184 * NOTICE: Requires the tt_news extension to be loaded. 01185 * 01186 * @param integer Page id 01187 * @return string HTML for the listing 01188 */ 01189 function getTable_tt_news($id) { 01190 01191 $this->addElement_tdParams = array( 01192 'title' => ' nowrap="nowrap"', 01193 'datetime' => ' nowrap="nowrap"', 01194 'starttime' => ' nowrap="nowrap"', 01195 'author' => ' nowrap="nowrap"' 01196 ); 01197 $fList = 'title,author,author_email,datetime,starttime,category,image'; 01198 $out = $this->makeOrdinaryList('tt_news', $id, $fList, 1); 01199 $this->addElement_tdParams = array(); 01200 return $out; 01201 } 01202 01203 /** 01204 * Renders calender elements link records from the tt_calender table from page id 01205 * NOTICE: Requires the tt_calender extension to be loaded. 01206 * 01207 * @param integer Page id 01208 * @return string HTML for the listing 01209 */ 01210 function getTable_tt_calender($id) { 01211 01212 $type = $GLOBALS['SOBE']->MOD_SETTINGS['tt_calender']; 01213 switch ($type) { 01214 case 'date': 01215 // Date default 01216 $fList = 'date,title'; 01217 $icon = 0; 01218 $out = $this->makeOrdinaryList('tt_calender', $id, $fList, $icon, ' AND type=0'); 01219 return $out; 01220 break; 01221 case 'date_ext': 01222 // Date extended 01223 $fList = 'title;date;time;datetext;link,note'; 01224 $icon = 1; 01225 $out = $this->makeOrdinaryList('tt_calender', $id, $fList, $icon, ' AND type=0'); 01226 return $out; 01227 break; 01228 case 'todo': 01229 // Todo default 01230 $fList = 'title,complete,priority,date'; 01231 $icon = 0; 01232 $out = $this->makeOrdinaryList('tt_calender', $id, $fList, $icon, ' AND type=1'); 01233 return $out; 01234 break; 01235 case 'todo_ext': 01236 // Todo extended 01237 $fList = 'title;complete;priority;date;workgroup;responsible;category,note'; 01238 $icon = 1; 01239 $out = $this->makeOrdinaryList('tt_calender', $id, $fList, $icon, ' AND type=1'); 01240 return $out; 01241 break; 01242 default: 01243 // Overview, both todo and calender 01244 $fList = 'title,date,time,week'; 01245 $icon = 1; 01246 $out = $this->makeOrdinaryList('tt_calender', $id, $fList, $icon, ' AND type=0'); 01247 $out .= $this->makeOrdinaryList('tt_calender', $id, $fList, $icon, ' AND type=1'); 01248 return $out; 01249 break; 01250 } 01251 } 01252 01253 /** 01254 * Renders shopping elements from the tt_products table from page id 01255 * NOTICE: Requires the tt_products extension to be loaded. 01256 * 01257 * @param integer Page id 01258 * @return string HTML for the listing 01259 */ 01260 function getTable_tt_products($id) { 01261 01262 $type = $GLOBALS['SOBE']->MOD_SETTINGS['tt_products']; 01263 switch ($type) { 01264 case 'ext': 01265 $fList = 'title;itemnumber;price;price2;inStock;category,image,note'; 01266 $icon = 1; 01267 $out = $this->makeOrdinaryList('tt_products', $id, $fList, $icon); 01268 break; 01269 default: 01270 $fList = 'title,itemnumber,price,category,image'; 01271 $icon = 1; 01272 $out = $this->makeOrdinaryList('tt_products', $id, $fList, $icon); 01273 break; 01274 } 01275 01276 return $out; 01277 } 01278 01279 01280 /********************************** 01281 * 01282 * Generic listing of items 01283 * 01284 **********************************/ 01285 01286 /** 01287 * Creates a standard list of elements from a table. 01288 * 01289 * @param string Table name 01290 * @param integer Page id. 01291 * @param string Comma list of fields to display 01292 * @param boolean If true, icon is shown 01293 * @param string Additional WHERE-clauses. 01294 * @return string HTML table 01295 */ 01296 function makeOrdinaryList($table, $id, $fList, $icon = 0, $addWhere = '') { 01297 global $TCA; 01298 01299 // Initialize: 01300 $out = ''; 01301 $queryParts = $this->makeQueryArray($table, $id, $addWhere); 01302 $this->setTotalItems($queryParts); 01303 $dbCount = 0; 01304 01305 // Make query for records if there were any records found in the count operation: 01306 if ($this->totalItems) { 01307 $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts); 01308 $dbCount = $GLOBALS['TYPO3_DB']->sql_num_rows($result); 01309 } 01310 01311 // If records were found, render the list: 01312 $out = ''; 01313 if ($dbCount) { 01314 01315 // Set fields 01316 $this->fieldArray = t3lib_div::trimExplode(',', '__cmds__,' . $fList, TRUE); 01317 01318 // Header line is drawn 01319 $theData = array(); 01320 $theData = $this->headerFields($this->fieldArray, $table, $theData); 01321 if ($this->doEdit) { 01322 $theData['__cmds__'] = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::editOnClick('&edit[' . $table . '][' . $this->id . ']=new', $this->backPath)) . '" title="' . $GLOBALS['LANG']->getLL('new', TRUE) . '">' . 01323 t3lib_iconWorks::getSpriteIcon('actions-document-new') . 01324 '</a>'; 01325 } 01326 $out .= $this->addelement(1, '', $theData, ' class="c-headLine"', 15); 01327 01328 // Render Items 01329 $this->eCounter = $this->firstElementNumber; 01330 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { 01331 t3lib_BEfunc::workspaceOL($table, $row); 01332 01333 if (is_array($row)) { 01334 list($flag, $code) = $this->fwd_rwd_nav(); 01335 $out .= $code; 01336 if ($flag) { 01337 $params = '&edit[' . $table . '][' . $row['uid'] . ']=edit'; 01338 $Nrow = array(); 01339 01340 // Setting icons/edit links: 01341 if ($icon) { 01342 $Nrow['__cmds__'] = $this->getIcon($table, $row); 01343 } 01344 if ($this->doEdit) { 01345 $Nrow['__cmds__'] .= '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::editOnClick($params, $this->backPath)) . '" title="' . $GLOBALS['LANG']->getLL('edit', TRUE) . '">' . 01346 t3lib_iconWorks::getSpriteIcon('actions-document-open') . 01347 '</a>'; 01348 } else { 01349 $Nrow['__cmds__'] .= $this->noEditIcon(); 01350 } 01351 01352 // Get values: 01353 $Nrow = $this->dataFields($this->fieldArray, $table, $row, $Nrow); 01354 $tdparams = $this->eCounter % 2 ? ' class="bgColor4"' : ' class="bgColor4-20"'; 01355 $out .= $this->addelement(1, '', $Nrow, $tdparams); 01356 } 01357 $this->eCounter++; 01358 } 01359 } 01360 01361 // Wrap it all in a table: 01362 $out = ' 01363 01364 <!-- 01365 STANDARD LIST OF "' . $table . '" 01366 --> 01367 <table border="0" cellpadding="1" cellspacing="2" width="480" class="typo3-page-stdlist"> 01368 ' . $out . ' 01369 </table>'; 01370 } 01371 return $out; 01372 } 01373 01374 /** 01375 * Adds content to all data fields in $out array 01376 * 01377 * @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. 01378 * @param string Table name 01379 * @param array Record array 01380 * @param array Array to which the data is added 01381 * @return array $out array returned after processing. 01382 * @see makeOrdinaryList() 01383 */ 01384 function dataFields($fieldArr, $table, $row, $out = array()) { 01385 global $TCA; 01386 01387 // Check table validity: 01388 if ($TCA[$table]) { 01389 t3lib_div::loadTCA($table); 01390 $thumbsCol = $TCA[$table]['ctrl']['thumbnail']; 01391 01392 // Traverse fields: 01393 foreach ($fieldArr as $fieldName) { 01394 01395 if ($TCA[$table]['columns'][$fieldName]) { // Each field has its own cell (if configured in TCA) 01396 if ($fieldName == $thumbsCol) { // If the column is a thumbnail column: 01397 $out[$fieldName] = $this->thumbCode($row, $table, $fieldName); 01398 } else { // ... otherwise just render the output: 01399 $out[$fieldName] = nl2br(htmlspecialchars(trim(t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getProcessedValue($table, $fieldName, $row[$fieldName], 0, 0, 0, $row['uid']), 250)))); 01400 } 01401 } 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) 01402 $theFields = explode(';', $fieldName); 01403 01404 // Traverse fields, separated by ";" (displayed in a single cell). 01405 foreach ($theFields as $fName2) { 01406 if ($TCA[$table]['columns'][$fName2]) { 01407 $out[$fieldName] .= '<strong>' . $GLOBALS['LANG']->sL($TCA[$table]['columns'][$fName2]['label'], 1) . '</strong>' . 01408 ' ' . 01409 htmlspecialchars(t3lib_div::fixed_lgd_cs(t3lib_BEfunc::getProcessedValue($table, $fName2, $row[$fName2], 0, 0, 0, $row['uid']), 25)) . 01410 '<br />'; 01411 } 01412 } 01413 } 01414 // If no value, add a nbsp. 01415 if (!$out[$fieldName]) { 01416 $out[$fieldName] = ' '; 01417 } 01418 01419 // Wrap in dimmed-span tags if record is "disabled" 01420 if ($this->isDisabled($table, $row)) { 01421 $out[$fieldName] = $GLOBALS['TBE_TEMPLATE']->dfw($out[$fieldName]); 01422 } 01423 } 01424 } 01425 return $out; 01426 } 01427 01428 /** 01429 * Header fields made for the listing of records 01430 * 01431 * @param array Field names 01432 * @param string The table name 01433 * @param array Array to which the headers are added. 01434 * @return array $out returned after addition of the header fields. 01435 * @see makeOrdinaryList() 01436 */ 01437 function headerFields($fieldArr, $table, $out = array()) { 01438 global $TCA; 01439 01440 t3lib_div::loadTCA($table); 01441 01442 foreach ($fieldArr as $fieldName) { 01443 $ll = $GLOBALS['LANG']->sL($TCA[$table]['columns'][$fieldName]['label'], 1); 01444 $out[$fieldName] = '<strong>' . ($ll ? $ll : ' ') . '</strong>'; 01445 } 01446 return $out; 01447 } 01448 01449 01450 /********************************** 01451 * 01452 * Additional functions; Pages 01453 * 01454 **********************************/ 01455 01456 /** 01457 * Adds pages-rows to an array, selecting recursively in the page tree. 01458 * 01459 * @param array Array which will accumulate page rows 01460 * @param integer Pid to select from 01461 * @param string Query-where clause 01462 * @param string Prefixed icon code. 01463 * @param integer Depth (decreasing) 01464 * @return array $theRows, but with added rows. 01465 */ 01466 function pages_getTree($theRows, $pid, $qWhere, $treeIcons, $depth) { 01467 $depth--; 01468 if ($depth >= 0) { 01469 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'pages', 'pid=' . intval($pid) . $qWhere, '', 'sorting'); 01470 $c = 0; 01471 $rc = $GLOBALS['TYPO3_DB']->sql_num_rows($res); 01472 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 01473 t3lib_BEfunc::workspaceOL('pages', $row); 01474 if (is_array($row)) { 01475 $c++; 01476 $row['treeIcons'] = $treeIcons . '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/ol/join' . ($rc == $c ? 'bottom' : '') . '.gif', 'width="18" height="16"') . ' alt="" />'; 01477 $theRows[] = $row; 01478 01479 // Get the branch 01480 $spaceOutIcons = '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/ol/' . ($rc == $c ? 'blank.gif' : 'line.gif'), 'width="18" height="16"') . ' alt="" />'; 01481 $theRows = $this->pages_getTree($theRows, $row['uid'], $qWhere, $treeIcons . $spaceOutIcons, $row['php_tree_stop'] ? 0 : $depth); 01482 } 01483 } 01484 } else { 01485 $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('uid', 'pages', 'pid=' . intval($pid) . $qWhere); 01486 if ($count) { 01487 $this->plusPages[$pid] = $count; 01488 } 01489 } 01490 return $theRows; 01491 } 01492 01493 /** 01494 * Adds a list item for the pages-rendering 01495 * 01496 * @param array Record array 01497 * @param array Field list 01498 * @return string HTML for the item 01499 */ 01500 function pages_drawItem($row, $fieldArr) { 01501 global $TCA; 01502 01503 // Initialization 01504 $theIcon = $this->getIcon('pages', $row); 01505 01506 // Preparing and getting the data-array 01507 $theData = Array(); 01508 foreach ($fieldArr as $field) { 01509 switch ($field) { 01510 case 'title': 01511 $red = $this->plusPages[$row['uid']] ? '<font color="red"><strong>+ </strong></font>' : ''; 01512 $pTitle = htmlspecialchars(t3lib_BEfunc::getProcessedValue('pages', $field, $row[$field], 20)); 01513 if ($red) { 01514 $pTitle = '<a href="' . htmlspecialchars($this->script . '?id=' . $row['uid']) . '">' . $pTitle . '</a>'; 01515 } 01516 $theData[$field] = $row['treeIcons'] . $theIcon . $red . $pTitle . ' '; 01517 break; 01518 case 'php_tree_stop': 01519 case 'TSconfig': 01520 $theData[$field] = $row[$field] ? ' <strong>x</strong>' : ' '; 01521 break; 01522 case 'uid': 01523 if ($GLOBALS['BE_USER']->doesUserHaveAccess($row, 2)) { 01524 $params = '&edit[pages][' . $row['uid'] . ']=edit'; 01525 $eI = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::editOnClick($params, $this->backPath, '')) . '" title="' . $GLOBALS['LANG']->getLL('editThisPage', TRUE) . '">' . 01526 t3lib_iconWorks::getSpriteIcon('actions-document-open') . 01527 '</a>'; 01528 } else { 01529 $eI = ''; 01530 } 01531 $theData[$field] = '<span align="right">' . $row['uid'] . $eI . '</span>'; 01532 break; 01533 default: 01534 if (substr($field, 0, 6) == 'table_') { 01535 $f2 = substr($field, 6); 01536 if ($TCA[$f2]) { 01537 $c = $this->numberOfRecords($f2, $row['uid']); 01538 $theData[$field] = ' ' . ($c ? $c : ''); 01539 } 01540 } elseif (substr($field, 0, 5) == 'HITS_') { 01541 if (t3lib_extMgm::isLoaded('sys_stat')) { 01542 $fParts = explode(':', substr($field, 5)); 01543 switch ($fParts[0]) { 01544 case 'days': 01545 $timespan = mktime(0, 0, 0) + intval($fParts[1]) * 3600 * 24; 01546 // Page hits 01547 $number = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows( 01548 '*', 01549 'sys_stat', 01550 $this->stat_select_field . '=' . intval($row['uid']) . 01551 ' AND tstamp >=' . intval($timespan) . 01552 ' AND tstamp <' . intval($timespan + 3600 * 24) 01553 ); 01554 if ($number) { 01555 // Sessions 01556 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery( 01557 'count(*)', 01558 'sys_stat', 01559 $this->stat_select_field . '=' . intval($row['uid']) . ' 01560 AND tstamp>=' . intval($timespan) . ' 01561 AND tstamp<' . intval($timespan + 3600 * 24) . ' 01562 AND surecookie!=""', 01563 'surecookie' 01564 ); 01565 $scnumber = $GLOBALS['TYPO3_DB']->sql_num_rows($res); 01566 01567 $number .= '/' . $scnumber; 01568 } else { 01569 $number = ''; 01570 } 01571 break; 01572 } 01573 $theData[$field] = ' ' . $number; 01574 } else { 01575 $theData[$field] = ' '; 01576 } 01577 } else { 01578 $theData[$field] = ' ' . htmlspecialchars(t3lib_BEfunc::getProcessedValue('pages', $field, $row[$field])); 01579 } 01580 break; 01581 } 01582 } 01583 $this->addElement_tdParams['title'] = ($row['_CSSCLASS'] ? ' class="' . $row['_CSSCLASS'] . '"' : ''); 01584 return $this->addelement(1, '', $theData); 01585 } 01586 01587 01588 /********************************** 01589 * 01590 * Additional functions; Content Elements 01591 * 01592 **********************************/ 01593 01594 /** 01595 * Draw header for a content element column: 01596 * 01597 * @param string Column name 01598 * @param string Edit params (Syntax: &edit[...] for alt_doc.php) 01599 * @param string New element params (Syntax: &edit[...] for alt_doc.php) 01600 * @return string HTML table 01601 */ 01602 function tt_content_drawColHeader($colName, $editParams, $newParams) { 01603 01604 $icons = ''; 01605 // Create command links: 01606 if ($this->tt_contentConfig['showCommands']) { 01607 // New record: 01608 if ($newParams) { 01609 $icons .= '<a href="#" onclick="' . htmlspecialchars($newParams) . '" title="' . $GLOBALS['LANG']->getLL('newInColumn', TRUE) . '">' . 01610 t3lib_iconWorks::getSpriteIcon('actions-document-new') . 01611 '</a>'; 01612 } 01613 // Edit whole of column: 01614 if ($editParams) { 01615 $icons .= '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::editOnClick($editParams, $this->backPath)) . '" title="' . $GLOBALS['LANG']->getLL('editColumn', TRUE) . '">' . 01616 t3lib_iconWorks::getSpriteIcon('actions-document-open') . 01617 '</a>'; 01618 } 01619 } 01620 if (strlen($icons)) { 01621 $icons = '<div class="t3-page-colHeader-icons">' . $icons . '</div>'; 01622 } 01623 01624 // Create header row: 01625 $out = '<div class="t3-page-colHeader t3-row-header"> 01626 ' . $icons . ' 01627 <div class="t3-page-colHeader-label">' . htmlspecialchars($colName) . '</div> 01628 </div>'; 01629 return $out; 01630 } 01631 01632 /** 01633 * Draw the header for a single tt_content element 01634 * 01635 * @param array Record array 01636 * @param integer Amount of pixel space above the header. 01637 * @param boolean If set the buttons for creating new elements and moving up and down are not shown. 01638 * @param boolean If set, we are in language mode and flags will be shown for languages 01639 * @return string HTML table with the record header. 01640 */ 01641 function tt_content_drawHeader($row, $space = 0, $disableMoveAndNewButtons = FALSE, $langMode = FALSE) { 01642 global $TCA; 01643 01644 // Load full table description: 01645 t3lib_div::loadTCA('tt_content'); 01646 01647 // Get record locking status: 01648 if ($lockInfo = t3lib_BEfunc::isRecordLocked('tt_content', $row['uid'])) { 01649 $lockIcon = '<a href="#" onclick="' . htmlspecialchars('alert(' . $GLOBALS['LANG']->JScharCode($lockInfo['msg']) . ');return false;') . '" title="' . htmlspecialchars($lockInfo['msg']) . '">' . 01650 t3lib_iconWorks::getSpriteIcon('status-warning-in-use') . 01651 '</a>'; 01652 } else { 01653 $lockIcon = ''; 01654 } 01655 01656 // Call stats information hook 01657 $stat = ''; 01658 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'])) { 01659 $_params = array('tt_content', $row['uid'], &$row); 01660 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'] as $_funcRef) { 01661 $stat .= t3lib_div::callUserFunction($_funcRef, $_params, $this); 01662 } 01663 } 01664 01665 // Create line with type of content element and icon/lock-icon/title: 01666 $ceType = $this->getIcon('tt_content', $row) . ' ' . 01667 $lockIcon . ' ' . 01668 $stat . ' ' . 01669 ($langMode ? $this->languageFlag($row['sys_language_uid']) : '') . ' ' . 01670 ' <strong>' . htmlspecialchars($this->CType_labels[$row['CType']]) . '</strong>'; 01671 01672 // If show info is set...; 01673 if ($this->tt_contentConfig['showInfo']) { 01674 01675 // Get processed values: 01676 $info = Array(); 01677 $this->getProcessedValue('tt_content', 'hidden,starttime,endtime,fe_group,spaceBefore,spaceAfter', $row, $info); 01678 01679 // Render control panel for the element: 01680 if ($this->tt_contentConfig['showCommands'] && $this->doEdit) { 01681 01682 if (!$disableMoveAndNewButtons) { 01683 // New content element: 01684 if ($this->option_newWizard) { 01685 $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')) . "';"; 01686 } else { 01687 $params = '&edit[tt_content][' . (-$row['uid']) . ']=new'; 01688 $onClick = t3lib_BEfunc::editOnClick($params, $this->backPath); 01689 } 01690 $out .= '<a href="#" onclick="' . htmlspecialchars($onClick) . '" title="' . $GLOBALS['LANG']->getLL('newAfter', 1) . '">' . 01691 t3lib_iconWorks::getSpriteIcon('actions-document-new') . 01692 '</a>'; 01693 } 01694 01695 // Edit content element: 01696 $params = '&edit[tt_content][' . $this->tt_contentData['nextThree'][$row['uid']] . ']=edit'; 01697 $out .= '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::editOnClick($params, $this->backPath)) . '" title="' . 01698 htmlspecialchars($this->nextThree > 1 ? sprintf($GLOBALS['LANG']->getLL('nextThree'), $this->nextThree) : $GLOBALS['LANG']->getLL('edit')) . '">' . 01699 t3lib_iconWorks::getSpriteIcon('actions-document-open') . 01700 '</a>'; 01701 01702 // Hide element: 01703 $hiddenField = $TCA['tt_content']['ctrl']['enablecolumns']['disabled']; 01704 if ($hiddenField && $TCA['tt_content']['columns'][$hiddenField] && (!$TCA['tt_content']['columns'][$hiddenField]['exclude'] || $GLOBALS['BE_USER']->check('non_exclude_fields', 'tt_content:' . $hiddenField))) { 01705 if ($row[$hiddenField]) { 01706 $params = '&data[tt_content][' . ($row['_ORIG_uid'] ? $row['_ORIG_uid'] : $row['uid']) . '][' . $hiddenField . ']=0'; 01707 $out .= '<a href="' . htmlspecialchars($GLOBALS['SOBE']->doc->issueCommand($params)) . '" title="' . $GLOBALS['LANG']->getLL('unHide', TRUE) . '">' . 01708 t3lib_iconWorks::getSpriteIcon('actions-edit-unhide') . 01709 '</a>'; 01710 } else { 01711 $params = '&data[tt_content][' . ($row['_ORIG_uid'] ? $row['_ORIG_uid'] : $row['uid']) . '][' . $hiddenField . ']=1'; 01712 $out .= '<a href="' . htmlspecialchars($GLOBALS['SOBE']->doc->issueCommand($params)) . '" title="' . $GLOBALS['LANG']->getLL('hide', TRUE) . '">' . 01713 t3lib_iconWorks::getSpriteIcon('actions-edit-hide') . 01714 '</a>'; 01715 } 01716 } 01717 01718 // Delete 01719 $params = '&cmd[tt_content][' . $row['uid'] . '][delete]=1'; 01720 $confirm = $GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->getLL('deleteWarning') . 01721 t3lib_BEfunc::translationCount('tt_content', $row['uid'], ' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.translationsOfRecord'))); 01722 $out .= '<a href="' . htmlspecialchars($GLOBALS['SOBE']->doc->issueCommand($params)) . '" onclick="' . htmlspecialchars('return confirm(' . $confirm . ');') . '" title="' . $GLOBALS['LANG']->getLL('deleteItem', TRUE) . '">' . 01723 t3lib_iconWorks::getSpriteIcon('actions-edit-delete') . 01724 '</a>'; 01725 01726 if (!$disableMoveAndNewButtons) { 01727 $out .= '<span class="t3-page-ce-icons-move">'; 01728 // Move element up: 01729 if ($this->tt_contentData['prev'][$row['uid']]) { 01730 $params = '&cmd[tt_content][' . $row['uid'] . '][move]=' . $this->tt_contentData['prev'][$row['uid']]; 01731 $out .= '<a href="' . htmlspecialchars($GLOBALS['SOBE']->doc->issueCommand($params)) . '" title="' . $GLOBALS['LANG']->getLL('moveUp', TRUE) . '">' . 01732 t3lib_iconWorks::getSpriteIcon('actions-move-up') . 01733 '</a>'; 01734 } else { 01735 $out .= t3lib_iconWorks::getSpriteIcon('empty-empty'); 01736 } 01737 // Move element down: 01738 if ($this->tt_contentData['next'][$row['uid']]) { 01739 $params = '&cmd[tt_content][' . $row['uid'] . '][move]= ' . $this->tt_contentData['next'][$row['uid']]; 01740 $out .= '<a href="' . htmlspecialchars($GLOBALS['SOBE']->doc->issueCommand($params)) . '" title="' . $GLOBALS['LANG']->getLL('moveDown', TRUE) . '">' . 01741 t3lib_iconWorks::getSpriteIcon('actions-move-down') . 01742 '</a>'; 01743 } else { 01744 $out .= t3lib_iconWorks::getSpriteIcon('empty-empty'); 01745 } 01746 $out .= '</span>'; 01747 } 01748 } 01749 01750 // Display info from records fields: 01751 $infoOutput = ''; 01752 if (count($info)) { 01753 $infoOutput = '<div class="t3-page-ce-info"> 01754 ' . implode('<br />', $info) . ' 01755 </div>'; 01756 } 01757 } 01758 // Wrap the whole header 01759 // NOTE: end-tag for <div class="t3-page-ce-body"> is in getTable_tt_content() 01760 return '<h4 class="t3-page-ce-header"> 01761 <div class="t3-row-header"> 01762 ' . $out . ' 01763 </div> 01764 </h4> 01765 <div class="t3-page-ce-body"> 01766 <div class="t3-page-ce-type"> 01767 ' . $ceType . ' 01768 </div> 01769 ' . $infoOutput; 01770 } 01771 01772 /** 01773 * Draws the preview content for a content element 01774 * 01775 * @param string Content element 01776 * @param boolean Set if the RTE link can be created. 01777 * @return string HTML 01778 */ 01779 function tt_content_drawItem($row, $isRTE = FALSE) { 01780 global $TCA; 01781 01782 $out = ''; 01783 $outHeader = ''; 01784 01785 // Make header: 01786 if ($row['header']) { 01787 $infoArr = Array(); 01788 $this->getProcessedValue('tt_content', 'header_position,header_layout,header_link', $row, $infoArr); 01789 01790 // If header layout is set to 'hidden', display an accordant note: 01791 if ($row['header_layout'] == 100) { 01792 $hiddenHeaderNote = ' <em>[' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:labels.hidden', true) . ']</em>'; 01793 } 01794 $outHeader = ($row['date'] ? htmlspecialchars($this->itemLabels['date'] . ' ' . t3lib_BEfunc::date($row['date'])) . '<br />' : '') . 01795 '<strong>' . $this->linkEditContent($this->renderText($row['header']), $row) . $hiddenHeaderNote . '</strong><br />'; 01796 } 01797 01798 // Make content: 01799 $infoArr = array(); 01800 $drawItem = true; 01801 01802 // Hook: Render an own preview of a record 01803 $drawItemHooks =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem']; 01804 01805 if (is_array($drawItemHooks)) { 01806 foreach ($drawItemHooks as $hookClass) { 01807 $hookObject = t3lib_div::getUserObj($hookClass); 01808 01809 if (!($hookObject instanceof tx_cms_layout_tt_content_drawItemHook)) { 01810 throw new UnexpectedValueException('$hookObject must implement interface tx_cms_layout_tt_content_drawItemHook', 1218547409); 01811 } 01812 01813 $hookObject->preProcess($this, $drawItem, $outHeader, $out, $row); 01814 } 01815 } 01816 01817 // Draw preview of the item depending on its CType (if not disabled by previous hook): 01818 if ($drawItem) { 01819 switch ($row['CType']) { 01820 case 'header': 01821 if ($row['subheader']) { 01822 $out .= $this->linkEditContent($this->renderText($row['subheader']), $row) . '<br />'; 01823 } 01824 break; 01825 case 'text': 01826 case 'textpic': 01827 case 'image': 01828 if ($row['CType'] == 'text' || $row['CType'] == 'textpic') { 01829 if ($row['bodytext']) { 01830 $this->getProcessedValue('tt_content', 'text_align,text_face,text_size,text_color,text_properties', $row, $infoArr); 01831 $out .= $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />'; 01832 } 01833 } 01834 if ($row['CType'] == 'textpic' || $row['CType'] == 'image') { 01835 if ($row['image']) { 01836 $out .= $this->thumbCode($row, 'tt_content', 'image') . '<br />'; 01837 if ($row['imagecaption']) { 01838 $out .= $this->linkEditContent($this->renderText($row['imagecaption']), $row) . '<br />'; 01839 } 01840 } 01841 } 01842 break; 01843 case 'bullets': 01844 case 'table': 01845 case 'mailform': 01846 if ($row['bodytext']) { 01847 $out .= $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />'; 01848 } 01849 break; 01850 case 'uploads': 01851 if ($row['media']) { 01852 $out .= $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />'; 01853 } 01854 break; 01855 case 'multimedia': 01856 if ($row['multimedia']) { 01857 $out .= $this->renderText($row['multimedia']) . '<br />'; 01858 $out .= $this->renderText($row['parameters']) . '<br />'; 01859 } 01860 break; 01861 case 'splash': 01862 if ($row['bodytext']) { 01863 $out .= $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />'; 01864 } 01865 if ($row['image']) { 01866 $out .= $this->thumbCode($row, 'tt_content', 'image') . '<br />'; 01867 } 01868 break; 01869 case 'menu': 01870 if ($row['pages']) { 01871 $out .= $this->linkEditContent($row['pages'], $row) . '<br />'; 01872 } 01873 break; 01874 case 'shortcut': 01875 if ($row['records']) { 01876 $out .= $this->linkEditContent($row['shortcut'], $row) . '<br />'; 01877 } 01878 break; 01879 case 'list': 01880 $out .= $GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel('tt_content', 'list_type'), 1) . ' ' . 01881 $GLOBALS['LANG']->sL(t3lib_BEfunc::getLabelFromItemlist('tt_content', 'list_type', $row['list_type']), 1) . '<br />'; 01882 $hookArr = array(); 01883 $hookOut = ''; 01884 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info'][$row['list_type']])) { 01885 $hookArr = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info'][$row['list_type']]; 01886 } elseif (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info']['_DEFAULT'])) { 01887 $hookArr = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info']['_DEFAULT']; 01888 } 01889 if (count($hookArr) > 0) { 01890 $_params = array('pObj' => &$this, 'row' => $row, 'infoArr' => $infoArr); 01891 foreach ($hookArr as $_funcRef) { 01892 $hookOut .= t3lib_div::callUserFunction($_funcRef, $_params, $this); 01893 } 01894 } 01895 if (strcmp($hookOut, '')) { 01896 $out .= $hookOut; 01897 } else { 01898 $out .= $GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel('tt_content', 'select_key'), 1) . ' ' . $row['select_key'] . '<br />'; 01899 } 01900 01901 $out .= $GLOBALS['LANG']->sL(t3lib_BEfunc::getLabelFromItemlist('tt_content', 'pages', $row['pages']), 1) . '<br />'; 01902 break; 01903 case 'script': 01904 $out .= $GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel('tt_content', 'select_key'), 1) . ' ' . $row['select_key'] . '<br />'; 01905 $out .= '<br />' . $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />'; 01906 $out .= '<br />' . $this->linkEditContent($this->renderText($row['imagecaption']), $row) . '<br />'; 01907 break; 01908 default: 01909 if ($row['bodytext']) { 01910 $out .= $this->linkEditContent($this->renderText($row['bodytext']), $row) . '<br />'; 01911 } 01912 break; 01913 } 01914 } 01915 01916 // Wrap span-tags: 01917 $out = ' 01918 <span class="exampleContent">' . $out . '</span>'; 01919 // Add header: 01920 $out = $outHeader . $out; 01921 // Add RTE button: 01922 if ($isRTE) { 01923 $out .= $this->linkRTEbutton($row); 01924 } 01925 01926 // Return values: 01927 if ($this->isDisabled('tt_content', $row)) { 01928 return $GLOBALS['TBE_TEMPLATE']->dfw($out); 01929 } else { 01930 return $out; 01931 } 01932 } 01933 01934 /** 01935 * Filters out all tt_content uids which are already translated so only non-translated uids is left. 01936 * 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 (?) 01937 * 01938 * @param array Numeric array with uids of tt_content elements in the default language 01939 * @param integer Page pid 01940 * @param integer Sys language UID 01941 * @return array Modified $defLanguageCount 01942 */ 01943 function getNonTranslatedTTcontentUids($defLanguageCount, $id, $lP) { 01944 if ($lP && count($defLanguageCount)) { 01945 01946 // Select all translations here: 01947 $queryParts = $this->makeQueryArray('tt_content', $id, 'AND sys_language_uid=' . intval($lP) . ' AND l18n_parent IN (' . implode(',', $defLanguageCount) . ')'); 01948 $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts); 01949 01950 // Flip uids: 01951 $defLanguageCount = array_flip($defLanguageCount); 01952 01953 // Traverse any selected elements and unset original UID if any: 01954 $rowArr = $this->getResult($result); 01955 foreach ($rowArr as $row) { 01956 unset($defLanguageCount[$row['l18n_parent']]); 01957 } 01958 01959 // Flip again: 01960 $defLanguageCount = array_keys($defLanguageCount); 01961 } 01962 01963 return $defLanguageCount; 01964 } 01965 01966 /** 01967 * Creates button which is used to create copies of records.. 01968 * 01969 * @param array Numeric array with uids of tt_content elements in the default language 01970 * @param integer Sys language UID 01971 * @return string "Copy languages" button, if available. 01972 */ 01973 function newLanguageButton($defLanguageCount, $lP) { 01974 if ($this->doEdit && count($defLanguageCount) && $lP) { 01975 01976 $params = ''; 01977 foreach ($defLanguageCount as $uidVal) { 01978 $params .= '&cmd[tt_content][' . $uidVal . '][localize]=' . $lP; 01979 } 01980 01981 // Copy for language: 01982 $onClick = "window.location.href='" . $GLOBALS['SOBE']->doc->issueCommand($params) . "'; return false;"; 01983 $theNewButton = $GLOBALS['SOBE']->doc->t3Button($onClick, $GLOBALS['LANG']->getLL('newPageContent_copyForLang') . ' [' . count($defLanguageCount) . ']'); 01984 return $theNewButton; 01985 } 01986 } 01987 01988 /** 01989 * Creates onclick-attribute content for a new content element 01990 * 01991 * @param integer Page id where to create the element. 01992 * @param integer Preset: Column position value 01993 * @param integer Preset: Sys langauge value 01994 * @return string String for onclick attribute. 01995 * @see getTable_tt_content() 01996 */ 01997 function newContentElementOnClick($id, $colPos, $sys_language) { 01998 if ($this->option_newWizard) { 01999 $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')) . "';"; 02000 } else { 02001 $onClick = t3lib_BEfunc::editOnClick('&edit[tt_content][' . $id . ']=new&defVals[tt_content][colPos]=' . $colPos . '&defVals[tt_content][sys_language_uid]=' . $sys_language, $this->backPath); 02002 } 02003 return $onClick; 02004 } 02005 02006 /** 02007 * Will create a link on the input string and possible a big button after the string which links to editing in the RTE 02008 * Used for content element content displayed so the user can click the content / "Edit in Rich Text Editor" button 02009 * 02010 * @param string String to link. Must be prepared for HTML output. 02011 * @param array The row. 02012 * @return string If the whole thing was editable ($this->doEdit) $str is return with link around. Otherwise just $str. 02013 * @see getTable_tt_content() 02014 */ 02015 function linkEditContent($str, $row) { 02016 $addButton = ''; 02017 $onClick = ''; 02018 02019 if ($this->doEdit) { 02020 // Setting onclick action for content link: 02021 $onClick = t3lib_BEfunc::editOnClick('&edit[tt_content][' . $row['uid'] . ']=edit', $this->backPath); 02022 } 02023 // Return link 02024 return $onClick ? '<a href="#" onclick="' . htmlspecialchars($onClick) . '" title="' . $GLOBALS['LANG']->getLL('edit', 1) . '">' . $str . '</a>' . $addButton : $str; 02025 } 02026 02027 /** 02028 * Adds a button to edit the row in RTE wizard 02029 * 02030 * @param array The row of tt_content element 02031 * @return string Button to click if you want to edit in RTE wizard. 02032 */ 02033 function linkRTEbutton($row) { 02034 $params = array(); 02035 $params['table'] = 'tt_content'; 02036 $params['uid'] = $row['uid']; 02037 $params['pid'] = $row['pid']; 02038 $params['field'] = 'bodytext'; 02039 $params['returnUrl'] = t3lib_div::linkThisScript(); 02040 $RTEonClick = "window.location.href='" . $this->backPath . "wizard_rte.php?" . t3lib_div::implodeArrayForUrl('', array('P' => $params)) . "';return false;"; 02041 $addButton = $this->option_showBigButtons && $this->doEdit ? $GLOBALS['SOBE']->doc->t3Button($RTEonClick, $GLOBALS['LANG']->getLL('editInRTE')) : ''; 02042 02043 return $addButton; 02044 } 02045 02046 /** 02047 * Make selector box for creating new translation in a language 02048 * Displays only languages which are not yet present for the current page and 02049 * that are not disabled with page TS. 02050 * 02051 * @param integer Page id for which to create a new language (pages_language_overlay record) 02052 * @return string <select> HTML element (if there were items for the box anyways...) 02053 * @see getTable_tt_content() 02054 */ 02055 function languageSelector($id) { 02056 if ($GLOBALS['BE_USER']->check('tables_modify', 'pages_language_overlay')) { 02057 02058 // First, select all 02059 $res = $GLOBALS['SOBE']->exec_languageQuery(0); 02060 $langSelItems = array(); 02061 $langSelItems[0] = ' 02062 <option value="0"></option>'; 02063 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 02064 if ($GLOBALS['BE_USER']->checkLanguageAccess($row['uid'])) { 02065 $langSelItems[$row['uid']] = ' 02066 <option value="' . $row['uid'] . '">' . htmlspecialchars($row['title']) . '</option>'; 02067 } 02068 } 02069 02070 // Then, subtract the languages which are already on the page: 02071 $res = $GLOBALS['SOBE']->exec_languageQuery($id); 02072 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 02073 unset($langSelItems[$row['uid']]); 02074 } 02075 // Remove disallowed languages 02076 if (count($langSelItems) > 1 && 02077 !$GLOBALS['BE_USER']->user['admin'] && 02078 strlen($GLOBALS['BE_USER']->groupData['allowed_languages'])) { 02079 02080 $allowed_languages = array_flip(explode(',', $GLOBALS['BE_USER']->groupData['allowed_languages'])); 02081 02082 if (count($allowed_languages)) { 02083 foreach ($langSelItems as $key => $value) { 02084 if (!isset($allowed_languages[$key]) && $key != 0) { 02085 unset($langSelItems[$key]); 02086 } 02087 } 02088 } 02089 } 02090 // Remove disabled languages 02091 $modSharedTSconfig = t3lib_BEfunc::getModTSconfig($id, 'mod.SHARED'); 02092 $disableLanguages = isset($modSharedTSconfig['properties']['disableLanguages']) ? t3lib_div::trimExplode(',', $modSharedTSconfig['properties']['disableLanguages'], 1) : array(); 02093 if (count($langSelItems) && count($disableLanguages)) { 02094 foreach ($disableLanguages as $language) { 02095 if ($language != 0 && isset($langSelItems[$language])) { 02096 unset($langSelItems[$language]); 02097 } 02098 } 02099 } 02100 02101 // If any languages are left, make selector: 02102 if (count($langSelItems) > 1) { 02103 $onChangeContent = 'window.location.href=\'' . $this->backPath . 'alt_doc.php?&edit[pages_language_overlay][' . $id . ']=new&overrideVals[pages_language_overlay][doktype]=' . (int) $this->pageRecord['doktype'] . '&overrideVals[pages_language_overlay][sys_language_uid]=\'+this.options[this.selectedIndex].value+\'&returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')) . '\''; 02104 return $GLOBALS['LANG']->getLL('new_language', 1) . ': <select name="createNewLanguage" onchange="' . htmlspecialchars($onChangeContent) . '"> 02105 ' . implode('', $langSelItems) . ' 02106 </select><br /><br />'; 02107 } 02108 } 02109 } 02110 02111 /** 02112 * Traverse the result pointer given, adding each record to array and setting some internal values at the same time. 02113 * 02114 * @param pointer SQL result pointer for select query. 02115 * @param string Table name defaulting to tt_content 02116 * @return array The selected rows returned in this array. 02117 */ 02118 function getResult($result, $table = 'tt_content') { 02119 02120 // Initialize: 02121 $editUidList = ''; 02122 $recs = Array(); 02123 $nextTree = $this->nextThree; 02124 $c = 0; 02125 $output = Array(); 02126 02127 // Traverse the result: 02128 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { 02129 02130 t3lib_BEfunc::workspaceOL($table, $row, -99, TRUE); 02131 02132 if ($row) { 02133 // Add the row to the array: 02134 $output[] = $row; 02135 02136 // Set an internal register: 02137 $recs[$c] = $row['uid']; 02138 02139 // Create the list of the next three ids (for editing links...) 02140 for ($a = 0; $a < $nextTree; $a++) { 02141 if (isset($recs[$c - $a])) { 02142 $this->tt_contentData['nextThree'][$recs[$c - $a]] .= $row['uid'] . ','; 02143 } 02144 } 02145 02146 // Set next/previous ids: 02147 if (isset($recs[$c - 1])) { 02148 if (isset($recs[$c - 2])) { 02149 $this->tt_contentData['prev'][$row['uid']] = -$recs[$c - 2]; 02150 } else { 02151 $this->tt_contentData['prev'][$row['uid']] = $row['pid']; 02152 } 02153 $this->tt_contentData['next'][$recs[$c - 1]] = -$row['uid']; 02154 } 02155 $c++; 02156 } 02157 } 02158 02159 // Return selected records 02160 return $output; 02161 } 02162 02163 02164 /********************************** 02165 * 02166 * Additional functions; Message board items (tt_board) 02167 * 02168 **********************************/ 02169 02170 /** 02171 * Traverses recursively a branch in a message board. 02172 * 02173 * @param array Array of rows (build up recursively) 02174 * @param integer tt_content parent uid 02175 * @param integer Page id 02176 * @param string Additional query part. 02177 * @param string HTML content to prefix items with (to draw the proper tree-graphics) 02178 * @return array $theRows, but with added content 02179 */ 02180 function tt_board_getTree($theRows, $parent, $pid, $qWhere, $treeIcons) { 02181 02182 // Select tt_board elements: 02183 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_board', 'pid=' . intval($pid) . ' AND parent=' . intval($parent) . $qWhere, '', 'crdate'); 02184 02185 // Traverse the results: 02186 $c = 0; 02187 $rc = $GLOBALS['TYPO3_DB']->sql_num_rows($res); 02188 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 02189 $c++; 02190 $row['treeIcons'] = $treeIcons . '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/ol/' . ($rc == $c ? 'joinbottom.gif' : 'join.gif'), 'width="18" height="16"') . ' alt="" />'; 02191 $theRows[] = $row; 02192 02193 // Get the branch 02194 $theRows = $this->tt_board_getTree( 02195 $theRows, 02196 $row['uid'], 02197 $row['pid'], 02198 $qWhere, 02199 $treeIcons . '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/ol/' . ($rc == $c ? 'blank.gif' : 'line.gif'), 'width="18" height="16"') . ' alt="" />' 02200 ); 02201 } 02202 02203 // Return modified rows: 02204 return $theRows; 02205 } 02206 02207 /** 02208 * Adds an element to the tt_board listing: 02209 * 02210 * @param string Table name 02211 * @param array The record row 02212 * @param string Reply count, if applicable. 02213 * @return string Return content of element (table row) 02214 */ 02215 function tt_board_drawItem($table, $row, $re) { 02216 02217 // Building data-arary with content: 02218 $theData = Array(); 02219 $theData['subject'] = t3lib_div::fixed_lgd_cs(htmlspecialchars($row['subject']), 25) . ' '; 02220 $theData['author'] = t3lib_div::fixed_lgd_cs(htmlspecialchars($row['author']), 15) . ' '; 02221 $theData['date'] = t3lib_div::fixed_lgd_cs(t3lib_BEfunc::datetime($row['crdate']), 20) . ' '; 02222 $theData['age'] = t3lib_BEfunc::calcAge($GLOBALS['EXEC_TIME'] - $row['crdate'], $this->agePrefixes) . ' '; 02223 if ($re) { 02224 $theData['replys'] = $re; 02225 } 02226 02227 // Subject is built: 02228 $theData['subject'] = 02229 $row['treeIcons'] . 02230 $this->getIcon($table, $row) . 02231 $theData['subject']; 02232 02233 // Adding element: 02234 return $this->addelement(1, '', $theData); 02235 } 02236 02237 02238 /******************************** 02239 * 02240 * Various helper functions 02241 * 02242 ********************************/ 02243 02244 /** 02245 * Counts and returns the number of records on the page with $pid 02246 * 02247 * @param string Table name 02248 * @param integer Page id 02249 * @return integer Number of records. 02250 */ 02251 function numberOfRecords($table, $pid) { 02252 if ($GLOBALS['TCA'][$table]) { 02253 $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows( 02254 'uid', 02255 $table, 02256 'pid=' . intval($pid) . 02257 t3lib_BEfunc::deleteClause($table) . 02258 t3lib_BEfunc::versioningPlaceholderClause($table) 02259 ); 02260 } 02261 return intval($count); 02262 } 02263 02264 /** 02265 * Processing of larger amounts of text (usually from RTE/bodytext fields) with word wrapping etc. 02266 * 02267 * @param string Input string 02268 * @return string Output string 02269 */ 02270 function renderText($input) { 02271 $input = $this->strip_tags($input, true); 02272 $input = t3lib_div::fixed_lgd_cs($input, 1500); 02273 return nl2br(htmlspecialchars(trim($this->wordWrapper($input)))); 02274 } 02275 02276 /** 02277 * Creates the icon image tag for record from table and wraps it in a link which will trigger the click menu. 02278 * 02279 * @param string Table name 02280 * @param array Record array 02281 * @param string Record title (NOT USED) 02282 * @return string HTML for the icon 02283 */ 02284 function getIcon($table, $row) { 02285 02286 // Initialization 02287 $alttext = t3lib_BEfunc::getRecordIconAltText($row, $table); 02288 $iconImg = t3lib_iconWorks::getSpriteIconForRecord($table, $row, array('title' => $alttext)); 02289 $this->counter++; 02290 02291 // The icon with link 02292 $theIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconImg, $table, $row['uid']); 02293 02294 return $theIcon; 02295 } 02296 02297 /** 02298 * Creates processed values for all fieldnames in $fieldList based on values from $row array. 02299 * The result is 'returned' through $info which is passed as a reference 02300 * 02301 * @param string Table name 02302 * @param string Commalist of fields. 02303 * @param array Record from which to take values for processing. 02304 * @param array Array to which the processed values are added. 02305 * @return void 02306 */ 02307 function getProcessedValue($table, $fieldList, $row, &$info) { 02308 02309 // Splitting values from $fieldList: 02310 $fieldArr = explode(',', $fieldList); 02311 02312 // Traverse fields from $fieldList: 02313 foreach ($fieldArr as $field) { 02314 if ($row[$field]) { 02315 $info[] = htmlspecialchars($this->itemLabels[$field]) . ' ' . htmlspecialchars(t3lib_BEfunc::getProcessedValue($table, $field, $row[$field])); 02316 } 02317 } 02318 } 02319 02320 /** 02321 * Returns true, if the record given as parameters is NOT visible based on hidden/starttime/endtime (if available) 02322 * 02323 * @param string Tablename of table to test 02324 * @param array Record row. 02325 * @return boolean Returns true, if disabled. 02326 */ 02327 function isDisabled($table, $row) { 02328 global $TCA; 02329 if ( 02330 ($TCA[$table]['ctrl']['enablecolumns']['disabled'] && $row[$TCA[$table]['ctrl']['enablecolumns']['disabled']]) || 02331 ($TCA[$table]['ctrl']['enablecolumns']['starttime'] && $row[$TCA[$table]['ctrl']['enablecolumns']['starttime']] > $GLOBALS['EXEC_TIME']) || 02332 ($TCA[$table]['ctrl']['enablecolumns']['endtime'] && $row[$TCA[$table]['ctrl']['enablecolumns']['endtime']] && $row[$TCA[$table]['ctrl']['enablecolumns']['endtime']] < $GLOBALS['EXEC_TIME']) 02333 ) { 02334 return true; 02335 } 02336 } 02337 02338 /** 02339 * 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. 02340 * Works well on normal texts, little less well when HTML is involved (since much HTML will have long strings that will be broken). 02341 * 02342 * @param string Content to word-wrap. 02343 * @param integer Max number of chars in a word before it will be wrapped. 02344 * @param string Character to insert when wrapping. 02345 * @return string Processed output. 02346 */ 02347 function wordWrapper($content, $max = 50, $char = ' -') { 02348 $array = preg_split('/[ ' . LF . ']/', $content); 02349 foreach ($array as $val) { 02350 if (strlen($val) > $max) { 02351 $content = str_replace($val, substr(chunk_split($val, $max, $char), 0, -1), $content); 02352 } 02353 } 02354 return $content; 02355 } 02356 02357 /** 02358 * Returns icon for "no-edit" of a record. 02359 * 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... 02360 * 02361 * @param string Label key from LOCAL_LANG 02362 * @return string IMG tag for icon. 02363 */ 02364 function noEditIcon($label = 'noEditItems') { 02365 return t3lib_iconWorks::getSpriteIcon('status-edit-read-only', array('title' => $GLOBALS['LANG']->getLL($label, TRUE))); 02366 } 02367 02368 /** 02369 * 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. 02370 * 02371 * @return void 02372 */ 02373 function cleanTableNames() { 02374 global $TCA; 02375 02376 // Get all table names: 02377 $tableNames = array_flip(array_keys($TCA)); 02378 02379 // Unset common names: 02380 unset($tableNames['pages']); 02381 unset($tableNames['static_template']); 02382 unset($tableNames['sys_filemounts']); 02383 unset($tableNames['sys_action']); 02384 unset($tableNames['sys_workflows']); 02385 unset($tableNames['be_users']); 02386 unset($tableNames['be_groups']); 02387 02388 $this->allowedTableNames = array(); 02389 02390 // Traverse table names and set them in allowedTableNames array IF they can be read-accessed by the user. 02391 if (is_array($tableNames)) { 02392 foreach ($tableNames as $k => $v) { 02393 if ($GLOBALS['BE_USER']->check('tables_select', $k)) { 02394 $this->allowedTableNames['table_' . $k] = $k; 02395 } 02396 } 02397 } 02398 } 02399 02400 /** 02401 * Checking if the RTE is available/enabled for a certain table/field and if so, it returns true. 02402 * Used to determine if the RTE button should be displayed. 02403 * 02404 * @param string Table name 02405 * @param array Record row (needed, if there are RTE dependencies based on other fields in the record) 02406 * @param string Field name 02407 * @return boolean Returns true if the rich text editor would be enabled/available for the field name specified. 02408 */ 02409 function isRTEforField($table, $row, $field) { 02410 $specConf = $this->getSpecConfForField($table, $row, $field); 02411 $p = t3lib_BEfunc::getSpecConfParametersFromArray($specConf['rte_transform']['parameters']); 02412 if (isset($specConf['richtext']) && (!$p['flag'] || !$row[$p['flag']])) { 02413 t3lib_BEfunc::fixVersioningPid($table, $row); 02414 list($tscPID, $thePidValue) = t3lib_BEfunc::getTSCpid($table, $row['uid'], $row['pid']); 02415 if ($thePidValue >= 0) { // If the pid-value is not negative (that is, a pid could NOT be fetched) 02416 $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE', t3lib_BEfunc::getPagesTSconfig($tscPID)); 02417 $RTEtypeVal = t3lib_BEfunc::getTCAtypeValue($table, $row); 02418 $thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'], $table, $field, $RTEtypeVal); 02419 if (!$thisConfig['disabled']) { 02420 return TRUE; 02421 } 02422 } 02423 } 02424 02425 return FALSE; 02426 } 02427 02428 /** 02429 * Returns "special" configuration from the "types" configuration in TCA for the record given by tablename/fieldname. 02430 * Used by isRTEforField() in the process of finding whether a field has RTE enabled or not. 02431 * 02432 * @param string Table name 02433 * @param array Record array 02434 * @param string Field name 02435 * @return array Spec. conf (if available) 02436 * @access private 02437 * @see isRTEforField() 02438 */ 02439 function getSpecConfForField($table, $row, $field) { 02440 02441 // Get types-configuration for the record: 02442 $types_fieldConfig = t3lib_BEfunc::getTCAtypes($table, $row); 02443 02444 // Find the given field and return the spec key value if found: 02445 if (is_array($types_fieldConfig)) { 02446 foreach ($types_fieldConfig as $vconf) { 02447 if ($vconf['field'] == $field) { 02448 return $vconf['spec']; 02449 } 02450 } 02451 } 02452 } 02453 02454 02455 /***************************************** 02456 * 02457 * External renderings 02458 * 02459 *****************************************/ 02460 02461 /** 02462 * Creates an info-box for the current page (identified by input record). 02463 * 02464 * @param array Page record 02465 * @param boolean If set, there will be shown an edit icon, linking to editing of the page properties. 02466 * @return string HTML for the box. 02467 */ 02468 function getPageInfoBox($rec, $edit = 0) { 02469 global $LANG; 02470 02471 // If editing of the page properties is allowed: 02472 if ($edit) { 02473 $params = '&edit[pages][' . $rec['uid'] . ']=edit'; 02474 $editIcon = '<a href="#" onclick="' . htmlspecialchars(t3lib_BEfunc::editOnClick($params, $this->backPath)) . '" title="' . $GLOBALS['LANG']->getLL('edit', TRUE) . '">' . 02475 t3lib_iconWorks::getSpriteIcon('actions-document-open') . 02476 '</a>'; 02477 } else { 02478 $editIcon = $this->noEditIcon('noEditPage'); 02479 } 02480 02481 // Setting page icon, link, title: 02482 $outPutContent = t3lib_iconWorks::getSpriteIconForRecord('pages', $rec, array('title' => t3lib_BEfunc::titleAttribForPages($rec))) . 02483 $editIcon . 02484 ' ' . 02485 htmlspecialchars($rec['title']); 02486 02487 02488 // Init array where infomation is accumulated as label/value pairs. 02489 $lines = array(); 02490 02491 // Owner user/group: 02492 if ($this->pI_showUser) { 02493 // User: 02494 $users = t3lib_BEfunc::getUserNames('username,usergroup,usergroup_cached_list,uid,realName'); 02495 $groupArray = explode(',', $GLOBALS['BE_USER']->user['usergroup_cached_list']); 02496 $users = t3lib_BEfunc::blindUserNames($users, $groupArray); 02497 $lines[] = array($LANG->getLL('pI_crUser') . ':', htmlspecialchars($users[$rec['cruser_id']]['username']) . ' (' . $users[$rec['cruser_id']]['realName'] . ')'); 02498 } 02499 02500 // Created: 02501 $lines[] = array( 02502 $LANG->getLL('pI_crDate') . ':', 02503 t3lib_BEfunc::datetime($rec['crdate']) . ' (' . t3lib_BEfunc::calcAge($GLOBALS['EXEC_TIME'] - $rec['crdate'], $this->agePrefixes) . ')', 02504 ); 02505 02506 // Last change: 02507 $lines[] = array( 02508 $LANG->getLL('pI_lastChange') . ':', 02509 t3lib_BEfunc::datetime($rec['tstamp']) . ' (' . t3lib_BEfunc::calcAge($GLOBALS['EXEC_TIME'] - $rec['tstamp'], $this->agePrefixes) . ')', 02510 ); 02511 02512 // Last change of content: 02513 if ($rec['SYS_LASTCHANGED']) { 02514 $lines[] = array( 02515 $LANG->getLL('pI_lastChangeContent') . ':', 02516 t3lib_BEfunc::datetime($rec['SYS_LASTCHANGED']) . ' (' . t3lib_BEfunc::calcAge($GLOBALS['EXEC_TIME'] - $rec['SYS_LASTCHANGED'], $this->agePrefixes) . ')', 02517 ); 02518 } 02519 02520 // Spacer: 02521 $lines[] = ''; 02522 02523 // Display contents of certain page fields, if any value: 02524 $dfields = explode(',', 'alias,target,hidden,starttime,endtime,fe_group,no_cache,cache_timeout,newUntil,lastUpdated,subtitle,keywords,description,abstract,author,author_email'); 02525 foreach ($dfields as $fV) { 02526 if ($rec[$fV]) { 02527 $lines[] = array($GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel('pages', $fV)), t3lib_BEfunc::getProcessedValue('pages', $fV, $rec[$fV])); 02528 } 02529 } 02530 02531 // Page hits (depends on "sys_stat" extension) 02532 if ($this->pI_showStat && t3lib_extMgm::isLoaded('sys_stat')) { 02533 02534 // Counting total hits: 02535 $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', 'sys_stat', 'page_id=' . intval($rec['uid'])); 02536 if ($count) { 02537 02538 // Get min/max 02539 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('min(tstamp) AS min,max(tstamp) AS max', 'sys_stat', 'page_id=' . intval($rec['uid'])); 02540 $rrow2 = $GLOBALS['TYPO3_DB']->sql_fetch_row($res); 02541 02542 $lines[] = ''; 02543 $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) . ')'); 02544 $lines[] = array($LANG->getLL('pI_hitsTotal') . ':', $rrow2[0]); 02545 02546 02547 // Last 10 days 02548 $nextMidNight = mktime(0, 0, 0) + 1 * 3600 * 24; 02549 02550 $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'); 02551 $days = array(); 02552 while ($rrow = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) { 02553 $days[$rrow[1]] = $rrow[0]; 02554 } 02555 02556 $headerH = array(); 02557 $contentH = array(); 02558 for ($a = 9; $a >= 0; $a--) { 02559 $headerH[] = ' 02560 <td class="bgColor5" nowrap="nowrap"> ' . date('d', $nextMidNight - ($a + 1) * 24 * 3600) . ' </td>'; 02561 $contentH[] = ' 02562 <td align="center">' . ($days[$a] ? intval($days[$a]) : '-') . '</td>'; 02563 } 02564 02565 // Compile first hit-table (last 10 days) 02566 $hitTable = ' 02567 <table border="0" cellpadding="0" cellspacing="1" class="typo3-page-hits"> 02568 <tr>' . implode('', $headerH) . '</tr> 02569 <tr>' . implode('', $contentH) . '</tr> 02570 </table>'; 02571 $lines[] = array($LANG->getLL('pI_hits10days') . ':', $hitTable, 1); 02572 02573 02574 // Last 24 hours 02575 $nextHour = mktime(date('H'), 0, 0) + 3600; 02576 $hours = 16; 02577 02578 $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'); 02579 $days = array(); 02580 while ($rrow = $GLOBALS['TYPO3_DB']->sql_fetch_row($res)) { 02581 $days[$rrow[1]] = $rrow[0]; 02582 } 02583 02584 $headerH = array(); 02585 $contentH = array(); 02586 for ($a = ($hours - 1); $a >= 0; $a--) { 02587 $headerH[] = ' 02588 <td class="bgColor5" nowrap="nowrap"> ' . intval(date('H', $nextHour - ($a + 1) * 3600)) . ' </td>'; 02589 $contentH[] = ' 02590 <td align="center">' . ($days[$a] ? intval($days[$a]) : '-') . '</td>'; 02591 } 02592 02593 // Compile second hit-table (last 24 hours) 02594 $hitTable = ' 02595 <table border="0" cellpadding="0" cellspacing="1" class="typo3-page-stat"> 02596 <tr>' . implode('', $headerH) . '</tr> 02597 <tr>' . implode('', $contentH) . '</tr> 02598 </table>'; 02599 $lines[] = array($LANG->getLL('pI_hits24hours') . ':', $hitTable, 1); 02600 } 02601 } 02602 02603 02604 // Finally, wrap the elements in the $lines array in table cells/rows 02605 foreach ($lines as $fV) { 02606 if (is_array($fV)) { 02607 if (!$fV[2]) { 02608 $fV[1] = htmlspecialchars($fV[1]); 02609 } 02610 $out .= ' 02611 <tr> 02612 <td class="bgColor4" nowrap="nowrap"><strong>' . htmlspecialchars($fV[0]) . ' </strong></td> 02613 <td class="bgColor4">' . $fV[1] . '</td> 02614 </tr>'; 02615 } else { 02616 $out .= ' 02617 <tr> 02618 <td colspan="2"><img src="clear.gif" width="1" height="3" alt="" /></td> 02619 </tr>'; 02620 } 02621 } 02622 02623 // Wrap table tags around... 02624 $outPutContent .= ' 02625 02626 02627 02628 <!-- 02629 Page info box: 02630 --> 02631 <table border="0" cellpadding="0" cellspacing="1" id="typo3-page-info"> 02632 ' . $out . ' 02633 </table>'; 02634 02635 // ... and return it. 02636 return $outPutContent; 02637 } 02638 02639 /** 02640 * Creates a menu of the tables that can be listed by this function 02641 * Only tables which has records on the page will be included. 02642 * Notice: The function also fills in the internal variable $this->activeTables with icon/titles. 02643 * 02644 * @param integer Page id from which we are listing records (the function will look up if there are records on the page) 02645 * @return string HTML output. 02646 */ 02647 function getTableMenu($id) { 02648 global $TCA; 02649 02650 // Initialize: 02651 $this->activeTables = array(); 02652 $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! 02653 02654 // External tables: 02655 if (is_array($this->externalTables)) { 02656 $theTables = array_unique(array_merge($theTables, array_keys($this->externalTables))); 02657 } 02658 02659 // Traverse tables to check: 02660 foreach ($theTables as $tName) { 02661 02662 // Check access and whether the proper extensions are loaded: 02663 if ($GLOBALS['BE_USER']->check('tables_select', $tName) && (t3lib_extMgm::isLoaded($tName) || t3lib_div::inList('fe_users,tt_content', $tName) || isset($this->externalTables[$tName]))) { 02664 02665 // Make query to count records from page: 02666 $c = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows( 02667 'uid', 02668 $tName, 02669 'pid=' . intval($id) . 02670 t3lib_BEfunc::deleteClause($tName) . 02671 t3lib_BEfunc::versioningPlaceholderClause($tName) 02672 ); 02673 02674 // If records were found (or if "tt_content" is the table...): 02675 if ($c || t3lib_div::inList('tt_content', $tName)) { 02676 02677 // Add row to menu: 02678 $out .= ' 02679 <td><a href="#' . $tName . '"></a>' . 02680 t3lib_iconWorks::getSpriteIconForRecord($tName, Array(), array('title' => $GLOBALS['LANG']->sL($TCA[$tName]['ctrl']['title'], 1))) . 02681 '</td>'; 02682 02683 // ... and to the internal array, activeTables we also add table icon and title (for use elsewhere) 02684 $this->activeTables[$tName] = 02685 t3lib_iconWorks::getSpriteIconForRecord($tName, Array(), array('title' => $GLOBALS['LANG']->sL($TCA[$tName]['ctrl']['title'], 1) . ': ' . $c . ' ' . $GLOBALS['LANG']->getLL('records', 1))) . 02686 ' ' . 02687 $GLOBALS['LANG']->sL($TCA[$tName]['ctrl']['title'], 1); 02688 } 02689 } 02690 } 02691 02692 // Wrap cells in table tags: 02693 $out = ' 02694 02695 02696 02697 <!-- 02698 Menu of tables on the page (table menu) 02699 --> 02700 <table border="0" cellpadding="0" cellspacing="0" id="typo3-page-tblMenu"> 02701 <tr>' . $out . ' 02702 </tr> 02703 </table>'; 02704 02705 // Return the content: 02706 return $out; 02707 } 02708 02709 /** 02710 * Enhancement for the strip_tags function that provides the feature to fill in empty tags. 02711 * Example <link email@hostname.com></link> is accepted by TYPO3 but would not displayed in the Backend otherwise. 02712 * 02713 * @param string Input string 02714 * @param boolean If true, empty tags will be filled with the first attribute of the tag before. 02715 * @return string Input string with all HTML and PHP tags stripped 02716 */ 02717 function strip_tags($content, $fillEmptyContent = false) { 02718 if ($fillEmptyContent && strstr($content, '><')) { 02719 $content = preg_replace('/(<[^ >]* )([^ >]*)([^>]*>)(<\/[^>]*>)/', '$1$2$3$2$4', $content); 02720 } 02721 $content = preg_replace('/<br.?\/?>/', LF, $content); 02722 02723 return strip_tags($content); 02724 } 02725 } 02726 02727 02728 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/cms/layout/class.tx_cms_layout.php'])) { 02729 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/cms/layout/class.tx_cms_layout.php']); 02730 } 02731 02732 ?>
1.8.0