2 /***************************************************************
5 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
29 * Contains class with layout/output function for TYPO3 Backend Scripts
31 * Revised for TYPO3 3.6 2/2003 by Kasper Skårhøj
32 * XHTML-trans compliant
34 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
37 if (!defined('TYPO3_MODE')) {
38 die('Can\'t include this file directly.');
42 * TYPO3 Backend Template Class
44 * This class contains functions for starting and ending the HTML of backend modules
45 * It also contains methods for outputting sections of content.
46 * Further there are functions for making icons, links, setting form-field widths etc.
47 * Color scheme and stylesheet definitions are also available here.
48 * Finally this file includes the language class for TYPO3's backend.
50 * After this file $LANG and $TBE_TEMPLATE are global variables / instances of their respective classes.
51 * This file is typically included right after the init.php file,
52 * if language and layout is needed.
54 * Please refer to Inside TYPO3 for a discussion of how to use this API.
56 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
62 // Vars you typically might want to/should set from outside after making instance of this class:
63 // 'backPath' pointing back to the PATH_typo3
65 // 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.
67 // 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
68 var $JScodeLibArray = array();
69 // Additional header code (eg. a JavaScript section) could be accommulated in this var. It will be directly outputted in the header.
71 // Additional header code for ExtJS. It will be included in document header and inserted in a Ext.onReady(function()
73 // 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.
74 var $JScodeArray = array();
75 // 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.
77 // Doc-type used in the header. Default is xhtml_trans. You can also set it to 'html_3', 'xhtml_strict' or 'xhtml_frames'.
79 // HTML template with markers for module
80 var $moduleTemplate = '';
81 // the base file (not overlaid by TBE_STYLES) for the current module, useful for hooks when finding out which modules is rendered currently
82 protected $moduleTemplateFilename = '';
84 // Other vars you can change, but less frequently used:
87 // Id which can be set for the body tag. Default value is based on script ID
89 // You can add additional attributes to the body-tag through this variable.
90 var $bodyTagAdditions = '';
91 // Additional CSS styles which will be added to the <style> section in the header
92 var $inDocStyles = '';
93 // Like $inDocStyles but for use as array with associative keys to prevent double inclusion of css code
94 var $inDocStylesArray = array();
95 // Multiplication factor for formWidth() input size (default is 48* this value).
96 var $form_rowsToStylewidth = 9.58;
97 // Compensation for large documents (used in class.t3lib_tceforms.php)
98 var $form_largeComp = 1.33;
99 // 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.
102 // TYPO3 Colorscheme.
103 // If you want to change this, please do so through a skin using the global var $GLOBALS['TBE_STYLES']
104 // Light background color
105 var $bgColor = '#F7F3EF';
107 var $bgColor2 = '#9BA1A8';
109 var $bgColor3 = '#F6F2E6';
110 // light tablerow background, brownish
111 var $bgColor4 = '#D9D5C9';
112 // light tablerow background, greenish
113 var $bgColor5 = '#ABBBB4';
114 // light tablerow background, yellowish, for section headers. Light.
115 var $bgColor6 = '#E7DBA8';
116 var $hoverColor = '#254D7B';
117 // Filename of stylesheet (relative to PATH_typo3)
118 var $styleSheetFile = '';
119 // Filename of stylesheet #2 - linked to right after the $this->styleSheetFile script (relative to PATH_typo3)
120 var $styleSheetFile2 = '';
121 // Filename of a post-stylesheet - included right after all inline styles.
122 var $styleSheetFile_post = '';
123 // Background image of page (relative to PATH_typo3)
124 var $backGroundImage = '';
125 // Inline css styling set from TBE_STYLES array
126 var $inDocStyles_TBEstyle = '';
129 * Whether to use the X-UA-Compatible meta tag
132 protected $useCompatibilityTag = TRUE
;
135 * X-Ua-Compatible version output in meta tag
138 protected $xUaCompatibilityVersion = 'IE=9';
141 // stylesheets from core
142 protected $stylesheetsCore = array(
143 'structure' => 'stylesheets/structure/',
144 'visual' => 'stylesheets/visual/',
145 'generatedSprites' => '../typo3temp/sprites/',
148 // Include these CSS directories from skins by default
149 protected $stylesheetsSkins = array(
150 'structure' => 'stylesheets/structure/',
151 'visual' => 'stylesheets/visual/',
155 * JavaScript files loaded for every page in the Backend
158 protected $jsFiles = array(
159 'modernizr' => 'contrib/modernizr/modernizr.min.js',
163 // Will output the parsetime of the scripts in milliseconds (for admin-users). Set this to FALSE when releasing TYPO3. Only for dev.
164 var $parseTimeFlag = 0;
167 // Default charset. see function initCharset()
168 var $charset = 'utf-8';
169 // Internal: Indicates if a <div>-output section is open
170 var $sectionFlag = 0;
171 // (Default) Class for wrapping <DIV>-tag of page. Is set in class extensions.
174 var $pageHeaderBlock = '';
175 var $endOfPageJsBlock = '';
177 var $hasDocheader = TRUE
;
180 * @var t3lib_PageRenderer
182 protected $pageRenderer;
183 // Alternative template file
184 protected $pageHeaderFooterTemplateFile = '';
186 protected $extDirectStateProvider = FALSE
;
189 * Whether flashmessages should be rendered or not
191 * @var boolean $showFlashMessages
193 public $showFlashMessages = TRUE
;
195 const STATUS_ICON_ERROR
= 3;
196 const STATUS_ICON_WARNING
= 2;
197 const STATUS_ICON_NOTIFICATION
= 1;
198 const STATUS_ICON_OK
= -1;
202 * Imports relevant parts from global $GLOBALS['TBE_STYLES'] (colorscheme)
204 public function __construct() {
205 // Initializes the page rendering object:
206 $this->getPageRenderer();
208 // Setting default scriptID:
209 if (($temp_M = (string) t3lib_div
::_GET('M')) && $GLOBALS['TBE_MODULES']['_PATHS'][$temp_M]) {
210 $this->scriptID
= preg_replace('/^.*\/(sysext|ext)\//', 'ext/', $GLOBALS['TBE_MODULES']['_PATHS'][$temp_M] . 'index.php');
212 $this->scriptID
= preg_replace('/^.*\/(sysext|ext)\//', 'ext/', substr(PATH_thisScript
, strlen(PATH_site
)));
214 if (TYPO3_mainDir
!='typo3/' && substr($this->scriptID
, 0, strlen(TYPO3_mainDir
)) == TYPO3_mainDir
) {
215 // This fixes if TYPO3_mainDir has been changed so the script ids are STILL "typo3/..."
216 $this->scriptID
= 'typo3/'.substr($this->scriptID
, strlen(TYPO3_mainDir
));
219 $this->bodyTagId
= preg_replace('/[^A-Za-z0-9-]/', '-', $this->scriptID
);
221 // Individual configuration per script? If so, make a recursive merge of the arrays:
222 if (is_array($GLOBALS['TBE_STYLES']['scriptIDindex'][$this->scriptID
])) {
224 $ovr = $GLOBALS['TBE_STYLES']['scriptIDindex'][$this->scriptID
];
226 $GLOBALS['TBE_STYLES'] = t3lib_div
::array_merge_recursive_overrule($GLOBALS['TBE_STYLES'], $ovr);
227 // Have to unset - otherwise the second instantiation will do it again!
228 unset($GLOBALS['TBE_STYLES']['scriptIDindex'][$this->scriptID
]);
232 if ($GLOBALS['TBE_STYLES']['mainColors']['bgColor']) $this->bgColor
=$GLOBALS['TBE_STYLES']['mainColors']['bgColor'];
233 if ($GLOBALS['TBE_STYLES']['mainColors']['bgColor1']) $this->bgColor1
=$GLOBALS['TBE_STYLES']['mainColors']['bgColor1'];
234 if ($GLOBALS['TBE_STYLES']['mainColors']['bgColor2']) $this->bgColor2
=$GLOBALS['TBE_STYLES']['mainColors']['bgColor2'];
235 if ($GLOBALS['TBE_STYLES']['mainColors']['bgColor3']) $this->bgColor3
=$GLOBALS['TBE_STYLES']['mainColors']['bgColor3'];
236 if ($GLOBALS['TBE_STYLES']['mainColors']['bgColor4']) $this->bgColor4
=$GLOBALS['TBE_STYLES']['mainColors']['bgColor4'];
237 if ($GLOBALS['TBE_STYLES']['mainColors']['bgColor5']) $this->bgColor5
=$GLOBALS['TBE_STYLES']['mainColors']['bgColor5'];
238 if ($GLOBALS['TBE_STYLES']['mainColors']['bgColor6']) $this->bgColor6
=$GLOBALS['TBE_STYLES']['mainColors']['bgColor6'];
239 if ($GLOBALS['TBE_STYLES']['mainColors']['hoverColor']) $this->hoverColor
=$GLOBALS['TBE_STYLES']['mainColors']['hoverColor'];
242 if ($GLOBALS['TBE_STYLES']['stylesheet']) $this->styleSheetFile
= $GLOBALS['TBE_STYLES']['stylesheet'];
243 if ($GLOBALS['TBE_STYLES']['stylesheet2']) $this->styleSheetFile2
= $GLOBALS['TBE_STYLES']['stylesheet2'];
244 if ($GLOBALS['TBE_STYLES']['styleSheetFile_post']) $this->styleSheetFile_post
= $GLOBALS['TBE_STYLES']['styleSheetFile_post'];
245 if ($GLOBALS['TBE_STYLES']['inDocStyles_TBEstyle']) $this->inDocStyles_TBEstyle
= $GLOBALS['TBE_STYLES']['inDocStyles_TBEstyle'];
247 // include all stylesheets
248 foreach ($this->getSkinStylesheetDirectories() as $stylesheetDirectory) {
249 $this->addStylesheetDirectory($stylesheetDirectory);
253 if ($GLOBALS['TBE_STYLES']['background']) $this->backGroundImage
= $GLOBALS['TBE_STYLES']['background'];
257 * Gets instance of PageRenderer configured with the current language, file references and debug settings
259 * @return t3lib_PageRenderer
261 public function getPageRenderer() {
262 if (!isset($this->pageRenderer
)) {
263 $this->pageRenderer
= t3lib_div
::makeInstance('t3lib_PageRenderer');
264 $this->pageRenderer
->setTemplateFile(
265 TYPO3_mainDir
. 'templates/template_page_backend.html'
267 $this->pageRenderer
->setLanguage($GLOBALS['LANG']->lang
);
268 $this->pageRenderer
->enableConcatenateFiles();
269 $this->pageRenderer
->enableCompressCss();
270 $this->pageRenderer
->enableCompressJavascript();
272 // Add all JavaScript files defined in $this->jsFiles to the PageRenderer
273 foreach ($this->jsFiles
as $file) {
274 $this->pageRenderer
->addJsFile($GLOBALS['BACK_PATH'] . $file);
277 if (intval($GLOBALS['TYPO3_CONF_VARS']['BE']['debug']) === 1) {
278 $this->pageRenderer
->enableDebugMode();
280 return $this->pageRenderer
;
284 * Sets inclusion of StateProvider
288 public function setExtDirectStateProvider() {
289 $this->extDirectStateProvider
= TRUE
;
292 /*****************************************
294 * EVALUATION FUNCTIONS
295 * Various centralized processing
297 *****************************************/
300 * Makes click menu link (context sensitive menu)
301 * 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)
302 * 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)
304 * @param string $str String to be wrapped in link, typ. image tag.
305 * @param string $table Table name/File path. If the icon is for a database record, enter the tablename from $GLOBALS['TCA']. If a file then enter the absolute filepath
306 * @param integer $uid If icon is for database record this is the UID for the record from $table
307 * @param boolean $listFr Tells the top frame script that the link is coming from a "list" frame which means a frame from within the backend content frame.
308 * @param string $addParams Additional GET parameters for the link to alt_clickmenu.php
309 * @param string $enDisItems 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.
310 * @param boolean $returnOnClick If set, will return only the onclick JavaScript, not the whole link.
311 * @return string The link-wrapped input string.
313 function wrapClickMenuOnIcon($str, $table, $uid = 0, $listFr = TRUE
, $addParams = '', $enDisItems = '', $returnOnClick = FALSE
) {
314 $backPath = rawurlencode($this->backPath
).'|'.t3lib_div
::shortMD5($this->backPath
.'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']);
315 $onClick = 'showClickmenu("' . $table . '","' . ($uid !== 0 ?
$uid : '') . '","' . strval($listFr) . '","' . str_replace('+', '%2B', $enDisItems) . '","' . str_replace('&', '&', addcslashes($backPath, '"')) . '","' . str_replace('&', '&', addcslashes($addParams, '"')) . '");return false;';
316 return $returnOnClick ?
$onClick : '<a href="#" onclick="'.htmlspecialchars($onClick).'" oncontextmenu="'.htmlspecialchars($onClick).'">'.$str.'</a>';
320 * Makes link to page $id in frontend (view page)
321 * Returns an magnifier-glass icon which links to the frontend index.php document for viewing the page with id $id
322 * $id must be a page-uid
323 * If the BE_USER has access to Web>List then a link to that module is shown as well (with return-url)
325 * @param integer $id The page id
326 * @param string $backPath The current "BACK_PATH" (the back relative to the typo3/ directory)
327 * @param string $addParams Additional parameters for the image tag(s)
328 * @return string HTML string with linked icon(s)
330 function viewPageIcon($id, $backPath, $addParams = 'hspace="3"') {
332 // If access to Web>List for user, then link to that module.
333 $str = t3lib_BEfunc
::getListViewLink(
336 'returnUrl' => t3lib_div
::getIndpEnv('REQUEST_URI'),
338 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showList')
341 // Make link to view page
342 $str.= '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc
::viewOnClick($id, $backPath, t3lib_BEfunc
::BEgetRootLine($id))).'">'.
343 '<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="" />' .
349 * Returns a URL with a command to TYPO3 Core Engine (tce_db.php)
350 * See description of the API elsewhere.
352 * @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"
353 * @param string $redirectUrl Redirect URL if any other that t3lib_div::getIndpEnv('REQUEST_URI') is wished
354 * @return string URL to tce_db.php + parameters (backpath is taken from $this->backPath)
355 * @see t3lib_BEfunc::editOnClick()
357 function issueCommand($params, $redirectUrl = '') {
358 $redirectUrl = $redirectUrl ?
$redirectUrl : t3lib_div
::getIndpEnv('REQUEST_URI');
359 $commandUrl = $this->backPath
.'tce_db.php?' .
361 '&redirect=' . ($redirectUrl == -1 ?
"'+T3_THIS_LOCATION+'" : rawurlencode($redirectUrl)) .
362 '&vC='.rawurlencode($GLOBALS['BE_USER']->veriCode()) .
363 t3lib_BEfunc
::getUrlToken('tceAction') .
370 * Returns TRUE if click-menu layers can be displayed for the current user/browser
371 * Use this to test if click-menus (context sensitive menus) can and should be displayed in the backend.
374 * @deprecated since TYPO3 4.7, will be removed in TYPO3 6.1 - This function makes no sense anymore
376 function isCMlayers() {
377 t3lib_div
::logDeprecatedFunction();
378 return !$GLOBALS['BE_USER']->uc
['disableCMlayers'] && $GLOBALS['CLIENT']['FORMSTYLE'] && !($GLOBALS['CLIENT']['SYSTEM']=='mac' && $GLOBALS['CLIENT']['BROWSER']=='Opera');
382 * Makes the header (icon+title) for a page (or other record). Used in most modules under Web>*
383 * $table and $row must be a tablename/record from that table
384 * $path will be shown as alt-text for the icon.
385 * The title will be truncated to 45 chars.
387 * @param string $table Table name
388 * @param array $row Record row
389 * @param string $path Alt text
390 * @param boolean $noViewPageIcon Set $noViewPageIcon TRUE if you don't want a magnifier-icon for viewing the page in the frontend
391 * @param array $tWrap is an array with indexes 0 and 1 each representing HTML-tags (start/end) which will wrap the title
392 * @return string HTML content
394 function getHeader($table, $row, $path, $noViewPageIcon = FALSE
, $tWrap = array('', '')) {
396 if (is_array($row) && $row['uid']) {
397 $iconImgTag = t3lib_iconWorks
::getSpriteIconForRecord($table, $row, array('title' => htmlspecialchars($path)));
398 $title = strip_tags(t3lib_BEfunc
::getRecordTitle($table, $row));
399 $viewPage = $noViewPageIcon ?
'' : $this->viewPageIcon($row['uid'], $this->backPath
, '');
400 if ($table == 'pages')
401 $path .= ' - ' . t3lib_BEfunc
::titleAttribForPages($row, '', 0);
403 $iconImgTag = t3lib_iconWorks
::getSpriteIcon('apps-pagetree-page-domain', array('title' => htmlspecialchars($path)));
404 $title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
407 return '<span class="typo3-moduleHeader">' .
408 $this->wrapClickMenuOnIcon($iconImgTag, $table, $row['uid']) .
410 $tWrap[0] . htmlspecialchars(t3lib_div
::fixed_lgd_cs($title, 45)) . $tWrap[1] .
415 * Like ->getHeader() but for files in the File>* main module/submodules
416 * Returns the file-icon with the path of the file set in the alt/title attribute. Shows the file-name after the icon.
418 * @param string $title Title string, expected to be the filepath
419 * @param string $path Alt text
420 * @param string $iconfile The icon file (relative to TYPO3 dir)
421 * @return string HTML content
423 function getFileheader($title, $path, $iconfile) {
424 $fileInfo = t3lib_div
::split_fileref($title);
425 $title = htmlspecialchars(t3lib_div
::fixed_lgd_cs($fileInfo['path'], -35)).'<strong>'.htmlspecialchars($fileInfo['file']).'</strong>';
426 return '<span class="typo3-moduleHeader"><img'.t3lib_iconWorks
::skinImg($this->backPath
, $iconfile, 'width="18" height="16"').' title="'.htmlspecialchars($path).'" alt="" />'.$title.'</span>';
430 * Returns a linked shortcut-icon which will call the shortcut frame and set a shortcut there back to the calling page/module
432 * @param string $gvList Is the list of GET variables to store (if any)
433 * @param string $setList Is the list of SET[] variables to store (if any) - SET[] variables a stored in $GLOBALS["SOBE"]->MOD_SETTINGS for backend modules
434 * @param string $modName Module name string
435 * @param string $motherModName 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.
436 * @return string HTML content
438 function makeShortcutIcon($gvList, $setList, $modName, $motherModName = '') {
439 $backPath=$this->backPath
;
440 $storeUrl=$this->makeShortcutUrl($gvList, $setList);
441 $pathInfo = parse_url(t3lib_div
::getIndpEnv('REQUEST_URI'));
443 // Add the module identifier automatically if typo3/mod.php is used:
444 if (preg_match('/typo3\/mod\.php$/', $pathInfo['path']) && isset($GLOBALS['TBE_MODULES']['_PATHS'][$modName])) {
445 $storeUrl = '&M='.$modName.$storeUrl;
448 if (!strcmp($motherModName, '1')) {
449 $mMN="&motherModName='+top.currentModuleLoaded+'";
450 } elseif ($motherModName) {
451 $mMN='&motherModName='.rawurlencode($motherModName);
454 $onClick = 'top.ShortcutManager.createShortcut('
455 .$GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.makeBookmark')).', '
456 .'\''.$backPath.'\', '
457 .'\''.rawurlencode($modName).'\', '
458 . '\'' . rawurlencode($pathInfo['path'] . '?' . $storeUrl) . $mMN . '\''
461 $sIcon = '<a href="#" onclick="' . htmlspecialchars($onClick).'" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.makeBookmark', TRUE
) . '">'
462 . t3lib_iconworks
::getSpriteIcon('actions-system-shortcut-new') . '</a>';
467 * MAKE url for storing
470 * @param string $gvList Is the list of GET variables to store (if any)
471 * @param string $setList Is the list of SET[] variables to store (if any) - SET[] variables a stored in $GLOBALS["SOBE"]->MOD_SETTINGS for backend modules
474 * @see makeShortcutIcon()
476 function makeShortcutUrl($gvList, $setList) {
477 $GET = t3lib_div
::_GET();
478 $storeArray = array_merge(
479 t3lib_div
::compileSelectedGetVarsFromArray($gvList, $GET),
480 array('SET' => t3lib_div
::compileSelectedGetVarsFromArray($setList, (array)$GLOBALS['SOBE']->MOD_SETTINGS
))
482 $storeUrl = t3lib_div
::implodeArrayForUrl('', $storeArray);
487 * Returns <input> attributes to set the width of an text-type input field.
488 * For client browsers with no CSS support the cols/size attribute is returned.
489 * For CSS compliant browsers (recommended) a ' style="width: ...px;"' is returned.
491 * @param integer $size A relative number which multiplied with approx. 10 will lead to the width in pixels
492 * @param boolean $textarea A flag you can set for textareas - DEPRECATED, use ->formWidthText() for textareas!!!
493 * @param string $styleOverride A string which will be returned as attribute-value for style="" instead of the calculated width (if CSS is enabled)
494 * @return string Tag attributes for an <input> tag (regarding width)
495 * @see formWidthText()
497 function formWidth($size = 48, $textarea = FALSE
, $styleOverride = '') {
498 $wAttrib = $textarea?
'cols':'size';
499 // If not setting the width by style-attribute
500 if (!$GLOBALS['CLIENT']['FORMSTYLE']) {
501 $retVal = ' '.$wAttrib.'="'.$size.'"';
502 } else { // Setting width by style-attribute. 'cols' MUST be avoided with NN6+
503 $pixels = ceil($size*$this->form_rowsToStylewidth
);
504 $retVal = $styleOverride ?
' style="'.$styleOverride.'"' : ' style="width:'.$pixels.'px;"';
510 * This function is dedicated to textareas, which has the wrapping on/off option to observe.
512 * <textarea rows="10" wrap="off" '.$GLOBALS["TBE_TEMPLATE"]->formWidthText(48, "", "off").'>
514 * <textarea rows="10" wrap="virtual" '.$GLOBALS["TBE_TEMPLATE"]->formWidthText(48, "", "virtual").'>
516 * @param integer $size A relative number which multiplied with approx. 10 will lead to the width in pixels
517 * @param string $styleOverride A string which will be returned as attribute-value for style="" instead of the calculated width (if CSS is enabled)
518 * @param string $wrap 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.
519 * @return string Tag attributes for an <input> tag (regarding width)
522 function formWidthText($size = 48, $styleOverride = '', $wrap = '') {
523 $wTags = $this->formWidth($size, 1, $styleOverride);
524 // 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...
525 if (strtolower(trim($wrap)) != 'off' && $GLOBALS['CLIENT']['BROWSER']=='net' && $GLOBALS['CLIENT']['VERSION'] >= 5) {
526 $wTags .= ' cols="'.$size.'"';
532 * Returns JavaScript variables setting the returnUrl and thisScript location for use by JavaScript on the page.
533 * Used in fx. db_list.php (Web>List)
535 * @param string $thisLocation URL to "this location" / current script
536 * @return string Urls are returned as JavaScript variables T3_RETURN_URL and T3_THIS_LOCATION
537 * @see typo3/db_list.php
539 function redirectUrls($thisLocation = '') {
540 $thisLocation = $thisLocation?
$thisLocation:t3lib_div
::linkThisScript(
549 var T3_RETURN_URL = '".str_replace('%20', '', rawurlencode(t3lib_div
::sanitizeLocalUrl(t3lib_div
::_GP('returnUrl'))))."';
550 var T3_THIS_LOCATION = '".str_replace('%20', '', rawurlencode($thisLocation))."';
556 * Returns a formatted string of $tstamp
557 * Uses $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'] and $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] to format date and time
559 * @param integer $tstamp UNIX timestamp, seconds since 1970
560 * @param integer $type How much data to show: $type = 1: hhmm, $type = 10: ddmmmyy
561 * @return string Formatted timestamp
563 function formatTime($tstamp, $type) {
566 case 1: $dateStr = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'], $tstamp);
568 case 10: $dateStr = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $tstamp);
575 * Returns script parsetime IF ->parseTimeFlag is set and user is "admin"
576 * Automatically outputted in page end
578 * @return string HTML formated with <p>-tags
580 function parseTime() {
581 if ($this->parseTimeFlag
&& $GLOBALS['BE_USER']->isAdmin()) {
582 return '<p>(ParseTime: '.(t3lib_div
::milliseconds()-$GLOBALS['PARSETIME_START']).' ms</p>
583 <p>REQUEST_URI-length: '.strlen(t3lib_div
::getIndpEnv('REQUEST_URI')).')</p>';
588 * Defines whether to use the X-UA-Compatible meta tag.
590 * @param boolean $useCompatibilityTag Whether to use the tag
593 public function useCompatibilityTag($useCompatibilityTag = TRUE
) {
594 $this->useCompatibilityTag
= (bool
) $useCompatibilityTag;
597 /*****************************************
599 * PAGE BUILDING FUNCTIONS.
600 * Use this to build the HTML of your backend modules
602 *****************************************/
606 * This includes the proper header with charset, title, meta tag and beginning body-tag.
608 * @param string $title HTML Page title for the header
609 * @param boolean $includeCsh flag for including CSH
610 * @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)
613 function startPage($title, $includeCsh = TRUE
) {
614 // hook pre start page
615 if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preStartPageHook'])) {
616 $preStartPageHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preStartPageHook'];
617 if (is_array($preStartPageHook)) {
618 $hookParameters = array(
621 foreach ($preStartPageHook as $hookFunction) {
622 t3lib_div
::callUserFunction($hookFunction, $hookParameters, $this);
627 $this->pageRenderer
->backPath
= $this->backPath
;
629 // alternative template for Header and Footer
630 if ($this->pageHeaderFooterTemplateFile
) {
631 $file = t3lib_div
::getFileAbsFileName($this->pageHeaderFooterTemplateFile
, TRUE
);
633 $this->pageRenderer
->setTemplateFile($file);
637 // Send HTTP header for selected charset. Added by Robert Lemke 23.10.2003
638 $this->initCharset();
639 header('Content-Type:text/html;charset='.$this->charset
);
642 $htmlTag = '<html xmlns="http://www.w3.org/1999/xhtml">';
644 switch($this->docType
) {
646 $headerStart = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">';
648 // Disable rendering of XHTML tags
649 $this->getPageRenderer()->setRenderXhtml(FALSE
);
652 $headerStart = '<!DOCTYPE html
653 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
654 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
657 $headerStart = '<!DOCTYPE html
658 PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
659 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">';
662 $headerStart = '<!DOCTYPE html
663 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
664 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
668 // The fallthrough is intended as HTML5, as this is the default for the BE since TYPO3 4.5
669 $headerStart = '<!DOCTYPE html>' . LF
;
671 // Disable rendering of XHTML tags
672 $this->getPageRenderer()->setRenderXhtml(FALSE
);
676 $this->pageRenderer
->setHtmlTag($htmlTag);
678 // This loads the tabulator-in-textarea feature. It automatically modifies
679 // every textarea which is found.
680 if (!$GLOBALS['BE_USER']->uc
['disableTabInTextarea']) {
681 $this->loadJavascriptLib('tab.js');
684 // Include the JS for the Context Sensitive Help
686 $this->loadCshJavascript();
689 // Get the browser info
690 $browserInfo = t3lib_utility_Client
::getBrowserInfo(t3lib_div
::getIndpEnv('HTTP_USER_AGENT'));
692 // Set the XML prologue
693 $xmlPrologue = '<?xml version="1.0" encoding="' . $this->charset
. '"?>';
695 // Set the XML stylesheet
696 $xmlStylesheet = '<?xml-stylesheet href="#internalStyle" type="text/css"?>';
698 // Add the XML prologue for XHTML doctypes
699 if (strpos($this->docType
, 'xhtml') !== FALSE
) {
700 // Put the XML prologue before or after the doctype declaration according to browser
701 if ($browserInfo['browser'] === 'msie' && $browserInfo['version'] < 7) {
702 $headerStart = $headerStart . LF
. $xmlPrologue;
704 $headerStart = $xmlPrologue . LF
. $headerStart;
707 // Add the xml stylesheet according to doctype
708 if ($this->docType
!== 'xhtml_frames') {
709 $headerStart = $headerStart . LF
. $xmlStylesheet;
713 $this->pageRenderer
->setXmlPrologAndDocType($headerStart);
714 $this->pageRenderer
->setHeadTag('<head>' . LF
. '<!-- TYPO3 Script ID: '.htmlspecialchars($this->scriptID
).' -->');
715 $this->pageRenderer
->setCharSet($this->charset
);
716 $this->pageRenderer
->addMetaTag($this->generator());
717 $this->pageRenderer
->addMetaTag('<meta name="robots" content="noindex,follow" />');
718 if ($this->useCompatibilityTag
) {
719 $this->pageRenderer
->addMetaTag($this->xUaCompatible($this->xUaCompatibilityVersion
));
721 $this->pageRenderer
->setTitle($title);
726 if ($this->extDirectStateProvider
) {
727 $this->pageRenderer
->addJsFile($this->backPath
. '../t3lib/js/extjs/ExtDirect.StateProvider.js');
730 // Add jsCode for overriding the console with a debug panel connection
731 $this->pageRenderer
->addJsInlineCode(
732 'consoleOverrideWithDebugPanel',
733 'if (typeof top.Ext === "object") {
734 top.Ext.onReady(function() {
735 if (typeof console === "undefined") {
736 if (top && top.TYPO3 && top.TYPO3.Backend && top.TYPO3.Backend.DebugConsole) {
737 console = top.TYPO3.Backend.DebugConsole;
753 $this->pageRenderer
->addHeaderData($this->JScode
);
755 foreach ($this->JScodeArray
as $name => $code) {
756 $this->pageRenderer
->addJsInlineCode($name, $code, FALSE
);
759 if (count($this->JScodeLibArray
)) {
760 foreach($this->JScodeLibArray
as $library) {
761 $this->pageRenderer
->addHeaderData($library);
765 if ($this->extJScode
) {
766 $this->pageRenderer
->addExtOnReadyCode($this->extJScode
);
769 // hook for additional headerData
770 if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preHeaderRenderHook'])) {
771 $preHeaderRenderHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preHeaderRenderHook'];
772 if (is_array($preHeaderRenderHook)) {
773 $hookParameters = array(
774 'pageRenderer' => &$this->pageRenderer
,
776 foreach ($preHeaderRenderHook as $hookFunction) {
777 t3lib_div
::callUserFunction($hookFunction, $hookParameters, $this);
782 // Construct page header.
783 $str = $this->pageRenderer
->render(t3lib_PageRenderer
::PART_HEADER
);
785 $this->JScodeLibArray
= array();
786 $this->JScode
= $this->extJScode
= '';
787 $this->JScodeArray
= array();
789 $this->endOfPageJsBlock
= $this->pageRenderer
->render(t3lib_PageRenderer
::PART_FOOTER
);
791 if ($this->docType
== 'xhtml_frames') {
794 $str .= $this->docBodyTagBegin().
798 <!-- Wrapping DIV-section for whole page BEGIN -->
799 <div class="' . $this->divClass
. '">
801 : '' ) . trim($this->form
);
806 * Returns page end; This includes finishing form, div, body and html tags.
808 * @return string The HTML end of a page
812 $str = $this->sectionEnd().
815 $this->wrapScriptTags(t3lib_BEfunc
::getUpdateSignalCode()).
819 // If something is in buffer like debug, put it to end of page
820 if (ob_get_contents()) {
821 $str .= ob_get_clean();
822 if (!headers_sent()) {
823 header('Content-Encoding: None');
827 if ($this->docType
!== 'xhtml_frames') {
829 $str .= ($this->divClass?
'
831 <!-- Wrapping DIV-section for whole page END -->
832 </div>':'') . $this->endOfPageJsBlock
;
836 // Logging: Can't find better place to put it:
837 if (TYPO3_DLOG
) t3lib_div
::devLog('END of BACKEND session', 'template', 0, array('_FLUSH' => TRUE
));
843 * Shortcut for render the complete page of a module
845 * @param string $title page title
846 * @param string $content page content
847 * @param boolean $includeCsh flag for including csh code
848 * @return string complete page
850 public function render($title, $content, $includeCsh = TRUE
) {
851 $pageContent = $this->startPage($title, $includeCsh);
852 $pageContent .= $content;
853 $pageContent .= $this->endPage();
855 return $this->insertStylesAndJS($pageContent);
859 * Returns the header-bar in the top of most backend modules
860 * Closes section if open.
862 * @param string $text The text string for the header
863 * @return string HTML content
865 function header($text) {
868 <!-- MAIN Header in page top -->
869 <h2>'.htmlspecialchars($text).'</h2>
871 return $this->sectionEnd().$str;
875 * Begins an output section and sets header and content
877 * @param string $label The header
878 * @param string $text The HTML-content
879 * @param boolean $nostrtoupper A flag that will prevent the header from being converted to uppercase
880 * @param boolean $sH Defines the type of header (if set, "<h3>" rather than the default "h4")
881 * @param integer $type The number of an icon to show with the header (see the icon-function). -1,1,2,3
882 * @param boolean $allowHTMLinHeader If set, HTML tags are allowed in $label (otherwise this value is by default htmlspecialchars()'ed)
883 * @return string HTML content
884 * @see icons(), sectionHeader()
886 function section($label, $text, $nostrtoupper = FALSE
, $sH = FALSE
, $type = 0, $allowHTMLinHeader = FALSE
) {
891 if (!$allowHTMLinHeader) $label = htmlspecialchars($label);
892 $str.=$this->sectionHeader($this->icons($type).$label, $sH, $nostrtoupper ?
'' : ' class="uppercase"');
897 <!-- Section content -->
900 return $this->sectionBegin().$str;
904 * Inserts a divider image
905 * Ends a section (if open) before inserting the image
907 * @param integer $dist The margin-top/-bottom of the <hr> ruler.
908 * @return string HTML content
910 function divider($dist) {
911 $dist = intval($dist);
915 <hr style="margin-top: '.$dist.'px; margin-bottom: '.$dist.'px;" />
917 return $this->sectionEnd().$str;
921 * Returns a blank <div>-section with a height
923 * @param integer $dist Padding-top for the div-section (should be margin-top but konqueror (3.1) doesn't like it :-(
924 * @return string HTML content
926 function spacer($dist) {
930 <!-- Spacer element -->
931 <div style="padding-top: '.intval($dist).'px;"></div>
937 * Make a section header.
938 * Begins a section if not already open.
940 * @param string $label The label between the <h3> or <h4> tags. (Allows HTML)
941 * @param boolean $sH If set, <h3> is used, otherwise <h4>
942 * @param string $addAttrib Additional attributes to h-tag, eg. ' class=""'
943 * @return string HTML content
945 function sectionHeader($label, $sH = FALSE
, $addAttrib = '') {
946 $tag = ($sH ?
'h3' : 'h4');
947 if ($addAttrib && substr($addAttrib, 0, 1) !== ' ') {
948 $addAttrib = ' ' . $addAttrib;
952 <!-- Section header -->
953 <' . $tag . $addAttrib . '>' . $label . '</' . $tag . '>
955 return $this->sectionBegin() . $str;
959 * Begins an output section.
960 * Returns the <div>-begin tag AND sets the ->sectionFlag TRUE (if the ->sectionFlag is not already set!)
961 * 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!
963 * @return string HTML content
965 function sectionBegin() {
966 if (!$this->sectionFlag
) {
967 $this->sectionFlag
=1;
970 <!-- ***********************
971 Begin output section.
972 *********************** -->
980 * Ends and output section
981 * Returns the </div>-end tag AND clears the ->sectionFlag (but does so only IF the sectionFlag is set - that is a section is 'open')
982 * See sectionBegin() also.
984 * @return string HTML content
986 function sectionEnd() {
987 if ($this->sectionFlag
) {
988 $this->sectionFlag
=0;
991 <!-- *********************
993 ********************* -->
999 * If a form-tag is defined in ->form then and end-tag for that <form> element is outputted
1000 * Further a JavaScript section is outputted which will update the top.busy session-expiry object (unless $this->endJS is set to FALSE)
1002 * @return string HTML content (<script> tag section)
1004 function endPageJS() {
1005 return ($this->endJS?
'
1006 <script type="text/javascript">
1008 if (top.busy && top.busy.loginRefreshed) {
1009 top.busy.loginRefreshed();
1016 * Creates the bodyTag.
1017 * You can add to the bodyTag by $this->bodyTagAdditions
1019 * @return string HTML body tag
1021 function docBodyTagBegin() {
1022 $bodyContent = 'body onclick="if (top.menuReset) top.menuReset();" '.trim($this->bodyTagAdditions
.($this->bodyTagId ?
' id="'.$this->bodyTagId
.'"' : ''));
1023 return '<'.trim($bodyContent).'>';
1027 * Outputting document style
1029 * @return string HTML style section/link tags
1031 function docStyle() {
1033 // Request background image:
1034 if ($this->backGroundImage
) {
1035 $this->inDocStylesArray
[]=' BODY { background-image: url('.$this->backPath
.$this->backGroundImage
.'); }';
1038 // Add inDoc styles variables as well:
1039 $this->inDocStylesArray
[] = $this->inDocStyles
;
1040 $this->inDocStylesArray
[] = $this->inDocStyles_TBEstyle
;
1043 $inDocStyles = implode(LF
, $this->inDocStylesArray
);
1045 if ($this->styleSheetFile
) {
1046 $this->pageRenderer
->addCssFile($this->backPath
. $this->styleSheetFile
);
1048 if ($this->styleSheetFile2
) {
1049 $this->pageRenderer
->addCssFile($this->backPath
. $this->styleSheetFile2
);
1052 $this->pageRenderer
->addCssInlineBlock('inDocStyles', $inDocStyles . LF
. '/*###POSTCSSMARKER###*/');
1053 if ($this->styleSheetFile_post
) {
1054 $this->pageRenderer
->addCssFile($this->backPath
. $this->styleSheetFile_post
);
1060 * Insert additional style sheet link
1062 * @param string $key some key identifying the style sheet
1063 * @param string $href uri to the style sheet file
1064 * @param string $title value for the title attribute of the link element
1065 * @param string $relation value for the rel attribute of the link element
1068 function addStyleSheet($key, $href, $title = '', $relation = 'stylesheet') {
1069 if (strpos($href, '://') !== FALSE ||
substr($href, 0, 1) === '/') {
1072 $file = $this->backPath
. $href;
1074 $this->pageRenderer
->addCssFile($file, $relation, 'screen', $title);
1078 * Add all *.css files of the directory $path to the stylesheets
1080 * @param string $path directory to add
1083 function addStyleSheetDirectory($path) {
1084 // Calculation needed, when TYPO3 source is used via a symlink
1085 // absolute path to the stylesheets
1086 $filePath = dirname(t3lib_div
::getIndpEnv('SCRIPT_FILENAME')) . '/' . $GLOBALS['BACK_PATH'] . $path;
1088 $resolvedPath = t3lib_div
::resolveBackPath($filePath);
1089 // Read all files in directory and sort them alphabetically
1090 $files = t3lib_div
::getFilesInDir($resolvedPath, 'css', FALSE
, 1);
1091 foreach ($files as $file) {
1092 $this->pageRenderer
->addCssFile($GLOBALS['BACK_PATH'] . $path . $file, 'stylesheet', 'all');
1097 * Insert post rendering document style into already rendered content
1098 * This is needed for extobjbase
1100 * @param string $content style-content to insert.
1101 * @return string content with inserted styles
1103 function insertStylesAndJS($content) {
1104 // Insert accumulated CSS
1105 $this->inDocStylesArray
[] = $this->inDocStyles
;
1106 $styles = LF
.implode(LF
, $this->inDocStylesArray
);
1107 $content = str_replace('/*###POSTCSSMARKER###*/', $styles, $content);
1109 // Insert accumulated JS
1110 $jscode = $this->JScode
.LF
.$this->wrapScriptTags(implode(LF
, $this->JScodeArray
));
1111 $content = str_replace('<!--###POSTJSMARKER###-->', $jscode, $content);
1117 * Returns an array of all stylesheet directories belonging to core and skins
1119 * @return array Stylesheet directories
1121 public function getSkinStylesheetDirectories() {
1122 $stylesheetDirectories = array();
1124 // Add default core stylesheets
1125 foreach ($this->stylesheetsCore
as $stylesheetDir) {
1126 $stylesheetDirectories[] = $stylesheetDir;
1129 // Stylesheets from skins
1130 // merge default css directories ($this->stylesheetsSkin) with additional ones and include them
1131 if (is_array($GLOBALS['TBE_STYLES']['skins'])) {
1132 // loop over all registered skins
1133 foreach ($GLOBALS['TBE_STYLES']['skins'] as $skinExtKey => $skin) {
1134 $skinStylesheetDirs = $this->stylesheetsSkins
;
1136 // Skins can add custom stylesheetDirectories using
1137 // $GLOBALS['TBE_STYLES']['skins'][$_EXTKEY]['stylesheetDirectories']
1138 if (is_array($skin['stylesheetDirectories'])) {
1139 $skinStylesheetDirs = array_merge($skinStylesheetDirs, $skin['stylesheetDirectories']);
1142 // Add all registered directories
1143 foreach ($skinStylesheetDirs as $stylesheetDir) {
1144 // for EXT:myskin/stylesheets/ syntax
1145 if (substr($stylesheetDir, 0, 4) === 'EXT:') {
1146 list($extKey, $path) = explode('/', substr($stylesheetDir, 4), 2);
1147 if (strcmp($extKey, '') && t3lib_extMgm
::isLoaded($extKey) && strcmp($path, '')) {
1148 $stylesheetDirectories[] = t3lib_extMgm
::extRelPath($extKey) . $path;
1151 // For relative paths
1152 $stylesheetDirectories[] = t3lib_extMgm
::extRelPath($skinExtKey) . $stylesheetDir;
1157 return $stylesheetDirectories;
1161 * Initialize the charset.
1162 * Sets the internal $this->charset variable to the charset defined in $GLOBALS["LANG"] (or the default as set in this class)
1163 * Returns the meta-tag for the document header
1165 * @return string <meta> tag with charset from $this->charset or $GLOBALS['LANG']->charSet
1167 function initCharset() {
1168 // Set charset to the charset provided by the current backend users language selection:
1169 $this->charset
= $GLOBALS['LANG']->charSet ?
$GLOBALS['LANG']->charSet
: $this->charset
;
1171 return '<meta http-equiv="Content-Type" content="text/html; charset='.$this->charset
.'" />';
1175 * Returns generator meta tag
1177 * @return string <meta> tag with name "generator"
1179 function generator() {
1180 $str = 'TYPO3 '.TYPO3_branch
.', ' . TYPO3_URL_GENERAL
. ', © Kasper Skårhøj ' . TYPO3_copyright_year
. ', extensions are copyright of their respective owners.';
1181 return '<meta name="generator" content="'.$str .'" />';
1185 * Returns X-UA-Compatible meta tag
1187 * @param string $content Content of the compatible tag (default: IE-8)
1188 * @return string <meta http-equiv="X-UA-Compatible" content="???" />
1190 public function xUaCompatible($content = 'IE=8') {
1191 return '<meta http-equiv="X-UA-Compatible" content="' . $content . '" />';
1194 /*****************************************
1197 * Tables, buttons, formatting dimmed/red strings
1199 ******************************************/
1202 * Returns an image-tag with an 18x16 icon of the following types:
1205 * -1: OK icon (Check-mark)
1206 * 1: Notice (Speach-bubble)
1207 * 2: Warning (Yellow triangle)
1208 * 3: Fatal error (Red stop sign)
1210 * @param integer $type See description
1211 * @param string $styleAttribValue Value for style attribute
1212 * @return string HTML image tag (if applicable)
1214 function icons($type, $styleAttribValue = '') {
1216 case self
::STATUS_ICON_ERROR
:
1217 $icon = 'status-dialog-error';
1219 case self
::STATUS_ICON_WARNING
:
1220 $icon = 'status-dialog-warning';
1222 case self
::STATUS_ICON_NOTIFICATION
:
1223 $icon = 'status-dialog-notification';
1225 case self
::STATUS_ICON_OK
:
1226 $icon = 'status-dialog-ok';
1232 return t3lib_iconWorks
::getSpriteIcon($icon);
1237 * Returns an <input> button with the $onClick action and $label
1239 * @param string $onClick The value of the onclick attribute of the input tag (submit type)
1240 * @param string $label The label for the button (which will be htmlspecialchar'ed)
1241 * @return string A <input> tag of the type "submit"
1243 function t3Button($onClick, $label) {
1244 $button = '<input type="submit" onclick="'.htmlspecialchars($onClick).'; return false;" value="'.htmlspecialchars($label).'" />';
1249 * Dimmed-fontwrap. Returns the string wrapped in a <span>-tag defining the color to be gray/dimmed
1251 * @param string $string Input string
1252 * @return string Output string
1254 function dfw($string) {
1255 return '<span class="typo3-dimmed">'.$string.'</span>';
1259 * red-fontwrap. Returns the string wrapped in a <span>-tag defining the color to be red
1261 * @param string $string Input string
1262 * @return string Output string
1264 function rfw($string) {
1265 return '<span class="typo3-red">'.$string.'</span>';
1269 * Returns string wrapped in CDATA "tags" for XML / XHTML (wrap content of <script> and <style> sections in those!)
1271 * @param string $string Input string
1272 * @return string Output string
1274 function wrapInCData($string) {
1275 $string = '/*<![CDATA[*/'.
1283 * Wraps the input string in script tags.
1284 * Automatic re-identing of the JS code is done by using the first line as ident reference.
1285 * This is nice for identing JS code with PHP code on the same level.
1287 * @param string $string Input string
1288 * @param boolean $linebreak Wrap script element in linebreaks? Default is TRUE.
1289 * @return string Output string
1291 function wrapScriptTags($string, $linebreak = TRUE
) {
1292 if (trim($string)) {
1293 // <script wrapped in nl?
1294 $cr = $linebreak? LF
: '';
1296 // Remove nl from the beginning
1297 $string = preg_replace ('/^\n+/', '', $string);
1298 // Re-ident to one tab using the first line as reference
1300 if (preg_match('/^(\t+)/', $string, $match)) {
1301 $string = str_replace($match[1], TAB
, $string);
1303 $string = $cr.'<script type="text/javascript">
1309 return trim($string);
1312 // These vars defines the layout for the table produced by the table() function.
1313 // You can override these values from outside if you like.
1314 var $tableLayout = array(
1316 'defCol' => array('<td valign="top">', '</td>')
1319 var $table_TR = '<tr>';
1320 var $table_TABLE = '<table border="0" cellspacing="0" cellpadding="0" class="typo3-dblist" id="typo3-tmpltable">';
1323 * Returns a table based on the input $data
1325 * @param array $data Multidim array with first levels = rows, second levels = cells
1326 * @param array $layout If set, then this provides an alternative layout array instead of $this->tableLayout
1327 * @return string The HTML table.
1330 function table($data, $layout = NULL
) {
1332 if (is_array($data)) {
1333 $tableLayout = (is_array($layout) ?
$layout : $this->tableLayout
);
1336 foreach ($data as $tableRow) {
1337 if ($rowCount %
2) {
1338 $layout = is_array($tableLayout['defRowOdd']) ?
$tableLayout['defRowOdd'] : $tableLayout['defRow'];
1340 $layout = is_array($tableLayout['defRowEven']) ?
$tableLayout['defRowEven'] : $tableLayout['defRow'];
1342 $rowLayout = is_array($tableLayout[$rowCount]) ?
$tableLayout[$rowCount] : $layout;
1344 if (is_array($tableRow)) {
1346 foreach ($tableRow as $tableCell) {
1347 $cellWrap = (is_array($layout[$cellCount]) ?
$layout[$cellCount] : $layout['defCol']);
1348 $cellWrap = (is_array($rowLayout['defCol']) ?
$rowLayout['defCol'] : $cellWrap);
1349 $cellWrap = (is_array($rowLayout[$cellCount]) ?
$rowLayout[$cellCount] : $cellWrap);
1350 $rowResult .= $cellWrap[0] . $tableCell . $cellWrap[1];
1354 $rowWrap = (is_array($layout['tr']) ?
$layout['tr'] : array($this->table_TR
, '</tr>'));
1355 $rowWrap = (is_array($rowLayout['tr']) ?
$rowLayout['tr'] : $rowWrap);
1356 $result .= $rowWrap[0] . $rowResult . $rowWrap[1];
1359 $tableWrap = is_array($tableLayout['table']) ?
$tableLayout['table'] : array($this->table_TABLE
, '</table>');
1360 $result = $tableWrap[0] . $result . $tableWrap[1];
1366 * Constructs a table with content from the $arr1, $arr2 and $arr3.
1367 * Used in eg. ext/belog/mod/index.php - refer to that for examples
1369 * @param array $arr1 Menu elements on first level
1370 * @param array $arr2 Secondary items
1371 * @param array $arr3 Third-level items
1372 * @return string HTML content, <table>...</table>
1374 function menuTable($arr1, $arr2 = array(), $arr3 = array()) {
1375 $rows = max(array(count($arr1), count($arr2), count($arr3)));
1378 <table border="0" cellpadding="0" cellspacing="0" id="typo3-tablemenu">';
1379 for ($a = 0; $a < $rows; $a++
) {
1383 $cls[] = '<td valign="'.$valign.'">'.$arr1[$a][0].'</td><td>'.$arr1[$a][1].'</td>';
1385 $cls[] = '<td valign="'.$valign.'">'.$arr2[$a][0].'</td><td>'.$arr2[$a][1].'</td>';
1387 $cls[] = '<td valign="'.$valign.'">'.$arr3[$a][0].'</td><td>'.$arr3[$a][1].'</td>';
1390 $menu .= implode($cls, '<td> </td>');
1400 * Returns a one-row/two-celled table with $content and $menu side by side.
1401 * The table is a 100% width table and each cell is aligned left / right
1403 * @param string $content Content cell content (left)
1404 * @param string $menu Menu cell content (right)
1405 * @return string HTML output
1407 function funcMenu($content, $menu) {
1409 <table border="0" cellpadding="0" cellspacing="0" width="100%" id="typo3-funcmenu">
1411 <td valign="top" nowrap="nowrap">'.$content.'</td>
1412 <td valign="top" align="right" nowrap="nowrap">'.$menu.'</td>
1419 * Includes a javascript library that exists in the core /typo3/ directory. The
1420 * backpath is automatically applied
1422 * @param string $lib: Library name. Call it with the full path like "contrib/prototype/prototype.js" to load it
1425 function loadJavascriptLib($lib) {
1426 $this->pageRenderer
->addJsFile($this->backPath
. $lib);
1430 * Includes the necessary Javascript function for the clickmenu (context sensitive menus) in the document
1433 function getContextMenuCode() {
1434 $this->pageRenderer
->loadPrototype();
1435 $this->loadJavascriptLib('js/clickmenu.js');
1437 $this->JScodeArray
['clickmenu'] = '
1438 Clickmenu.clickURL = "'.$this->backPath
.'alt_clickmenu.php";
1439 Clickmenu.ajax = '.($this->isCMLayers() ?
'true' : 'false' ).';';
1443 * Includes the necessary javascript file (tree.js) for use on pages which have the
1444 * drag and drop functionality (usually pages and folder display trees)
1446 * @param string $table indicator of which table the drag and drop function should work on (pages or folders)
1449 function getDragDropCode($table) {
1450 $this->pageRenderer
->loadPrototype();
1451 $this->loadJavascriptLib('js/common.js');
1452 $this->loadJavascriptLib('js/tree.js');
1454 // Setting prefs for drag & drop
1455 $this->JScodeArray
['dragdrop'] = '
1456 DragDrop.changeURL = "'.$this->backPath
.'alt_clickmenu.php";
1457 DragDrop.backPath = "'.t3lib_div
::shortMD5(''.'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']).'";
1458 DragDrop.table = "'.$table.'";
1463 * This loads everything needed for the Context Sensitive Help (CSH)
1467 protected function loadCshJavascript() {
1468 $this->pageRenderer
->loadExtJS();
1469 $this->pageRenderer
->addJsFile($this->backPath
.'../t3lib/js/extjs/contexthelp.js');
1470 $this->pageRenderer
->addExtDirectCode();
1474 * Creates a tab menu from an array definition
1476 * Returns a tab menu for a module
1477 * Requires the JS function jumpToUrl() to be available
1479 * @param mixed $mainParams 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=...
1480 * @param string $elementName it the form elements name, probably something like "SET[...]"
1481 * @param string $currentValue is the value to be selected currently.
1482 * @param array $menuItems is an array with the menu items for the selector box
1483 * @param string $script is the script to send the &id to, if empty it's automatically found
1484 * @param string $addparams is additional parameters to pass to the script.
1485 * @return string HTML code for tab menu
1487 function getTabMenu($mainParams, $elementName, $currentValue, $menuItems, $script = '', $addparams = '') {
1490 if (is_array($menuItems)) {
1491 if (!is_array($mainParams)) {
1492 $mainParams = array('id' => $mainParams);
1494 $mainParams = t3lib_div
::implodeArrayForUrl('', $mainParams);
1496 if (!$script) {$script=basename(PATH_thisScript
);}
1499 foreach ($menuItems as $value => $label) {
1500 $menuDef[$value]['isActive'] = !strcmp($currentValue, $value);
1501 $menuDef[$value]['label'] = t3lib_div
::deHSCentities(htmlspecialchars($label));
1502 $menuDef[$value]['url'] = $script . '?' . $mainParams . $addparams . '&' . $elementName . '=' . $value;
1504 $content = $this->getTabMenuRaw($menuDef);
1511 * Creates the HTML content for the tab menu
1513 * @param array $menuItems Menu items for tabs
1514 * @return string Table HTML
1517 function getTabMenuRaw($menuItems) {
1520 if (is_array($menuItems)) {
1523 $count = count($menuItems);
1527 $widthRight = max (1, floor(30-pow($count, 1.72)));
1528 $widthTabs = 100 - $widthRight - $widthLeft;
1529 $widthNo = floor(($widthTabs - $addToAct)/$count);
1530 $addToAct = max ($addToAct, $widthTabs-($widthNo*$count));
1531 $widthAct = $widthNo +
$addToAct;
1532 $widthRight = 100 - ($widthLeft +
($count*$widthNo) +
$addToAct);
1534 foreach ($menuItems as $id => $def) {
1535 $isActive = $def['isActive'];
1536 $class = $isActive ?
'tabact' : 'tab';
1537 $width = $isActive ?
$widthAct : $widthNo;
1539 // @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.
1540 $label = $def['label'];
1541 $url = htmlspecialchars($def['url']);
1542 $params = $def['addParams'];
1544 $options .= '<td width="' . $width . '%" class="' . $class . '"><a href="' . $url . '" ' . $params . '>' . $label . '</a></td>';
1550 <table cellpadding="0" cellspacing="0" border="0" width="100%" id="typo3-tabmenu">
1552 <td width="'.$widthLeft.'%"> </td>
1554 <td width="'.$widthRight.'%"> </td>
1557 <div class="hr" style="margin:0px"></div>';
1565 * Creates a DYNAMIC tab-menu where the tabs are switched between with DHTML.
1566 * 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!
1568 * @param array $menuItems 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.
1569 * @param string $identString Identification string. This should be unique for every instance of a dynamic menu!
1570 * @param integer $toggle 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.
1571 * @param boolean $foldout 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.
1572 * @param boolean $noWrap If set, tab table cells are not allowed to wrap their content
1573 * @param boolean $fullWidth If set, the tabs will span the full width of their position
1574 * @param integer $defaultTabIndex 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.
1575 * @param integer $dividers2tabs If set to '1' empty tabs will be remove, If set to '2' empty tabs will be disabled
1576 * @return string JavaScript section for the HTML header.
1578 public function getDynTabMenu($menuItems, $identString, $toggle = 0, $foldout = FALSE
, $noWrap = TRUE
, $fullWidth = FALSE
, $defaultTabIndex = 1, $dividers2tabs = 2) {
1579 // Load the static code, if not already done with the function below
1580 $this->loadJavascriptLib('js/tabmenu.js');
1584 if (is_array($menuItems)) {
1587 $options = array(array());
1590 $id = $this->getDynTabMenuId($identString);
1591 $noWrap = $noWrap ?
' nowrap="nowrap"' : '';
1593 // Traverse menu items
1597 foreach ($menuItems as $index => $def) {
1598 // Need to add one so checking for first index in JavaScript
1599 // is different than if it is not set at all.
1602 // Switch to next tab row if needed
1603 if (!$foldout && ($def['newline'] === TRUE
&& $titleLenCount > 0)) {
1606 $options[$tabRows] = array();
1610 $onclick = 'this.blur(); DTM_toggle("'.$id.'","'.$index.'"); return false;';
1612 $onclick = 'this.blur(); DTM_activate("'.$id.'","'.$index.'", '.($toggle<0?
1:0).'); return false;';
1615 $isEmpty = !(strcmp(trim($def['content']), '') ||
strcmp(trim($def['icon']), ''));
1617 // "Removes" empty tabs
1618 if ($isEmpty && $dividers2tabs == 1) {
1622 $mouseOverOut = ' onmouseover="DTM_mouseOver(this);" onmouseout="DTM_mouseOut(this);"';
1623 $requiredIcon = '<img name="' . $id . '-' . $index . '-REQ" src="' . $GLOBALS['BACK_PATH'] . 'gfx/clear.gif" class="t3-TCEforms-reqTabImg" alt="" />';
1627 $options[$tabRows][] = '
1628 <td class="'.($isEmpty ?
'disabled' : 'tab').'" id="'.$id.'-'.$index.'-MENU"'.$noWrap.$mouseOverOut.'>'.
1629 ($isEmpty ?
'' : '<a href="#" onclick="'.htmlspecialchars($onclick).'"'.($def['linkTitle'] ?
' title="'.htmlspecialchars($def['linkTitle']).'"':'').'>').
1631 ($def['label'] ?
htmlspecialchars($def['label']) : ' ').
1633 $this->icons($def['stateIcon'], 'margin-left: 10px;').
1634 ($isEmpty ?
'' : '</a>').
1636 $titleLenCount+
= strlen($def['label']);
1638 // Create DIV layer for content:
1640 <div class="'.($isEmpty ?
'disabled' : 'tab').'" id="'.$id.'-'.$index.'-MENU"'.$mouseOverOut.'>'.
1641 ($isEmpty ?
'' : '<a href="#" onclick="'.htmlspecialchars($onclick).'"'.($def['linkTitle'] ?
' title="'.htmlspecialchars($def['linkTitle']).'"':'').'>').
1643 ($def['label'] ?
htmlspecialchars($def['label']) : ' ').
1645 ($isEmpty ?
'' : '</a>').
1649 // Create DIV layer for content:
1651 <div style="display: none;" id="'.$id.'-'.$index.'-DIV" class="c-tablayer">'.
1652 ($def['description'] ?
'<p class="c-descr">'.nl2br(htmlspecialchars($def['description'])).'</p>' : '').
1655 // Create initialization string:
1657 DTM_array["'.$id.'"]['.$c.'] = "'.$id.'-'.$index.'";
1659 // If not empty and we have the toggle option on, check if the tab needs to be expanded
1660 if ($toggle == 1 && !$isEmpty) {
1662 if (top.DTM_currentTabs["'.$id.'-'.$index.'"]) { DTM_toggle("'.$id.'","'.$index.'",1); }
1670 if (count($options)) {
1672 // Tab menu is compiled:
1675 for($a = 0; $a <= $tabRows; $a++
) {
1679 <table cellpadding="0" cellspacing="0" border="0"'.($fullWidth ?
' width="100%"' : '').' class="typo3-dyntabmenu">
1681 '.implode('', $options[$a]).'
1685 $content .= '<div class="typo3-dyntabmenu-tabs">'.$tabContent.'</div>';
1688 // Div layers are added:
1690 <!-- Div layers for tab menu: -->
1691 <div class="typo3-dyntabmenu-divs'.($foldout?
'-foldout':'').'">
1692 '.implode('', $divs).'</div>';
1694 // Java Script section added:
1696 <!-- Initialization JavaScript for the menu -->
1697 <script type="text/javascript">
1698 DTM_array["'.$id.'"] = new Array();
1699 '.implode('', $JSinit).'
1700 '.($toggle <= 0 ?
'DTM_activate("'.$id.'", top.DTM_currentTabs["'.$id.'"]?top.DTM_currentTabs["'.$id.'"]:'.intval($defaultTabIndex).', 0);' : '').'
1711 * Creates the id for dynTabMenus.
1713 * @param string $identString Identification string. This should be unique for every instance of a dynamic menu!
1714 * @return string The id with a short MD5 of $identString and prefixed "DTM-", like "DTM-2e8791854a"
1716 function getDynTabMenuId($identString) {
1717 $id = 'DTM-'.t3lib_div
::shortMD5($identString);
1722 * Creates the version selector for the page id inputted.
1723 * Requires the core version management extension, "version" to be loaded.
1725 * @param integer $id Page id to create selector for.
1726 * @param boolean $noAction If set, there will be no button for swapping page.
1729 public function getVersionSelector($id, $noAction = FALSE
) {
1730 if (t3lib_extMgm
::isLoaded('version')) {
1731 $versionGuiObj = t3lib_div
::makeInstance('tx_version_gui');
1732 return $versionGuiObj->getVersionSelector($id, $noAction);
1737 * Function to load a HTML template file with markers.
1738 * When calling from own extension, use syntax getHtmlTemplate('EXT:extkey/template.html')
1740 * @param string $filename tmpl name, usually in the typo3/template/ directory
1741 * @return string HTML of template
1743 function getHtmlTemplate($filename) {
1744 // setting the name of the original HTML template
1745 $this->moduleTemplateFilename
= $filename;
1747 if ($GLOBALS['TBE_STYLES']['htmlTemplates'][$filename]) {
1748 $filename = $GLOBALS['TBE_STYLES']['htmlTemplates'][$filename];
1750 if (t3lib_div
::isFirstPartOfStr($filename, 'EXT:')) {
1751 $filename = t3lib_div
::getFileAbsFileName($filename, TRUE
, TRUE
);
1752 } elseif (!t3lib_div
::isAbsPath($filename)) {
1753 $filename = t3lib_div
::resolveBackPath($this->backPath
. $filename);
1754 } elseif (!t3lib_div
::isAllowedAbsPath($filename)) {
1758 if ($filename !== '') {
1759 $htmlTemplate = t3lib_div
::getUrl($filename);
1761 return $htmlTemplate;
1765 * Define the template for the module
1767 * @param string $filename filename
1770 public function setModuleTemplate($filename) {
1771 // Load Prototype lib for IE event
1772 $this->pageRenderer
->loadPrototype();
1773 $this->loadJavascriptLib('js/iecompatibility.js');
1774 $this->moduleTemplate
= $this->getHtmlTemplate($filename);
1778 * Put together the various elements for the module <body> using a static HTML
1781 * @param array $pageRecord Record of the current page, used for page path and info
1782 * @param array $buttons HTML for all buttons
1783 * @param array $markerArray HTML for all other markers
1784 * @param array $subpartArray HTML for the subparts
1785 * @return string Composite HTML
1787 public function moduleBody($pageRecord = array(), $buttons = array(), $markerArray = array(), $subpartArray = array()) {
1788 // Get the HTML template for the module
1789 $moduleBody = t3lib_parsehtml
::getSubpart($this->moduleTemplate
, '###FULLDOC###');
1791 $this->inDocStylesArray
[] = 'html { overflow: hidden; }';
1793 // Get the page path for the docheader
1794 $markerArray['PAGEPATH'] = $this->getPagePath($pageRecord);
1795 // Get the page info for the docheader
1796 $markerArray['PAGEINFO'] = $this->getPageInfo($pageRecord);
1797 // Get all the buttons for the docheader
1798 $docHeaderButtons = $this->getDocHeaderButtons($buttons);
1799 // Merge docheader buttons with the marker array
1800 $markerArray = array_merge($markerArray, $docHeaderButtons);
1801 // replacing subparts
1802 foreach ($subpartArray as $marker => $content) {
1803 $moduleBody = t3lib_parsehtml
::substituteSubpart($moduleBody, $marker, $content);
1806 // adding flash messages
1807 if ($this->showFlashMessages
) {
1808 $flashMessages = t3lib_FlashMessageQueue
::renderFlashMessages();
1809 if (!empty($flashMessages)) {
1810 $markerArray['FLASHMESSAGES'] = '<div id="typo3-messages">' . $flashMessages . '</div>';
1812 // If there is no dedicated marker for the messages present
1813 // then force them to appear before the content
1814 if (strpos($moduleBody, '###FLASHMESSAGES###') === FALSE
) {
1815 $moduleBody = str_replace(
1817 '###FLASHMESSAGES######CONTENT###',
1824 // Hook for adding more markers/content to the page, like the version selector
1825 if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['moduleBodyPostProcess'])) {
1827 'moduleTemplateFilename' => &$this->moduleTemplateFilename
,
1828 'moduleTemplate' => &$this->moduleTemplate
,
1829 'moduleBody' => &$moduleBody,
1830 'markers' => &$markerArray,
1831 'parentObject' => &$this
1833 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['moduleBodyPostProcess'] as $funcRef) {
1834 t3lib_div
::callUserFunction($funcRef, $params, $this);
1838 // Replacing all markers with the finished markers and return the HTML content
1839 return t3lib_parsehtml
::substituteMarkerArray($moduleBody, $markerArray, '###|###');
1844 * Fill the button lists with the defined HTML
1846 * @param array $buttons HTML for all buttons
1847 * @return array Containing HTML for both buttonlists
1849 protected function getDocHeaderButtons($buttons) {
1851 // Fill buttons for left and right float
1852 $floats = array('left', 'right');
1853 foreach ($floats as $key) {
1854 // Get the template for each float
1855 $buttonTemplate = t3lib_parsehtml
::getSubpart($this->moduleTemplate
, '###BUTTON_GROUPS_' . strtoupper($key) . '###');
1856 // Fill the button markers in this float
1857 $buttonTemplate = t3lib_parsehtml
::substituteMarkerArray($buttonTemplate, $buttons, '###|###', TRUE
);
1858 // getting the wrap for each group
1859 $buttonWrap = t3lib_parsehtml
::getSubpart($this->moduleTemplate
, '###BUTTON_GROUP_WRAP###');
1860 // looping through the groups (max 6) and remove the empty groups
1861 for ($groupNumber = 1; $groupNumber < 6; $groupNumber++
) {
1862 $buttonMarker = '###BUTTON_GROUP' . $groupNumber . '###';
1863 $buttonGroup = t3lib_parsehtml
::getSubpart($buttonTemplate, $buttonMarker);
1864 if (trim($buttonGroup)) {
1866 $buttonGroup = t3lib_parsehtml
::substituteMarker($buttonWrap, '###BUTTONS###', $buttonGroup);
1868 $buttonTemplate = t3lib_parsehtml
::substituteSubpart($buttonTemplate, $buttonMarker, trim($buttonGroup));
1871 // Replace the marker with the template and remove all line breaks (for IE compat)
1872 $markers['BUTTONLIST_' . strtoupper($key)] = str_replace(LF
, '', $buttonTemplate);
1875 // Hook for manipulating docHeaderButtons
1876 if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['docHeaderButtonsHook'])) {
1878 'buttons' => $buttons,
1879 'markers' => &$markers,
1882 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['docHeaderButtonsHook'] as $funcRef) {
1883 t3lib_div
::callUserFunction($funcRef, $params, $this);
1891 * Generate the page path for docheader
1893 * @param array $pageRecord Current page
1894 * @return string Page path
1896 protected function getPagePath($pageRecord) {
1897 // Is this a real page
1898 if (is_array($pageRecord) && $pageRecord['uid']) {
1899 $title = substr($pageRecord['_thePathFull'], 0, -1);
1900 // Remove current page title
1901 $pos = strrpos($title, '/');
1902 if ($pos !== FALSE
) {
1903 $title = substr($title, 0, $pos) . '/';
1909 // Setting the path of the page
1910 $pagePath = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.path', 1) . ': <span class="typo3-docheader-pagePath">';
1912 // crop the title to title limit (or 50, if not defined)
1913 $cropLength = (empty($GLOBALS['BE_USER']->uc
['titleLen'])) ?
50 : $GLOBALS['BE_USER']->uc
['titleLen'];
1914 $croppedTitle = t3lib_div
::fixed_lgd_cs($title, -$cropLength);
1915 if ($croppedTitle !== $title) {
1916 $pagePath .= '<abbr title="' . htmlspecialchars($title) . '">' . htmlspecialchars($croppedTitle) . '</abbr>';
1918 $pagePath .= htmlspecialchars($title);
1920 $pagePath .= '</span>';
1925 * Setting page icon with clickmenu + uid for docheader
1927 * @param array $pageRecord Current page
1928 * @return string Page info
1930 protected function getPageInfo($pageRecord) {
1932 // Add icon with clickmenu, etc:
1933 // If there IS a real page
1934 if (is_array($pageRecord) && $pageRecord['uid']) {
1935 $alttext = t3lib_BEfunc
::getRecordIconAltText($pageRecord, 'pages');
1936 $iconImg = t3lib_iconWorks
::getSpriteIconForRecord('pages', $pageRecord, array('title'=>$alttext));
1938 $theIcon = $GLOBALS['SOBE']->doc
->wrapClickMenuOnIcon($iconImg, 'pages', $pageRecord['uid']);
1939 $uid = $pageRecord['uid'];
1940 $title = t3lib_BEfunc
::getRecordTitle('pages', $pageRecord);
1941 } else { // On root-level of page tree
1943 $iconImg = t3lib_iconWorks
::getSpriteIcon('apps-pagetree-root', array('title' => htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'])));
1944 if ($GLOBALS['BE_USER']->user
['admin']) {
1945 $theIcon = $GLOBALS['SOBE']->doc
->wrapClickMenuOnIcon($iconImg, 'pages', 0);
1947 $theIcon = $iconImg;
1950 $title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
1953 // Setting icon with clickmenu + uid
1954 $pageInfo = $theIcon . '<strong>' . htmlspecialchars($title) . ' [' . $uid . ']</strong>';
1959 * Makes a collapseable section. See reports module for an example
1961 * @param string $title
1962 * @param string $html
1964 * @param string $saveStatePointer
1967 public function collapseableSection($title, $html, $id, $saveStatePointer = '') {
1968 $hasSave = $saveStatePointer ? TRUE
: FALSE
;
1969 $collapsedStyle = $collapsedClass = '';
1972 /** @var $settings extDirect_DataProvider_BackendUserSettings */
1973 $settings = t3lib_div
::makeInstance('extDirect_DataProvider_BackendUserSettings');
1974 $value = $settings->get($saveStatePointer . '.' . $id);
1976 $collapsedStyle = ' style="display: none"';
1977 $collapsedClass = ' collapsed';
1979 $collapsedStyle = '';
1980 $collapsedClass = ' expanded';
1984 $this->pageRenderer
->loadExtJS();
1985 $this->pageRenderer
->addExtOnReadyCode('
1986 Ext.select("h2.section-header").each(function(element){
1987 element.on("click", function(event, tag) {
1990 div = el.next("div"),
1991 saveKey = el.getAttribute("rel");
1992 if (el.hasClass("collapsed")) {
1993 el.removeClass("collapsed").addClass("expanded");
1999 el.removeClass("expanded").addClass("collapsed");
2010 top.TYPO3.BackendUserSettings.ExtDirect.set(saveKey + "." + tag.id, state, function(response) {});
2017 <h2 id="' . $id . '" class="section-header' . $collapsedClass . '" rel="' . $saveStatePointer . '"> ' . $title . '</h2>
2018 <div' . $collapsedStyle . '>' . $html . '</div>
2024 // Extension classes of the template class.
2025 // These are meant to provide backend screens with different widths.
2026 // They still do because of the different class-prefixes used for the <div>-sections
2027 // but obviously the final width is determined by the stylesheet used.
2030 * 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
2031 * The class were more significant in the past than today.
2034 class bigDoc
extends template
{
2035 var $divClass = 'typo3-bigDoc';
2039 * Extension class for "template" - used for backend pages without the "document" background image
2040 * The class were more significant in the past than today.
2043 class noDoc
extends template
{
2044 var $divClass = 'typo3-noDoc';
2048 * 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)
2049 * The class were more significant in the past than today.
2052 class smallDoc
extends template
{
2053 var $divClass = 'typo3-smallDoc';
2057 * 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.
2058 * The class were more significant in the past than today. But probably you should use this one for most modules you make.
2061 class mediumDoc
extends template
{
2062 var $divClass = 'typo3-mediumDoc';
2066 * Extension class for "template" - used in the context of frontend editing.
2068 class frontendDoc
extends template
{
2071 * Gets instance of PageRenderer
2073 * @return t3lib_PageRenderer
2075 public function getPageRenderer() {
2076 if (!isset($this->pageRenderer
)) {
2077 $this->pageRenderer
= $GLOBALS['TSFE']->getPageRenderer();
2079 return $this->pageRenderer
;
2083 * Used in the frontend context to insert header data via TSFE->additionalHeaderData.
2084 * Mimics header inclusion from template->startPage().
2088 public function insertHeaderData() {
2090 $this->backPath
= $GLOBALS['TSFE']->backPath
= TYPO3_mainDir
;
2091 $this->pageRenderer
->setBackPath($this->backPath
);
2094 // Add applied JS/CSS to $GLOBALS['TSFE']
2095 if ($this->JScode
) {
2096 $this->pageRenderer
->addHeaderData($this->JScode
);
2098 if (count($this->JScodeArray
)) {
2099 foreach ($this->JScodeArray
as $name => $code) {
2100 $this->pageRenderer
->addJsInlineCode($name, $code, FALSE
);
2106 // The template is loaded
2107 $GLOBALS['TBE_TEMPLATE'] = t3lib_div
::makeInstance('template');