/** * render the section (Header or Footer) * * @param int $part section which should be rendered: self::PART_COMPLETE, self::PART_HEADER or self::PART_FOOTER * @return string content of rendered section */ public function render($part = self::PART_COMPLETE) { $jsFiles = ''; $cssFiles = ''; $cssInline = ''; $jsInline = ''; $jsFooterInline = ''; $jsFooterLibs = ''; $jsFooterFiles = ''; $noJS = FALSE; // preRenderHook for possible manuipulation if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-preProcess'])) { $params = array('jsLibs' => &$this->jsLibs, 'jsFiles' => &$this->jsFiles, 'jsFooterFiles' => &$this->jsFooterFiles, 'cssFiles' => &$this->cssFiles, 'headerData' => &$this->headerData, 'footerData' => &$this->footerData, 'jsInline' => &$this->jsInline, 'cssInline' => &$this->cssInline); foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_pagerenderer.php']['render-preProcess'] as $hook) { t3lib_div::callUserFunction($hook, $params, $this); } } $jsLibs = $this->renderJsLibraries(); if ($this->concatenateFiles) { // do the file concatenation $this->doConcatenate(); } if ($this->compressCss || $this->compressJavascript) { // do the file compression $this->doCompress(); } $metaTags = implode(LF, $this->metaTags); // remove ending slashes from static header block // if the page is beeing rendered as html (not xhtml) // and define variable $endingSlash for further use if ($this->getRenderXhtml()) { $endingSlash = ' /'; } else { $this->metaCharsetTag = str_replace(' />', '>', $this->metaCharsetTag); $this->baseUrlTag = str_replace(' />', '>', $this->baseUrlTag); $this->shortcutTag = str_replace(' />', '>', $this->shortcutTag); $endingSlash = ''; } if (count($this->cssFiles)) { foreach ($this->cssFiles as $file => $properties) { $file = t3lib_div::resolveBackPath($file); $file = t3lib_div::createVersionNumberedFilename($file); $tag = '<link rel="' . $properties['rel'] . '" type="text/css" href="' . htmlspecialchars($file) . '" media="' . $properties['media'] . '"' . ($properties['title'] ? ' title="' . $properties['title'] . '"' : '') . $endingSlash . '>'; if ($properties['allWrap'] && strpos($properties['allWrap'], '|') !== FALSE) { $tag = str_replace('|', $tag, $properties['allWrap']); } if ($properties['forceOnTop']) { $cssFiles = $tag . LF . $cssFiles; } else { $cssFiles .= LF . $tag; } } } if (count($this->cssInline)) { foreach ($this->cssInline as $name => $properties) { if ($properties['forceOnTop']) { $cssInline = '/*' . htmlspecialchars($name) . '*/' . LF . $properties['code'] . LF . $cssInline; } else { $cssInline .= '/*' . htmlspecialchars($name) . '*/' . LF . $properties['code'] . LF; } } $cssInline = $this->inlineCssWrap[0] . $cssInline . $this->inlineCssWrap[1]; } if (count($this->jsLibs)) { foreach ($this->jsLibs as $name => $properties) { $properties['file'] = t3lib_div::resolveBackPath($properties['file']); $properties['file'] = t3lib_div::createVersionNumberedFilename($properties['file']); $tag = '<script src="' . htmlspecialchars($properties['file']) . '" type="' . $properties['type'] . '"></script>'; if ($properties['allWrap'] && strpos($properties['allWrap'], '|') !== FALSE) { $tag = str_replace('|', $tag, $properties['allWrap']); } if ($properties['forceOnTop']) { if ($properties['section'] === self::PART_HEADER) { $jsLibs = $tag . LF . $jsLibs; } else { $jsFooterLibs = $tag . LF . $jsFooterLibs; } } else { if ($properties['section'] === self::PART_HEADER) { $jsLibs .= LF . $tag; } else { $jsFooterLibs .= LF . $tag; } } } } if (count($this->jsFiles)) { foreach ($this->jsFiles as $file => $properties) { $file = t3lib_div::resolveBackPath($file); $file = t3lib_div::createVersionNumberedFilename($file); $tag = '<script src="' . htmlspecialchars($file) . '" type="' . $properties['type'] . '"></script>'; if ($properties['allWrap'] && strpos($properties['allWrap'], '|') !== FALSE) { $tag = str_replace('|', $tag, $properties['allWrap']); } if ($properties['forceOnTop']) { if ($properties['section'] === self::PART_HEADER) { $jsFiles = $tag . LF . $jsFiles; } else { $jsFooterFiles = $tag . LF . $jsFooterFiles; } } else { if ($properties['section'] === self::PART_HEADER) { $jsFiles .= LF . $tag; } else { $jsFooterFiles .= LF . $tag; } } } } if (count($this->jsInline)) { foreach ($this->jsInline as $name => $properties) { if ($properties['forceOnTop']) { if ($properties['section'] === self::PART_HEADER) { $jsInline = '/*' . htmlspecialchars($name) . '*/' . LF . $properties['code'] . LF . $jsInline; } else { $jsFooterInline = '/*' . htmlspecialchars($name) . '*/' . LF . $properties['code'] . LF . $jsFooterInline; } } else { if ($properties['section'] === self::PART_HEADER) { $jsInline .= '/*' . htmlspecialchars($name) . '*/' . LF . $properties['code'] . LF; } else { $jsFooterInline .= '/*' . htmlspecialchars($name) . '*/' . LF . $properties['code'] . LF; } } } } if ($jsInline) { $jsInline = $this->inlineJavascriptWrap[0] . $jsInline . $this->inlineJavascriptWrap[1]; } if ($jsFooterInline) { $jsFooterInline = $this->inlineJavascriptWrap[0] . $jsFooterInline . $this->inlineJavascriptWrap[1]; } // get template $templateFile = t3lib_div::getFileAbsFileName($this->templateFile, TRUE); $template = t3lib_div::getURL($templateFile); if ($this->removeEmptyLinesFromTemplate) { $template = strtr($template, array(LF => '', CR => '')); } if ($part != self::PART_COMPLETE) { $templatePart = explode('###BODY###', $template); $template = $templatePart[$part - 1]; } if ($this->moveJsFromHeaderToFooter) { $jsFooterLibs = $jsLibs . LF . $jsFooterLibs; $jsLibs = ''; $jsFooterFiles = $jsFiles . LF . $jsFooterFiles; $jsFiles = ''; $jsFooterInline = $jsInline . LF . $jsFooterInline; $jsInline = ''; } $markerArray = array('XMLPROLOG_DOCTYPE' => $this->xmlPrologAndDocType, 'HTMLTAG' => $this->htmlTag, 'HEADTAG' => $this->headTag, 'METACHARSET' => $this->charSet ? str_replace('|', htmlspecialchars($this->charSet), $this->metaCharsetTag) : '', 'INLINECOMMENT' => $this->inlineComments ? LF . LF . '<!-- ' . LF . implode(LF, $this->inlineComments) . '-->' . LF . LF : '', 'BASEURL' => $this->baseUrl ? str_replace('|', $this->baseUrl, $this->baseUrlTag) : '', 'SHORTCUT' => $this->favIcon ? sprintf($this->shortcutTag, htmlspecialchars($this->favIcon), $this->iconMimeType) : '', 'CSS_INCLUDE' => $cssFiles, 'CSS_INLINE' => $cssInline, 'JS_INLINE' => $jsInline, 'JS_INCLUDE' => $jsFiles, 'JS_LIBS' => $jsLibs, 'TITLE' => $this->title ? str_replace('|', htmlspecialchars($this->title), $this->titleTag) : '', 'META' => $metaTags, 'HEADERDATA' => $this->headerData ? implode(LF, $this->headerData) : '', 'FOOTERDATA' => $this->footerData ? implode(LF, $this->footerData) : '', 'JS_LIBS_FOOTER' => $jsFooterLibs, 'JS_INCLUDE_FOOTER' => $jsFooterFiles, 'JS_INLINE_FOOTER' => $jsFooterInline, 'BODY' => $this->bodyContent); $markerArray = array_map('trim', $markerArray); $this->reset(); return trim(t3lib_parsehtml::substituteMarkerArray($template, $markerArray, '###|###')); }
/** * Renders the loop for a given loop name. * * @param string Key from $this->loops to render */ protected function renderLoop($loopName) { $loopContent = ''; $loopTemplate = $this->getSubpart('LOOP:' . $loopName); $loopContentMarker = 'loop_content:' . $loopName; $loopSingleItem = $this->getSubpart($loopContentMarker, $loopTemplate); if (empty($loopSingleItem)) { // backwards compatible fallback for unnamed loops $loopContentMarker = 'loop_content'; $loopSingleItem = $this->getSubpart($loopContentMarker, $loopTemplate); } $loopMarker = strtoupper($this->loops[$loopName]['marker']); $loopVariables = $this->loops[$loopName]['data']; $foundMarkers = $this->getMarkersFromTemplate($loopSingleItem, $loopMarker . '\\.'); $loopCount = count($loopVariables); if (count($foundMarkers)) { $iterationCount = 0; foreach ($loopVariables as $value) { $resolvedMarkers = $this->resolveVariableMarkers($foundMarkers, $value); $resolvedMarkers['LOOP_CURRENT_ITERATION_COUNT'] = ++$iterationCount; // pass the whole object / array / variable as is (serialized though) $resolvedMarkers[$loopMarker] = serialize($value); $currentIterationContent = t3lib_parsehtml::substituteMarkerArray($loopSingleItem, $resolvedMarkers, '###|###'); $inLoopMarkers = $this->getMarkersFromTemplate($currentIterationContent, 'LOOP:', FALSE); $inLoopMarkers = $this->filterProtectedLoops($inLoopMarkers); $currentIterationContent = $this->processInLoopMarkers($currentIterationContent, $loopName, $inLoopMarkers, $value); $currentIterationContent = $this->processConditions($currentIterationContent); $loopContent .= $currentIterationContent; } } $loopContent = t3lib_parsehtml::substituteSubpart($loopTemplate, '###' . strtoupper($loopContentMarker) . '###', $loopContent); $loopContent = t3lib_parsehtml::substituteMarkerArray($loopContent, array('LOOP_ELEMENT_COUNT' => $loopCount), '###|###'); $this->workOnSubpart = t3lib_parsehtml::substituteSubpart($this->workOnSubpart, '###LOOP:' . strtoupper($loopName) . '###', $loopContent); }
/** * Traverses the input $markContentArray array and for each key the marker * by the same name (possibly wrapped and in upper case) will be * substituted with the keys value in the array. * * This is very useful if you have a data-record to substitute in some * content. In particular when you use the $wrap and $uppercase values to * pre-process the markers. Eg. a key name like "myfield" could effectively * be represented by the marker "###MYFIELD###" if the wrap value * was "###|###" and the $uppercase boolean TRUE. * * @param string The content stream, typically HTML template content. * @param array The array of key/value pairs being marker/content values used in the substitution. For each element in this array the function will substitute a marker in the content stream with the content. * @param string A wrap value - [part 1] | [part 2] - for the markers before substitution * @param boolean If set, all marker string substitution is done with upper-case markers. * @param boolean If set, all unused marker are deleted. * @return string The processed output stream * @see substituteMarker(), substituteMarkerInObject(), TEMPLATE() */ public function substituteMarkerArray($content, array $markContentArray, $wrap = '', $uppercase = FALSE, $deleteUnused = FALSE) { return t3lib_parsehtml::substituteMarkerArray($content, $markContentArray, $wrap, $uppercase, $deleteUnused); }
/** * Fill the button lists with the defined HTML * * @param array HTML for all buttons * @return array Containing HTML for both buttonlists */ protected function getDocHeaderButtons($buttons) { $markers = array(); // Fill buttons for left and right float $floats = array('left', 'right'); foreach ($floats as $key) { // Get the template for each float $buttonTemplate = t3lib_parsehtml::getSubpart($this->moduleTemplate, '###BUTTON_GROUPS_' . strtoupper($key) . '###'); // Fill the button markers in this float $buttonTemplate = t3lib_parsehtml::substituteMarkerArray($buttonTemplate, $buttons, '###|###', true); // getting the wrap for each group $buttonWrap = t3lib_parsehtml::getSubpart($this->moduleTemplate, '###BUTTON_GROUP_WRAP###'); // looping through the groups (max 6) and remove the empty groups for ($groupNumber = 1; $groupNumber < 6; $groupNumber++) { $buttonMarker = '###BUTTON_GROUP' . $groupNumber . '###'; $buttonGroup = t3lib_parsehtml::getSubpart($buttonTemplate, $buttonMarker); if (trim($buttonGroup)) { if ($buttonWrap) { $buttonGroup = t3lib_parsehtml::substituteMarker($buttonWrap, '###BUTTONS###', $buttonGroup); } $buttonTemplate = t3lib_parsehtml::substituteSubpart($buttonTemplate, $buttonMarker, trim($buttonGroup)); } } // replace the marker with the template and remove all line breaks (for IE compat) $markers['BUTTONLIST_' . strtoupper($key)] = str_replace(LF, '', $buttonTemplate); } // Hook for manipulating docHeaderButtons if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['docHeaderButtonsHook'])) { $params = array('buttons' => $buttons, 'markers' => &$markers, 'pObj' => &$this); foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['docHeaderButtonsHook'] as $funcRef) { t3lib_div::callUserFunction($funcRef, $params, $this); } } return $markers; }
/** * List media types, along with options to edit & delete * * @return string HTML table of all the mimetypes */ function listMimeTypes() { global $LANG, $BACK_PATH, $BE_USER; // Load template $content = t3lib_parsehtml::getSubpart(t3lib_div::getURL($BACK_PATH . t3lib_extMgm::extRelPath('dam') . 'modfunc_tools_mimetypes/template.html'), '###MOD_TEMPLATE###'); $rowTemplate[1] = t3lib_parsehtml::getSubpart($content, '###ROW_1###'); $rowTemplate[2] = t3lib_parsehtml::getSubpart($content, '###ROW_2###'); // Add some JS $this->pObj->doc->JScode .= $this->pObj->doc->wrapScriptTags(' function deleteRecord(id) { // if (confirm(' . $LANG->JScharCode($LANG->getLL('deleteWarning')) . ')) { window.location.href = "' . $BACK_PATH . 'tce_db.php?cmd[tx_dam_media_types]["+id+"][delete]=1&redirect=' . rawurlencode(t3lib_div::getIndpEnv('TYPO3_REQUEST_URL')) . '&id=' . tx_dam_db::getPid() . '&vC=' . $BE_USER->veriCode() . '&prErr=1&uPT=1"; } return false; } '); // Get content $alternate = 1; $rows = ''; $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tx_dam_media_types', '', '', 'ext ASC'); while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $editURL = $BACK_PATH . 'alt_doc.php?returnUrl=' . rawurlencode(t3lib_div::getIndpEnv('TYPO3_REQUEST_URL')) . '&id=' . tx_dam_db::getPid() . '&edit[tx_dam_media_types][' . $row['uid'] . ']=edit'; //$deleteURL = $BACK_PATH . 'alt_doc.php?returnUrl=' . rawurlencode( t3lib_div::getIndpEnv('TYPO3_REQUEST_URL') ) . '&id=' . tx_dam_db::getPid() . '&edit[tx_dam_media_types][' . $row['uid'] . '][delete]=1'; $rowMarkers['EDIT'] = '<a href="#" onclick="window.location.href=\'' . $editURL . '\'; return false;"><img' . t3lib_iconWorks::skinImg($this->pObj->doc->backPath, 'gfx/edit2.gif', 'width="11" height="12"') . ' title="Edit this type" alt="" height="16" width="16"></a>'; $rowMarkers['DELETE'] = '<a href="#" onclick="deleteRecord(' . $row['uid'] . ')"><img' . t3lib_iconWorks::skinImg($this->pObj->doc->backPath, 'gfx/deletedok.gif', 'width="11" height="12"') . ' title="Delete this type" alt="" height="16" width="16"></a>'; $rowMarkers['EXTENSION'] = $row['ext']; $rowMarkers['MIME'] = $row['mime']; $rowMarkers['ICON'] = '<img src="' . $BACK_PATH . tx_dam::icon_getFileType(array('file_type' => $row['ext'], 'media_type' => $row['type'])) . '" />'; $rows .= t3lib_parsehtml::substituteMarkerArray($rowTemplate[$alternate], $rowMarkers, '###|###'); // Cycle the alternating rows if ($alternate == 2) { $alternate = 1; } else { $alternate = 2; } } $content = t3lib_parsehtml::substituteSubpart($content, '###ROWS###', $rows); $GLOBALS['TYPO3_DB']->sql_free_result($res); return $content; }
</li> <li class="t3-install-locked-user-settings"> Alternatively, in the Backend, go to <a href="../sysext/setup/mod/index.php">User tools > User settings</a> and let TYPO3 create this file for you. When you\'re finished, you can also visit <a href="../sysext/setup/mod/index.php">User tools > User settings</a> and delete the file from there. </li> </ul> <p> For security reasons, it is highly recommended that you either rename or delete the file after the operation is finished. </p> <p> As an additional security measure, if the file is older than one hour, TYPO3 will automatically delete it. </p> '); // Fill the markers $content = t3lib_parsehtml::substituteMarkerArray($template, $markers, '###|###', 1, 1); // Output the warning message and exit header('Content-Type: text/html; charset=utf-8'); header('Cache-Control: no-cache, must-revalidate'); header('Pragma: no-cache'); echo $content; exit; } // ***************************************************************************** // Defining constants necessary for the install-script to invoke the installer // ***************************************************************************** define('TYPO3_MOD_PATH', 'install/'); $BACK_PATH = '../'; // Defining this variable and setting it non-false will invoke the install-screen called from init.php define('TYPO3_enterInstallScript', '1'); require '../init.php';
/** * Gets the filled markers that are used in the HTML template. * * @return array The filled marker array */ protected function getBodyMarkers() { $bodyMarkers = array('TITLE' => $GLOBALS['LANG']->getLL('title')); if ($this->modTSconfig['properties']['sideBarEnable'] && $this->sideBarObj->position == 'left') { $sidebarMode = 'SIDEBAR_LEFT'; } elseif ($this->modTSconfig['properties']['sideBarEnable']) { $sidebarMode = 'SIDEBAR_TOP'; } else { $sidebarMode = 'SIDEBAR_DISABLED'; } $editareaTpl = t3lib_parsehtml::getSubpart($this->doc->moduleTemplate, $sidebarMode); if ($editareaTpl) { $editareaMarkers = array('TABROW' => $this->render_sidebar(), 'CONTENT' => $this->content); $editareaMarkers['FLASHMESSAGES'] = t3lib_FlashMessageQueue::renderFlashMessages(); $editareaContent = t3lib_parsehtml::substituteMarkerArray($editareaTpl, $editareaMarkers, '###|###', true); $bodyMarkers['EDITAREA'] = $editareaContent; } else { $bodyMarkers['CONTENT'] = $this->content; } return $bodyMarkers; }
/** * Creates a specialized form to configure the database. * * @param array $markers * @param tx_install $instObj */ protected function createDatabaseForm(array &$markers, tx_install $instObj) { $error_missingConnect = ' <p class="typo3-message message-error"> <strong> There is no connection to the database! </strong> <br /> (Username: <em>' . TYPO3_db_username . '</em>, Host: <em>' . TYPO3_db_host . '</em>, Using Password: YES) <br /> Go to Step 1 and enter a valid username and password! </p> '; // Add header marker for main template $markers['header'] = 'Select database'; // There should be a database host connection at this point if ($result = $GLOBALS['TYPO3_DB']->sql_pconnect(TYPO3_db_host, TYPO3_db_username, TYPO3_db_password)) { // Get the template file $templateFile = @file_get_contents(t3lib_extMgm::extPath('dbal') . $this->templateFilePath . 'install.html'); // Get the template part from the file $template = t3lib_parsehtml::getSubpart($templateFile, '###TEMPLATE###'); // Get the subpart for the database choice step $formSubPart = t3lib_parsehtml::getSubpart($template, '###DATABASE_FORM###'); // Get the subpart for the database options $step3DatabaseOptionsSubPart = t3lib_parsehtml::getSubpart($formSubPart, '###DATABASEOPTIONS###'); $dbArr = $instObj->getDatabaseList(); $dbIncluded = FALSE; foreach ($dbArr as $dbname) { // Define the markers content for database options $step3DatabaseOptionMarkers = array('databaseValue' => htmlspecialchars($dbname), 'databaseSelected' => $dbname === TYPO3_db ? 'selected="selected"' : '', 'databaseName' => htmlspecialchars($dbname)); // Add the option HTML to an array $step3DatabaseOptions[] = t3lib_parsehtml::substituteMarkerArray($step3DatabaseOptionsSubPart, $step3DatabaseOptionMarkers, '###|###', 1, 1); if ($dbname === TYPO3_db) { $dbIncluded = TRUE; } } if (!$dbIncluded && TYPO3_db) { // // Define the markers content when no access $step3DatabaseOptionMarkers = array('databaseValue' => htmlspecialchars(TYPO3_db), 'databaseSelected' => 'selected="selected"', 'databaseName' => htmlspecialchars(TYPO3_db) . ' (NO ACCESS!)'); // Add the option HTML to an array $step3DatabaseOptions[] = t3lib_parsehtml::substituteMarkerArray($step3DatabaseOptionsSubPart, $step3DatabaseOptionMarkers, '###|###', 1, 1); } // Substitute the subpart for the database options $content = t3lib_parsehtml::substituteSubpart($formSubPart, '###DATABASEOPTIONS###', implode(chr(10), $step3DatabaseOptions)); // Define the markers content $step3SubPartMarkers = array('step' => $instObj->step + 1, 'action' => htmlspecialchars($instObj->action), 'llOption2' => 'Select an EMPTY existing database:', 'llRemark2' => 'Any tables used by TYPO3 will be overwritten.', 'continue' => 'Continue'); // Add step marker for main template $markers['step'] = t3lib_parsehtml::substituteMarkerArray($content, $step3SubPartMarkers, '###|###', 1, 1); } else { // Add step marker for main template when no connection $markers['step'] = $error_missingConnect; } }
/** * Make login news - renders the HTML content for a list of news shown under * the login form. News data is added through $TYPO3_CONF_VARS * * @return string HTML content * @credits Idea by Jan-Hendrik Heuing */ function makeLoginNews() { $newsContent = ''; // Traverse news array IF there are records in it: if (is_array($GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews']) && count($GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews']) && !t3lib_div::_GP('loginRefresh')) { // get the main news template, and replace the subpart after looped through $newsContent = t3lib_parsehtml::getSubpart($GLOBALS['TBE_TEMPLATE']->moduleTemplate, '###LOGIN_NEWS###'); $newsItemTemplate = t3lib_parsehtml::getSubpart($newsContent, '###NEWS_ITEM###'); $newsItemContent = ''; $count = 1; foreach ($GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews'] as $newsItem) { $additionalClass = ''; if ($count == 1) { $additionalClass = ' first-item'; } elseif ($count == count($GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews'])) { $additionalClass = ' last-item'; } $newsItemMarker = array('###HEADER###' => htmlspecialchars($newsItem['header']), '###DATE###' => htmlspecialchars($newsItem['date']), '###CONTENT###' => trim($newsItem['content']), '###CLASS###' => $additionalClass); $count++; $newsItemContent .= t3lib_parsehtml::substituteMarkerArray($newsItemTemplate, $newsItemMarker); } $title = $GLOBALS['TYPO3_CONF_VARS']['BE']['loginNewsTitle'] ? $GLOBALS['TYPO3_CONF_VARS']['BE']['loginNewsTitle'] : $GLOBALS['LANG']->getLL('newsheadline'); $newsContent = t3lib_parsehtml::substituteMarker($newsContent, '###NEWS_HEADLINE###', htmlspecialchars($title)); $newsContent = t3lib_parsehtml::substituteSubpart($newsContent, '###NEWS_ITEM###', $newsItemContent); } return $newsContent; }
/** * Build the mail content. * * @param int $curPage: id of the current page * @param string $pageList: list of pages id * @param array $markerArray: array of markers * @param array $oldBrokenLink: markerarray with the number of link found * @return string Content of the mail */ protected function buildMail($curPage, $pageList, $markerArray, $oldBrokenLink) { $pageSectionHTML = t3lib_parsehtml::getSubpart($this->templateMail, '###PAGE_SECTION###'); if (is_array($markerArray)) { foreach ($markerArray as $markerKey => $markerValue) { if (empty($oldBrokenLink[$markerKey])) { $oldBrokenLink[$markerKey] = 0; } if ($markerValue != $oldBrokenLink[$markerKey]) { $this->dif = TRUE; } $markerArray[$markerKey . '_old'] = $oldBrokenLink[$markerKey]; } } $markerArray['title'] = t3lib_BEfunc::getRecordTitle('pages', t3lib_BEfunc::getRecord('pages', $curPage)); $content = ''; if ($markerArray['brokenlinkCount'] > 0) { $content = t3lib_parsehtml::substituteMarkerArray($pageSectionHTML, $markerArray, '###|###', TRUE, TRUE); } return $content; }
/** * Make login news - renders the HTML content for a list of news shown under * the login form. News data is added through $TYPO3_CONF_VARS * * @return string HTML content * @credits Idea by Jan-Hendrik Heuing * @deprecated $GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews'] is deprecated since 4.5. Use system news records instead. */ function makeLoginNews() { $newsContent = ''; $systemNews = $this->getSystemNews(); if (count($GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews'])) { t3lib_div::logDeprecatedFunction(); $GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews'] = array_merge($systemNews, $GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews']); } else { $GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews'] = $systemNews; } // Traverse news array IF there are records in it: if (is_array($GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews']) && count($GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews']) && !t3lib_div::_GP('loginRefresh')) { $htmlParser = t3lib_div::makeInstance('t3lib_parsehtml_proc'); // get the main news template, and replace the subpart after looped through $newsContent = t3lib_parsehtml::getSubpart($GLOBALS['TBE_TEMPLATE']->moduleTemplate, '###LOGIN_NEWS###'); $newsItemTemplate = t3lib_parsehtml::getSubpart($newsContent, '###NEWS_ITEM###'); $newsItem = ''; $count = 1; foreach ($GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews'] as $newsItemData) { $additionalClass = ''; if ($count == 1) { $additionalClass = ' first-item'; } elseif ($count == count($GLOBALS['TYPO3_CONF_VARS']['BE']['loginNews'])) { $additionalClass = ' last-item'; } $newsItemContent = $htmlParser->TS_transform_rte($htmlParser->TS_links_rte($newsItemData['content'])); $newsItemMarker = array('###HEADER###' => htmlspecialchars($newsItemData['header']), '###DATE###' => htmlspecialchars($newsItemData['date']), '###CONTENT###' => $newsItemContent, '###CLASS###' => $additionalClass); $count++; $newsItem .= t3lib_parsehtml::substituteMarkerArray($newsItemTemplate, $newsItemMarker); } $title = $GLOBALS['TYPO3_CONF_VARS']['BE']['loginNewsTitle'] ? $GLOBALS['TYPO3_CONF_VARS']['BE']['loginNewsTitle'] : $GLOBALS['LANG']->getLL('newsheadline'); $newsContent = t3lib_parsehtml::substituteMarker($newsContent, '###NEWS_HEADLINE###', htmlspecialchars($title)); $newsContent = t3lib_parsehtml::substituteSubpart($newsContent, '###NEWS_ITEM###', $newsItem); } return $newsContent; }
/** * Generates the css files * * @return void */ protected function generateCSS() { $cssData = ''; $cssIe6 = ''; if ($this->includeTimestampInCSS) { $timestamp = '?' . time(); } else { $timestamp = ''; } $spritePathForCSS = $this->resolveSpritePath(); $markerArray = array('###NAMESPACE###' => $this->nameSpace, '###DEFAULTWIDTH###' => $this->defaultWidth, '###DEFAULTHEIGHT###' => $this->defaultHeight, '###SPRITENAME###' => '', '###SPRITEURL###' => $spritePathForCSS ? $spritePathForCSS . '/' : ''); $markerArray['###SPRITEURL###'] .= $this->spriteName . '.png' . $timestamp; foreach ($this->spriteBases as $base) { $markerArray['###SPRITENAME###'] = $base; $cssData .= t3lib_parsehtml::substituteMarkerArray($this->templateSprite, $markerArray); } if ($this->generateGIFCopy) { $markerArray['###SPRITEURL###'] = str_replace('.png', '.gif', $markerArray['###SPRITEURL###']); foreach ($this->spriteBases as $base) { $cssIe6 .= t3lib_parsehtml::substituteMarkerArray($this->templateSprite, $markerArray); } } foreach ($this->iconsData as $key => $data) { $temp = $data['iconNameParts']; array_shift($temp); $cssName = implode('-', $temp); $markerArrayIcons = array('###NAMESPACE###' => $this->nameSpace, '###ICONNAME###' => $cssName, '###LEFT###' => $data['left'], '###TOP###' => $data['top'], '###SIZE_INFO###' => ''); if ($data['height'] != $this->defaultHeight) { $markerArrayIcons['###SIZE_INFO###'] .= TAB . 'height: ' . $data['height'] . 'px;' . LF; } if ($data['width'] != $this->defaultWidth) { $markerArrayIcons['###SIZE_INFO###'] .= TAB . 'width: ' . $data['width'] . 'px;' . LF; } $cssData .= t3lib_parsehtml::substituteMarkerArray($this->templateIcon, $markerArrayIcons); } t3lib_div::writeFile(PATH_site . $this->cssFolder . $this->spriteName . '.css', $cssData); if ($this->generateGIFCopy) { t3lib_div::writeFile(PATH_site . $this->cssFolder . $this->spriteName . '-ie6.css', $cssIe6); } }
/** * Builds the checkboxes out of the hooks array. * * @param array $brokenLinkOverView array of broken links information * @return string code content */ protected function getCheckOptions(array $brokenLinkOverView, $prefix = '') { $markerArray = array(); $additionalAttr = ''; if (!empty($prefix)) { $additionalAttr = ' onclick="toggleActionButton(\'' . $prefix . '\');" class="' . $prefix . '" '; } else { $additionalAttr = ' onclick="toggleActionButton(\'refresh\');" class="refresh" '; } $checkOptionsTemplate = t3lib_parsehtml::getSubpart($this->doc->moduleTemplate, '###CHECKOPTIONS_SECTION###'); $hookSectionContent = ''; $hookSectionTemplate = t3lib_parsehtml::getSubpart($checkOptionsTemplate, '###HOOK_SECTION###'); $markerArray['statistics_header'] = $this->doc->sectionHeader($GLOBALS['LANG']->getLL('report.statistics.header')); $totalCountLabel = $GLOBALS['LANG']->getLL('overviews.nbtotal'); $totalCountLabel = t3lib_BEfunc::wrapInHelp('linkvalidator', 'checkboxes', $totalCountLabel); $markerArray['total_count_label'] = $totalCountLabel; if (empty($brokenLinkOverView['brokenlinkCount'])) { $markerArray['total_count'] = '0'; } else { $markerArray['total_count'] = $brokenLinkOverView['brokenlinkCount']; } $linktypes = t3lib_div::trimExplode(',', $this->modTS['linktypes'], 1); $hookSectionContent = ''; if (is_array($linktypes)) { if (!empty($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks']) && is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'] as $type => $value) { if (in_array($type, $linktypes)) { $hookSectionMarker = array(); if (empty($brokenLinkOverView[$type])) { $hookSectionMarker['count'] = '0'; } else { $hookSectionMarker['count'] = $brokenLinkOverView[$type]; } $translation = $GLOBALS['LANG']->getLL('hooks.' . $type); $translation = $translation ? $translation : $type; $option = '<input type="checkbox" ' . $additionalAttr . ' id="' . $prefix . 'SET_' . $type . '" name="' . $prefix . 'SET[' . $type . ']" value="1"' . ($this->pObj->MOD_SETTINGS[$type] ? ' checked="checked"' : '') . '/>' . '<label for="' . $prefix . 'SET[' . $type . ']">' . htmlspecialchars($translation) . '</label>'; $hookSectionMarker['option'] = $option; $hookSectionContent .= t3lib_parsehtml::substituteMarkerArray($hookSectionTemplate, $hookSectionMarker, '###|###', TRUE, TRUE); } } } } $checkOptionsTemplate = t3lib_parsehtml::substituteSubpart($checkOptionsTemplate, '###HOOK_SECTION###', $hookSectionContent); return t3lib_parsehtml::substituteMarkerArray($checkOptionsTemplate, $markerArray, '###|###', TRUE, TRUE); }
/** * Returns HTML-code, which is a visual representation of a multidimensional array * Returns false if $array_in is not an array * * @param mixed $incomingValue Array to view * @return string HTML output */ function viewArray($incomingValue) { // Get the template file $templateFile = @file_get_contents(PATH_site . $this->templateFilePath . 'ViewArray.html'); if (is_array($incomingValue) && !empty($incomingValue)) { // Get the template part from the file $content = t3lib_parsehtml::getSubpart($templateFile, '###TEMPLATE###'); // Get the subpart for a single item $itemSubpart = t3lib_parsehtml::getSubpart($content, '###ITEM###'); foreach ($incomingValue as $key => $value) { if (is_array($value)) { $description = $this->viewArray($value); } elseif (is_object($value)) { $description = get_class($value); if (method_exists($value, '__toString')) { $description .= ': ' . (string) $value; } } else { if (gettype($value) == 'object') { $description = 'Unknown object'; } else { $description = htmlspecialchars((string) $value); } } // Define the markers content $itemMarkers = array('key' => htmlspecialchars((string) $key), 'description' => !empty($description) ? $description : ' '); // Fill the markers in the subpart $items[] = t3lib_parsehtml::substituteMarkerArray($itemSubpart, $itemMarkers, '###|###', TRUE, FALSE); } // Substitute the subpart for single item $content = t3lib_parsehtml::substituteSubpart($content, '###ITEM###', implode(chr(10), $items)); } return $content; }