Fixed bug #17670: Remove deprecated functions scheduled for removal in 4.6
[Packages/TYPO3.CMS.git] / typo3 / template.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Contains class with layout/output function for TYPO3 Backend Scripts
29 *
30 * $Id$
31 * Revised for TYPO3 3.6 2/2003 by Kasper Skårhøj
32 * XHTML-trans compliant
33 *
34 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
35 */
36 /**
37 * [CLASS/FUNCTION INDEX of SCRIPT]
38 *
39 * 145: function fw($str)
40 *
41 *
42 * 169: class template
43 * 224: function template()
44 *
45 * SECTION: EVALUATION FUNCTIONS
46 * 298: function wrapClickMenuOnIcon($str,$table,$uid='',$listFr=1,$addParams='',$enDisItems='', $returnOnClick=FALSE)
47 * 315: function viewPageIcon($id,$backPath,$addParams='hspace="3"')
48 * 341: function issueCommand($params,$rUrl='')
49 * 356: function isCMlayers()
50 * 366: function thisBlur()
51 * 376: function helpStyle()
52 * 393: function getHeader($table,$row,$path,$noViewPageIcon=0,$tWrap=array('',''))
53 * 419: function getFileheader($title,$path,$iconfile)
54 * 434: function makeShortcutIcon($gvList,$setList,$modName,$motherModName="")
55 * 467: function makeShortcutUrl($gvList,$setList)
56 * 488: function formWidth($size=48,$textarea=0,$styleOverride='')
57 * 513: function formWidthText($size=48,$styleOverride='',$wrap='')
58 * 530: function redirectUrls($thisLocation='')
59 * 554: function formatTime($tstamp,$type)
60 * 571: function parseTime()
61 *
62 * SECTION: PAGE BUILDING FUNCTIONS.
63 * 604: function startPage($title)
64 * 686: function endPage()
65 * 720: function header($text)
66 * 741: function section($label,$text,$nostrtoupper=FALSE,$sH=FALSE,$type=0,$allowHTMLinHeader=FALSE)
67 * 765: function divider($dist)
68 * 781: function spacer($dist)
69 * 800: function sectionHeader($label,$sH=FALSE,$addAttrib='')
70 * 817: function sectionBegin()
71 * 838: function sectionEnd()
72 * 858: function middle()
73 * 867: function endPageJS()
74 * 884: function docBodyTagBegin()
75 * 894: function docStyle()
76 * 936: function insertStylesAndJS($content)
77 * 956: function initCharset()
78 * 968: function generator()
79 *
80 * SECTION: OTHER ELEMENTS
81 * 1001: function icons($type, $styleAttribValue='')
82 * 1030: function t3Button($onClick,$label)
83 * 1041: function dfw($string)
84 * 1051: function rfw($string)
85 * 1061: function wrapInCData($string)
86 * 1078: function wrapScriptTags($string, $linebreak=TRUE)
87 * 1117: function table($arr, $layout='')
88 * 1159: function menuTable($arr1,$arr2=array(), $arr3=array())
89 * 1192: function funcMenu($content,$menu)
90 * 1210: function clearCacheMenu($id,$addSaveOptions=0)
91 * 1246: function getContextMenuCode()
92 * 1251: function showClickmenu(table, uid, listFr, enDisItems, backPath, addParams)
93 * 1280: function showClickmenu_noajax(url)
94 * 1287: function showClickmenu_ajax(t3ajax)
95 * 1472: function getDragDropCode($table)
96 * 1483: function cancelDragEvent(event)
97 * 1496: function mouseMoveEvent (event)
98 * 1509: function dragElement(id,elementID)
99 * 1528: function dropElement(id)
100 * 1577: function getTabMenu($mainParams,$elementName,$currentValue,$menuItems,$script='',$addparams='')
101 * 1607: function getTabMenuRaw($menuItems)
102 * 1676: function getDynTabMenu($menuItems,$identString,$toggle=0,$foldout=FALSE,$newRowCharLimit=50,$noWrap=1,$fullWidth=FALSE,$defaultTabIndex=1)
103 * 1801: function getDynTabMenuJScode()
104 * 1892: function getVersionSelector($id,$noAction=FALSE)
105 *
106 *
107 * 2060: class bigDoc extends template
108 *
109 *
110 * 2069: class noDoc extends template
111 *
112 *
113 * 2078: class smallDoc extends template
114 *
115 *
116 * 2087: class mediumDoc extends template
117 *
118 * TOTAL FUNCTIONS: 57
119 * (This index is automatically created/updated by the extension "extdeveval")
120 *
121 */
122
123
124
125 if (!defined('TYPO3_MODE')) die("Can't include this file directly.");
126
127
128 /**
129 * TYPO3 Backend Template Class
130 *
131 * This class contains functions for starting and ending the HTML of backend modules
132 * It also contains methods for outputting sections of content.
133 * Further there are functions for making icons, links, setting form-field widths etc.
134 * Color scheme and stylesheet definitions are also available here.
135 * Finally this file includes the language class for TYPO3's backend.
136 *
137 * After this file $LANG and $TBE_TEMPLATE are global variables / instances of their respective classes.
138 * This file is typically included right after the init.php file,
139 * if language and layout is needed.
140 *
141 * Please refer to Inside TYPO3 for a discussion of how to use this API.
142 *
143 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
144 * @package TYPO3
145 * @subpackage core
146 */
147 class template {
148
149 // Vars you typically might want to/should set from outside after making instance of this class:
150 var $backPath = ''; // 'backPath' pointing back to the PATH_typo3
151 var $form=''; // This can be set to the HTML-code for a formtag. Useful when you need a form to span the whole page; Inserted exactly after the body-tag.
152 var $JScodeLibArray = array(); // Similar to $JScode (see below) but used as an associative array to prevent double inclusion of JS code. This is used to include certain external Javascript libraries before the inline JS code. <script>-Tags are not wrapped around automatically
153 var $JScode=''; // Additional header code (eg. a JavaScript section) could be accommulated in this var. It will be directly outputted in the header.
154 var $extJScode = ''; // Additional header code for ExtJS. It will be included in document header and inserted in a Ext.onReady(function()
155 var $JScodeArray = array(); // Similar to $JScode but for use as array with associative keys to prevent double inclusion of JS code. a <script> tag is automatically wrapped around.
156 var $postCode=''; // Additional 'page-end' code could be accommulated in this var. It will be outputted at the end of page before </body> and some other internal page-end code.
157 var $docType = ''; // Doc-type used in the header. Default is xhtml_trans. You can also set it to 'html_3', 'xhtml_strict' or 'xhtml_frames'.
158 var $moduleTemplate = ''; // HTML template with markers for module
159 protected $moduleTemplateFilename = ''; // the base file (not overlaid by TBE_STYLES) for the current module, useful for hooks when finding out which modules is rendered currently
160
161 // Other vars you can change, but less frequently used:
162 var $scriptID=''; // Script ID.
163 var $bodyTagId=''; // Id which can be set for the body tag. Default value is based on script ID
164 var $bodyTagAdditions=''; // You can add additional attributes to the body-tag through this variable.
165 var $inDocStyles=''; // Additional CSS styles which will be added to the <style> section in the header
166 var $inDocStylesArray=array(); // Like $inDocStyles but for use as array with associative keys to prevent double inclusion of css code
167 var $form_rowsToStylewidth = 9.58; // Multiplication factor for formWidth() input size (default is 48* this value).
168 var $form_largeComp = 1.33; // Compensation for large documents (used in class.t3lib_tceforms.php)
169 var $endJS=1; // If set, then a JavaScript section will be outputted in the bottom of page which will try and update the top.busy session expiry object.
170
171 // TYPO3 Colorscheme.
172 // If you want to change this, please do so through a skin using the global var $TBE_STYLES
173 var $bgColor = '#F7F3EF'; // Light background color
174 var $bgColor2 = '#9BA1A8'; // Steel-blue
175 var $bgColor3 = '#F6F2E6'; // dok.color
176 var $bgColor4 = '#D9D5C9'; // light tablerow background, brownish
177 var $bgColor5 = '#ABBBB4'; // light tablerow background, greenish
178 var $bgColor6 = '#E7DBA8'; // light tablerow background, yellowish, for section headers. Light.
179 var $hoverColor = '#254D7B';
180 var $styleSheetFile = ''; // Filename of stylesheet (relative to PATH_typo3)
181 var $styleSheetFile2 = ''; // Filename of stylesheet #2 - linked to right after the $this->styleSheetFile script (relative to PATH_typo3)
182 var $styleSheetFile_post = ''; // Filename of a post-stylesheet - included right after all inline styles.
183 var $backGroundImage = ''; // Background image of page (relative to PATH_typo3)
184 var $inDocStyles_TBEstyle = ''; // Inline css styling set from TBE_STYLES array
185
186 /**
187 * Whether to use the X-UA-Compatible meta tag
188 * @var boolean
189 */
190 protected $useCompatibilityTag = TRUE;
191
192 // Skinning
193 // stylesheets from core
194 protected $stylesheetsCore = array(
195 'structure' => 'stylesheets/structure/',
196 'visual' => 'stylesheets/visual/',
197 'generatedSprites' => '../typo3temp/sprites/',
198 );
199
200 // include these CSS directories from skins by default
201 protected $stylesheetsSkins = array(
202 'structure' => 'stylesheets/structure/',
203 'visual' => 'stylesheets/visual/',
204 );
205
206 /**
207 * JavaScript files loaded for every page in the Backend
208 * @var array
209 */
210 protected $jsFiles = array(
211 'modernizr' => 'contrib/modernizr/modernizr.min.js',
212 );
213
214 // DEV:
215 var $parseTimeFlag = 0; // Will output the parsetime of the scripts in milliseconds (for admin-users). Set this to false when releasing TYPO3. Only for dev.
216
217 // INTERNAL
218 var $charset = 'iso-8859-1'; // Default charset. see function initCharset()
219
220 var $sectionFlag=0; // Internal: Indicates if a <div>-output section is open
221 var $divClass = ''; // (Default) Class for wrapping <DIV>-tag of page. Is set in class extensions.
222
223 var $pageHeaderBlock = '';
224 var $endOfPageJsBlock = '';
225
226 var $hasDocheader = true;
227
228 /**
229 * @var t3lib_PageRenderer
230 */
231 protected $pageRenderer;
232 protected $pageHeaderFooterTemplateFile = ''; // alternative template file
233
234 protected $extDirectStateProvider = FALSE;
235
236 /**
237 * Whether flashmessages should be rendered or not
238 *
239 * @var $showFlashMessages
240 */
241 public $showFlashMessages = TRUE;
242
243 /**
244 * Constructor
245 * Imports relevant parts from global $TBE_STYLES (colorscheme)
246 *
247 * @return void
248 */
249 function template() {
250 global $TBE_STYLES;
251
252 // Initializes the page rendering object:
253 $this->getPageRenderer();
254
255 // Setting default scriptID:
256 if (($temp_M = (string) t3lib_div::_GET('M')) && $GLOBALS['TBE_MODULES']['_PATHS'][$temp_M]) {
257 $this->scriptID = preg_replace('/^.*\/(sysext|ext)\//', 'ext/', $GLOBALS['TBE_MODULES']['_PATHS'][$temp_M] . 'index.php');
258 } else {
259 $this->scriptID = preg_replace('/^.*\/(sysext|ext)\//', 'ext/', substr(PATH_thisScript, strlen(PATH_site)));
260 }
261 if (TYPO3_mainDir!='typo3/' && substr($this->scriptID,0,strlen(TYPO3_mainDir)) == TYPO3_mainDir) {
262 $this->scriptID = 'typo3/'.substr($this->scriptID,strlen(TYPO3_mainDir)); // This fixes if TYPO3_mainDir has been changed so the script ids are STILL "typo3/..."
263 }
264
265 $this->bodyTagId = preg_replace('/[^A-Za-z0-9-]/','-',$this->scriptID);
266
267 // Individual configuration per script? If so, make a recursive merge of the arrays:
268 if (is_array($TBE_STYLES['scriptIDindex'][$this->scriptID])) {
269 $ovr = $TBE_STYLES['scriptIDindex'][$this->scriptID]; // Make copy
270 $TBE_STYLES = t3lib_div::array_merge_recursive_overrule($TBE_STYLES,$ovr); // merge styles.
271 unset($TBE_STYLES['scriptIDindex'][$this->scriptID]); // Have to unset - otherwise the second instantiation will do it again!
272 }
273
274 // Color scheme:
275 if ($TBE_STYLES['mainColors']['bgColor']) $this->bgColor=$TBE_STYLES['mainColors']['bgColor'];
276 if ($TBE_STYLES['mainColors']['bgColor1']) $this->bgColor1=$TBE_STYLES['mainColors']['bgColor1'];
277 if ($TBE_STYLES['mainColors']['bgColor2']) $this->bgColor2=$TBE_STYLES['mainColors']['bgColor2'];
278 if ($TBE_STYLES['mainColors']['bgColor3']) $this->bgColor3=$TBE_STYLES['mainColors']['bgColor3'];
279 if ($TBE_STYLES['mainColors']['bgColor4']) $this->bgColor4=$TBE_STYLES['mainColors']['bgColor4'];
280 if ($TBE_STYLES['mainColors']['bgColor5']) $this->bgColor5=$TBE_STYLES['mainColors']['bgColor5'];
281 if ($TBE_STYLES['mainColors']['bgColor6']) $this->bgColor6=$TBE_STYLES['mainColors']['bgColor6'];
282 if ($TBE_STYLES['mainColors']['hoverColor']) $this->hoverColor=$TBE_STYLES['mainColors']['hoverColor'];
283
284 // Main Stylesheets:
285 if ($TBE_STYLES['stylesheet']) $this->styleSheetFile = $TBE_STYLES['stylesheet'];
286 if ($TBE_STYLES['stylesheet2']) $this->styleSheetFile2 = $TBE_STYLES['stylesheet2'];
287 if ($TBE_STYLES['styleSheetFile_post']) $this->styleSheetFile_post = $TBE_STYLES['styleSheetFile_post'];
288 if ($TBE_STYLES['inDocStyles_TBEstyle']) $this->inDocStyles_TBEstyle = $TBE_STYLES['inDocStyles_TBEstyle'];
289
290 // include all stylesheets
291 foreach ($this->getSkinStylesheetDirectories() as $stylesheetDirectory) {
292 $this->addStylesheetDirectory($stylesheetDirectory);
293 }
294
295 // Background image
296 if ($TBE_STYLES['background']) $this->backGroundImage = $TBE_STYLES['background'];
297 }
298
299
300 /**
301 * Gets instance of PageRenderer
302 *
303 * @return t3lib_PageRenderer
304 */
305 public function getPageRenderer() {
306 if (!isset($this->pageRenderer)) {
307 $this->pageRenderer = t3lib_div::makeInstance('t3lib_PageRenderer');
308 $this->pageRenderer->setTemplateFile(
309 TYPO3_mainDir . 'templates/template_page_backend.html'
310 );
311 $this->pageRenderer->setLanguage($GLOBALS['LANG']->lang);
312 $this->pageRenderer->enableConcatenateFiles();
313 $this->pageRenderer->enableCompressCss();
314 $this->pageRenderer->enableCompressJavascript();
315
316 // add all JavaScript files defined in $this->jsFiles to the PageRenderer
317 foreach ($this->jsFiles as $file) {
318 $this->pageRenderer->addJsFile($GLOBALS['BACK_PATH'] . $file);
319 }
320 }
321 if (intval($GLOBALS['TYPO3_CONF_VARS']['BE']['debug']) === 1) {
322 $this->pageRenderer->enableDebugMode();
323 }
324 return $this->pageRenderer;
325 }
326
327
328
329 /**
330 * Sets inclusion of StateProvider
331 *
332 * @return void
333 */
334 public function setExtDirectStateProvider() {
335 $this->extDirectStateProvider = TRUE;
336 }
337
338
339
340
341
342
343
344
345
346 /*****************************************
347 *
348 * EVALUATION FUNCTIONS
349 * Various centralized processing
350 *
351 *****************************************/
352
353 /**
354 * Makes click menu link (context sensitive menu)
355 * Returns $str (possibly an <|img> tag/icon) wrapped in a link which will activate the context sensitive menu for the record ($table/$uid) or file ($table = file)
356 * The link will load the top frame with the parameter "&item" which is the table,uid and listFr arguments imploded by "|": rawurlencode($table.'|'.$uid.'|'.$listFr)
357 *
358 * @param string String to be wrapped in link, typ. image tag.
359 * @param string Table name/File path. If the icon is for a database record, enter the tablename from $TCA. If a file then enter the absolute filepath
360 * @param integer If icon is for database record this is the UID for the record from $table
361 * @param boolean Tells the top frame script that the link is coming from a "list" frame which means a frame from within the backend content frame.
362 * @param string Additional GET parameters for the link to alt_clickmenu.php
363 * @param string Enable / Disable click menu items. Example: "+new,view" will display ONLY these two items (and any spacers in between), "new,view" will display all BUT these two items.
364 * @param boolean If set, will return only the onclick JavaScript, not the whole link.
365 * @return string The link-wrapped input string.
366 */
367 function wrapClickMenuOnIcon($str,$table,$uid='',$listFr=1,$addParams='',$enDisItems='', $returnOnClick=FALSE) {
368 $backPath = rawurlencode($this->backPath).'|'.t3lib_div::shortMD5($this->backPath.'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']);
369 $onClick = 'showClickmenu("'.$table.'","'.$uid.'","'.$listFr.'","'.str_replace('+','%2B',$enDisItems).'","'.str_replace('&','&amp;',addcslashes($backPath,'"')).'","'.str_replace('&','&amp;',addcslashes($addParams,'"')).'");return false;';
370 return $returnOnClick ? $onClick : '<a href="#" onclick="'.htmlspecialchars($onClick).'"'.($GLOBALS['TYPO3_CONF_VARS']['BE']['useOnContextMenuHandler'] ? ' oncontextmenu="'.htmlspecialchars($onClick).'"' : '').'>'.$str.'</a>';
371 }
372
373 /**
374 * Makes link to page $id in frontend (view page)
375 * Returns an magnifier-glass icon which links to the frontend index.php document for viewing the page with id $id
376 * $id must be a page-uid
377 * If the BE_USER has access to Web>List then a link to that module is shown as well (with return-url)
378 *
379 * @param integer The page id
380 * @param string The current "BACK_PATH" (the back relative to the typo3/ directory)
381 * @param string Additional parameters for the image tag(s)
382 * @return string HTML string with linked icon(s)
383 */
384 function viewPageIcon($id,$backPath,$addParams='hspace="3"') {
385 global $BE_USER;
386 // If access to Web>List for user, then link to that module.
387 $str = t3lib_BEfunc::getListViewLink(
388 array(
389 'id' => $id,
390 'returnUrl' => t3lib_div::getIndpEnv('REQUEST_URI'),
391 ),
392 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showList')
393 );
394
395 // Make link to view page
396 $str.= '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::viewOnClick($id,$backPath,t3lib_BEfunc::BEgetRootLine($id))).'">'.
397 '<img'.t3lib_iconWorks::skinImg($backPath,'gfx/zoom.gif','width="12" height="12"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showPage',1).'"'.($addParams?' '.trim($addParams):"").' hspace="3" alt="" />'.
398 '</a>';
399 return $str;
400 }
401
402 /**
403 * Returns a URL with a command to TYPO3 Core Engine (tce_db.php)
404 * See description of the API elsewhere.
405 *
406 * @param string $params is a set of GET params to send to tce_db.php. Example: "&cmd[tt_content][123][move]=456" or "&data[tt_content][123][hidden]=1&data[tt_content][123][title]=Hello%20World"
407 * @param string Redirect URL if any other that t3lib_div::getIndpEnv('REQUEST_URI') is wished
408 * @return string URL to tce_db.php + parameters (backpath is taken from $this->backPath)
409 * @see t3lib_BEfunc::editOnClick()
410 */
411 function issueCommand($params,$rUrl='') {
412 $rUrl = $rUrl ? $rUrl : t3lib_div::getIndpEnv('REQUEST_URI');
413 $commandUrl = $this->backPath.'tce_db.php?' .
414 $params .
415 '&redirect=' . ($rUrl==-1 ? "'+T3_THIS_LOCATION+'" : rawurlencode($rUrl)) .
416 '&vC='.rawurlencode($GLOBALS['BE_USER']->veriCode()) .
417 t3lib_BEfunc::getUrlToken('tceAction') .
418 '&prErr=1&uPT=1';
419
420 return $commandUrl;
421 }
422
423 /**
424 * Returns true if click-menu layers can be displayed for the current user/browser
425 * Use this to test if click-menus (context sensitive menus) can and should be displayed in the backend.
426 *
427 * @return boolean
428 */
429 function isCMlayers() {
430 return !$GLOBALS['BE_USER']->uc['disableCMlayers'] && $GLOBALS['CLIENT']['FORMSTYLE'] && !($GLOBALS['CLIENT']['SYSTEM']=='mac' && $GLOBALS['CLIENT']['BROWSER']=='Opera');
431 }
432
433 /**
434 * Returns 'this.blur();' if the client supports CSS styles
435 * Use this in links to remove the underlining after being clicked
436 *
437 * @return string
438 * @deprecated since TYPO3 4.5, will be removed in TYPO3 4.7
439 */
440 function thisBlur() {
441 t3lib_div::logDeprecatedFunction();
442 return ($GLOBALS['CLIENT']['FORMSTYLE']?'this.blur();':'');
443 }
444
445 /**
446 * Returns ' style='cursor:help;'' if the client supports CSS styles
447 * Use for <a>-links to help texts
448 *
449 * @return string
450 * @deprecated since TYPO3 4.5, will be removed in TYPO3 4.7
451 */
452 function helpStyle() {
453 t3lib_div::logDeprecatedFunction();
454 return $GLOBALS['CLIENT']['FORMSTYLE'] ? ' style="cursor:help;"':'';
455 }
456
457 /**
458 * Makes the header (icon+title) for a page (or other record). Used in most modules under Web>*
459 * $table and $row must be a tablename/record from that table
460 * $path will be shown as alt-text for the icon.
461 * The title will be truncated to 45 chars.
462 *
463 * @param string Table name
464 * @param array Record row
465 * @param string Alt text
466 * @param boolean Set $noViewPageIcon true if you don't want a magnifier-icon for viewing the page in the frontend
467 * @param array $tWrap is an array with indexes 0 and 1 each representing HTML-tags (start/end) which will wrap the title
468 * @return string HTML content
469 */
470 function getHeader($table,$row,$path,$noViewPageIcon=0,$tWrap=array('','')) {
471 global $TCA;
472 if (is_array($row) && $row['uid']) {
473 $iconImgTag=t3lib_iconWorks::getSpriteIconForRecord($table, $row , array('title' => htmlspecialchars($path)));
474 $title= strip_tags($row[$TCA[$table]['ctrl']['label']]);
475 $viewPage = $noViewPageIcon ? '' : $this->viewPageIcon($row['uid'],$this->backPath,'');
476 if ($table=='pages') $path.=' - '.t3lib_BEfunc::titleAttribForPages($row,'',0);
477 } else {
478 $iconImgTag = t3lib_iconWorks::getSpriteIcon('apps-pagetree-page-domain', array('title' => htmlspecialchars($path)));
479 $title=$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
480 }
481
482 return '<span class="typo3-moduleHeader">'.$this->wrapClickMenuOnIcon($iconImgTag,$table,$row['uid']).
483 $viewPage.
484 $tWrap[0].htmlspecialchars(t3lib_div::fixed_lgd_cs($title,45)).$tWrap[1].'</span>';
485 }
486
487 /**
488 * Like ->getHeader() but for files in the File>* main module/submodules
489 * Returns the file-icon with the path of the file set in the alt/title attribute. Shows the file-name after the icon.
490 *
491 * @param string Title string, expected to be the filepath
492 * @param string Alt text
493 * @param string The icon file (relative to TYPO3 dir)
494 * @return string HTML content
495 */
496 function getFileheader($title,$path,$iconfile) {
497 $fileInfo = t3lib_div::split_fileref($title);
498 $title = htmlspecialchars(t3lib_div::fixed_lgd_cs($fileInfo['path'],-35)).'<strong>'.htmlspecialchars($fileInfo['file']).'</strong>';
499 return '<span class="typo3-moduleHeader"><img'.t3lib_iconWorks::skinImg($this->backPath,$iconfile,'width="18" height="16"').' title="'.htmlspecialchars($path).'" alt="" />'.$title.'</span>';
500 }
501
502 /**
503 * Returns a linked shortcut-icon which will call the shortcut frame and set a shortcut there back to the calling page/module
504 *
505 * @param string Is the list of GET variables to store (if any)
506 * @param string Is the list of SET[] variables to store (if any) - SET[] variables a stored in $GLOBALS["SOBE"]->MOD_SETTINGS for backend modules
507 * @param string Module name string
508 * @param string Is used to enter the "parent module name" if the module is a submodule under eg. Web>* or File>*. You can also set this value to "1" in which case the currentLoadedModule is sent to the shortcut script (so - not a fixed value!) - that is used in file_edit.php and wizard_rte.php scripts where those scripts are really running as a part of another module.
509 * @return string HTML content
510 */
511 function makeShortcutIcon($gvList,$setList,$modName,$motherModName="") {
512 $backPath=$this->backPath;
513 $storeUrl=$this->makeShortcutUrl($gvList,$setList);
514 $pathInfo = parse_url(t3lib_div::getIndpEnv('REQUEST_URI'));
515
516 // Add the module identifier automatically if typo3/mod.php is used:
517 if (preg_match('/typo3\/mod\.php$/', $pathInfo['path']) && isset($GLOBALS['TBE_MODULES']['_PATHS'][$modName])) {
518 $storeUrl = '&M='.$modName.$storeUrl;
519 }
520
521 if (!strcmp($motherModName,'1')) {
522 $mMN="&motherModName='+top.currentModuleLoaded+'";
523 } elseif ($motherModName) {
524 $mMN='&motherModName='.rawurlencode($motherModName);
525 } else $mMN='';
526
527 $onClick = 'top.ShortcutManager.createShortcut('
528 .$GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.makeBookmark')).', '
529 .'\''.$backPath.'\', '
530 .'\''.rawurlencode($modName).'\', '
531 .'\''.rawurlencode($pathInfo['path']."?".$storeUrl).$mMN.'\''
532 .');return false;';
533
534 $sIcon = '<a href="#" onclick="' . htmlspecialchars($onClick).'" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.makeBookmark', TRUE) . '">'
535 . t3lib_iconworks::getSpriteIcon('actions-system-shortcut-new') . '</a>';
536 return $sIcon;
537 }
538
539 /**
540 * MAKE url for storing
541 * Internal func
542 *
543 * @param string Is the list of GET variables to store (if any)
544 * @param string Is the list of SET[] variables to store (if any) - SET[] variables a stored in $GLOBALS["SOBE"]->MOD_SETTINGS for backend modules
545 * @return string
546 * @access private
547 * @see makeShortcutIcon()
548 */
549 function makeShortcutUrl($gvList,$setList) {
550 $GET = t3lib_div::_GET();
551 $storeArray = array_merge(
552 t3lib_div::compileSelectedGetVarsFromArray($gvList,$GET),
553 array('SET'=>t3lib_div::compileSelectedGetVarsFromArray($setList, (array)$GLOBALS['SOBE']->MOD_SETTINGS))
554 );
555 $storeUrl = t3lib_div::implodeArrayForUrl('',$storeArray);
556 return $storeUrl;
557 }
558
559 /**
560 * Returns <input> attributes to set the width of an text-type input field.
561 * For client browsers with no CSS support the cols/size attribute is returned.
562 * For CSS compliant browsers (recommended) a ' style="width: ...px;"' is returned.
563 *
564 * @param integer A relative number which multiplied with approx. 10 will lead to the width in pixels
565 * @param boolean A flag you can set for textareas - DEPRECATED, use ->formWidthText() for textareas!!!
566 * @param string A string which will be returned as attribute-value for style="" instead of the calculated width (if CSS is enabled)
567 * @return string Tag attributes for an <input> tag (regarding width)
568 * @see formWidthText()
569 */
570 function formWidth($size=48,$textarea=0,$styleOverride='') {
571 $wAttrib = $textarea?'cols':'size';
572 if (!$GLOBALS['CLIENT']['FORMSTYLE']) { // If not setting the width by style-attribute
573 $size = $size;
574 $retVal = ' '.$wAttrib.'="'.$size.'"';
575 } else { // Setting width by style-attribute. 'cols' MUST be avoided with NN6+
576 $pixels = ceil($size*$this->form_rowsToStylewidth);
577 $retVal = $styleOverride ? ' style="'.$styleOverride.'"' : ' style="width:'.$pixels.'px;"';
578 }
579 return $retVal;
580 }
581
582 /**
583 * This function is dedicated to textareas, which has the wrapping on/off option to observe.
584 * EXAMPLE:
585 * <textarea rows="10" wrap="off" '.$GLOBALS["TBE_TEMPLATE"]->formWidthText(48,"","off").'>
586 * or
587 * <textarea rows="10" wrap="virtual" '.$GLOBALS["TBE_TEMPLATE"]->formWidthText(48,"","virtual").'>
588 *
589 * @param integer A relative number which multiplied with approx. 10 will lead to the width in pixels
590 * @param string A string which will be returned as attribute-value for style="" instead of the calculated width (if CSS is enabled)
591 * @param string Pass on the wrap-attribute value you use in your <textarea>! This will be used to make sure that some browsers will detect wrapping alright.
592 * @return string Tag attributes for an <input> tag (regarding width)
593 * @see formWidth()
594 */
595 function formWidthText($size=48,$styleOverride='',$wrap='') {
596 $wTags = $this->formWidth($size,1,$styleOverride);
597 // Netscape 6+/Mozilla seems to have this ODD problem where there WILL ALWAYS be wrapping with the cols-attribute set and NEVER without the col-attribute...
598 if (strtolower(trim($wrap))!='off' && $GLOBALS['CLIENT']['BROWSER']=='net' && $GLOBALS['CLIENT']['VERSION']>=5) {
599 $wTags.=' cols="'.$size.'"';
600 }
601 return $wTags;
602 }
603
604 /**
605 * Returns JavaScript variables setting the returnUrl and thisScript location for use by JavaScript on the page.
606 * Used in fx. db_list.php (Web>List)
607 *
608 * @param string URL to "this location" / current script
609 * @return string
610 * @see typo3/db_list.php
611 */
612 function redirectUrls($thisLocation='') {
613 $thisLocation = $thisLocation?$thisLocation:t3lib_div::linkThisScript(
614 array(
615 'CB'=>'',
616 'SET'=>'',
617 'cmd' => '',
618 'popViewId'=>''
619 ));
620
621 $out ="
622 var T3_RETURN_URL = '".str_replace('%20','',rawurlencode(t3lib_div::sanitizeLocalUrl(t3lib_div::_GP('returnUrl'))))."';
623 var T3_THIS_LOCATION = '".str_replace('%20','',rawurlencode($thisLocation))."';
624 ";
625 return $out;
626 }
627
628 /**
629 * Returns a formatted string of $tstamp
630 * Uses $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'] and $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] to format date and time
631 *
632 * @param integer UNIX timestamp, seconds since 1970
633 * @param integer How much data to show: $type = 1: hhmm, $type = 10: ddmmmyy
634 * @return string Formatted timestamp
635 */
636 function formatTime($tstamp,$type) {
637 $dateStr = '';
638 switch($type) {
639 case 1: $dateStr = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'],$tstamp);
640 break;
641 case 10: $dateStr = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'],$tstamp);
642 break;
643 }
644 return $dateStr;
645 }
646
647 /**
648 * Returns script parsetime IF ->parseTimeFlag is set and user is "admin"
649 * Automatically outputted in page end
650 *
651 * @return string
652 */
653 function parseTime() {
654 if ($this->parseTimeFlag && $GLOBALS['BE_USER']->isAdmin()) {
655 return '<p>(ParseTime: '.(t3lib_div::milliseconds()-$GLOBALS['PARSETIME_START']).' ms</p>
656 <p>REQUEST_URI-length: '.strlen(t3lib_div::getIndpEnv('REQUEST_URI')).')</p>';
657 }
658 }
659
660 /**
661 * Defines whether to use the X-UA-Compatible meta tag.
662 *
663 * @param boolean $useCompatibilityTag Whether to use the tag
664 * @return void
665 */
666 public function useCompatibilityTag($useCompatibilityTag = TRUE) {
667 $this->useCompatibilityTag = (bool) $useCompatibilityTag;
668 }
669
670
671
672
673
674
675
676
677
678
679
680
681 /*****************************************
682 *
683 * PAGE BUILDING FUNCTIONS.
684 * Use this to build the HTML of your backend modules
685 *
686 *****************************************/
687
688 /**
689 * Returns page start
690 * This includes the proper header with charset, title, meta tag and beginning body-tag.
691 *
692 * @param string HTML Page title for the header
693 * @param boolean flag for including CSH
694 * @return string Returns the whole header section of a HTML-document based on settings in internal variables (like styles, javascript code, charset, generator and docType)
695 * @see endPage()
696 */
697 function startPage($title, $includeCsh = TRUE) {
698 // hook pre start page
699 if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preStartPageHook'])) {
700 $preStartPageHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preStartPageHook'];
701 if (is_array($preStartPageHook)) {
702 $hookParameters = array(
703 'title' => &$title,
704 );
705 foreach ($preStartPageHook as $hookFunction) {
706 t3lib_div::callUserFunction($hookFunction, $hookParameters, $this);
707 }
708 }
709 }
710
711 $this->pageRenderer->backPath = $this->backPath;
712
713 // alternative template for Header and Footer
714 if ($this->pageHeaderFooterTemplateFile) {
715 $file = t3lib_div::getFileAbsFileName($this->pageHeaderFooterTemplateFile, TRUE);
716 if ($file) {
717 $this->pageRenderer->setTemplateFile($file);
718 }
719 }
720 // For debugging: If this outputs "QuirksMode"/"BackCompat" (IE) the browser runs in quirks-mode. Otherwise the value is "CSS1Compat"
721 # $this->JScodeArray[]='alert(document.compatMode);';
722
723 // Send HTTP header for selected charset. Added by Robert Lemke 23.10.2003
724 $this->initCharset();
725 header ('Content-Type:text/html;charset='.$this->charset);
726
727 // Standard HTML tag
728 $htmlTag = '<html xmlns="http://www.w3.org/1999/xhtml">';
729
730 switch($this->docType) {
731 case 'html_3':
732 $headerStart = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">';
733 $htmlTag = '<html>';
734 // disable rendering of XHTML tags
735 $this->getPageRenderer()->setRenderXhtml(FALSE);
736 break;
737 case 'xhtml_strict':
738 $headerStart = '<!DOCTYPE html
739 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
740 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
741 break;
742 case 'xhtml_frames':
743 $headerStart = '<!DOCTYPE html
744 PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
745 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">';
746 break;
747 case 'xhtml_trans':
748 $headerStart = '<!DOCTYPE html
749 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
750 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
751 // The fallthrough is intended as HTML5, as this is the default for the BE since TYPO3 4.5
752 case 'html5':
753 default:
754 $headerStart = '<!DOCTYPE html>' . LF;
755 $htmlTag = '<html>';
756 // disable rendering of XHTML tags
757 $this->getPageRenderer()->setRenderXhtml(FALSE);
758 break;
759 }
760
761 $this->pageRenderer->setHtmlTag($htmlTag);
762
763 // This loads the tabulator-in-textarea feature. It automatically modifies
764 // every textarea which is found.
765 if (!$GLOBALS['BE_USER']->uc['disableTabInTextarea']) {
766 $this->loadJavascriptLib('tab.js');
767 }
768
769 // include the JS for the Context Sensitive Help
770 if ($includeCsh) {
771 $this->loadCshJavascript();
772 }
773
774 // Get the browser info
775 $browserInfo = t3lib_utility_Client::getBrowserInfo(t3lib_div::getIndpEnv('HTTP_USER_AGENT'));
776
777 // Set the XML prologue
778 $xmlPrologue = '<?xml version="1.0" encoding="' . $this->charset . '"?>';
779
780 // Set the XML stylesheet
781 $xmlStylesheet = '<?xml-stylesheet href="#internalStyle" type="text/css"?>';
782
783 // Add the XML prologue for XHTML doctypes
784 if (strpos($this->doctype, 'xhtml') !== FALSE) {
785 // Put the XML prologue before or after the doctype declaration according to browser
786 if ($browserInfo['browser'] === 'msie' && $browserInfo['version'] < 7) {
787 $headerStart = $headerStart . LF . $xmlPrologue;
788 } else {
789 $headerStart = $xmlPrologue . LF . $headerStart;
790 }
791
792 // Add the xml stylesheet according to doctype
793 if ($this->docType !== 'xhtml_frames') {
794 $headerStart = $headerStart . LF . $xmlStylesheet;
795 }
796 }
797
798 $this->pageRenderer->setXmlPrologAndDocType($headerStart);
799 $this->pageRenderer->setHeadTag('<head>' . LF. '<!-- TYPO3 Script ID: '.htmlspecialchars($this->scriptID).' -->');
800 $this->pageRenderer->setCharSet($this->charset);
801 $this->pageRenderer->addMetaTag($this->generator());
802 if ($this->useCompatibilityTag) {
803 $this->pageRenderer->addMetaTag($this->xUaCompatible());
804 }
805 $this->pageRenderer->setTitle($title);
806
807 // add docstyles
808 $this->docStyle();
809
810 if ($this->extDirectStateProvider) {
811 $this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/ExtDirect.StateProvider.js');
812 }
813
814 // add jsCode for overriding the console with a debug panel connection
815 $this->pageRenderer->addJsInlineCode(
816 'consoleOverrideWithDebugPanel',
817 'if (typeof top.Ext === "object") {
818 top.Ext.onReady(function() {
819 if (typeof console === "undefined") {
820 if (top && top.TYPO3 && top.TYPO3.Backend && top.TYPO3.Backend.DebugConsole) {
821 console = top.TYPO3.Backend.DebugConsole;
822 } else {
823 console = {
824 log: Ext.log,
825 info: Ext.log,
826 warn: Ext.log,
827 error: Ext.log
828 };
829 }
830 }
831 });
832 }
833 ');
834
835 $this->pageRenderer->addHeaderData($this->JScode);
836
837 foreach ($this->JScodeArray as $name => $code) {
838 $this->pageRenderer->addJsInlineCode($name, $code);
839 }
840
841 if (count($this->JScodeLibArray)) {
842 foreach($this->JScodeLibArray as $library) {
843 $this->pageRenderer->addHeaderData($library);
844 }
845 }
846
847 if ($this->extJScode) {
848 $this->pageRenderer->addExtOnReadyCode($this->extJScode);
849 }
850
851 // hook for additional headerData
852 if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preHeaderRenderHook'])) {
853 $preHeaderRenderHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preHeaderRenderHook'];
854 if (is_array($preHeaderRenderHook)) {
855 $hookParameters = array(
856 'pageRenderer' => &$this->pageRenderer,
857 );
858 foreach ($preHeaderRenderHook as $hookFunction) {
859 t3lib_div::callUserFunction($hookFunction, $hookParameters, $this);
860 }
861 }
862 }
863
864 // Construct page header.
865 $str = $this->pageRenderer->render(t3lib_PageRenderer::PART_HEADER);
866
867 $this->JScodeLibArray = array();
868 $this->JScode = $this->extJScode = '';
869 $this->JScodeArray = array();
870
871 $this->endOfPageJsBlock = $this->pageRenderer->render(t3lib_PageRenderer::PART_FOOTER);
872
873 if ($this->docType=='xhtml_frames') {
874 return $str;
875 } else
876 $str.=$this->docBodyTagBegin().
877 ($this->divClass?'
878
879 <!-- Wrapping DIV-section for whole page BEGIN -->
880 <div class="' . $this->divClass . '">
881 ' : '' ) . trim($this->form);
882 return $str;
883 }
884
885 /**
886 * Returns page end; This includes finishing form, div, body and html tags.
887 *
888 * @return string The HTML end of a page
889 * @see startPage()
890 */
891 function endPage() {
892 $str = $this->sectionEnd().
893 $this->postCode.
894 $this->endPageJS().
895 $this->wrapScriptTags(t3lib_BEfunc::getUpdateSignalCode()).
896 $this->parseTime().
897 ($this->form?'
898 </form>':'');
899 // if something is in buffer like debug, put it to end of page
900 if (ob_get_contents()) {
901 $str .= ob_get_clean();
902 header('Content-Encoding: None');
903 }
904
905 if ($this->docType !== 'xhtml_frames') {
906
907 $str .= ($this->divClass?'
908
909 <!-- Wrapping DIV-section for whole page END -->
910 </div>':'') . $this->endOfPageJsBlock ;
911 t3lib_formprotection_Factory::get()->persistTokens();
912 }
913
914
915 // Logging: Can't find better place to put it:
916 if (TYPO3_DLOG) t3lib_div::devLog('END of BACKEND session', 'template', 0, array('_FLUSH' => true));
917
918 return $str;
919 }
920
921 /**
922 * Shortcut for render the complete page of a module
923 *
924 * @param $title page title
925 * @param $content page content
926 * @param bool $includeCsh flag for including csh code
927 * @return string complete page
928 */
929 public function render($title, $content, $includeCsh = TRUE) {
930 $pageContent = $this->startPage($title, $includeCsh);
931 $pageContent .= $content;
932 $pageContent .= $this->endPage();
933
934 return $this->insertStylesAndJS($pageContent);
935 }
936
937 /**
938 * Returns the header-bar in the top of most backend modules
939 * Closes section if open.
940 *
941 * @param string The text string for the header
942 * @return string HTML content
943 */
944 function header($text) {
945 $str='
946
947 <!-- MAIN Header in page top -->
948 <h2>'.htmlspecialchars($text).'</h2>
949 ';
950 return $this->sectionEnd().$str;
951 }
952
953 /**
954 * Begins an output section and sets header and content
955 *
956 * @param string The header
957 * @param string The HTML-content
958 * @param boolean A flag that will prevent the header from being converted to uppercase
959 * @param boolean Defines the type of header (if set, "<h3>" rather than the default "h4")
960 * @param integer The number of an icon to show with the header (see the icon-function). -1,1,2,3
961 * @param boolean If set, HTML tags are allowed in $label (otherwise this value is by default htmlspecialchars()'ed)
962 * @return string HTML content
963 * @see icons(), sectionHeader()
964 */
965 function section($label,$text,$nostrtoupper=FALSE,$sH=FALSE,$type=0,$allowHTMLinHeader=FALSE) {
966 $str='';
967
968 // Setting header
969 if ($label) {
970 if (!$allowHTMLinHeader) $label = htmlspecialchars($label);
971 $str.=$this->sectionHeader($this->icons($type).$label, $sH, $nostrtoupper ? '' : ' class="uppercase"');
972 }
973 // Setting content
974 $str.='
975
976 <!-- Section content -->
977 '.$text;
978
979 return $this->sectionBegin().$str;
980 }
981
982 /**
983 * Inserts a divider image
984 * Ends a section (if open) before inserting the image
985 *
986 * @param integer The margin-top/-bottom of the <hr> ruler.
987 * @return string HTML content
988 */
989 function divider($dist) {
990 $dist = intval($dist);
991 $str='
992
993 <!-- DIVIDER -->
994 <hr style="margin-top: '.$dist.'px; margin-bottom: '.$dist.'px;" />
995 ';
996 return $this->sectionEnd().$str;
997 }
998
999 /**
1000 * Returns a blank <div>-section with a height
1001 *
1002 * @param integer Padding-top for the div-section (should be margin-top but konqueror (3.1) doesn't like it :-(
1003 * @return string HTML content
1004 */
1005 function spacer($dist) {
1006 if ($dist>0) {
1007 return '
1008
1009 <!-- Spacer element -->
1010 <div style="padding-top: '.intval($dist).'px;"></div>
1011 ';
1012 }
1013 }
1014
1015 /**
1016 * Make a section header.
1017 * Begins a section if not already open.
1018 *
1019 * @param string The label between the <h3> or <h4> tags. (Allows HTML)
1020 * @param boolean If set, <h3> is used, otherwise <h4>
1021 * @param string Additional attributes to h-tag, eg. ' class=""'
1022 * @return string HTML content
1023 */
1024 function sectionHeader($label, $sH=FALSE, $addAttrib='') {
1025 $tag = ($sH ? 'h3' : 'h4');
1026 if ($addAttrib && substr($addAttrib, 0, 1) !== ' ') {
1027 $addAttrib = ' ' . $addAttrib;
1028 }
1029 $str='
1030
1031 <!-- Section header -->
1032 <' . $tag . $addAttrib . '>' . $label . '</' . $tag . '>
1033 ';
1034 return $this->sectionBegin() . $str;
1035 }
1036
1037 /**
1038 * Begins an output section.
1039 * Returns the <div>-begin tag AND sets the ->sectionFlag true (if the ->sectionFlag is not already set!)
1040 * You can call this function even if a section is already begun since the function will only return something if the sectionFlag is not already set!
1041 *
1042 * @return string HTML content
1043 */
1044 function sectionBegin() {
1045 if (!$this->sectionFlag) {
1046 $this->sectionFlag=1;
1047 $str='
1048
1049 <!-- ***********************
1050 Begin output section.
1051 *********************** -->
1052 <div>
1053 ';
1054 return $str;
1055 } else return '';
1056 }
1057
1058 /**
1059 * Ends and output section
1060 * Returns the </div>-end tag AND clears the ->sectionFlag (but does so only IF the sectionFlag is set - that is a section is 'open')
1061 * See sectionBegin() also.
1062 *
1063 * @return string HTML content
1064 */
1065 function sectionEnd() {
1066 if ($this->sectionFlag) {
1067 $this->sectionFlag=0;
1068 return '
1069 </div>
1070 <!-- *********************
1071 End output section.
1072 ********************* -->
1073 ';
1074 } else return '';
1075 }
1076
1077 /**
1078 * If a form-tag is defined in ->form then and end-tag for that <form> element is outputted
1079 * Further a JavaScript section is outputted which will update the top.busy session-expiry object (unless $this->endJS is set to false)
1080 *
1081 * @return string HTML content (<script> tag section)
1082 */
1083 function endPageJS() {
1084 return ($this->endJS?'
1085 <script type="text/javascript">
1086 /*<![CDATA[*/
1087 if (top.busy && top.busy.loginRefreshed) {
1088 top.busy.loginRefreshed();
1089 }
1090 /*]]>*/
1091 </script>':'');
1092 }
1093
1094 /**
1095 * Creates the bodyTag.
1096 * You can add to the bodyTag by $this->bodyTagAdditions
1097 *
1098 * @return string HTML body tag
1099 */
1100 function docBodyTagBegin() {
1101 $bodyContent = 'body onclick="if (top.menuReset) top.menuReset();" '.trim($this->bodyTagAdditions.($this->bodyTagId ? ' id="'.$this->bodyTagId.'"' : ''));
1102 return '<'.trim($bodyContent).'>';
1103 }
1104
1105 /**
1106 * Outputting document style
1107 *
1108 * @return string HTML style section/link tags
1109 */
1110 function docStyle() {
1111
1112 // Request background image:
1113 if ($this->backGroundImage) {
1114 $this->inDocStylesArray[]=' BODY { background-image: url('.$this->backPath.$this->backGroundImage.'); }';
1115 }
1116
1117 // Add inDoc styles variables as well:
1118 $this->inDocStylesArray[] = $this->inDocStyles;
1119 $this->inDocStylesArray[] = $this->inDocStyles_TBEstyle;
1120
1121 // Implode it all:
1122 $inDocStyles = implode(LF, $this->inDocStylesArray);
1123
1124 if ($this->styleSheetFile) {
1125 $this->pageRenderer->addCssFile($this->backPath . $this->styleSheetFile);
1126 }
1127 if ($this->styleSheetFile2) {
1128 $this->pageRenderer->addCssFile($this->backPath . $this->styleSheetFile2);
1129 }
1130
1131 $this->pageRenderer->addCssInlineBlock('inDocStyles', $inDocStyles . LF . '/*###POSTCSSMARKER###*/');
1132 if ($this->styleSheetFile_post) {
1133 $this->pageRenderer->addCssFile($this->backPath . $this->styleSheetFile_post);
1134 }
1135
1136 }
1137
1138 /**
1139 * Insert additional style sheet link
1140 *
1141 * @param string $key: some key identifying the style sheet
1142 * @param string $href: uri to the style sheet file
1143 * @param string $title: value for the title attribute of the link element
1144 * @return string $relation: value for the rel attribute of the link element
1145 * @return void
1146 */
1147 function addStyleSheet($key, $href, $title='', $relation='stylesheet') {
1148 if (strpos($href, '://') !== FALSE || substr($href, 0, 1) === '/') {
1149 $file = $href;
1150 } else {
1151 $file = $this->backPath . $href;
1152 }
1153 $this->pageRenderer->addCssFile($file, $relation, 'screen', $title);
1154 }
1155
1156 /**
1157 * Add all *.css files of the directory $path to the stylesheets
1158 *
1159 * @param string directory to add
1160 * @return void
1161 */
1162 function addStyleSheetDirectory($path) {
1163 // calculation needed, when TYPO3 source is used via a symlink
1164 // absolute path to the stylesheets
1165 $filePath = dirname(t3lib_div::getIndpEnv('SCRIPT_FILENAME')) . '/' . $GLOBALS['BACK_PATH'] . $path;
1166 // clean the path
1167 $resolvedPath = t3lib_div::resolveBackPath($filePath);
1168 // read all files in directory and sort them alphabetically
1169 $files = t3lib_div::getFilesInDir($resolvedPath, 'css', FALSE, 1);
1170 foreach ($files as $file) {
1171 $this->pageRenderer->addCssFile($GLOBALS['BACK_PATH'] . $path . $file, 'stylesheet', 'all');
1172 }
1173 }
1174
1175 /**
1176 * Insert post rendering document style into already rendered content
1177 * This is needed for extobjbase
1178 *
1179 * @param string style-content to insert.
1180 * @return string content with inserted styles
1181 */
1182 function insertStylesAndJS($content) {
1183 // insert accumulated CSS
1184 $this->inDocStylesArray[] = $this->inDocStyles;
1185 $styles = LF.implode(LF, $this->inDocStylesArray);
1186 $content = str_replace('/*###POSTCSSMARKER###*/',$styles,$content);
1187
1188 // insert accumulated JS
1189 $jscode = $this->JScode.LF.$this->wrapScriptTags(implode(LF, $this->JScodeArray));
1190 $content = str_replace('<!--###POSTJSMARKER###-->',$jscode,$content);
1191
1192 return $content;
1193 }
1194
1195 /**
1196 * Returns an array of all stylesheet directories belonging to core and skins
1197 *
1198 * @return array Stylesheet directories
1199 */
1200 public function getSkinStylesheetDirectories() {
1201 $stylesheetDirectories = array();
1202
1203 // add default core stylesheets
1204 foreach ($this->stylesheetsCore as $stylesheetDir) {
1205 $stylesheetDirectories[] = $stylesheetDir;
1206 }
1207
1208 // Stylesheets from skins
1209 // merge default css directories ($this->stylesheetsSkin) with additional ones and include them
1210 if (is_array($GLOBALS['TBE_STYLES']['skins'])) {
1211 // loop over all registered skins
1212 foreach ($GLOBALS['TBE_STYLES']['skins'] as $skinExtKey => $skin) {
1213 $skinStylesheetDirs = $this->stylesheetsSkins;
1214
1215 // skins can add custom stylesheetDirectories using
1216 // $TBE_STYLES['skins'][$_EXTKEY]['stylesheetDirectories']
1217 if (is_array($skin['stylesheetDirectories'])) {
1218 $skinStylesheetDirs = array_merge($skinStylesheetDirs, $skin['stylesheetDirectories']);
1219 }
1220
1221 // add all registered directories
1222 foreach ($skinStylesheetDirs as $stylesheetDir) {
1223 // for EXT:myskin/stylesheets/ syntax
1224 if (substr($stylesheetDir, 0, 4) === 'EXT:') {
1225 list($extKey, $path) = explode('/', substr($stylesheetDir, 4), 2);
1226 if (strcmp($extKey, '') && t3lib_extMgm::isLoaded($extKey) && strcmp($path, '')) {
1227 $stylesheetDirectories[] = t3lib_extMgm::extRelPath($extKey) . $path;
1228 }
1229 } else {
1230 // for relative paths
1231 $stylesheetDirectories[] = t3lib_extMgm::extRelPath($skinExtKey) . $stylesheetDir;
1232 }
1233 }
1234 }
1235 }
1236 return $stylesheetDirectories;
1237 }
1238
1239 /**
1240 * Initialize the charset.
1241 * Sets the internal $this->charset variable to the charset defined in $GLOBALS["LANG"] (or the default as set in this class)
1242 * Returns the meta-tag for the document header
1243 *
1244 * @return string <meta> tag with charset from $this->charset or $GLOBALS['LANG']->charSet
1245 */
1246 function initCharset() {
1247 // Set charset to the charset provided by the current backend users language selection:
1248 $this->charset = $GLOBALS['LANG']->charSet ? $GLOBALS['LANG']->charSet : $this->charset;
1249 // Return meta tag:
1250 return '<meta http-equiv="Content-Type" content="text/html; charset='.$this->charset.'" />';
1251 }
1252
1253 /**
1254 * Returns generator meta tag
1255 *
1256 * @return string <meta> tag with name "generator"
1257 */
1258 function generator() {
1259 $str = 'TYPO3 '.TYPO3_branch.', ' . TYPO3_URL_GENERAL . ', &#169; Kasper Sk&#229;rh&#248;j 1998-2009, extensions are copyright of their respective owners.';
1260 return '<meta name="generator" content="'.$str .'" />';
1261 }
1262
1263 /**
1264 * Returns X-UA-Compatible meta tag
1265 *
1266 * @param string $content Content of the compatible tag (default: IE-8)
1267 * @return string <meta http-equiv="X-UA-Compatible" content="???" />
1268 */
1269 public function xUaCompatible($content = 'IE=8') {
1270 return '<meta http-equiv="X-UA-Compatible" content="' . $content . '" />';
1271 }
1272
1273
1274
1275
1276
1277
1278
1279 /*****************************************
1280 *
1281 * OTHER ELEMENTS
1282 * Tables, buttons, formatting dimmed/red strings
1283 *
1284 ******************************************/
1285
1286
1287 /**
1288 * Returns an image-tag with an 18x16 icon of the following types:
1289 *
1290 * $type:
1291 * -1: OK icon (Check-mark)
1292 * 1: Notice (Speach-bubble)
1293 * 2: Warning (Yellow triangle)
1294 * 3: Fatal error (Red stop sign)
1295 *
1296 * @param integer See description
1297 * @param string Value for style attribute
1298 * @return string HTML image tag (if applicable)
1299 */
1300 function icons($type, $styleAttribValue='') {
1301 switch($type) {
1302 case '3':
1303 $icon = 'status-dialog-error';
1304 break;
1305 case '2':
1306 $icon = 'status-dialog-warning';
1307 break;
1308 case '1':
1309 $icon = 'status-dialog-notification';
1310 break;
1311 case '-1':
1312 $icon = 'status-dialog-ok';
1313 break;
1314 default:
1315 break;
1316 }
1317 if ($icon) {
1318 return t3lib_iconWorks::getSpriteIcon($icon);
1319 }
1320 }
1321
1322 /**
1323 * Returns an <input> button with the $onClick action and $label
1324 *
1325 * @param string The value of the onclick attribute of the input tag (submit type)
1326 * @param string The label for the button (which will be htmlspecialchar'ed)
1327 * @return string A <input> tag of the type "submit"
1328 */
1329 function t3Button($onClick,$label) {
1330 $button = '<input type="submit" onclick="'.htmlspecialchars($onClick).'; return false;" value="'.htmlspecialchars($label).'" />';
1331 return $button;
1332 }
1333
1334 /**
1335 * dimmed-fontwrap. Returns the string wrapped in a <span>-tag defining the color to be gray/dimmed
1336 *
1337 * @param string Input string
1338 * @return string Output string
1339 */
1340 function dfw($string) {
1341 return '<span class="typo3-dimmed">'.$string.'</span>';
1342 }
1343
1344 /**
1345 * red-fontwrap. Returns the string wrapped in a <span>-tag defining the color to be red
1346 *
1347 * @param string Input string
1348 * @return string Output string
1349 */
1350 function rfw($string) {
1351 return '<span class="typo3-red">'.$string.'</span>';
1352 }
1353
1354 /**
1355 * Returns string wrapped in CDATA "tags" for XML / XHTML (wrap content of <script> and <style> sections in those!)
1356 *
1357 * @param string Input string
1358 * @return string Output string
1359 */
1360 function wrapInCData($string) {
1361 $string = '/*<![CDATA[*/'.
1362 $string.
1363 '/*]]>*/';
1364
1365 return $string;
1366 }
1367
1368 /**
1369 * Wraps the input string in script tags.
1370 * Automatic re-identing of the JS code is done by using the first line as ident reference.
1371 * This is nice for identing JS code with PHP code on the same level.
1372 *
1373 * @param string Input string
1374 * @param boolean Wrap script element in linebreaks? Default is TRUE.
1375 * @return string Output string
1376 */
1377 function wrapScriptTags($string, $linebreak=TRUE) {
1378 if(trim($string)) {
1379 // <script wrapped in nl?
1380 $cr = $linebreak? LF : '';
1381
1382 // remove nl from the beginning
1383 $string = preg_replace ('/^\n+/', '', $string);
1384 // re-ident to one tab using the first line as reference
1385 $match = array();
1386 if(preg_match('/^(\t+)/',$string,$match)) {
1387 $string = str_replace($match[1],TAB, $string);
1388 }
1389 $string = $cr.'<script type="text/javascript">
1390 /*<![CDATA[*/
1391 '.$string.'
1392 /*]]>*/
1393 </script>'.$cr;
1394 }
1395 return trim($string);
1396 }
1397
1398 // These vars defines the layout for the table produced by the table() function.
1399 // You can override these values from outside if you like.
1400 var $tableLayout = array(
1401 'defRow' => array(
1402 'defCol' => array('<td valign="top">','</td>')
1403 )
1404 );
1405 var $table_TR = '<tr>';
1406 var $table_TABLE = '<table border="0" cellspacing="0" cellpadding="0" class="typo3-dblist" id="typo3-tmpltable">';
1407
1408 /**
1409 * Returns a table based on the input $data
1410 *
1411 * @param array Multidim array with first levels = rows, second levels = cells
1412 * @param array If set, then this provides an alternative layout array instead of $this->tableLayout
1413 * @return string The HTML table.
1414 * @internal
1415 */
1416 function table($data, $layout = '') {
1417 $result = '';
1418 if (is_array($data)) {
1419 $tableLayout = (is_array($layout) ? $layout : $this->tableLayout);
1420
1421 $rowCount = 0;
1422 foreach ($data as $tableRow) {
1423 if ($rowCount % 2) {
1424 $layout = is_array($tableLayout['defRowOdd']) ? $tableLayout['defRowOdd'] : $tableLayout['defRow'];
1425 } else {
1426 $layout = is_array($tableLayout['defRowEven']) ? $tableLayout['defRowEven'] : $tableLayout['defRow'];
1427 }
1428 $rowLayout = is_array($tableLayout[$rowCount]) ? $tableLayout[$rowCount] : $layout;
1429 $rowResult = '';
1430 if (is_array($tableRow)) {
1431 $cellCount = 0;
1432 foreach ($tableRow as $tableCell) {
1433 $cellWrap = (is_array($layout[$cellCount]) ? $layout[$cellCount] : $layout['defCol']);
1434 $cellWrap = (is_array($rowLayout['defCol']) ? $rowLayout['defCol'] : $cellWrap);
1435 $cellWrap = (is_array($rowLayout[$cellCount]) ? $rowLayout[$cellCount] : $cellWrap);
1436 $rowResult .= $cellWrap[0] . $tableCell . $cellWrap[1];
1437 $cellCount++;
1438 }
1439 }
1440 $rowWrap = (is_array($layout['tr']) ? $layout['tr'] : array($this->table_TR, '</tr>'));
1441 $rowWrap = (is_array($rowLayout['tr']) ? $rowLayout['tr'] : $rowWrap);
1442 $result .= $rowWrap[0] . $rowResult . $rowWrap[1];
1443 $rowCount++;
1444 }
1445 $tableWrap = is_array($tableLayout['table']) ? $tableLayout['table'] : array($this->table_TABLE, '</table>');
1446 $result = $tableWrap[0] . $result . $tableWrap[1];
1447 }
1448 return $result;
1449 }
1450
1451 /**
1452 * Constructs a table with content from the $arr1, $arr2 and $arr3.
1453 * Used in eg. ext/belog/mod/index.php - refer to that for examples
1454 *
1455 * @param array Menu elements on first level
1456 * @param array Secondary items
1457 * @param array Third-level items
1458 * @return string HTML content, <table>...</table>
1459 */
1460 function menuTable($arr1,$arr2=array(), $arr3=array()) {
1461 $rows = max(array(count($arr1),count($arr2),count($arr3)));
1462
1463 $menu='
1464 <table border="0" cellpadding="0" cellspacing="0" id="typo3-tablemenu">';
1465 for($a=0;$a<$rows;$a++) {
1466 $menu.='<tr>';
1467 $cls=array();
1468 $valign='middle';
1469 $cls[]='<td valign="'.$valign.'">'.$arr1[$a][0].'</td><td>'.$arr1[$a][1].'</td>';
1470 if (count($arr2)) {
1471 $cls[]='<td valign="'.$valign.'">'.$arr2[$a][0].'</td><td>'.$arr2[$a][1].'</td>';
1472 if (count($arr3)) {
1473 $cls[]='<td valign="'.$valign.'">'.$arr3[$a][0].'</td><td>'.$arr3[$a][1].'</td>';
1474 }
1475 }
1476 $menu.=implode($cls,'<td>&nbsp;&nbsp;</td>');
1477 $menu.='</tr>';
1478 }
1479 $menu.='
1480 </table>
1481 ';
1482 return $menu;
1483 }
1484
1485 /**
1486 * Returns a one-row/two-celled table with $content and $menu side by side.
1487 * The table is a 100% width table and each cell is aligned left / right
1488 *
1489 * @param string Content cell content (left)
1490 * @param string Menu cell content (right)
1491 * @return string HTML output
1492 */
1493 function funcMenu($content,$menu) {
1494 return '
1495 <table border="0" cellpadding="0" cellspacing="0" width="100%" id="typo3-funcmenu">
1496 <tr>
1497 <td valign="top" nowrap="nowrap">'.$content.'</td>
1498 <td valign="top" align="right" nowrap="nowrap">'.$menu.'</td>
1499 </tr>
1500 </table>';
1501 }
1502
1503 /**
1504 * Creates a selector box with clear-cache items.
1505 * Rather specialized functions - at least don't use it with $addSaveOptions unless you know what you do...
1506 *
1507 * @param integer The page uid of the "current page" - the one that will be cleared as "clear cache for this page".
1508 * @param boolean If $addSaveOptions is set, then also the array of save-options for TCE_FORMS will appear.
1509 * @return string <select> tag with content - a selector box for clearing the cache
1510 */
1511 function clearCacheMenu($id,$addSaveOptions=0) {
1512 global $BE_USER;
1513 $opt=array();
1514 if ($addSaveOptions) {
1515 $opt[]='<option value="">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.menu',1).'</option>';
1516 $opt[]='<option value="TBE_EDITOR.checkAndDoSubmit(1);">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveDoc',1).'</option>';
1517 $opt[]='<option value="document.editform.closeDoc.value=-2; TBE_EDITOR.checkAndDoSubmit(1);">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveCloseDoc',1).'</option>';
1518 if ($BE_USER->uc['allSaveFunctions']) $opt[]='<option value="document.editform.closeDoc.value=-3; TBE_EDITOR.checkAndDoSubmit(1);">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveCloseAllDocs',1).'</option>';
1519 $opt[]='<option value="document.editform.closeDoc.value=2; document.editform.submit();">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.closeDoc',1).'</option>';
1520 $opt[]='<option value="document.editform.closeDoc.value=3; document.editform.submit();">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.closeAllDocs',1).'</option>';
1521 $opt[]='<option value=""></option>';
1522 }
1523 $opt[]='<option value="">[ '.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_clearCache',1).' ]</option>';
1524 if ($id) $opt[]='<option value="'.$id.'">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_thisPage',1).'</option>';
1525 if ($BE_USER->isAdmin() || $BE_USER->getTSConfigVal('options.clearCache.pages')) $opt[]='<option value="pages">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_pages',1).'</option>';
1526 if ($BE_USER->isAdmin() || $BE_USER->getTSConfigVal('options.clearCache.all')) $opt[]='<option value="all">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_all',1).'</option>';
1527
1528 $onChange = 'if (!this.options[this.selectedIndex].value) {
1529 this.selectedIndex=0;
1530 } else if (this.options[this.selectedIndex].value.indexOf(\';\')!=-1) {
1531 eval(this.options[this.selectedIndex].value);
1532 } else {
1533 window.location.href=\'' . $this->backPath .
1534 'tce_db.php?vC=' . $BE_USER->veriCode() .
1535 t3lib_BEfunc::getUrlToken('tceAction') .
1536 '&redirect=' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')) .
1537 '&cacheCmd=\'+this.options[this.selectedIndex].value;
1538 }';
1539 $af_content = '<select name="cacheCmd" onchange="'.htmlspecialchars($onChange).'">'.implode('',$opt).'</select>';
1540
1541 if (count($opt)>1) {
1542 return $af_content;
1543 }
1544 }
1545
1546
1547 /**
1548 * Includes a javascript library that exists in the core /typo3/ directory. The
1549 * backpath is automatically applied
1550 *
1551 * @param string $lib: Library name. Call it with the full path
1552 * like "contrib/prototype/prototype.js" to load it
1553 * @return void
1554 */
1555 function loadJavascriptLib($lib) {
1556 $this->pageRenderer->addJsFile($this->backPath . $lib);
1557 }
1558
1559
1560
1561 /**
1562 * Includes the necessary Javascript function for the clickmenu (context sensitive menus) in the document
1563 *
1564 * @return array Deprecated: Includes the code already in the doc, so the return array is always empty.
1565 * Please just call this function without expecting a return value for future calls
1566 */
1567 function getContextMenuCode() {
1568 $this->pageRenderer->loadPrototype();
1569 $this->loadJavascriptLib('js/clickmenu.js');
1570
1571 $this->JScodeArray['clickmenu'] = '
1572 Clickmenu.clickURL = "'.$this->backPath.'alt_clickmenu.php";
1573 Clickmenu.ajax = '.($this->isCMLayers() ? 'true' : 'false' ).';';
1574
1575 // return array deprecated since 4.2
1576 return array('','','');
1577 }
1578
1579 /**
1580 * Includes the necessary javascript file (tree.js) for use on pages which have the
1581 * drag and drop functionality (usually pages and folder display trees)
1582 *
1583 * @param string indicator of which table the drag and drop function should work on (pages or folders)
1584 * @return array If values are present: [0] = A <script> section for the HTML page header, [1] = onmousemove/onload handler for HTML tag or alike, [2] = One empty <div> layer for the follow-mouse drag element
1585 */
1586 function getDragDropCode($table) {
1587 $this->pageRenderer->loadPrototype();
1588 $this->loadJavascriptLib('js/common.js');
1589 $this->loadJavascriptLib('js/tree.js');
1590
1591 // setting prefs for drag & drop
1592 $this->JScodeArray['dragdrop'] = '
1593 DragDrop.changeURL = "'.$this->backPath.'alt_clickmenu.php";
1594 DragDrop.backPath = "'.t3lib_div::shortMD5(''.'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']).'";
1595 DragDrop.table = "'.$table.'";
1596 ';
1597
1598 // return array deprecated since 4.2
1599 return array('','','');
1600 }
1601
1602 /**
1603 * This loads everything needed for the Context Sensitive Help (CSH)
1604 *
1605 * @return void
1606 */
1607 protected function loadCshJavascript() {
1608 $this->pageRenderer->loadExtJS();
1609 $this->pageRenderer->addJsFile($this->backPath .'../t3lib/js/extjs/contexthelp.js');
1610 $this->pageRenderer->addExtDirectCode();
1611 }
1612
1613 /**
1614 * Creates a tab menu from an array definition
1615 *
1616 * Returns a tab menu for a module
1617 * Requires the JS function jumpToUrl() to be available
1618 *
1619 * @param mixed $id is the "&id=" parameter value to be sent to the module, but it can be also a parameter array which will be passed instead of the &id=...
1620 * @param string $elementName it the form elements name, probably something like "SET[...]"
1621 * @param string $currentValue is the value to be selected currently.
1622 * @param array $menuItems is an array with the menu items for the selector box
1623 * @param string $script is the script to send the &id to, if empty it's automatically found
1624 * @param string $addParams is additional parameters to pass to the script.
1625 * @return string HTML code for tab menu
1626 * @author René Fritz <r.fritz@colorcube.de>
1627 */
1628 function getTabMenu($mainParams,$elementName,$currentValue,$menuItems,$script='',$addparams='') {
1629 $content='';
1630
1631 if (is_array($menuItems)) {
1632 if (!is_array($mainParams)) {
1633 $mainParams = array('id' => $mainParams);
1634 }
1635 $mainParams = t3lib_div::implodeArrayForUrl('',$mainParams);
1636
1637 if (!$script) {$script=basename(PATH_thisScript);}
1638
1639 $menuDef = array();
1640 foreach($menuItems as $value => $label) {
1641 $menuDef[$value]['isActive'] = !strcmp($currentValue,$value);
1642 $menuDef[$value]['label'] = t3lib_div::deHSCentities(htmlspecialchars($label));
1643 $menuDef[$value]['url'] = $script . '?' . $mainParams . $addparams . '&' . $elementName . '=' . $value;
1644 }
1645 $content = $this->getTabMenuRaw($menuDef);
1646
1647 }
1648 return $content;
1649 }
1650
1651 /**
1652 * Creates the HTML content for the tab menu
1653 *
1654 * @param array Menu items for tabs
1655 * @return string Table HTML
1656 * @access private
1657 */
1658 function getTabMenuRaw($menuItems) {
1659 $content='';
1660
1661 if (is_array($menuItems)) {
1662 $options='';
1663
1664 $count = count($menuItems);
1665 $widthLeft = 1;
1666 $addToAct = 5;
1667
1668 $widthRight = max (1,floor(30-pow($count,1.72)));
1669 $widthTabs = 100 - $widthRight - $widthLeft;
1670 $widthNo = floor(($widthTabs - $addToAct)/$count);
1671 $addToAct = max ($addToAct,$widthTabs-($widthNo*$count));
1672 $widthAct = $widthNo + $addToAct;
1673 $widthRight = 100 - ($widthLeft + ($count*$widthNo) + $addToAct);
1674
1675 foreach($menuItems as $id => $def) {
1676 $isActive = $def['isActive'];
1677 $class = $isActive ? 'tabact' : 'tab';
1678 $width = $isActive ? $widthAct : $widthNo;
1679
1680 // @rene: Here you should probably wrap $label and $url in htmlspecialchars() in order to make sure its XHTML compatible! I did it for $url already since that is VERY likely to break.
1681 $label = $def['label'];
1682 $url = htmlspecialchars($def['url']);
1683 $params = $def['addParams'];
1684
1685 $options .= '<td width="' . $width . '%" class="' . $class . '"><a href="' . $url . '" ' . $params . '>' . $label . '</a></td>';
1686 }
1687
1688 if ($options) {
1689 $content .= '
1690 <!-- Tab menu -->
1691 <table cellpadding="0" cellspacing="0" border="0" width="100%" id="typo3-tabmenu">
1692 <tr>
1693 <td width="'.$widthLeft.'%">&nbsp;</td>
1694 '.$options.'
1695 <td width="'.$widthRight.'%">&nbsp;</td>
1696 </tr>
1697 </table>
1698 <div class="hr" style="margin:0px"></div>';
1699 }
1700
1701 }
1702 return $content;
1703 }
1704
1705 /**
1706 * Creates a DYNAMIC tab-menu where the tabs are switched between with DHTML.
1707 * Should work in MSIE, Mozilla, Opera and Konqueror. On Konqueror I did find a serious problem: <textarea> fields loose their content when you switch tabs!
1708 *
1709 * @param array Numeric array where each entry is an array in itself with associative keys: "label" contains the label for the TAB, "content" contains the HTML content that goes into the div-layer of the tabs content. "description" contains description text to be shown in the layer. "linkTitle" is short text for the title attribute of the tab-menu link (mouse-over text of tab). "stateIcon" indicates a standard status icon (see ->icon(), values: -1, 1, 2, 3). "icon" is an image tag placed before the text.
1710 * @param string Identification string. This should be unique for every instance of a dynamic menu!
1711 * @param integer If "1", then enabling one tab does not hide the others - they simply toggles each sheet on/off. This makes most sense together with the $foldout option. If "-1" then it acts normally where only one tab can be active at a time BUT you can click a tab and it will close so you have no active tabs.
1712 * @param boolean If set, the tabs are rendered as headers instead over each sheet. Effectively this means there is no tab menu, but rather a foldout/foldin menu. Make sure to set $toggle as well for this option.
1713 * @param integer Character limit for a new row, 0 by default, because this parameter is deprecated since TYPO3 4.5
1714 * @param boolean If set, tab table cells are not allowed to wrap their content
1715 * @param boolean If set, the tabs will span the full width of their position
1716 * @param integer Default tab to open (for toggle <=0). Value corresponds to integer-array index + 1 (index zero is "1", index "1" is 2 etc.). A value of zero (or something non-existing) will result in no default tab open.
1717 * @param integer If set to '1' empty tabs will be remove, If set to '2' empty tabs will be disabled
1718 * @return string JavaScript section for the HTML header.
1719 */
1720 public function getDynTabMenu($menuItems, $identString, $toggle = 0, $foldout = FALSE, $newRowCharLimit = 0, $noWrap = 1, $fullWidth = FALSE, $defaultTabIndex = 1, $dividers2tabs = 2) {
1721 // load the static code, if not already done with the function below
1722 $this->loadJavascriptLib('js/tabmenu.js');
1723
1724 $content = '';
1725
1726 if (is_array($menuItems)) {
1727
1728 // Init:
1729 $options = array(array());
1730 $divs = array();
1731 $JSinit = array();
1732 $id = $this->getDynTabMenuId($identString);
1733 $noWrap = $noWrap ? ' nowrap="nowrap"' : '';
1734
1735 // Traverse menu items
1736 $c=0;
1737 $tabRows=0;
1738 $titleLenCount = 0;
1739 foreach($menuItems as $index => $def) {
1740 // Need to add one so checking for first index in JavaScript
1741 // is different than if it is not set at all.
1742 $index += 1;
1743
1744 // Switch to next tab row if needed
1745 if (!$foldout && (($newRowCharLimit > 0 && $titleLenCount > $newRowCharLimit) | ($def['newline'] === TRUE && $titleLenCount > 0))) {
1746 $titleLenCount=0;
1747 $tabRows++;
1748 $options[$tabRows] = array();
1749 }
1750
1751 if ($toggle==1) {
1752 $onclick = 'this.blur(); DTM_toggle("'.$id.'","'.$index.'"); return false;';
1753 } else {
1754 $onclick = 'this.blur(); DTM_activate("'.$id.'","'.$index.'", '.($toggle<0?1:0).'); return false;';
1755 }
1756
1757 $isEmpty = !(strcmp(trim($def['content']),'') || strcmp(trim($def['icon']),''));
1758
1759 // "Removes" empty tabs
1760 if ($isEmpty && $dividers2tabs == 1) {
1761 continue;
1762 }
1763
1764 $mouseOverOut = ' onmouseover="DTM_mouseOver(this);" onmouseout="DTM_mouseOut(this);"';
1765 $requiredIcon = '<img name="' . $id . '-' . $index . '-REQ" src="' . $GLOBALS['BACK_PATH'] . 'gfx/clear.gif" class="t3-TCEforms-reqTabImg" alt="" />';
1766
1767 if (!$foldout) {
1768 // Create TAB cell:
1769 $options[$tabRows][] = '
1770 <td class="'.($isEmpty ? 'disabled' : 'tab').'" id="'.$id.'-'.$index.'-MENU"'.$noWrap.$mouseOverOut.'>'.
1771 ($isEmpty ? '' : '<a href="#" onclick="'.htmlspecialchars($onclick).'"'.($def['linkTitle'] ? ' title="'.htmlspecialchars($def['linkTitle']).'"':'').'>').
1772 $def['icon'].
1773 ($def['label'] ? htmlspecialchars($def['label']) : '&nbsp;').
1774 $requiredIcon.
1775 $this->icons($def['stateIcon'],'margin-left: 10px;').
1776 ($isEmpty ? '' : '</a>').
1777 '</td>';
1778 $titleLenCount+= strlen($def['label']);
1779 } else {
1780 // Create DIV layer for content:
1781 $divs[] = '
1782 <div class="'.($isEmpty ? 'disabled' : 'tab').'" id="'.$id.'-'.$index.'-MENU"'.$mouseOverOut.'>'.
1783 ($isEmpty ? '' : '<a href="#" onclick="'.htmlspecialchars($onclick).'"'.($def['linkTitle'] ? ' title="'.htmlspecialchars($def['linkTitle']).'"':'').'>').
1784 $def['icon'].
1785 ($def['label'] ? htmlspecialchars($def['label']) : '&nbsp;').
1786 $requiredIcon.
1787 ($isEmpty ? '' : '</a>').
1788 '</div>';
1789 }
1790
1791 // Create DIV layer for content:
1792 $divs[] = '
1793 <div style="display: none;" id="'.$id.'-'.$index.'-DIV" class="c-tablayer">'.
1794 ($def['description'] ? '<p class="c-descr">'.nl2br(htmlspecialchars($def['description'])).'</p>' : '').
1795 $def['content'].
1796 '</div>';
1797 // Create initialization string:
1798 $JSinit[] = '
1799 DTM_array["'.$id.'"]['.$c.'] = "'.$id.'-'.$index.'";
1800 ';
1801 // If not empty and we have the toggle option on, check if the tab needs to be expanded
1802 if ($toggle == 1 && !$isEmpty) {
1803 $JSinit[] = '
1804 if (top.DTM_currentTabs["'.$id.'-'.$index.'"]) { DTM_toggle("'.$id.'","'.$index.'",1); }
1805 ';
1806 }
1807
1808 $c++;
1809 }
1810
1811 // Render menu:
1812 if (count($options)) {
1813
1814 // Tab menu is compiled:
1815 if (!$foldout) {
1816 $tabContent = '';
1817 for($a=0;$a<=$tabRows;$a++) {
1818 $tabContent.= '
1819
1820 <!-- Tab menu -->
1821 <table cellpadding="0" cellspacing="0" border="0"'.($fullWidth ? ' width="100%"' : '').' class="typo3-dyntabmenu">
1822 <tr>
1823 '.implode('',$options[$a]).'
1824 </tr>
1825 </table>';
1826 }
1827 $content.= '<div class="typo3-dyntabmenu-tabs">'.$tabContent.'</div>';
1828 }
1829
1830 // Div layers are added:
1831 $content.= '
1832 <!-- Div layers for tab menu: -->
1833 <div class="typo3-dyntabmenu-divs'.($foldout?'-foldout':'').'">
1834 '.implode('',$divs).'</div>';
1835
1836 // Java Script section added:
1837 $content.= '
1838 <!-- Initialization JavaScript for the menu -->
1839 <script type="text/javascript">
1840 DTM_array["'.$id.'"] = new Array();
1841 '.implode('',$JSinit).'
1842 '.($toggle<=0 ? 'DTM_activate("'.$id.'", top.DTM_currentTabs["'.$id.'"]?top.DTM_currentTabs["'.$id.'"]:'.intval($defaultTabIndex).', 0);' : '').'
1843 </script>
1844
1845 ';
1846 }
1847
1848 }
1849 return $content;
1850 }
1851
1852 /**
1853 * Creates the id for dynTabMenus.
1854 *
1855 * @param string $identString: Identification string. This should be unique for every instance of a dynamic menu!
1856 * @return string The id with a short MD5 of $identString and prefixed "DTM-", like "DTM-2e8791854a"
1857 */
1858 function getDynTabMenuId($identString) {
1859 $id = 'DTM-'.t3lib_div::shortMD5($identString);
1860 return $id;
1861 }
1862
1863 /**
1864 * Creates the version selector for the page id inputted.
1865 * Requires the core version management extension, "version" to be loaded.
1866 *
1867 * @param integer Page id to create selector for.
1868 * @param boolean If set, there will be no button for swapping page.
1869 * @return void
1870 */
1871 public function getVersionSelector($id, $noAction = FALSE) {
1872 if (t3lib_extMgm::isLoaded('version')) {
1873 $versionGuiObj = t3lib_div::makeInstance('tx_version_gui');
1874 return $versionGuiObj->getVersionSelector($id, $noAction);
1875 }
1876 }
1877
1878 /**
1879 * Function to load a HTML template file with markers.
1880 * When calling from own extension, use syntax getHtmlTemplate('EXT:extkey/template.html')
1881 *
1882 * @param string tmpl name, usually in the typo3/template/ directory
1883 * @return string HTML of template
1884 */
1885 function getHtmlTemplate($filename) {
1886 // setting the name of the original HTML template
1887 $this->moduleTemplateFilename = $filename;
1888
1889 if ($GLOBALS['TBE_STYLES']['htmlTemplates'][$filename]) {
1890 $filename = $GLOBALS['TBE_STYLES']['htmlTemplates'][$filename];
1891 }
1892 if (t3lib_div::isFirstPartOfStr($filename, 'EXT:')) {
1893 $filename = t3lib_div::getFileAbsFileName($filename, TRUE, TRUE);
1894 } else if (!t3lib_div::isAbsPath($filename)) {
1895 $filename = t3lib_div::resolveBackPath($this->backPath . $filename);
1896 } else if (!t3lib_div::isAllowedAbsPath($filename)) {
1897 $filename = '';
1898 }
1899 $htmlTemplate = '';
1900 if ($filename !== '') {
1901 $htmlTemplate = t3lib_div::getURL($filename);
1902 }
1903 return $htmlTemplate;
1904 }
1905
1906 /**
1907 * Define the template for the module
1908 *
1909 * @param string filename
1910 */
1911 public function setModuleTemplate($filename) {
1912 // Load Prototype lib for IE event
1913 $this->pageRenderer->loadPrototype();
1914 $this->loadJavascriptLib('js/iecompatibility.js');
1915 $this->moduleTemplate = $this->getHtmlTemplate($filename);
1916 }
1917
1918 /**
1919 * Put together the various elements for the module <body> using a static HTML
1920 * template
1921 *
1922 * @param array Record of the current page, used for page path and info
1923 * @param array HTML for all buttons
1924 * @param array HTML for all other markers
1925 * @return string Composite HTML
1926 */
1927 public function moduleBody($pageRecord = array(), $buttons = array(), $markerArray = array(), $subpartArray = array()) {
1928 // Get the HTML template for the module
1929 $moduleBody = t3lib_parsehtml::getSubpart($this->moduleTemplate, '###FULLDOC###');
1930 // Add CSS
1931 $this->inDocStylesArray[] = 'html { overflow: hidden; }';
1932 // Add JS code to the <head> for IE
1933 $this->JScode.= $this->wrapScriptTags('
1934 // workaround since IE6 cannot deal with relative height for scrolling elements
1935 function resizeDocBody() {
1936 $("typo3-docbody").style.height = (document.body.offsetHeight - parseInt($("typo3-docheader").getStyle("height")));
1937 }
1938 if (Prototype.Browser.IE) {
1939 var version = parseFloat(navigator.appVersion.split(\';\')[1].strip().split(\' \')[1]);
1940 if (version == 6) {
1941 Event.observe(window, "resize", resizeDocBody, false);
1942 Event.observe(window, "load", resizeDocBody, false);
1943 }
1944 }
1945 ');
1946
1947 // Get the page path for the docheader
1948 $markerArray['PAGEPATH'] = $this->getPagePath($pageRecord);
1949 // Get the page info for the docheader
1950 $markerArray['PAGEINFO'] = $this->getPageInfo($pageRecord);
1951 // Get all the buttons for the docheader
1952 $docHeaderButtons = $this->getDocHeaderButtons($buttons);
1953 // Merge docheader buttons with the marker array
1954 $markerArray = array_merge($markerArray, $docHeaderButtons);
1955 // replacing subparts
1956 foreach ($subpartArray as $marker => $content) {
1957 $moduleBody = t3lib_parsehtml::substituteSubpart($moduleBody, $marker, $content);
1958 }
1959
1960 // adding flash messages
1961 if ($this->showFlashMessages) {
1962 $flashMessages = t3lib_FlashMessageQueue::renderFlashMessages();
1963 if (!empty($flashMessages)) {
1964 $markerArray['FLASHMESSAGES'] = '<div id="typo3-messages">' . $flashMessages . '</div>';
1965
1966 // if there is no dedicated marker for the messages present
1967 // then force them to appear before the content
1968 if (strpos($moduleBody, '###FLASHMESSAGES###') === FALSE) {
1969 $moduleBody = str_replace(
1970 '###CONTENT###',
1971 '###FLASHMESSAGES######CONTENT###',
1972 $moduleBody
1973 );
1974 }
1975 }
1976 }
1977
1978 // Hook for adding more markers/content to the page, like the version selector
1979 if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['moduleBodyPostProcess'])) {
1980 $params = array(
1981 'moduleTemplateFilename' => &$this->moduleTemplateFilename,
1982 'moduleTemplate' => &$this->moduleTemplate,
1983 'moduleBody' => &$moduleBody,
1984 'markers' => &$markerArray,
1985 'parentObject' => &$this
1986 );
1987 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['moduleBodyPostProcess'] as $funcRef) {
1988 t3lib_div::callUserFunction($funcRef, $params, $this);
1989 }
1990 }
1991
1992 // replacing all markers with the finished markers and return the HTML content
1993 return t3lib_parsehtml::substituteMarkerArray($moduleBody, $markerArray, '###|###');
1994
1995 }
1996
1997 /**
1998 * Fill the button lists with the defined HTML
1999 *
2000 * @param array HTML for all buttons
2001 * @return array Containing HTML for both buttonlists
2002 */
2003 protected function getDocHeaderButtons($buttons) {
2004 $markers = array();
2005 // Fill buttons for left and right float
2006 $floats = array('left', 'right');
2007 foreach($floats as $key) {
2008 // Get the template for each float
2009 $buttonTemplate = t3lib_parsehtml::getSubpart($this->moduleTemplate, '###BUTTON_GROUPS_' . strtoupper($key) . '###');
2010 // Fill the button markers in this float
2011 $buttonTemplate = t3lib_parsehtml::substituteMarkerArray($buttonTemplate, $buttons, '###|###', true);
2012 // getting the wrap for each group
2013 $buttonWrap = t3lib_parsehtml::getSubpart($this->moduleTemplate, '###BUTTON_GROUP_WRAP###');
2014 // looping through the groups (max 6) and remove the empty groups
2015 for ($groupNumber = 1; $groupNumber < 6; $groupNumber++) {
2016 $buttonMarker = '###BUTTON_GROUP' . $groupNumber . '###';
2017 $buttonGroup = t3lib_parsehtml::getSubpart($buttonTemplate, $buttonMarker);
2018 if (trim($buttonGroup)) {
2019 if ($buttonWrap) {
2020 $buttonGroup = t3lib_parsehtml::substituteMarker($buttonWrap, '###BUTTONS###', $buttonGroup);
2021 }
2022 $buttonTemplate = t3lib_parsehtml::substituteSubpart($buttonTemplate, $buttonMarker, trim($buttonGroup));
2023 }
2024 }
2025 // replace the marker with the template and remove all line breaks (for IE compat)
2026 $markers['BUTTONLIST_' . strtoupper($key)] = str_replace(LF, '', $buttonTemplate);
2027 }
2028
2029 // Hook for manipulating docHeaderButtons
2030 if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['docHeaderButtonsHook'])) {
2031 $params = array(
2032 'buttons' => $buttons,
2033 'markers' => &$markers,
2034 'pObj' => &$this
2035 );
2036 foreach($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['docHeaderButtonsHook'] as $funcRef) {
2037 t3lib_div::callUserFunction($funcRef, $params, $this);
2038 }
2039 }
2040
2041 return $markers;
2042 }
2043
2044 /**
2045 * Generate the page path for docheader
2046 *
2047 * @param array Current page
2048 * @return string Page path
2049 */
2050 protected function getPagePath($pageRecord) {
2051 // Is this a real page
2052 if ($pageRecord['uid']) {
2053 $title = substr($pageRecord['_thePathFull'], 0, -1);
2054 // remove current page title
2055 $pos = strrpos($title, '/');
2056 if ($pos !== FALSE) {
2057 $title = substr($title, 0, $pos) . '/';
2058 }
2059 } else {
2060 $title = '';
2061 }
2062
2063 // Setting the path of the page
2064 $pagePath = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.path', 1) . ': <span class="typo3-docheader-pagePath">';
2065
2066 // crop the title to title limit (or 50, if not defined)
2067 $cropLength = (empty($GLOBALS['BE_USER']->uc['titleLen'])) ? 50 : $GLOBALS['BE_USER']->uc['titleLen'];
2068 $croppedTitle = t3lib_div::fixed_lgd_cs($title, -$cropLength);
2069 if ($croppedTitle !== $title) {
2070 $pagePath .= '<abbr title="' . htmlspecialchars($title) . '">' . htmlspecialchars($croppedTitle) . '</abbr>';
2071 } else {
2072 $pagePath .= htmlspecialchars($title);
2073 }
2074 $pagePath .= '</span>';
2075 return $pagePath;
2076 }
2077
2078 /**
2079 * Setting page icon with clickmenu + uid for docheader
2080 *
2081 * @param array Current page
2082 * @return string Page info
2083 */
2084 protected function getPageInfo($pageRecord) {
2085 global $BE_USER;
2086 // Add icon with clickmenu, etc:
2087 if ($pageRecord['uid']) { // If there IS a real page
2088 $alttext = t3lib_BEfunc::getRecordIconAltText($pageRecord, 'pages');
2089 $iconImg = t3lib_iconWorks::getSpriteIconForRecord('pages', $pageRecord, array('title'=>$alttext));
2090 // Make Icon:
2091 $theIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconImg, 'pages', $pageRecord['uid']);
2092 $uid = $pageRecord['uid'];
2093 $title = t3lib_BEfunc::getRecordTitle('pages', $pageRecord);
2094 } else { // On root-level of page tree
2095 // Make Icon
2096 $iconImg = t3lib_iconWorks::getSpriteIcon('apps-pagetree-root', array('title' => htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'])));
2097 if($BE_USER->user['admin']) {
2098 $theIcon = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($iconImg, 'pages', 0);
2099 } else {
2100 $theIcon = $iconImg;
2101 }
2102 $uid = '0';
2103 $title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
2104 }
2105
2106 // Setting icon with clickmenu + uid
2107 $pageInfo = $theIcon . '<strong>' . htmlspecialchars($title) . '&nbsp;[' . $uid . ']</strong>';
2108 return $pageInfo;
2109 }
2110
2111 /**
2112 * Makes a collapseable section. See reports module for an example
2113 *
2114 * @param string $title
2115 * @param string $html
2116 * @param string $id
2117 * @param string $saveStatePointer
2118 * @return string
2119 */
2120 public function collapseableSection($title, $html, $id, $saveStatePointer = '') {
2121 $hasSave = $saveStatePointer ? TRUE : FALSE;
2122 $collapsedStyle = $collapsedClass = '';
2123
2124 if ($hasSave) {
2125 /** @var $settings extDirect_DataProvider_BackendUserSettings */
2126 $settings = t3lib_div::makeInstance('extDirect_DataProvider_BackendUserSettings');
2127 $value = $settings->get($saveStatePointer . '.' . $id);
2128 if ($value) {
2129 $collapsedStyle = ' style="display: none"';
2130 $collapsedClass = ' collapsed';
2131 } else {
2132 $collapsedStyle = '';
2133 $collapsedClass = ' expanded';
2134 }
2135 }
2136
2137 $this->pageRenderer->loadExtJS();
2138 $this->pageRenderer->addExtOnReadyCode('
2139 Ext.select("h2.section-header").each(function(element){
2140 element.on("click", function(event, tag) {
2141 var state = 0,
2142 el = Ext.fly(tag),
2143 div = el.next("div"),
2144 saveKey = el.getAttribute("rel");
2145 if (el.hasClass("collapsed")) {
2146 el.removeClass("collapsed").addClass("expanded");
2147 div.slideIn("t", {
2148 easing: "easeIn",
2149 duration: .5
2150 });
2151 } else {
2152 el.removeClass("expanded").addClass("collapsed");
2153 div.slideOut("t", {
2154 easing: "easeOut",
2155 duration: .5,
2156 remove: false,
2157 useDisplay: true
2158 });
2159 state = 1;
2160 }
2161 if (saveKey) {
2162 try {
2163 top.TYPO3.BackendUserSettings.ExtDirect.set(saveKey + "." + tag.id, state, function(response) {});
2164 } catch(e) {}
2165 }
2166 });
2167 });
2168 ');
2169 return '
2170 <h2 id="' . $id . '" class="section-header' . $collapsedClass . '" rel="' . $saveStatePointer . '"> ' . $title . '</h2>
2171 <div' . $collapsedStyle . '>' . $html . '</div>
2172 ';
2173
2174 }
2175
2176
2177 }
2178
2179
2180 // ******************************
2181 // Extension classes of the template class.
2182 // These are meant to provide backend screens with different widths.
2183 // They still do because of the different class-prefixes used for the <div>-sections
2184 // but obviously the final width is determined by the stylesheet used.
2185 // ******************************
2186
2187 /**
2188 * Extension class for "template" - used for backend pages which are wide. Typically modules taking up all the space in the "content" frame of the backend
2189 * The class were more significant in the past than today.
2190 *
2191 */
2192 class bigDoc extends template {
2193 var $divClass = 'typo3-bigDoc';
2194 }
2195
2196 /**
2197 * Extension class for "template" - used for backend pages without the "document" background image
2198 * The class were more significant in the past than today.
2199 *
2200 */
2201 class noDoc extends template {
2202 var $divClass = 'typo3-noDoc';
2203 }
2204
2205 /**
2206 * Extension class for "template" - used for backend pages which were narrow (like the Web>List modules list frame. Or the "Show details" pop up box)
2207 * The class were more significant in the past than today.
2208 *
2209 */
2210 class smallDoc extends template {
2211 var $divClass = 'typo3-smallDoc';
2212 }
2213
2214 /**
2215 * Extension class for "template" - used for backend pages which were medium wide. Typically submodules to Web or File which were presented in the list-frame when the content frame were divided into a navigation and list frame.
2216 * The class were more significant in the past than today. But probably you should use this one for most modules you make.
2217 *
2218 */
2219 class mediumDoc extends template {
2220 var $divClass = 'typo3-mediumDoc';
2221 }
2222
2223
2224 /**
2225 * Extension class for "template" - used in the context of frontend editing.
2226 */
2227 class frontendDoc extends template {
2228
2229 /**
2230 * Gets instance of PageRenderer
2231 *
2232 * @return t3lib_PageRenderer
2233 */
2234 public function getPageRenderer() {
2235 if (!isset($this->pageRenderer)) {
2236 $this->pageRenderer = $GLOBALS['TSFE']->getPageRenderer();
2237 }
2238 return $this->pageRenderer;
2239 }
2240
2241 /**
2242 * Used in the frontend context to insert header data via TSFE->additionalHeaderData.
2243 * Mimics header inclusion from template->startPage().
2244 *
2245 * @return void
2246 */
2247 public function insertHeaderData() {
2248
2249 $this->backPath = $GLOBALS['TSFE']->backPath = TYPO3_mainDir;
2250 $this->pageRenderer->setBackPath($this->backPath);
2251 $this->docStyle();
2252
2253 // add applied JS/CSS to $GLOBALS['TSFE']
2254 if ($this->JScode) {
2255 $this->pageRenderer->addHeaderData($this->JScode);
2256 }
2257 if (count($this->JScodeArray)) {
2258 foreach ($this->JScodeArray as $name => $code) {
2259 $this->pageRenderer->addJsInlineCode($name, $code);
2260 }
2261 }
2262 }
2263 }
2264
2265
2266 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/template.php'])) {
2267 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/template.php']);
2268 }
2269
2270
2271
2272 // ******************************
2273 // The template is loaded
2274 // ******************************
2275 $GLOBALS['TBE_TEMPLATE'] = t3lib_div::makeInstance('template');
2276
2277
2278 ?>