/** * Returns page start * This includes the proper header with charset, title, meta tag and beginning body-tag. * * @param string HTML Page title for the header * @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) * @see endPage() */ function startPage($title) { // hook pre start page if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preStartPageHook'])) { $preStartPageHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preStartPageHook']; if (is_array($preStartPageHook)) { $hookParameters = array('title' => &$title); foreach ($preStartPageHook as $hookFunction) { t3lib_div::callUserFunction($hookFunction, $hookParameters, $this); } } } $this->pageRenderer->backPath = $this->backPath; // alternative template for Header and Footer if ($this->pageHeaderFooterTemplateFile) { $file = t3lib_div::getFileAbsFileName($this->pageHeaderFooterTemplateFile, TRUE); if ($file) { $this->pageRenderer->setTemplateFile($file); } } // For debugging: If this outputs "QuirksMode"/"BackCompat" (IE) the browser runs in quirks-mode. Otherwise the value is "CSS1Compat" # $this->JScodeArray[]='alert(document.compatMode);'; // Send HTTP header for selected charset. Added by Robert Lemke 23.10.2003 $this->initCharset(); header('Content-Type:text/html;charset=' . $this->charset); // Standard HTML tag $htmlTag = '<html xmlns="http://www.w3.org/1999/xhtml">'; switch ($this->docType) { case 'html_3': $headerStart = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">'; $htmlTag = '<html>'; // disable rendering of XHTML tags $this->getPageRenderer()->setRenderXhtml(FALSE); break; case 'xhtml_strict': $headerStart = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'; break; case 'xhtml_frames': $headerStart = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">'; break; case 'html_5': $headerStart = '<!DOCTYPE html>' . LF; $htmlTag = '<html>'; // disable rendering of XHTML tags $this->getPageRenderer()->setRenderXhtml(FALSE); break; // The fallthrough is intended as XHTML 1.0 transitional is the default for the BE. // The fallthrough is intended as XHTML 1.0 transitional is the default for the BE. case 'xhtml_trans': default: $headerStart = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'; } $this->pageRenderer->setHtmlTag($htmlTag); // This loads the tabulator-in-textarea feature. It automatically modifies // every textarea which is found. if (!$GLOBALS['BE_USER']->uc['disableTabInTextarea']) { $this->loadJavascriptLib('tab.js'); } // Get the browser info $browserInfo = t3lib_utility_Client::getBrowserInfo(t3lib_div::getIndpEnv('HTTP_USER_AGENT')); // Set the XML prologue $xmlPrologue = '<?xml version="1.0" encoding="' . $this->charset . '"?>'; // Set the XML stylesheet $xmlStylesheet = '<?xml-stylesheet href="#internalStyle" type="text/css"?>'; // Add the XML prologue for XHTML doctypes if ($this->docType !== 'html_3' && $this->docType !== 'html_5') { // Put the XML prologue before or after the doctype declaration according to browser if ($browserInfo['browser'] === 'msie' && $browserInfo['version'] < 7) { $headerStart = $headerStart . LF . $xmlPrologue; } else { $headerStart = $xmlPrologue . LF . $headerStart; } // Add the xml stylesheet according to doctype if ($this->docType !== 'xhtml_frames') { $headerStart = $headerStart . LF . $xmlStylesheet; } } $this->pageRenderer->setXmlPrologAndDocType($headerStart); $this->pageRenderer->setHeadTag('<head>' . LF . '<!-- TYPO3 Script ID: ' . htmlspecialchars($this->scriptID) . ' -->'); $this->pageRenderer->setCharSet($this->charset); $this->pageRenderer->addMetaTag($this->generator()); if ($this->useCompatibilityTag) { $this->pageRenderer->addMetaTag($this->xUaCompatible()); } $this->pageRenderer->setTitle($title); // add docstyles $this->docStyle(); // add jsCode - has to go to headerData as it may contain the script tags already $this->pageRenderer->addHeaderData($this->JScode); foreach ($this->JScodeArray as $name => $code) { $this->pageRenderer->addJsInlineCode($name, $code); } if (count($this->JScodeLibArray)) { foreach ($this->JScodeLibArray as $library) { $this->pageRenderer->addHeaderData($library); } } if ($this->extJScode) { $this->pageRenderer->addExtOnReadyCode($this->extJScode); } // hook for additional headerData if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preHeaderRenderHook'])) { $preHeaderRenderHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preHeaderRenderHook']; if (is_array($preHeaderRenderHook)) { $hookParameters = array('pageRenderer' => &$this->pageRenderer); foreach ($preHeaderRenderHook as $hookFunction) { t3lib_div::callUserFunction($hookFunction, $hookParameters, $this); } } } // Construct page header. $str = $this->pageRenderer->render(t3lib_PageRenderer::PART_HEADER); $this->JScodeLibArray = array(); $this->JScode = $this->extJScode = ''; $this->JScodeArray = array(); $this->endOfPageJsBlock = $this->pageRenderer->render(t3lib_PageRenderer::PART_FOOTER); if ($this->docType == 'xhtml_frames') { return $str; } else { $str .= $this->docBodyTagBegin() . ($this->divClass ? ' <!-- Wrapping DIV-section for whole page BEGIN --> <div class="' . $this->divClass . '"> ' : '') . trim($this->form); } return $str; }
/** * @test */ public function checkGeckoVersion() { $userAgentString = 'Mozilla/5.0 (Windows; U; Windows NT 6.0; de; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3'; $infoArray = t3lib_utility_Client::getBrowserInfo($userAgentString); $this->assertEquals('1.9.2.3', $infoArray['all']['gecko']); }
/** * Generates an array with abstracted browser information * * @param string $userAgent: The useragent string, t3lib_div::getIndpEnv('HTTP_USER_AGENT') * @return array Contains keys "browser", "version", "system" */ protected function getBrowserInfo($userAgent) { return t3lib_utility_Client::getBrowserInfo($userAgent); }
/** * Formats and echoes the exception as XHTML. * * @param Exception $exception The exception object * @return void * @author Robert Lemke <*****@*****.**> */ public function echoExceptionWeb(Exception $exception) { if (!headers_sent()) { header("HTTP/1.1 500 Internal Server Error"); } $filePathAndName = $exception->getFile(); $exceptionCodeNumber = $exception->getCode() > 0 ? '#' . $exception->getCode() . ': ' : ''; /** * TODO: 25.09.2009 * either remove this line or let the link point to site that offers error information for TYPO3 */ // $moreInformationLink = ($exceptionCodeNumber != '') ? '(<a href="' . TYPO3_URL_EXCEPTION . $exception->getCode() . '">More information</a>)' : ''; $backtraceCode = $this->getBacktraceCode($exception->getTrace()); $this->writeLogEntries($exception, self::CONTEXT_WEB); // Set the XML prologue $xmlPrologue = '<?xml version="1.0" encoding="utf-8"?>'; // Set the doctype declaration $docType = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">'; // Get the browser info $browserInfo = t3lib_utility_Client::getBrowserInfo(t3lib_div::getIndpEnv('HTTP_USER_AGENT')); // Put the XML prologue before or after the doctype declaration according to browser if ($browserInfo['browser'] === 'msie' && $browserInfo['version'] < 7) { $headerStart = $docType . LF . $xmlPrologue; } else { $headerStart = $xmlPrologue . LF . $docType; } echo $headerStart . ' <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>TYPO3 Exception</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css"> .ExceptionProperty { color: #101010; } pre { margin: 0; font-size: 11px; color: #515151; background-color: #D0D0D0; padding-left: 30px; } </style> </head> <body> <div style=" position: absolute; left: 10px; background-color: #B9B9B9; outline: 1px solid #515151; color: #515151; font-family: Arial, Helvetica, sans-serif; font-size: 12px; margin: 10px; padding: 0; "> <div style="width: 100%; background-color: #515151; color: white; padding: 2px; margin: 0 0 6px 0;">Uncaught TYPO3 Exception</div> <div style="width: 100%; padding: 2px; margin: 0 0 6px 0;"> <strong style="color: #BE0027;">' . $exceptionCodeNumber . $exception->getMessage() . '</strong> ' . '<br /> <br /> <span class="ExceptionProperty">' . get_class($exception) . '</span> thrown in file<br /> <span class="ExceptionProperty">' . $filePathAndName . '</span> in line <span class="ExceptionProperty">' . $exception->getLine() . '</span>.<br /> <br /> ' . $backtraceCode . ' </div> </div> </body> </html> '; }
/** * Client Browser Information * * @param string $userAgent: The useragent string, t3lib_div::getIndpEnv('HTTP_USER_AGENT') * @return array Contains keys "useragent", "browser", "version", "system" * where "browser" is limited to the engines * and where "version" is a floating number */ function clientInfo($userAgent = '') { if (!$userAgent) { $userAgent = t3lib_div::getIndpEnv('HTTP_USER_AGENT'); } $browserInfo = t3lib_utility_Client::getBrowserInfo($userAgent); // Known engines: order is not irrelevant! $knownEngines = array('opera', 'msie', 'gecko', 'webkit'); if (is_array($browserInfo['all'])) { foreach ($knownEngines as $engine) { if ($browserInfo['all'][$engine]) { $browserInfo['browser'] = $engine; $browserInfo['version'] = t3lib_utility_Client::getVersion($browserInfo['all'][$engine]); break; } } } return $browserInfo; }
/** * This wraps and returns the main content of the page into proper html-code. * * @param string $content The page content * @return string The full HTML page */ function outputWrapper($content) { // Get the template file if (!$this->passwordOK) { $this->template = @file_get_contents(PATH_site . $this->templateFilePath . 'Install_login.html'); } elseif ($this->mode == '123') { $this->template = @file_get_contents(PATH_site . $this->templateFilePath . 'Install_123.html'); } else { $this->template = @file_get_contents(PATH_site . $this->templateFilePath . 'Install.html'); } // Add prototype to javascript array for output $this->javascript[] = '<script type="text/javascript" src="' . t3lib_div::createVersionNumberedFilename('../contrib/prototype/prototype.js') . '"></script>'; // Add JS functions for output $this->javascript[] = '<script type="text/javascript" src="' . t3lib_div::createVersionNumberedFilename('../sysext/install/Resources/Public/Javascript/install.js') . '"></script>'; // Include the default stylesheets $this->stylesheets[] = '<link rel="stylesheet" type="text/css" href="' . t3lib_div::createVersionNumberedFilename($this->backPath . 'sysext/install/Resources/Public/Stylesheets/reset.css') . '" />'; $this->stylesheets[] = '<link rel="stylesheet" type="text/css" href="' . t3lib_div::createVersionNumberedFilename($this->backPath . 'sysext/install/Resources/Public/Stylesheets/general.css') . '" />'; // Get the browser info $browserInfo = t3lib_utility_Client::getBrowserInfo(t3lib_div::getIndpEnv('HTTP_USER_AGENT')); // Add the stylesheet for Internet Explorer if ($browserInfo['browser'] === 'msie') { // IE7 if (intval($browserInfo['version']) === 7) { $this->stylesheets[] = '<link rel="stylesheet" type="text/css" href="' . t3lib_div::createVersionNumberedFilename($this->backPath . 'sysext/install/Resources/Public/Stylesheets/ie7.css') . '" />'; // IE6 } elseif (intval($browserInfo['version']) < 7) { $this->stylesheets[] = '<link rel="stylesheet" type="text/css" href="' . t3lib_div::createVersionNumberedFilename($this->backPath . 'sysext/install/Resources/Public/Stylesheets/ie6.css') . '" />'; } } // Include the stylesheets based on screen if ($this->mode == '123') { $this->stylesheets[] = '<link rel="stylesheet" type="text/css" href="' . t3lib_div::createVersionNumberedFilename($this->backPath . 'sysext/install/Resources/Public/Stylesheets/install_123.css') . '" />'; } elseif ($this->passwordOK) { $this->stylesheets[] = '<link rel="stylesheet" type="text/css" href="' . t3lib_div::createVersionNumberedFilename($this->backPath . 'sysext/install/Resources/Public/Stylesheets/install.css') . '" />'; } else { $this->stylesheets[] = '<link rel="stylesheet" type="text/css" href="' . t3lib_div::createVersionNumberedFilename($this->backPath . 'sysext/install/Resources/Public/Stylesheets/install.css') . '" />'; $this->stylesheets[] = '<link rel="stylesheet" type="text/css" href="' . t3lib_div::createVersionNumberedFilename($this->backPath . 'sysext/install/Resources/Public/Stylesheets/install_login.css') . '" />'; } // Define the markers content if ($this->mode == '123') { $this->markers['headTitle'] = 'Installing TYPO3 ' . TYPO3_branch; } else { $this->markers['headTitle'] = ' TYPO3 ' . TYPO3_version . ' Install Tool on site: ' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] . ' '; } $this->markers['title'] = 'TYPO3 ' . TYPO3_version; $this->markers['javascript'] = implode(chr(10), $this->javascript); $this->markers['stylesheets'] = implode(chr(10), $this->stylesheets); $this->markers['llErrors'] = 'The following errors occured'; $this->markers['copyright'] = $this->copyright(); $this->markers['charset'] = $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] ? $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] : 'iso-8859-1'; $this->markers['backendUrl'] = '../index.php'; $this->markers['backend'] = 'Backend admin'; $this->markers['frontendUrl'] = '../../index.php'; $this->markers['frontend'] = 'Frontend website'; $this->markers['metaCharset'] = 'Content-Type" content="text/html; charset='; if (!empty($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'])) { $this->markers['metaCharset'] .= $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset']; } else { $this->markers['metaCharset'] .= 'iso-8859-1'; } // Add the error messages if (!empty($this->errorMessages)) { // Get the subpart for all error messages $errorMessagesSubPart = t3lib_parsehtml::getSubpart($this->template, '###ERRORMESSAGES###'); // Get the subpart for a single error message $errorMessageSubPart = t3lib_parsehtml::getSubpart($errorMessagesSubPart, '###MESSAGES###'); $errors = array(); foreach ($this->errorMessages as $errorMessage) { // Define the markers content $errorMessageMarkers = array('message' => $errorMessage); // Fill the markers in the subpart $errors[] = t3lib_parsehtml::substituteMarkerArray($errorMessageSubPart, $errorMessageMarkers, '###|###', TRUE, FALSE); } // Substitute the subpart for a single message $errorMessagesSubPart = t3lib_parsehtml::substituteSubpart($errorMessagesSubPart, '###MESSAGES###', implode(chr(10), $errors)); } // Version subpart is only allowed when password is ok if ($this->passwordOK) { // Get the subpart for the version $versionSubPart = t3lib_parsehtml::getSubpart($this->template, '###VERSIONSUBPART###'); // Define the markers content $versionSubPartMarkers['version'] = 'Version: ' . TYPO3_version; // Fill the markers in the subpart $versionSubPart = t3lib_parsehtml::substituteMarkerArray($versionSubPart, $versionSubPartMarkers, '###|###', TRUE, FALSE); } // Substitute the version subpart $this->template = t3lib_parsehtml::substituteSubpart($this->template, '###VERSIONSUBPART###', $versionSubPart); // Substitute the menu subpart $this->template = t3lib_parsehtml::substituteSubpart($this->template, '###MENU###', $this->menu()); // Substitute the error messages subpart $this->template = t3lib_parsehtml::substituteSubpart($this->template, '###ERRORMESSAGES###', $errorMessagesSubPart); // Substitute the content subpart $this->template = t3lib_parsehtml::substituteSubpart($this->template, '###CONTENT###', $content); // Fill the markers $this->template = t3lib_parsehtml::substituteMarkerArray($this->template, $this->markers, '###|###', TRUE, FALSE); return $this->template; }