PageRenderTime 56ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/typo3/template.php

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