2 namespace TYPO3\CMS\Backend\Template
;
5 * TYPO3 Backend Template Class
7 * This class contains functions for starting and ending the HTML of backend modules
8 * It also contains methods for outputting sections of content.
9 * Further there are functions for making icons, links, setting form-field widths etc.
10 * Color scheme and stylesheet definitions are also available here.
11 * Finally this file includes the language class for TYPO3's backend.
13 * After this file $LANG and $TBE_TEMPLATE are global variables / instances of their respective classes.
14 * This file is typically included right after the init.php file,
15 * if language and layout is needed.
17 * Please refer to Inside TYPO3 for a discussion of how to use this API.
19 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
23 class DocumentTemplate
{
25 // Vars you typically might want to/should set from outside after making instance of this class:
26 // 'backPath' pointing back to the PATH_typo3
28 * @todo Define visibility
30 public $backPath = '';
32 // 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.
34 * @todo Define visibility
38 // 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
40 * @todo Define visibility
42 public $JScodeLibArray = array();
44 // Additional header code (eg. a JavaScript section) could be accommulated in this var. It will be directly outputted in the header.
46 * @todo Define visibility
50 // Additional header code for ExtJS. It will be included in document header and inserted in a Ext.onReady(function()
52 * @todo Define visibility
54 public $extJScode = '';
56 // 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.
58 * @todo Define visibility
60 public $JScodeArray = array();
62 // 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.
64 * @todo Define visibility
66 public $postCode = '';
68 // Doc-type used in the header. Default is xhtml_trans. You can also set it to 'html_3', 'xhtml_strict' or 'xhtml_frames'.
70 * @todo Define visibility
74 // HTML template with markers for module
76 * @todo Define visibility
78 public $moduleTemplate = '';
80 // the base file (not overlaid by TBE_STYLES) for the current module, useful for hooks when finding out which modules is rendered currently
81 protected $moduleTemplateFilename = '';
83 // Other vars you can change, but less frequently used:
86 * @todo Define visibility
88 public $scriptID = '';
90 // Id which can be set for the body tag. Default value is based on script ID
92 * @todo Define visibility
94 public $bodyTagId = '';
96 // You can add additional attributes to the body-tag through this variable.
98 * @todo Define visibility
100 public $bodyTagAdditions = '';
102 // Additional CSS styles which will be added to the <style> section in the header
104 * @todo Define visibility
106 public $inDocStyles = '';
108 // Like $inDocStyles but for use as array with associative keys to prevent double inclusion of css code
110 * @todo Define visibility
112 public $inDocStylesArray = array();
114 // Multiplication factor for formWidth() input size (default is 48* this value).
116 * @todo Define visibility
118 public $form_rowsToStylewidth = 9.58;
120 // Compensation for large documents (used in class.t3lib_tceforms.php)
122 * @todo Define visibility
124 public $form_largeComp = 1.33;
126 // 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.
128 * @todo Define visibility
132 // TYPO3 Colorscheme.
133 // If you want to change this, please do so through a skin using the global var $GLOBALS['TBE_STYLES']
134 // Light background color
136 * @todo Define visibility
138 public $bgColor = '#F7F3EF';
142 * @todo Define visibility
144 public $bgColor2 = '#9BA1A8';
148 * @todo Define visibility
150 public $bgColor3 = '#F6F2E6';
152 // light tablerow background, brownish
154 * @todo Define visibility
156 public $bgColor4 = '#D9D5C9';
158 // light tablerow background, greenish
160 * @todo Define visibility
162 public $bgColor5 = '#ABBBB4';
164 // light tablerow background, yellowish, for section headers. Light.
166 * @todo Define visibility
168 public $bgColor6 = '#E7DBA8';
171 * @todo Define visibility
173 public $hoverColor = '#254D7B';
175 // Filename of stylesheet (relative to PATH_typo3)
177 * @todo Define visibility
179 public $styleSheetFile = '';
181 // Filename of stylesheet #2 - linked to right after the $this->styleSheetFile script (relative to PATH_typo3)
183 * @todo Define visibility
185 public $styleSheetFile2 = '';
187 // Filename of a post-stylesheet - included right after all inline styles.
189 * @todo Define visibility
191 public $styleSheetFile_post = '';
193 // Background image of page (relative to PATH_typo3)
195 * @todo Define visibility
197 public $backGroundImage = '';
199 // Inline css styling set from TBE_STYLES array
201 * @todo Define visibility
203 public $inDocStyles_TBEstyle = '';
206 * Whether to use the X-UA-Compatible meta tag
210 protected $useCompatibilityTag = TRUE;
213 * X-Ua-Compatible version output in meta tag
217 protected $xUaCompatibilityVersion = 'IE=9';
220 // stylesheets from core
221 protected $stylesheetsCore = array(
222 'structure' => 'stylesheets/structure/',
223 'visual' => 'stylesheets/visual/',
224 'generatedSprites' => '../typo3temp/sprites/'
227 // Include these CSS directories from skins by default
228 protected $stylesheetsSkins = array(
229 'structure' => 'stylesheets/structure/',
230 'visual' => 'stylesheets/visual/'
234 * JavaScript files loaded for every page in the Backend
238 protected $jsFiles = array(
239 'modernizr' => 'contrib/modernizr/modernizr.min.js'
243 // Will output the parsetime of the scripts in milliseconds (for admin-users). Set this to FALSE when releasing TYPO3. Only for dev.
245 * @todo Define visibility
247 public $parseTimeFlag = 0;
250 * internal character set, nowadays utf-8 for everything
252 protected $charset = 'utf-8';
254 // Internal: Indicates if a <div>-output section is open
256 * @todo Define visibility
258 public $sectionFlag = 0;
260 // (Default) Class for wrapping <DIV>-tag of page. Is set in class extensions.
262 * @todo Define visibility
264 public $divClass = '';
267 * @todo Define visibility
269 public $pageHeaderBlock = '';
272 * @todo Define visibility
274 public $endOfPageJsBlock = '';
277 * @todo Define visibility
279 public $hasDocheader = TRUE;
282 * @var \TYPO3\CMS\Core\Page\PageRenderer
284 protected $pageRenderer;
286 // Alternative template file
287 protected $pageHeaderFooterTemplateFile = '';
289 protected $extDirectStateProvider = FALSE;
292 * Whether flashmessages should be rendered or not
294 * @var boolean $showFlashMessages
296 public $showFlashMessages = TRUE;
298 const STATUS_ICON_ERROR
= 3;
299 const STATUS_ICON_WARNING
= 2;
300 const STATUS_ICON_NOTIFICATION
= 1;
301 const STATUS_ICON_OK
= -1;
304 * Imports relevant parts from global $GLOBALS['TBE_STYLES'] (colorscheme)
306 public function __construct() {
307 // Initializes the page rendering object:
308 $this->getPageRenderer();
309 // Setting default scriptID:
310 if (($temp_M = (string) \TYPO3\CMS\Core\Utility\GeneralUtility
::_GET('M')) && $GLOBALS['TBE_MODULES']['_PATHS'][$temp_M]) {
311 $this->scriptID
= preg_replace('/^.*\\/(sysext|ext)\\//', 'ext/', $GLOBALS['TBE_MODULES']['_PATHS'][$temp_M] . 'index.php');
313 $this->scriptID
= preg_replace('/^.*\\/(sysext|ext)\\//', 'ext/', substr(PATH_thisScript
, strlen(PATH_site
)));
315 if (TYPO3_mainDir
!= 'typo3/' && substr($this->scriptID
, 0, strlen(TYPO3_mainDir
)) == TYPO3_mainDir
) {
316 // This fixes if TYPO3_mainDir has been changed so the script ids are STILL "typo3/..."
317 $this->scriptID
= 'typo3/' . substr($this->scriptID
, strlen(TYPO3_mainDir
));
319 $this->bodyTagId
= preg_replace('/[^A-Za-z0-9-]/', '-', $this->scriptID
);
320 // Individual configuration per script? If so, make a recursive merge of the arrays:
321 if (is_array($GLOBALS['TBE_STYLES']['scriptIDindex'][$this->scriptID
])) {
323 $ovr = $GLOBALS['TBE_STYLES']['scriptIDindex'][$this->scriptID
];
325 $GLOBALS['TBE_STYLES'] = \TYPO3\CMS\Core\Utility\GeneralUtility
::array_merge_recursive_overrule($GLOBALS['TBE_STYLES'], $ovr);
326 // Have to unset - otherwise the second instantiation will do it again!
327 unset($GLOBALS['TBE_STYLES']['scriptIDindex'][$this->scriptID
]);
330 if ($GLOBALS['TBE_STYLES']['mainColors']['bgColor']) {
331 $this->bgColor
= $GLOBALS['TBE_STYLES']['mainColors']['bgColor'];
333 if ($GLOBALS['TBE_STYLES']['mainColors']['bgColor1']) {
334 $this->bgColor1
= $GLOBALS['TBE_STYLES']['mainColors']['bgColor1'];
336 if ($GLOBALS['TBE_STYLES']['mainColors']['bgColor2']) {
337 $this->bgColor2
= $GLOBALS['TBE_STYLES']['mainColors']['bgColor2'];
339 if ($GLOBALS['TBE_STYLES']['mainColors']['bgColor3']) {
340 $this->bgColor3
= $GLOBALS['TBE_STYLES']['mainColors']['bgColor3'];
342 if ($GLOBALS['TBE_STYLES']['mainColors']['bgColor4']) {
343 $this->bgColor4
= $GLOBALS['TBE_STYLES']['mainColors']['bgColor4'];
345 if ($GLOBALS['TBE_STYLES']['mainColors']['bgColor5']) {
346 $this->bgColor5
= $GLOBALS['TBE_STYLES']['mainColors']['bgColor5'];
348 if ($GLOBALS['TBE_STYLES']['mainColors']['bgColor6']) {
349 $this->bgColor6
= $GLOBALS['TBE_STYLES']['mainColors']['bgColor6'];
351 if ($GLOBALS['TBE_STYLES']['mainColors']['hoverColor']) {
352 $this->hoverColor
= $GLOBALS['TBE_STYLES']['mainColors']['hoverColor'];
355 if ($GLOBALS['TBE_STYLES']['stylesheet']) {
356 $this->styleSheetFile
= $GLOBALS['TBE_STYLES']['stylesheet'];
358 if ($GLOBALS['TBE_STYLES']['stylesheet2']) {
359 $this->styleSheetFile2
= $GLOBALS['TBE_STYLES']['stylesheet2'];
361 if ($GLOBALS['TBE_STYLES']['styleSheetFile_post']) {
362 $this->styleSheetFile_post
= $GLOBALS['TBE_STYLES']['styleSheetFile_post'];
364 if ($GLOBALS['TBE_STYLES']['inDocStyles_TBEstyle']) {
365 $this->inDocStyles_TBEstyle
= $GLOBALS['TBE_STYLES']['inDocStyles_TBEstyle'];
367 // include all stylesheets
368 foreach ($this->getSkinStylesheetDirectories() as $stylesheetDirectory) {
369 $this->addStylesheetDirectory($stylesheetDirectory);
372 if ($GLOBALS['TBE_STYLES']['background']) {
373 $this->backGroundImage
= $GLOBALS['TBE_STYLES']['background'];
378 * Gets instance of PageRenderer configured with the current language, file references and debug settings
380 * @return \TYPO3\CMS\Core\Page\PageRenderer
382 public function getPageRenderer() {
383 if (!isset($this->pageRenderer
)) {
384 $this->pageRenderer
= \TYPO3\CMS\Core\Utility\GeneralUtility
::makeInstance('TYPO3\\CMS\\Core\\Page\\PageRenderer');
385 $this->pageRenderer
->setTemplateFile(TYPO3_mainDir
. 'templates/template_page_backend.html');
386 $this->pageRenderer
->setLanguage($GLOBALS['LANG']->lang
);
387 $this->pageRenderer
->enableConcatenateFiles();
388 $this->pageRenderer
->enableCompressCss();
389 $this->pageRenderer
->enableCompressJavascript();
390 // Add all JavaScript files defined in $this->jsFiles to the PageRenderer
391 foreach ($this->jsFiles
as $file) {
392 $this->pageRenderer
->addJsFile($GLOBALS['BACK_PATH'] . $file);
395 if (intval($GLOBALS['TYPO3_CONF_VARS']['BE']['debug']) === 1) {
396 $this->pageRenderer
->enableDebugMode();
398 return $this->pageRenderer
;
402 * Sets inclusion of StateProvider
406 public function setExtDirectStateProvider() {
407 $this->extDirectStateProvider
= TRUE;
410 /*****************************************
412 * EVALUATION FUNCTIONS
413 * Various centralized processing
415 *****************************************/
417 * Makes click menu link (context sensitive menu)
418 * 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)
419 * 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)
421 * @param string $str String to be wrapped in link, typ. image tag.
422 * @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
423 * @param integer $uid If icon is for database record this is the UID for the record from $table
424 * @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.
425 * @param string $addParams Additional GET parameters for the link to alt_clickmenu.php
426 * @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.
427 * @param boolean $returnOnClick If set, will return only the onclick JavaScript, not the whole link.
428 * @return string The link-wrapped input string.
429 * @todo Define visibility
431 public function wrapClickMenuOnIcon($str, $table, $uid = 0, $listFr = TRUE, $addParams = '', $enDisItems = '', $returnOnClick = FALSE) {
432 $backPath = rawurlencode($this->backPath
) . '|' . \TYPO3\CMS\Core\Utility\GeneralUtility
::shortMD5(($this->backPath
. '|' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']));
433 $onClick = 'showClickmenu("' . $table . '","' . ($uid !== 0 ?
$uid : '') . '","' . strval($listFr) . '","' . str_replace('+', '%2B', $enDisItems) . '","' . str_replace('&', '&', addcslashes($backPath, '"')) . '","' . str_replace('&', '&', addcslashes($addParams, '"')) . '");return false;';
434 return $returnOnClick ?
$onClick : '<a href="#" onclick="' . htmlspecialchars($onClick) . '" oncontextmenu="' . htmlspecialchars($onClick) . '">' . $str . '</a>';
438 * Makes link to page $id in frontend (view page)
439 * Returns an magnifier-glass icon which links to the frontend index.php document for viewing the page with id $id
440 * $id must be a page-uid
441 * If the BE_USER has access to Web>List then a link to that module is shown as well (with return-url)
443 * @param integer $id The page id
444 * @param string $backPath The current "BACK_PATH" (the back relative to the typo3/ directory)
445 * @param string $addParams Additional parameters for the image tag(s)
446 * @return string HTML string with linked icon(s)
447 * @todo Define visibility
449 public function viewPageIcon($id, $backPath, $addParams = 'hspace="3"') {
450 // If access to Web>List for user, then link to that module.
451 $str = \TYPO3\CMS\Backend\Utility\BackendUtility
::getListViewLink(array(
453 'returnUrl' => \TYPO3\CMS\Core\Utility\GeneralUtility
::getIndpEnv('REQUEST_URI')
454 ), $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showList'));
455 // Make link to view page
456 $str .= '<a href="#" onclick="' . htmlspecialchars(\TYPO3\CMS\Backend\Utility\BackendUtility
::viewOnClick($id, $backPath, \TYPO3\CMS\Backend\Utility\BackendUtility
::BEgetRootLine($id))) . '">' . '<img' . \TYPO3\CMS\Backend\Utility\IconUtility
::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="" />' . '</a>';
461 * Returns a URL with a command to TYPO3 Core Engine (tce_db.php)
462 * See description of the API elsewhere.
464 * @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
465 * @param string $redirectUrl Redirect URL if any other that t3lib_div::getIndpEnv('REQUEST_URI') is wished
466 * @return string URL to tce_db.php + parameters (backpath is taken from $this->backPath)
467 * @see t3lib_BEfunc::editOnClick()
468 * @todo Define visibility
470 public function issueCommand($params, $redirectUrl = '') {
471 $redirectUrl = $redirectUrl ?
$redirectUrl : \TYPO3\CMS\Core\Utility\GeneralUtility
::getIndpEnv('REQUEST_URI');
472 $commandUrl = $this->backPath
. 'tce_db.php?' . $params . '&redirect=' . ($redirectUrl == -1 ?
'\'+T3_THIS_LOCATION+\'' : rawurlencode($redirectUrl)) . '&vC=' . rawurlencode($GLOBALS['BE_USER']->veriCode()) . \TYPO3\CMS\Backend\Utility\BackendUtility
::getUrlToken('tceAction') . '&prErr=1&uPT=1';
477 * Returns TRUE if click-menu layers can be displayed for the current user/browser
478 * Use this to test if click-menus (context sensitive menus) can and should be displayed in the backend.
481 * @deprecated since TYPO3 4.7, will be removed in TYPO3 6.1 - This function makes no sense anymore
482 * @todo Define visibility
484 public function isCMlayers() {
485 \TYPO3\CMS\Core\Utility\GeneralUtility
::logDeprecatedFunction();
486 return !$GLOBALS['BE_USER']->uc
['disableCMlayers'] && $GLOBALS['CLIENT']['FORMSTYLE'] && !($GLOBALS['CLIENT']['SYSTEM'] == 'mac' && $GLOBALS['CLIENT']['BROWSER'] == 'Opera');
490 * Makes the header (icon+title) for a page (or other record). Used in most modules under Web>*
491 * $table and $row must be a tablename/record from that table
492 * $path will be shown as alt-text for the icon.
493 * The title will be truncated to 45 chars.
495 * @param string $table Table name
496 * @param array $row Record row
497 * @param string $path Alt text
498 * @param boolean $noViewPageIcon Set $noViewPageIcon TRUE if you don't want a magnifier-icon for viewing the page in the frontend
499 * @param array $tWrap is an array with indexes 0 and 1 each representing HTML-tags (start/end) which will wrap the title
500 * @return string HTML content
501 * @todo Define visibility
503 public function getHeader($table, $row, $path, $noViewPageIcon = FALSE, $tWrap = array('', '')) {
505 if (is_array($row) && $row['uid']) {
506 $iconImgTag = \TYPO3\CMS\Backend\Utility\IconUtility
::getSpriteIconForRecord($table, $row, array('title' => htmlspecialchars($path)));
507 $title = strip_tags(\TYPO3\CMS\Backend\Utility\BackendUtility
::getRecordTitle($table, $row));
508 $viewPage = $noViewPageIcon ?
'' : $this->viewPageIcon($row['uid'], $this->backPath
, '');
509 if ($table == 'pages') {
510 $path .= ' - ' . \TYPO3\CMS\Backend\Utility\BackendUtility
::titleAttribForPages($row, '', 0);
513 $iconImgTag = \TYPO3\CMS\Backend\Utility\IconUtility
::getSpriteIcon('apps-pagetree-page-domain', array('title' => htmlspecialchars($path)));
514 $title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
516 return '<span class="typo3-moduleHeader">' . $this->wrapClickMenuOnIcon($iconImgTag, $table, $row['uid']) . $viewPage . $tWrap[0] . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility
::fixed_lgd_cs($title, 45)) . $tWrap[1] . '</span>';
520 * Like ->getHeader() but for files in the File>* main module/submodules
521 * Returns the file-icon with the path of the file set in the alt/title attribute. Shows the file-name after the icon.
523 * @param string $title Title string, expected to be the filepath
524 * @param string $path Alt text
525 * @param string $iconfile The icon file (relative to TYPO3 dir)
526 * @return string HTML content
527 * @todo Define visibility
529 public function getFileheader($title, $path, $iconfile) {
530 $fileInfo = \TYPO3\CMS\Core\Utility\GeneralUtility
::split_fileref($title);
531 $title = htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility
::fixed_lgd_cs($fileInfo['path'], -35)) . '<strong>' . htmlspecialchars($fileInfo['file']) . '</strong>';
532 return '<span class="typo3-moduleHeader"><img' . \TYPO3\CMS\Backend\Utility\IconUtility
::skinImg($this->backPath
, $iconfile, 'width="18" height="16"') . ' title="' . htmlspecialchars($path) . '" alt="" />' . $title . '</span>';
536 * Returns a linked shortcut-icon which will call the shortcut frame and set a shortcut there back to the calling page/module
538 * @param string $gvList Is the list of GET variables to store (if any)
539 * @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
540 * @param string $modName Module name string
541 * @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.
542 * @return string HTML content
543 * @todo Define visibility
545 public function makeShortcutIcon($gvList, $setList, $modName, $motherModName = '') {
546 $backPath = $this->backPath
;
547 $storeUrl = $this->makeShortcutUrl($gvList, $setList);
548 $pathInfo = parse_url(\TYPO3\CMS\Core\Utility\GeneralUtility
::getIndpEnv('REQUEST_URI'));
549 // Add the module identifier automatically if typo3/mod.php is used:
550 if (preg_match('/typo3\\/mod\\.php$/', $pathInfo['path']) && isset($GLOBALS['TBE_MODULES']['_PATHS'][$modName])) {
551 $storeUrl = '&M=' . $modName . $storeUrl;
553 if (!strcmp($motherModName, '1')) {
554 $mMN = '&motherModName=\'+top.currentModuleLoaded+\'';
555 } elseif ($motherModName) {
556 $mMN = '&motherModName=' . rawurlencode($motherModName);
560 $onClick = 'top.ShortcutManager.createShortcut(' . $GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.makeBookmark')) . ', ' . '\'' . $backPath . '\', ' . '\'' . rawurlencode($modName) . '\', ' . '\'' . rawurlencode(($pathInfo['path'] . '?' . $storeUrl)) . $mMN . '\'' . ');return false;';
561 $sIcon = '<a href="#" onclick="' . htmlspecialchars($onClick) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.makeBookmark', TRUE) . '">' . \t3lib_iconworks
::getSpriteIcon('actions-system-shortcut-new') . '</a>';
566 * MAKE url for storing
569 * @param string $gvList Is the list of GET variables to store (if any)
570 * @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
573 * @see makeShortcutIcon()
574 * @todo Define visibility
576 public function makeShortcutUrl($gvList, $setList) {
577 $GET = \TYPO3\CMS\Core\Utility\GeneralUtility
::_GET();
578 $storeArray = array_merge(\TYPO3\CMS\Core\Utility\GeneralUtility
::compileSelectedGetVarsFromArray($gvList, $GET), array('SET' => \TYPO3\CMS\Core\Utility\GeneralUtility
::compileSelectedGetVarsFromArray($setList, (array) $GLOBALS['SOBE']->MOD_SETTINGS
)));
579 $storeUrl = \TYPO3\CMS\Core\Utility\GeneralUtility
::implodeArrayForUrl('', $storeArray);
584 * Returns <input> attributes to set the width of an text-type input field.
585 * For client browsers with no CSS support the cols/size attribute is returned.
586 * For CSS compliant browsers (recommended) a ' style="width: ...px;"' is returned.
588 * @param integer $size A relative number which multiplied with approx. 10 will lead to the width in pixels
589 * @param boolean $textarea A flag you can set for textareas - DEPRECATED, use ->formWidthText() for textareas!!!
590 * @param string $styleOverride A string which will be returned as attribute-value for style="" instead of the calculated width (if CSS is enabled)
591 * @return string Tag attributes for an <input> tag (regarding width)
592 * @see formWidthText()
593 * @todo Define visibility
595 public function formWidth($size = 48, $textarea = FALSE, $styleOverride = '') {
596 $wAttrib = $textarea ?
'cols' : 'size';
597 // If not setting the width by style-attribute
598 if (!$GLOBALS['CLIENT']['FORMSTYLE']) {
599 $retVal = ' ' . $wAttrib . '="' . $size . '"';
601 // Setting width by style-attribute. 'cols' MUST be avoided with NN6+
602 $pixels = ceil($size * $this->form_rowsToStylewidth
);
603 $retVal = $styleOverride ?
' style="' . $styleOverride . '"' : ' style="width:' . $pixels . 'px;"';
609 * This function is dedicated to textareas, which has the wrapping on/off option to observe.
611 * <textarea rows="10" wrap="off" '.$GLOBALS["TBE_TEMPLATE"]->formWidthText(48, "", "off").'>
613 * <textarea rows="10" wrap="virtual" '.$GLOBALS["TBE_TEMPLATE"]->formWidthText(48, "", "virtual").'>
615 * @param integer $size A relative number which multiplied with approx. 10 will lead to the width in pixels
616 * @param string $styleOverride A string which will be returned as attribute-value for style="" instead of the calculated width (if CSS is enabled)
617 * @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.
618 * @return string Tag attributes for an <input> tag (regarding width)
620 * @todo Define visibility
622 public function formWidthText($size = 48, $styleOverride = '', $wrap = '') {
623 $wTags = $this->formWidth($size, 1, $styleOverride);
624 // 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...
625 if (strtolower(trim($wrap)) != 'off' && $GLOBALS['CLIENT']['BROWSER'] == 'net' && $GLOBALS['CLIENT']['VERSION'] >= 5) {
626 $wTags .= ' cols="' . $size . '"';
632 * Returns JavaScript variables setting the returnUrl and thisScript location for use by JavaScript on the page.
633 * Used in fx. db_list.php (Web>List)
635 * @param string $thisLocation URL to "this location" / current script
636 * @return string Urls are returned as JavaScript variables T3_RETURN_URL and T3_THIS_LOCATION
637 * @see typo3/db_list.php
638 * @todo Define visibility
640 public function redirectUrls($thisLocation = '') {
641 $thisLocation = $thisLocation ?
$thisLocation : \TYPO3\CMS\Core\Utility\GeneralUtility
::linkThisScript(array(
648 var T3_RETURN_URL = \'' . str_replace('%20', '', rawurlencode(\TYPO3\CMS\Core\Utility\GeneralUtility
::sanitizeLocalUrl(\TYPO3\CMS\Core\Utility\GeneralUtility
::_GP('returnUrl')))) . '\';
649 var T3_THIS_LOCATION = \'' . str_replace('%20', '', rawurlencode($thisLocation)) . '\';
655 * Returns a formatted string of $tstamp
656 * Uses $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'] and $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] to format date and time
658 * @param integer $tstamp UNIX timestamp, seconds since 1970
659 * @param integer $type How much data to show: $type = 1: hhmm, $type = 10: ddmmmyy
660 * @return string Formatted timestamp
661 * @todo Define visibility
663 public function formatTime($tstamp, $type) {
667 $dateStr = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'], $tstamp);
670 $dateStr = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], $tstamp);
677 * Returns script parsetime IF ->parseTimeFlag is set and user is "admin"
678 * Automatically outputted in page end
680 * @return string HTML formated with <p>-tags
681 * @todo Define visibility
683 public function parseTime() {
684 if ($this->parseTimeFlag
&& $GLOBALS['BE_USER']->isAdmin()) {
685 return '<p>(ParseTime: ' . (\TYPO3\CMS\Core\Utility\GeneralUtility
::milliseconds() - $GLOBALS['PARSETIME_START']) . ' ms</p>
686 <p>REQUEST_URI-length: ' . strlen(\TYPO3\CMS\Core\Utility\GeneralUtility
::getIndpEnv('REQUEST_URI')) . ')</p>';
691 * Defines whether to use the X-UA-Compatible meta tag.
693 * @param boolean $useCompatibilityTag Whether to use the tag
696 public function useCompatibilityTag($useCompatibilityTag = TRUE) {
697 $this->useCompatibilityTag
= (bool) $useCompatibilityTag;
700 /*****************************************
702 * PAGE BUILDING FUNCTIONS.
703 * Use this to build the HTML of your backend modules
705 *****************************************/
708 * This includes the proper header with charset, title, meta tag and beginning body-tag.
710 * @param string $title HTML Page title for the header
711 * @param boolean $includeCsh flag for including CSH
712 * @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)
714 * @todo Define visibility
716 public function startPage($title, $includeCsh = TRUE) {
717 // hook pre start page
718 if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preStartPageHook'])) {
719 $preStartPageHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preStartPageHook'];
720 if (is_array($preStartPageHook)) {
721 $hookParameters = array(
724 foreach ($preStartPageHook as $hookFunction) {
725 \TYPO3\CMS\Core\Utility\GeneralUtility
::callUserFunction($hookFunction, $hookParameters, $this);
729 $this->pageRenderer
->backPath
= $this->backPath
;
730 // alternative template for Header and Footer
731 if ($this->pageHeaderFooterTemplateFile
) {
732 $file = \TYPO3\CMS\Core\Utility\GeneralUtility
::getFileAbsFileName($this->pageHeaderFooterTemplateFile
, TRUE);
734 $this->pageRenderer
->setTemplateFile($file);
737 // Send HTTP header for selected charset. Added by Robert Lemke 23.10.2003
738 header('Content-Type:text/html;charset=' . $this->charset
);
740 $htmlTag = '<html xmlns="http://www.w3.org/1999/xhtml">';
741 switch ($this->docType
) {
743 $headerStart = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">';
745 // Disable rendering of XHTML tags
746 $this->getPageRenderer()->setRenderXhtml(FALSE);
749 $headerStart = '<!DOCTYPE html
750 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
751 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
754 $headerStart = '<!DOCTYPE html
755 PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
756 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">';
759 $headerStart = '<!DOCTYPE html
760 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
761 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
766 // The fallthrough is intended as HTML5, as this is the default for the BE since TYPO3 4.5
767 $headerStart = '<!DOCTYPE html>' . LF
;
769 // Disable rendering of XHTML tags
770 $this->getPageRenderer()->setRenderXhtml(FALSE);
773 $this->pageRenderer
->setHtmlTag($htmlTag);
774 // This loads the tabulator-in-textarea feature. It automatically modifies
775 // every textarea which is found.
776 if (!$GLOBALS['BE_USER']->uc
['disableTabInTextarea']) {
777 $this->loadJavascriptLib('tab.js');
779 // Include the JS for the Context Sensitive Help
781 $this->loadCshJavascript();
783 // Get the browser info
784 $browserInfo = \TYPO3\CMS\Core\Utility\ClientUtility
::getBrowserInfo(\TYPO3\CMS\Core\Utility\GeneralUtility
::getIndpEnv('HTTP_USER_AGENT'));
785 // Set the XML prologue
786 $xmlPrologue = '<?xml version="1.0" encoding="' . $this->charset
. '"?>';
787 // Set the XML stylesheet
788 $xmlStylesheet = '<?xml-stylesheet href="#internalStyle" type="text/css"?>';
789 // Add the XML prologue for XHTML doctypes
790 if (strpos($this->docType
, 'xhtml') !== FALSE) {
791 // Put the XML prologue before or after the doctype declaration according to browser
792 if ($browserInfo['browser'] === 'msie' && $browserInfo['version'] < 7) {
793 $headerStart = $headerStart . LF
. $xmlPrologue;
795 $headerStart = $xmlPrologue . LF
. $headerStart;
797 // Add the xml stylesheet according to doctype
798 if ($this->docType
!== 'xhtml_frames') {
799 $headerStart = $headerStart . LF
. $xmlStylesheet;
802 $this->pageRenderer
->setXmlPrologAndDocType($headerStart);
803 $this->pageRenderer
->setHeadTag('<head>' . LF
. '<!-- TYPO3 Script ID: ' . htmlspecialchars($this->scriptID
) . ' -->');
804 $this->pageRenderer
->setCharSet($this->charset
);
805 $this->pageRenderer
->addMetaTag($this->generator());
806 $this->pageRenderer
->addMetaTag('<meta name="robots" content="noindex,follow" />');
807 $this->pageRenderer
->setFavIcon('gfx/favicon.ico');
808 if ($this->useCompatibilityTag
) {
809 $this->pageRenderer
->addMetaTag($this->xUaCompatible($this->xUaCompatibilityVersion
));
811 $this->pageRenderer
->setTitle($title);
814 if ($this->extDirectStateProvider
) {
815 $this->pageRenderer
->addJsFile($this->backPath
. '../t3lib/js/extjs/ExtDirect.StateProvider.js');
817 // Add jsCode for overriding the console with a debug panel connection
818 $this->pageRenderer
->addJsInlineCode('consoleOverrideWithDebugPanel', 'if (typeof top.Ext === "object") {
819 top.Ext.onReady(function() {
820 if (typeof console === "undefined") {
821 if (top && top.TYPO3 && top.TYPO3.Backend && top.TYPO3.Backend.DebugConsole) {
822 console = top.TYPO3.Backend.DebugConsole;
835 $this->pageRenderer
->addHeaderData($this->JScode
);
836 foreach ($this->JScodeArray
as $name => $code) {
837 $this->pageRenderer
->addJsInlineCode($name, $code, FALSE);
839 if (count($this->JScodeLibArray
)) {
840 foreach ($this->JScodeLibArray
as $library) {
841 $this->pageRenderer
->addHeaderData($library);
844 if ($this->extJScode
) {
845 $this->pageRenderer
->addExtOnReadyCode($this->extJScode
);
847 // hook for additional headerData
848 if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preHeaderRenderHook'])) {
849 $preHeaderRenderHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preHeaderRenderHook'];
850 if (is_array($preHeaderRenderHook)) {
851 $hookParameters = array(
852 'pageRenderer' => &$this->pageRenderer
854 foreach ($preHeaderRenderHook as $hookFunction) {
855 \TYPO3\CMS\Core\Utility\GeneralUtility
::callUserFunction($hookFunction, $hookParameters, $this);
859 // Construct page header.
860 $str = $this->pageRenderer
->render(\TYPO3\CMS\Core\Page\PageRenderer
::PART_HEADER
);
861 $this->JScodeLibArray
= array();
862 $this->JScode
= ($this->extJScode
= '');
863 $this->JScodeArray
= array();
864 $this->endOfPageJsBlock
= $this->pageRenderer
->render(\TYPO3\CMS\Core\Page\PageRenderer
::PART_FOOTER
);
865 if ($this->docType
== 'xhtml_frames') {
868 $str .= $this->docBodyTagBegin() . ($this->divClass ?
'
870 <!-- Wrapping DIV-section for whole page BEGIN -->
871 <div class="' . $this->divClass
. '">
872 ' : '') . trim($this->form
);
878 * Returns page end; This includes finishing form, div, body and html tags.
880 * @return string The HTML end of a page
882 * @todo Define visibility
884 public function endPage() {
885 $str = $this->sectionEnd() . $this->postCode
. $this->endPageJS() . $this->wrapScriptTags(\TYPO3\CMS\Backend\Utility\BackendUtility
::getUpdateSignalCode()) . $this->parseTime() . ($this->form ?
'
887 // If something is in buffer like debug, put it to end of page
888 if (ob_get_contents()) {
889 $str .= ob_get_clean();
890 if (!headers_sent()) {
891 header('Content-Encoding: None');
894 if ($this->docType
!== 'xhtml_frames') {
895 $str .= ($this->divClass ?
'
897 <!-- Wrapping DIV-section for whole page END -->
898 </div>' : '') . $this->endOfPageJsBlock
;
900 // Logging: Can't find better place to put it:
902 \TYPO3\CMS\Core\Utility\GeneralUtility
::devLog('END of BACKEND session', 'TYPO3\\CMS\\Backend\\Template\\DocumentTemplate', 0, array('_FLUSH' => TRUE));
908 * Shortcut for render the complete page of a module
910 * @param string $title page title
911 * @param string $content page content
912 * @param boolean $includeCsh flag for including csh code
913 * @return string complete page
915 public function render($title, $content, $includeCsh = TRUE) {
916 $pageContent = $this->startPage($title, $includeCsh);
917 $pageContent .= $content;
918 $pageContent .= $this->endPage();
919 return $this->insertStylesAndJS($pageContent);
923 * Returns the header-bar in the top of most backend modules
924 * Closes section if open.
926 * @param string $text The text string for the header
927 * @return string HTML content
928 * @todo Define visibility
930 public function header($text) {
933 <!-- MAIN Header in page top -->
934 <h2>' . htmlspecialchars($text) . '</h2>
936 return $this->sectionEnd() . $str;
940 * Begins an output section and sets header and content
942 * @param string $label The header
943 * @param string $text The HTML-content
944 * @param boolean $nostrtoupper A flag that will prevent the header from being converted to uppercase
945 * @param boolean $sH Defines the type of header (if set, "<h3>" rather than the default "h4")
946 * @param integer $type The number of an icon to show with the header (see the icon-function). -1,1,2,3
947 * @param boolean $allowHTMLinHeader If set, HTML tags are allowed in $label (otherwise this value is by default htmlspecialchars()'ed)
948 * @return string HTML content
949 * @see icons(), sectionHeader()
950 * @todo Define visibility
952 public function section($label, $text, $nostrtoupper = FALSE, $sH = FALSE, $type = 0, $allowHTMLinHeader = FALSE) {
956 if (!$allowHTMLinHeader) {
957 $label = htmlspecialchars($label);
959 $str .= $this->sectionHeader($this->icons($type) . $label, $sH, $nostrtoupper ?
'' : ' class="uppercase"');
964 <!-- Section content -->
966 return $this->sectionBegin() . $str;
970 * Inserts a divider image
971 * Ends a section (if open) before inserting the image
973 * @param integer $dist The margin-top/-bottom of the <hr> ruler.
974 * @return string HTML content
975 * @todo Define visibility
977 public function divider($dist) {
978 $dist = intval($dist);
982 <hr style="margin-top: ' . $dist . 'px; margin-bottom: ' . $dist . 'px;" />
984 return $this->sectionEnd() . $str;
988 * Returns a blank <div>-section with a height
990 * @param integer $dist Padding-top for the div-section (should be margin-top but konqueror (3.1) doesn't like it :-(
991 * @return string HTML content
992 * @todo Define visibility
994 public function spacer($dist) {
998 <!-- Spacer element -->
999 <div style="padding-top: ' . intval($dist) . 'px;"></div>
1005 * Make a section header.
1006 * Begins a section if not already open.
1008 * @param string $label The label between the <h3> or <h4> tags. (Allows HTML)
1009 * @param boolean $sH If set, <h3> is used, otherwise <h4>
1010 * @param string $addAttrib Additional attributes to h-tag, eg. ' class=""'
1011 * @return string HTML content
1012 * @todo Define visibility
1014 public function sectionHeader($label, $sH = FALSE, $addAttrib = '') {
1015 $tag = $sH ?
'h3' : 'h4';
1016 if ($addAttrib && substr($addAttrib, 0, 1) !== ' ') {
1017 $addAttrib = ' ' . $addAttrib;
1021 <!-- Section header -->
1022 <' . $tag . $addAttrib . '>' . $label . '</' . $tag . '>
1024 return $this->sectionBegin() . $str;
1028 * Begins an output section.
1029 * Returns the <div>-begin tag AND sets the ->sectionFlag TRUE (if the ->sectionFlag is not already set!)
1030 * 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!
1032 * @return string HTML content
1033 * @todo Define visibility
1035 public function sectionBegin() {
1036 if (!$this->sectionFlag
) {
1037 $this->sectionFlag
= 1;
1040 <!-- ***********************
1041 Begin output section.
1042 *********************** -->
1052 * Ends and output section
1053 * Returns the </div>-end tag AND clears the ->sectionFlag (but does so only IF the sectionFlag is set - that is a section is 'open')
1054 * See sectionBegin() also.
1056 * @return string HTML content
1057 * @todo Define visibility
1059 public function sectionEnd() {
1060 if ($this->sectionFlag
) {
1061 $this->sectionFlag
= 0;
1064 <!-- *********************
1066 ********************* -->
1074 * If a form-tag is defined in ->form then and end-tag for that <form> element is outputted
1075 * Further a JavaScript section is outputted which will update the top.busy session-expiry object (unless $this->endJS is set to FALSE)
1077 * @return string HTML content (<script> tag section)
1078 * @todo Define visibility
1080 public function endPageJS() {
1081 return $this->endJS ?
'
1082 <script type="text/javascript">
1084 if (top.busy && top.busy.loginRefreshed) {
1085 top.busy.loginRefreshed();
1092 * Creates the bodyTag.
1093 * You can add to the bodyTag by $this->bodyTagAdditions
1095 * @return string HTML body tag
1096 * @todo Define visibility
1098 public function docBodyTagBegin() {
1099 $bodyContent = 'body onclick="if (top.menuReset) top.menuReset();" ' . trim(($this->bodyTagAdditions
. ($this->bodyTagId ?
' id="' . $this->bodyTagId
. '"' : '')));
1100 return '<' . trim($bodyContent) . '>';
1104 * Outputting document style
1106 * @return string HTML style section/link tags
1107 * @todo Define visibility
1109 public function docStyle() {
1110 // Request background image:
1111 if ($this->backGroundImage
) {
1112 $this->inDocStylesArray
[] = ' BODY { background-image: url(' . $this->backPath
. $this->backGroundImage
. '); }';
1114 // Add inDoc styles variables as well:
1115 $this->inDocStylesArray
[] = $this->inDocStyles
;
1116 $this->inDocStylesArray
[] = $this->inDocStyles_TBEstyle
;
1118 $inDocStyles = implode(LF
, $this->inDocStylesArray
);
1119 if ($this->styleSheetFile
) {
1120 $this->pageRenderer
->addCssFile($this->backPath
. $this->styleSheetFile
);
1122 if ($this->styleSheetFile2
) {
1123 $this->pageRenderer
->addCssFile($this->backPath
. $this->styleSheetFile2
);
1125 $this->pageRenderer
->addCssInlineBlock('inDocStyles', $inDocStyles . LF
. '/*###POSTCSSMARKER###*/');
1126 if ($this->styleSheetFile_post
) {
1127 $this->pageRenderer
->addCssFile($this->backPath
. $this->styleSheetFile_post
);
1132 * Insert additional style sheet link
1134 * @param string $key some key identifying the style sheet
1135 * @param string $href uri to the style sheet file
1136 * @param string $title value for the title attribute of the link element
1137 * @param string $relation value for the rel attribute of the link element
1139 * @todo Define visibility
1141 public function addStyleSheet($key, $href, $title = '', $relation = 'stylesheet') {
1142 if (strpos($href, '://') !== FALSE ||
substr($href, 0, 1) === '/') {
1145 $file = $this->backPath
. $href;
1147 $this->pageRenderer
->addCssFile($file, $relation, 'screen', $title);
1151 * Add all *.css files of the directory $path to the stylesheets
1153 * @param string $path directory to add
1155 * @todo Define visibility
1157 public function addStyleSheetDirectory($path) {
1158 // Calculation needed, when TYPO3 source is used via a symlink
1159 // absolute path to the stylesheets
1160 $filePath = dirname(\TYPO3\CMS\Core\Utility\GeneralUtility
::getIndpEnv('SCRIPT_FILENAME')) . '/' . $GLOBALS['BACK_PATH'] . $path;
1162 $resolvedPath = \TYPO3\CMS\Core\Utility\GeneralUtility
::resolveBackPath($filePath);
1163 // Read all files in directory and sort them alphabetically
1164 $files = \TYPO3\CMS\Core\Utility\GeneralUtility
::getFilesInDir($resolvedPath, 'css', FALSE, 1);
1165 foreach ($files as $file) {
1166 $this->pageRenderer
->addCssFile($GLOBALS['BACK_PATH'] . $path . $file, 'stylesheet', 'all');
1171 * Insert post rendering document style into already rendered content
1172 * This is needed for extobjbase
1174 * @param string $content style-content to insert.
1175 * @return string content with inserted styles
1176 * @todo Define visibility
1178 public function insertStylesAndJS($content) {
1179 // Insert accumulated CSS
1180 $this->inDocStylesArray
[] = $this->inDocStyles
;
1181 $styles = LF
. implode(LF
, $this->inDocStylesArray
);
1182 $content = str_replace('/*###POSTCSSMARKER###*/', $styles, $content);
1183 // Insert accumulated JS
1184 $jscode = $this->JScode
. LF
. $this->wrapScriptTags(implode(LF
, $this->JScodeArray
));
1185 $content = str_replace('<!--###POSTJSMARKER###-->', $jscode, $content);
1190 * Returns an array of all stylesheet directories belonging to core and skins
1192 * @return array Stylesheet directories
1194 public function getSkinStylesheetDirectories() {
1195 $stylesheetDirectories = array();
1196 // Add default core stylesheets
1197 foreach ($this->stylesheetsCore
as $stylesheetDir) {
1198 $stylesheetDirectories[] = $stylesheetDir;
1200 // Stylesheets from skins
1201 // merge default css directories ($this->stylesheetsSkin) with additional ones and include them
1202 if (is_array($GLOBALS['TBE_STYLES']['skins'])) {
1203 // loop over all registered skins
1204 foreach ($GLOBALS['TBE_STYLES']['skins'] as $skinExtKey => $skin) {
1205 $skinStylesheetDirs = $this->stylesheetsSkins
;
1206 // Skins can add custom stylesheetDirectories using
1207 // $GLOBALS['TBE_STYLES']['skins'][$_EXTKEY]['stylesheetDirectories']
1208 if (is_array($skin['stylesheetDirectories'])) {
1209 $skinStylesheetDirs = array_merge($skinStylesheetDirs, $skin['stylesheetDirectories']);
1211 // Add all registered directories
1212 foreach ($skinStylesheetDirs as $stylesheetDir) {
1213 // for EXT:myskin/stylesheets/ syntax
1214 if (substr($stylesheetDir, 0, 4) === 'EXT:') {
1215 list($extKey, $path) = explode('/', substr($stylesheetDir, 4), 2);
1216 if (strcmp($extKey, '') && \TYPO3\CMS\Core\Extension\ExtensionManager
::isLoaded($extKey) && strcmp($path, '')) {
1217 $stylesheetDirectories[] = \TYPO3\CMS\Core\Extension\ExtensionManager
::extRelPath($extKey) . $path;
1220 // For relative paths
1221 $stylesheetDirectories[] = \TYPO3\CMS\Core\Extension\ExtensionManager
::extRelPath($skinExtKey) . $stylesheetDir;
1226 return $stylesheetDirectories;
1230 * Initialize the charset.
1231 * Sets the internal $this->charset variable to the charset defined in $GLOBALS["LANG"] (or the default as set in this class)
1232 * Returns the meta-tag for the document header
1234 * @return string <meta> tag with charset from $this->charset or $GLOBALS['LANG']->charSet
1235 * @todo Define visibility
1236 * @deprecated since TYPO3 6.0, remove in 6.2. The charset is utf-8 all the time for the backend now
1238 public function initCharset() {
1239 \TYPO3\CMS\Core\Utility\GeneralUtility
::logDeprecatedFunction();
1241 return '<meta http-equiv="Content-Type" content="text/html; charset=' . $this->charset
. '" />';
1245 * Returns generator meta tag
1247 * @return string <meta> tag with name "generator
1248 * @todo Define visibility
1250 public function generator() {
1251 $str = 'TYPO3 ' . TYPO3_branch
. ', ' . TYPO3_URL_GENERAL
. ', © Kasper Skårhøj ' . TYPO3_copyright_year
. ', extensions are copyright of their respective owners.';
1252 return '<meta name="generator" content="' . $str . '" />';
1256 * Returns X-UA-Compatible meta tag
1258 * @param string $content Content of the compatible tag (default: IE-8)
1259 * @return string <meta http-equiv="X-UA-Compatible" content="???" />
1261 public function xUaCompatible($content = 'IE=8') {
1262 return '<meta http-equiv="X-UA-Compatible" content="' . $content . '" />';
1265 /*****************************************
1268 * Tables, buttons, formatting dimmed/red strings
1270 ******************************************/
1272 * Returns an image-tag with an 18x16 icon of the following types:
1275 * -1: OK icon (Check-mark)
1276 * 1: Notice (Speach-bubble)
1277 * 2: Warning (Yellow triangle)
1278 * 3: Fatal error (Red stop sign)
1280 * @param integer $type See description
1281 * @param string $styleAttribValue Value for style attribute
1282 * @return string HTML image tag (if applicable)
1283 * @todo Define visibility
1285 public function icons($type, $styleAttribValue = '') {
1287 case self
::STATUS_ICON_ERROR
:
1288 $icon = 'status-dialog-error';
1290 case self
::STATUS_ICON_WARNING
:
1291 $icon = 'status-dialog-warning';
1293 case self
::STATUS_ICON_NOTIFICATION
:
1294 $icon = 'status-dialog-notification';
1296 case self
::STATUS_ICON_OK
:
1297 $icon = 'status-dialog-ok';
1303 return \TYPO3\CMS\Backend\Utility\IconUtility
::getSpriteIcon($icon);
1308 * Returns an <input> button with the $onClick action and $label
1310 * @param string $onClick The value of the onclick attribute of the input tag (submit type)
1311 * @param string $label The label for the button (which will be htmlspecialchar'ed)
1312 * @return string A <input> tag of the type "submit
1313 * @todo Define visibility
1315 public function t3Button($onClick, $label) {
1316 $button = '<input type="submit" onclick="' . htmlspecialchars($onClick) . '; return false;" value="' . htmlspecialchars($label) . '" />';
1321 * Dimmed-fontwrap. Returns the string wrapped in a <span>-tag defining the color to be gray/dimmed
1323 * @param string $string Input string
1324 * @return string Output string
1325 * @todo Define visibility
1327 public function dfw($string) {
1328 return '<span class="typo3-dimmed">' . $string . '</span>';
1332 * red-fontwrap. Returns the string wrapped in a <span>-tag defining the color to be red
1334 * @param string $string Input string
1335 * @return string Output string
1336 * @todo Define visibility
1338 public function rfw($string) {
1339 return '<span class="typo3-red">' . $string . '</span>';
1343 * Returns string wrapped in CDATA "tags" for XML / XHTML (wrap content of <script> and <style> sections in those!)
1345 * @param string $string Input string
1346 * @return string Output string
1347 * @todo Define visibility
1349 public function wrapInCData($string) {
1350 $string = '/*<![CDATA[*/' . $string . '/*]]>*/';
1355 * Wraps the input string in script tags.
1356 * Automatic re-identing of the JS code is done by using the first line as ident reference.
1357 * This is nice for identing JS code with PHP code on the same level.
1359 * @param string $string Input string
1360 * @param boolean $linebreak Wrap script element in linebreaks? Default is TRUE.
1361 * @return string Output string
1362 * @todo Define visibility
1364 public function wrapScriptTags($string, $linebreak = TRUE) {
1365 if (trim($string)) {
1366 // <script wrapped in nl?
1367 $cr = $linebreak ? LF
: '';
1368 // Remove nl from the beginning
1369 $string = preg_replace('/^\\n+/', '', $string);
1370 // Re-ident to one tab using the first line as reference
1372 if (preg_match('/^(\\t+)/', $string, $match)) {
1373 $string = str_replace($match[1], TAB
, $string);
1375 $string = $cr . '<script type="text/javascript">
1381 return trim($string);
1384 // These vars defines the layout for the table produced by the table() function.
1385 // You can override these values from outside if you like.
1387 * @todo Define visibility
1389 public $tableLayout = array(
1391 'defCol' => array('<td valign="top">', '</td>')
1396 * @todo Define visibility
1398 public $table_TR = '<tr>';
1401 * @todo Define visibility
1403 public $table_TABLE = '<table border="0" cellspacing="0" cellpadding="0" class="typo3-dblist" id="typo3-tmpltable">';
1406 * Returns a table based on the input $data
1408 * @param array $data Multidim array with first levels = rows, second levels = cells
1409 * @param array $layout If set, then this provides an alternative layout array instead of $this->tableLayout
1410 * @return string The HTML table.
1412 * @todo Define visibility
1414 public function table($data, $layout = NULL) {
1416 if (is_array($data)) {
1417 $tableLayout = is_array($layout) ?
$layout : $this->tableLayout
;
1419 foreach ($data as $tableRow) {
1420 if ($rowCount %
2) {
1421 $layout = is_array($tableLayout['defRowOdd']) ?
$tableLayout['defRowOdd'] : $tableLayout['defRow'];
1423 $layout = is_array($tableLayout['defRowEven']) ?
$tableLayout['defRowEven'] : $tableLayout['defRow'];
1425 $rowLayout = is_array($tableLayout[$rowCount]) ?
$tableLayout[$rowCount] : $layout;
1427 if (is_array($tableRow)) {
1429 foreach ($tableRow as $tableCell) {
1430 $cellWrap = is_array($layout[$cellCount]) ?
$layout[$cellCount] : $layout['defCol'];
1431 $cellWrap = is_array($rowLayout['defCol']) ?
$rowLayout['defCol'] : $cellWrap;
1432 $cellWrap = is_array($rowLayout[$cellCount]) ?
$rowLayout[$cellCount] : $cellWrap;
1433 $rowResult .= $cellWrap[0] . $tableCell . $cellWrap[1];
1437 $rowWrap = is_array($layout['tr']) ?
$layout['tr'] : array($this->table_TR
, '</tr>');
1438 $rowWrap = is_array($rowLayout['tr']) ?
$rowLayout['tr'] : $rowWrap;
1439 $result .= $rowWrap[0] . $rowResult . $rowWrap[1];
1442 $tableWrap = is_array($tableLayout['table']) ?
$tableLayout['table'] : array($this->table_TABLE
, '</table>');
1443 $result = $tableWrap[0] . $result . $tableWrap[1];
1449 * Constructs a table with content from the $arr1, $arr2 and $arr3.
1450 * Used in eg. ext/belog/mod/index.php - refer to that for examples
1452 * @param array $arr1 Menu elements on first level
1453 * @param array $arr2 Secondary items
1454 * @param array $arr3 Third-level items
1455 * @return string HTML content, <table>...</table>
1456 * @todo Define visibility
1458 public function menuTable($arr1, $arr2 = array(), $arr3 = array()) {
1459 $rows = max(array(count($arr1), count($arr2), count($arr3)));
1461 <table border="0" cellpadding="0" cellspacing="0" id="typo3-tablemenu">';
1462 for ($a = 0; $a < $rows; $a++
) {
1466 $cls[] = '<td valign="' . $valign . '">' . $arr1[$a][0] . '</td><td>' . $arr1[$a][1] . '</td>';
1468 $cls[] = '<td valign="' . $valign . '">' . $arr2[$a][0] . '</td><td>' . $arr2[$a][1] . '</td>';
1470 $cls[] = '<td valign="' . $valign . '">' . $arr3[$a][0] . '</td><td>' . $arr3[$a][1] . '</td>';
1473 $menu .= implode($cls, '<td> </td>');
1483 * Returns a one-row/two-celled table with $content and $menu side by side.
1484 * The table is a 100% width table and each cell is aligned left / right
1486 * @param string $content Content cell content (left)
1487 * @param string $menu Menu cell content (right)
1488 * @return string HTML output
1489 * @todo Define visibility
1491 public function funcMenu($content, $menu) {
1493 <table border="0" cellpadding="0" cellspacing="0" width="100%" id="typo3-funcmenu">
1495 <td valign="top" nowrap="nowrap">' . $content . '</td>
1496 <td valign="top" align="right" nowrap="nowrap">' . $menu . '</td>
1502 * Includes a javascript library that exists in the core /typo3/ directory. The
1503 * backpath is automatically applied
1505 * @param string $lib: Library name. Call it with the full path like "contrib/prototype/prototype.js" to load it
1507 * @todo Define visibility
1509 public function loadJavascriptLib($lib) {
1510 $this->pageRenderer
->addJsFile($this->backPath
. $lib);
1514 * Includes the necessary Javascript function for the clickmenu (context sensitive menus) in the document
1517 * @todo Define visibility
1519 public function getContextMenuCode() {
1520 $this->pageRenderer
->loadPrototype();
1521 $this->loadJavascriptLib('js/clickmenu.js');
1522 $this->JScodeArray
['clickmenu'] = '
1523 Clickmenu.clickURL = "' . $this->backPath
. 'alt_clickmenu.php";
1524 Clickmenu.ajax = ' . ($this->isCMLayers() ?
'true' : 'false') . ';';
1528 * Includes the necessary javascript file (tree.js) for use on pages which have the
1529 * drag and drop functionality (usually pages and folder display trees)
1531 * @param string $table indicator of which table the drag and drop function should work on (pages or folders)
1533 * @todo Define visibility
1535 public function getDragDropCode($table) {
1536 $this->pageRenderer
->loadPrototype();
1537 $this->loadJavascriptLib('js/common.js');
1538 $this->loadJavascriptLib('js/tree.js');
1539 // Setting prefs for drag & drop
1540 $this->JScodeArray
['dragdrop'] = '
1541 DragDrop.changeURL = "' . $this->backPath
. 'alt_clickmenu.php";
1542 DragDrop.backPath = "' . \TYPO3\CMS\Core\Utility\GeneralUtility
::shortMD5(('' . '|' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) . '";
1543 DragDrop.table = "' . $table . '";
1548 * This loads everything needed for the Context Sensitive Help (CSH)
1552 protected function loadCshJavascript() {
1553 $this->pageRenderer
->loadExtJS();
1554 $this->pageRenderer
->addJsFile($this->backPath
. '../t3lib/js/extjs/contexthelp.js');
1555 $this->pageRenderer
->addExtDirectCode();
1559 * Creates a tab menu from an array definition
1561 * Returns a tab menu for a module
1562 * Requires the JS function jumpToUrl() to be available
1564 * @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=...
1565 * @param string $elementName it the form elements name, probably something like "SET[...]
1566 * @param string $currentValue is the value to be selected currently.
1567 * @param array $menuItems is an array with the menu items for the selector box
1568 * @param string $script is the script to send the &id to, if empty it's automatically found
1569 * @param string $addparams is additional parameters to pass to the script.
1570 * @return string HTML code for tab menu
1571 * @todo Define visibility
1573 public function getTabMenu($mainParams, $elementName, $currentValue, $menuItems, $script = '', $addparams = '') {
1575 if (is_array($menuItems)) {
1576 if (!is_array($mainParams)) {
1577 $mainParams = array('id' => $mainParams);
1579 $mainParams = \TYPO3\CMS\Core\Utility\GeneralUtility
::implodeArrayForUrl('', $mainParams);
1581 $script = basename(PATH_thisScript
);
1584 foreach ($menuItems as $value => $label) {
1585 $menuDef[$value]['isActive'] = !strcmp($currentValue, $value);
1586 $menuDef[$value]['label'] = \TYPO3\CMS\Core\Utility\GeneralUtility
::deHSCentities(htmlspecialchars($label));
1587 $menuDef[$value]['url'] = $script . '?' . $mainParams . $addparams . '&' . $elementName . '=' . $value;
1589 $content = $this->getTabMenuRaw($menuDef);
1595 * Creates the HTML content for the tab menu
1597 * @param array $menuItems Menu items for tabs
1598 * @return string Table HTML
1600 * @todo Define visibility
1602 public function getTabMenuRaw($menuItems) {
1604 if (is_array($menuItems)) {
1606 $count = count($menuItems);
1609 $widthRight = max(1, floor(30 - pow($count, 1.72)));
1610 $widthTabs = 100 - $widthRight - $widthLeft;
1611 $widthNo = floor(($widthTabs - $addToAct) / $count);
1612 $addToAct = max($addToAct, $widthTabs - $widthNo * $count);
1613 $widthAct = $widthNo +
$addToAct;
1614 $widthRight = 100 - ($widthLeft +
$count * $widthNo +
$addToAct);
1615 foreach ($menuItems as $id => $def) {
1616 $isActive = $def['isActive'];
1617 $class = $isActive ?
'tabact' : 'tab';
1618 $width = $isActive ?
$widthAct : $widthNo;
1619 // @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.
1620 $label = $def['label'];
1621 $url = htmlspecialchars($def['url']);
1622 $params = $def['addParams'];
1623 $options .= '<td width="' . $width . '%" class="' . $class . '"><a href="' . $url . '" ' . $params . '>' . $label . '</a></td>';
1628 <table cellpadding="0" cellspacing="0" border="0" width="100%" id="typo3-tabmenu">
1630 <td width="' . $widthLeft . '%"> </td>
1632 <td width="' . $widthRight . '%"> </td>
1635 <div class="hr" style="margin:0px"></div>';
1642 * Creates a DYNAMIC tab-menu where the tabs are switched between with DHTML.
1643 * 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!
1645 * @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.
1646 * @param string $identString Identification string. This should be unique for every instance of a dynamic menu!
1647 * @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.
1648 * @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.
1649 * @param boolean $noWrap If set, tab table cells are not allowed to wrap their content
1650 * @param boolean $fullWidth If set, the tabs will span the full width of their position
1651 * @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.
1652 * @param integer $dividers2tabs If set to '1' empty tabs will be remove, If set to '2' empty tabs will be disabled
1653 * @return string JavaScript section for the HTML header.
1655 public function getDynTabMenu($menuItems, $identString, $toggle = 0, $foldout = FALSE, $noWrap = TRUE, $fullWidth = FALSE, $defaultTabIndex = 1, $dividers2tabs = 2) {
1656 // Load the static code, if not already done with the function below
1657 $this->loadJavascriptLib('js/tabmenu.js');
1659 if (is_array($menuItems)) {
1661 $options = array(array());
1664 $id = $this->getDynTabMenuId($identString);
1665 $noWrap = $noWrap ?
' nowrap="nowrap"' : '';
1666 // Traverse menu items
1670 foreach ($menuItems as $index => $def) {
1671 // Need to add one so checking for first index in JavaScript
1672 // is different than if it is not set at all.
1674 // Switch to next tab row if needed
1675 if (!$foldout && ($def['newline'] === TRUE && $titleLenCount > 0)) {
1678 $options[$tabRows] = array();
1681 $onclick = 'this.blur(); DTM_toggle("' . $id . '","' . $index . '"); return false;';
1683 $onclick = 'this.blur(); DTM_activate("' . $id . '","' . $index . '", ' . ($toggle < 0 ?
1 : 0) . '); return false;';
1685 $isEmpty = !(strcmp(trim($def['content']), '') ||
strcmp(trim($def['icon']), ''));
1686 // "Removes" empty tabs
1687 if ($isEmpty && $dividers2tabs == 1) {
1690 $mouseOverOut = ' onmouseover="DTM_mouseOver(this);" onmouseout="DTM_mouseOut(this);"';
1691 $requiredIcon = '<img name="' . $id . '-' . $index . '-REQ" src="' . $GLOBALS['BACK_PATH'] . 'gfx/clear.gif" class="t3-TCEforms-reqTabImg" alt="" />';
1694 $options[$tabRows][] = '
1695 <td class="' . ($isEmpty ?
'disabled' : 'tab') . '" id="' . $id . '-' . $index . '-MENU"' . $noWrap . $mouseOverOut . '>' . ($isEmpty ?
'' : '<a href="#" onclick="' . htmlspecialchars($onclick) . '"' . ($def['linkTitle'] ?
' title="' . htmlspecialchars($def['linkTitle']) . '"' : '') . '>') . $def['icon'] . ($def['label'] ?
htmlspecialchars($def['label']) : ' ') . $requiredIcon . $this->icons($def['stateIcon'], 'margin-left: 10px;') . ($isEmpty ?
'' : '</a>') . '</td>';
1696 $titleLenCount +
= strlen($def['label']);
1698 // Create DIV layer for content:
1700 <div class="' . ($isEmpty ?
'disabled' : 'tab') . '" id="' . $id . '-' . $index . '-MENU"' . $mouseOverOut . '>' . ($isEmpty ?
'' : '<a href="#" onclick="' . htmlspecialchars($onclick) . '"' . ($def['linkTitle'] ?
' title="' . htmlspecialchars($def['linkTitle']) . '"' : '') . '>') . $def['icon'] . ($def['label'] ?
htmlspecialchars($def['label']) : ' ') . $requiredIcon . ($isEmpty ?
'' : '</a>') . '</div>';
1702 // Create DIV layer for content:
1704 <div style="display: none;" id="' . $id . '-' . $index . '-DIV" class="c-tablayer">' . ($def['description'] ?
'<p class="c-descr">' . nl2br(htmlspecialchars($def['description'])) . '</p>' : '') . $def['content'] . '</div>';
1705 // Create initialization string:
1707 DTM_array["' . $id . '"][' . $c . '] = "' . $id . '-' . $index . '";
1709 // If not empty and we have the toggle option on, check if the tab needs to be expanded
1710 if ($toggle == 1 && !$isEmpty) {
1712 if (top.DTM_currentTabs["' . $id . '-' . $index . '"]) { DTM_toggle("' . $id . '","' . $index . '",1); }
1718 if (count($options)) {
1719 // Tab menu is compiled:
1722 for ($a = 0; $a <= $tabRows; $a++
) {
1726 <table cellpadding="0" cellspacing="0" border="0"' . ($fullWidth ?
' width="100%"' : '') . ' class="typo3-dyntabmenu">
1728 ' . implode('', $options[$a]) . '
1732 $content .= '<div class="typo3-dyntabmenu-tabs">' . $tabContent . '</div>';
1734 // Div layers are added:
1736 <!-- Div layers for tab menu: -->
1737 <div class="typo3-dyntabmenu-divs' . ($foldout ?
'-foldout' : '') . '">
1738 ' . implode('', $divs) . '</div>';
1739 // Java Script section added:
1741 <!-- Initialization JavaScript for the menu -->
1742 <script type="text/javascript">
1743 DTM_array["' . $id . '"] = new Array();
1744 ' . implode('', $JSinit) . '
1745 ' . ($toggle <= 0 ?
'DTM_activate("' . $id . '", top.DTM_currentTabs["' . $id . '"]?top.DTM_currentTabs["' . $id . '"]:' . intval($defaultTabIndex) . ', 0);' : '') . '
1755 * Creates the id for dynTabMenus.
1757 * @param string $identString Identification string. This should be unique for every instance of a dynamic menu!
1758 * @return string The id with a short MD5 of $identString and prefixed "DTM-", like "DTM-2e8791854a
1759 * @todo Define visibility
1761 public function getDynTabMenuId($identString) {
1762 $id = 'DTM-' . \TYPO3\CMS\Core\Utility\GeneralUtility
::shortMD5($identString);
1767 * Creates the version selector for the page id inputted.
1768 * Requires the core version management extension, "version" to be loaded.
1770 * @param integer $id Page id to create selector for.
1771 * @param boolean $noAction If set, there will be no button for swapping page.
1774 public function getVersionSelector($id, $noAction = FALSE) {
1775 if (\TYPO3\CMS\Core\Extension\ExtensionManager
::isLoaded('version')) {
1776 $versionGuiObj = \TYPO3\CMS\Core\Utility\GeneralUtility
::makeInstance('TYPO3\\CMS\\Version\\View\\VersionView');
1777 return $versionGuiObj->getVersionSelector($id, $noAction);
1782 * Function to load a HTML template file with markers.
1783 * When calling from own extension, use syntax getHtmlTemplate('EXT:extkey/template.html')
1785 * @param string $filename tmpl name, usually in the typo3/template/ directory
1786 * @return string HTML of template
1787 * @todo Define visibility
1789 public function getHtmlTemplate($filename) {
1790 // setting the name of the original HTML template
1791 $this->moduleTemplateFilename
= $filename;
1792 if ($GLOBALS['TBE_STYLES']['htmlTemplates'][$filename]) {
1793 $filename = $GLOBALS['TBE_STYLES']['htmlTemplates'][$filename];
1795 if (\TYPO3\CMS\Core\Utility\GeneralUtility
::isFirstPartOfStr($filename, 'EXT:')) {
1796 $filename = \TYPO3\CMS\Core\Utility\GeneralUtility
::getFileAbsFileName($filename, TRUE, TRUE);
1797 } elseif (!\TYPO3\CMS\Core\Utility\GeneralUtility
::isAbsPath($filename)) {
1798 $filename = \TYPO3\CMS\Core\Utility\GeneralUtility
::resolveBackPath($this->backPath
. $filename);
1799 } elseif (!\TYPO3\CMS\Core\Utility\GeneralUtility
::isAllowedAbsPath($filename)) {
1803 if ($filename !== '') {
1804 $htmlTemplate = \TYPO3\CMS\Core\Utility\GeneralUtility
::getUrl($filename);
1806 return $htmlTemplate;
1810 * Define the template for the module
1812 * @param string $filename filename
1815 public function setModuleTemplate($filename) {
1816 // Load Prototype lib for IE event
1817 $this->pageRenderer
->loadPrototype();
1818 $this->loadJavascriptLib('js/iecompatibility.js');
1819 $this->moduleTemplate
= $this->getHtmlTemplate($filename);
1823 * Put together the various elements for the module <body> using a static HTML
1826 * @param array $pageRecord Record of the current page, used for page path and info
1827 * @param array $buttons HTML for all buttons
1828 * @param array $markerArray HTML for all other markers
1829 * @param array $subpartArray HTML for the subparts
1830 * @return string Composite HTML
1832 public function moduleBody($pageRecord = array(), $buttons = array(), $markerArray = array(), $subpartArray = array()) {
1833 // Get the HTML template for the module
1834 $moduleBody = \TYPO3\CMS\Core\Html\HtmlParser
::getSubpart($this->moduleTemplate
, '###FULLDOC###');
1836 $this->inDocStylesArray
[] = 'html { overflow: hidden; }';
1837 // Get the page path for the docheader
1838 $markerArray['PAGEPATH'] = $this->getPagePath($pageRecord);
1839 // Get the page info for the docheader
1840 $markerArray['PAGEINFO'] = $this->getPageInfo($pageRecord);
1841 // Get all the buttons for the docheader
1842 $docHeaderButtons = $this->getDocHeaderButtons($buttons);
1843 // Merge docheader buttons with the marker array
1844 $markerArray = array_merge($markerArray, $docHeaderButtons);
1845 // replacing subparts
1846 foreach ($subpartArray as $marker => $content) {
1847 $moduleBody = \TYPO3\CMS\Core\Html\HtmlParser
::substituteSubpart($moduleBody, $marker, $content);
1849 // adding flash messages
1850 if ($this->showFlashMessages
) {
1851 $flashMessages = \TYPO3\CMS\Core\Messaging\FlashMessageQueue
::renderFlashMessages();
1852 if (!empty($flashMessages)) {
1853 $markerArray['FLASHMESSAGES'] = '<div id="typo3-messages">' . $flashMessages . '</div>';
1854 // If there is no dedicated marker for the messages present
1855 // then force them to appear before the content
1856 if (strpos($moduleBody, '###FLASHMESSAGES###') === FALSE) {
1857 $moduleBody = str_replace('###CONTENT###', '###FLASHMESSAGES######CONTENT###', $moduleBody);
1861 // Hook for adding more markers/content to the page, like the version selector
1862 if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['moduleBodyPostProcess'])) {
1864 'moduleTemplateFilename' => &$this->moduleTemplateFilename
,
1865 'moduleTemplate' => &$this->moduleTemplate
,
1866 'moduleBody' => &$moduleBody,
1867 'markers' => &$markerArray,
1868 'parentObject' => &$this
1870 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['moduleBodyPostProcess'] as $funcRef) {
1871 \TYPO3\CMS\Core\Utility\GeneralUtility
::callUserFunction($funcRef, $params, $this);
1874 // Replacing all markers with the finished markers and return the HTML content
1875 return \TYPO3\CMS\Core\Html\HtmlParser
::substituteMarkerArray($moduleBody, $markerArray, '###|###');
1879 * Fill the button lists with the defined HTML
1881 * @param array $buttons HTML for all buttons
1882 * @return array Containing HTML for both buttonlists
1884 protected function getDocHeaderButtons($buttons) {
1886 // Fill buttons for left and right float
1887 $floats = array('left', 'right');
1888 foreach ($floats as $key) {
1889 // Get the template for each float
1890 $buttonTemplate = \TYPO3\CMS\Core\Html\HtmlParser
::getSubpart($this->moduleTemplate
, '###BUTTON_GROUPS_' . strtoupper($key) . '###');
1891 // Fill the button markers in this float
1892 $buttonTemplate = \TYPO3\CMS\Core\Html\HtmlParser
::substituteMarkerArray($buttonTemplate, $buttons, '###|###', TRUE);
1893 // getting the wrap for each group
1894 $buttonWrap = \TYPO3\CMS\Core\Html\HtmlParser
::getSubpart($this->moduleTemplate
, '###BUTTON_GROUP_WRAP###');
1895 // looping through the groups (max 6) and remove the empty groups
1896 for ($groupNumber = 1; $groupNumber < 6; $groupNumber++
) {
1897 $buttonMarker = '###BUTTON_GROUP' . $groupNumber . '###';
1898 $buttonGroup = \TYPO3\CMS\Core\Html\HtmlParser
::getSubpart($buttonTemplate, $buttonMarker);
1899 if (trim($buttonGroup)) {
1901 $buttonGroup = \TYPO3\CMS\Core\Html\HtmlParser
::substituteMarker($buttonWrap, '###BUTTONS###', $buttonGroup);
1903 $buttonTemplate = \TYPO3\CMS\Core\Html\HtmlParser
::substituteSubpart($buttonTemplate, $buttonMarker, trim($buttonGroup));
1906 // Replace the marker with the template and remove all line breaks (for IE compat)
1907 $markers['BUTTONLIST_' . strtoupper($key)] = str_replace(LF
, '', $buttonTemplate);
1909 // Hook for manipulating docHeaderButtons
1910 if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['docHeaderButtonsHook'])) {
1912 'buttons' => $buttons,
1913 'markers' => &$markers,
1916 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['docHeaderButtonsHook'] as $funcRef) {
1917 \TYPO3\CMS\Core\Utility\GeneralUtility
::callUserFunction($funcRef, $params, $this);
1924 * Generate the page path for docheader
1926 * @param array $pageRecord Current page
1927 * @return string Page path
1929 protected function getPagePath($pageRecord) {
1930 // Is this a real page
1931 if (is_array($pageRecord) && $pageRecord['uid']) {
1932 $title = substr($pageRecord['_thePathFull'], 0, -1);
1933 // Remove current page title
1934 $pos = strrpos($title, '/');
1935 if ($pos !== FALSE) {
1936 $title = substr($title, 0, $pos) . '/';
1941 // Setting the path of the page
1942 $pagePath = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.path', 1) . ': <span class="typo3-docheader-pagePath">';
1943 // crop the title to title limit (or 50, if not defined)
1944 $cropLength = empty($GLOBALS['BE_USER']->uc
['titleLen']) ?
50 : $GLOBALS['BE_USER']->uc
['titleLen'];
1945 $croppedTitle = \TYPO3\CMS\Core\Utility\GeneralUtility
::fixed_lgd_cs($title, -$cropLength);
1946 if ($croppedTitle !== $title) {
1947 $pagePath .= '<abbr title="' . htmlspecialchars($title) . '">' . htmlspecialchars($croppedTitle) . '</abbr>';
1949 $pagePath .= htmlspecialchars($title);
1951 $pagePath .= '</span>';
1956 * Setting page icon with clickmenu + uid for docheader
1958 * @param array $pageRecord Current page
1959 * @return string Page info
1961 protected function getPageInfo($pageRecord) {
1962 // Add icon with clickmenu, etc:
1963 // If there IS a real page
1964 if (is_array($pageRecord) && $pageRecord['uid']) {
1965 $alttext = \TYPO3\CMS\Backend\Utility\BackendUtility
::getRecordIconAltText($pageRecord, 'pages');
1966 $iconImg = \TYPO3\CMS\Backend\Utility\IconUtility
::getSpriteIconForRecord('pages', $pageRecord, array('title' => $alttext));
1968 $theIcon = $GLOBALS['SOBE']->doc
->wrapClickMenuOnIcon($iconImg, 'pages', $pageRecord['uid']);
1969 $uid = $pageRecord['uid'];
1970 $title = \TYPO3\CMS\Backend\Utility\BackendUtility
::getRecordTitle('pages', $pageRecord);
1972 // On root-level of page tree
1974 $iconImg = \TYPO3\CMS\Backend\Utility\IconUtility
::getSpriteIcon('apps-pagetree-root', array('title' => htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'])));
1975 if ($GLOBALS['BE_USER']->user
['admin']) {
1976 $theIcon = $GLOBALS['SOBE']->doc
->wrapClickMenuOnIcon($iconImg, 'pages', 0);
1978 $theIcon = $iconImg;
1981 $title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
1983 // Setting icon with clickmenu + uid
1984 $pageInfo = $theIcon . '<strong>' . htmlspecialchars($title) . ' [' . $uid . ']</strong>';
1989 * Makes a collapseable section. See reports module for an example
1991 * @param string $title
1992 * @param string $html
1994 * @param string $saveStatePointer
1997 public function collapseableSection($title, $html, $id, $saveStatePointer = '') {
1998 $hasSave = $saveStatePointer ?
TRUE : FALSE;
1999 $collapsedStyle = ($collapsedClass = '');
2001 /** @var $settings \TYPO3\CMS\Backend\User\ExtDirect\BackendUserSettingsDataProvider */
2002 $settings = \TYPO3\CMS\Core\Utility\GeneralUtility
::makeInstance('TYPO3\\CMS\\Backend\\User\\ExtDirect\\BackendUserSettingsDataProvider');
2003 $value = $settings->get($saveStatePointer . '.' . $id);
2005 $collapsedStyle = ' style="display: none"';
2006 $collapsedClass = ' collapsed';
2008 $collapsedStyle = '';
2009 $collapsedClass = ' expanded';
2012 $this->pageRenderer
->loadExtJS();
2013 $this->pageRenderer
->addExtOnReadyCode('
2014 Ext.select("h2.section-header").each(function(element){
2015 element.on("click", function(event, tag) {
2018 div = el.next("div"),
2019 saveKey = el.getAttribute("rel");
2020 if (el.hasClass("collapsed")) {
2021 el.removeClass("collapsed").addClass("expanded");
2027 el.removeClass("expanded").addClass("collapsed");
2038 top.TYPO3.BackendUserSettings.ExtDirect.set(saveKey + "." + tag.id, state, function(response) {});
2045 <h2 id="' . $id . '" class="section-header' . $collapsedClass . '" rel="' . $saveStatePointer . '"> ' . $title . '</h2>
2046 <div' . $collapsedStyle . '>' . $html . '</div>