PageRenderTime 69ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 1ms

/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

Large files files are truncated, but you can click here to view the full file

  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_r

Large files files are truncated, but you can click here to view the full file