/** * Checks if a given string is a valid frame URL to be loaded in the * backend. * * @param string $url potential URL to check * * @return string either $url if $url is considered to be harmless, or an * empty string otherwise */ private static function internalSanitizeLocalUrl($url = '') { $sanitizedUrl = ''; $decodedUrl = rawurldecode($url); if ($decodedUrl !== t3lib_div::removeXSS($decodedUrl)) { $decodedUrl = ''; } if (!empty($url) && $decodedUrl !== '') { $testAbsoluteUrl = t3lib_div::resolveBackPath($decodedUrl); $testRelativeUrl = t3lib_div::resolveBackPath(t3lib_div::dirname(t3lib_div::getIndpEnv('SCRIPT_NAME')) . '/' . $decodedUrl); // That's what's usually carried in TYPO3_SITE_PATH $typo3_site_path = substr(t3lib_div::getIndpEnv('TYPO3_SITE_URL'), strlen(t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST'))); // Pass if URL is on the current host: if (self::isValidUrl($decodedUrl)) { if (self::isOnCurrentHost($decodedUrl) && strpos($decodedUrl, t3lib_div::getIndpEnv('TYPO3_SITE_URL')) === 0) { $sanitizedUrl = $url; } // Pass if URL is an absolute file path: } elseif (t3lib_div::isAbsPath($decodedUrl) && t3lib_div::isAllowedAbsPath($decodedUrl)) { $sanitizedUrl = $url; // Pass if URL is absolute and below TYPO3 base directory: } elseif (strpos($testAbsoluteUrl, $typo3_site_path) === 0 && substr($decodedUrl, 0, 1) === '/') { $sanitizedUrl = $url; // Pass if URL is relative and below TYPO3 base directory: } elseif (strpos($testRelativeUrl, $typo3_site_path) === 0 && substr($decodedUrl, 0, 1) !== '/') { $sanitizedUrl = $url; } } if (!empty($url) && empty($sanitizedUrl)) { t3lib_div::sysLog('The URL "' . $url . '" is not considered to be local and was denied.', 'Core', t3lib_div::SYSLOG_SEVERITY_NOTICE); } return $sanitizedUrl; }
public static function clearTempDir() { // Delete all files in typo3temp/rtehtmlarea $tempPath = t3lib_div::resolveBackPath(PATH_typo3 . '../typo3temp/rtehtmlarea/'); $handle = @opendir($tempPath); if ($handle !== FALSE) { while (($file = readdir($handle)) !== FALSE) { if ($file != '.' && $file != '..') { $tempFile = $tempPath . $file; if (is_file($tempFile)) { unlink($tempFile); } } } closedir($handle); } // Delete all files in typo3temp/compressor with names that start with "htmlarea" $tempPath = t3lib_div::resolveBackPath(PATH_typo3 . '../typo3temp/compressor/'); $handle = @opendir($tempPath); if ($handle !== FALSE) { while (($file = readdir($handle)) !== FALSE) { if (substr($file, 0, 8) === 'htmlarea') { $tempFile = $tempPath . $file; if (is_file($tempFile)) { unlink($tempFile); } } } closedir($handle); } // Log the action $GLOBALS['BE_USER']->writelog(3, 1, 0, 0, 'htmlArea RTE: User %s has cleared the RTE cache', array($GLOBALS['BE_USER']->user['username'])); }
function clearTempDir() { $tempPath = t3lib_div::resolveBackPath(PATH_typo3 . '../typo3temp/rtehtmlarea/'); $handle = opendir($tempPath); while ($data = readdir($handle)) { if (!is_dir($data) && $data != "." && $data != "..") { unlink($tempPath . $data); } } closedir($handle); }
/** * renders the actual logo code * * @return string logo html code snippet to use in the backend */ public function render() { $logoFile = 'gfx/alt_backend_logo.gif'; // default if (is_string($this->logo)) { // overwrite $logoFile = $this->logo; } $imgInfo = getimagesize(PATH_site . TYPO3_mainDir . $logoFile); $logo = '<a href="http://www.typo3.com/" target="_blank">' . '<img' . t3lib_iconWorks::skinImg('', $logoFile, $imgInfo[3]) . ' title="TYPO3 Content Management System" alt="" />' . '</a>'; // overwrite with custom logo if ($GLOBALS['TBE_STYLES']['logo']) { $imgInfo = @getimagesize(t3lib_div::resolveBackPath(PATH_typo3 . $GLOBALS['TBE_STYLES']['logo'], 3)); $logo = '<a href="http://www.typo3.com/" target="_blank">' . '<img src="' . $GLOBALS['TBE_STYLES']['logo'] . '" ' . $imgInfo[3] . ' title="TYPO3 Content Management System" alt="" />' . '</a>'; } return $logo; }
/** * Interface function. This will be called from the sprite manager to * refresh all caches. * * @return void */ public function generate() { $this->generatorInstance = t3lib_div::makeInstance('t3lib_spritemanager_SpriteGenerator', 'GeneratorHandler'); $this->generatorInstance->setOmmitSpriteNameInIconName(TRUE)->setIncludeTimestampInCSS(TRUE)->setSpriteFolder(t3lib_SpriteManager::$tempPath)->setCSSFolder(t3lib_SpriteManager::$tempPath); $iconsToProcess = array_merge((array) $GLOBALS['TBE_STYLES']['spritemanager']['singleIcons'], $this->collectTcaSpriteIcons()); foreach ($iconsToProcess as $iconName => $iconFile) { $iconsToProcess[$iconName] = t3lib_div::resolveBackPath('typo3/' . $iconFile); } $generatorResponse = $this->generatorInstance->generateSpriteFromArray($iconsToProcess); if (!is_dir(PATH_site . t3lib_SpriteManager::$tempPath . 'ie6')) { t3lib_div::mkdir(PATH_site . t3lib_SpriteManager::$tempPath . 'ie6'); } t3lib_div::upload_copy_move($generatorResponse['spriteGifImage'], t3lib_div::dirname($generatorResponse['spriteGifImage']) . '/ie6/' . basename($generatorResponse['spriteGifImage'])); unlink($generatorResponse['spriteGifImage']); t3lib_div::upload_copy_move($generatorResponse['cssGif'], t3lib_div::dirname($generatorResponse['cssGif']) . '/ie6/' . basename($generatorResponse['cssGif'])); unlink($generatorResponse['cssGif']); $this->iconNames = array_merge($this->iconNames, $generatorResponse['iconNames']); parent::generate(); }
/** * If it is an URL, nothing to do, if it is a file, check if path is allowed and prepend current url * * @param string $url * @return string * @throws UnexpectedValueException */ public static function getCorrectUrl($url) { if (empty($url)) { throw new UnexpectedValueException('An empty url is given'); } $url = self::getFalFilename($url); // check URL $urlInfo = parse_url($url); // means: it is no external url if (!isset($urlInfo['scheme'])) { // resolve paths like ../ $url = t3lib_div::resolveBackPath($url); // absolute path is used to check path $absoluteUrl = t3lib_div::getFileAbsFileName($url); if (!t3lib_div::isAllowedAbsPath($absoluteUrl)) { throw new UnexpectedValueException('The path "' . $url . '" is not allowed.'); } // append current domain $url = t3lib_div::getIndpEnv('TYPO3_SITE_URL') . $url; } return $url; }
function catXMLExportImportAction($l10ncfgObj) { global $LANG, $BACK_PATH, $BE_USER; $allowedSettingFiles = array('across' => 'acrossL10nmgrConfig.dst', 'dejaVu' => 'dejaVuL10nmgrConfig.dvflt', 'memoq' => 'memoQ.mqres', 'transit' => 'StarTransit_XML_UTF_TYPO3.FFD', 'sdltrados2007' => 'SDLTradosTagEditor.ini', 'sdltrados2009' => 'TYPO3_l10nmgr.sdlfiletype', 'sdlpassolo' => 'SDLPassolo.xfg'); /** @var $service tx_l10nmgr_l10nBaseService */ $service = t3lib_div::makeInstance('tx_l10nmgr_l10nBaseService'); $info = '<br/>'; $info .= '<input type="submit" value="' . $LANG->getLL('general.action.refresh.button.title') . '" name="_" /><br /><br/>'; $info .= '<div id="ddtabs" class="basictab" style="border:0px solid gray;margin:0px;"> <ul style="border:0px solid #999999; "> <li><a onClick="expandcontent(\'sc1\', this)" style="margin:0px;">' . $LANG->getLL('export.xml.headline.title') . '</a></li> <li><a onClick="expandcontent(\'sc2\', this)" style="margin:0px;">' . $LANG->getLL('import.xml.headline.title') . '</a></li> <li><a onClick="expandcontent(\'sc3\', this)" style="margin:0px;">' . $LANG->getLL('file.settings.downloads.title') . '</a></li> <li><a onClick="expandcontent(\'sc4\', this)" style="margin:0px;">' . $LANG->getLL('l10nmgr.documentation.title') . '</a></li> </ul></div>'; $info .= '<div id="tabcontentcontainer" style="height:150px;border:1px solid gray;padding-right:5px;width:100%;">'; $info .= '<div id="sc1" class="tabcontent">'; //$info .= '<div id="sc1" class="tabcontent">'; $_selectOptions = array('0' => '-default-'); $_selectOptions = $_selectOptions + $this->MOD_MENU["lang"]; $info .= '<input type="checkbox" value="1" name="check_exports" /> ' . $LANG->getLL('export.xml.check_exports.title') . '<br />'; $info .= '<input type="checkbox" value="1" name="no_check_xml" /> ' . $LANG->getLL('export.xml.no_check_xml.title') . '<br />'; $info .= '<input type="checkbox" value="1" name="check_utf8" /> ' . $LANG->getLL('export.xml.checkUtf8.title') . '<br />'; $info .= $LANG->getLL('export.xml.source-language.title') . $this->_getSelectField("export_xml_forcepreviewlanguage", '0', $_selectOptions) . '<br />'; // Add the option to send to FTP server, if FTP information is defined if (!empty($this->lConf['ftp_server']) && !empty($this->lConf['ftp_server_username']) && !empty($this->lConf['ftp_server_password'])) { $info .= '<input type="checkbox" value="1" name="ftp_upload" id="tx_l10nmgr_ftp_upload" /> <label for="tx_l10nmgr_ftp_upload">' . $GLOBALS['LANG']->getLL('export.xml.ftp.title') . '</label>'; } $info .= '<br /><br/>'; $info .= '<input type="submit" value="Export" name="export_xml" /><br /><br /><br/>'; $info .= '</div>'; $info .= '<div id="sc2" class="tabcontent">'; $info .= '<input type="checkbox" value="1" name="make_preview_link" /> ' . $LANG->getLL('import.xml.make_preview_link.title') . '<br />'; $info .= '<input type="checkbox" value="1" name="import_delL10N" /> ' . $LANG->getLL('import.xml.delL10N.title') . '<br />'; $info .= '<input type="checkbox" value="1" name="import_oldformat" /> ' . $LANG->getLL('import.xml.old-format.title') . '<br /><br />'; $info .= '<input type="file" size="60" name="uploaded_import_file" /><br /><br /><input type="submit" value="Import" name="import_xml" /><br /><br /> '; $info .= '</div>'; $info .= '<div id="sc3" class="tabcontent">'; $info .= $this->doc->icons(1) . $LANG->getLL('file.settings.available.title'); for (reset($allowedSettingFiles); list($settingId, $settingFileName) = each($allowedSettingFiles);) { $currentFile = t3lib_div::resolveBackPath($BACK_PATH . t3lib_extMgm::extRelPath('l10nmgr') . 'settings/' . $settingFileName); if (is_file($currentFile) && is_readable($currentFile)) { $size = t3lib_div::formatSize((int) filesize($currentFile), ' Bytes| KB| MB| GB'); $info .= '<br/><a href="' . t3lib_div::rawUrlEncodeFP($currentFile) . '" title="' . $LANG->getLL('file.settings.download.title') . '" target="_blank">' . $LANG->getLL('file.settings.' . $settingId . '.title') . ' (' . $size . ')' . '</a> '; } } $info .= '</div>'; $info .= '<div id="sc4" class="tabcontent">'; $info .= '<a href="' . t3lib_extMgm::extRelPath('l10nmgr') . 'doc/manual.sxw" target="_new">Download</a>'; $info .= '</div>'; $info .= '</div>'; $actionInfo = ''; // Read uploaded file: if (t3lib_div::_POST('import_xml') && $_FILES['uploaded_import_file']['tmp_name'] && is_uploaded_file($_FILES['uploaded_import_file']['tmp_name'])) { $uploadedTempFile = t3lib_div::upload_to_tempfile($_FILES['uploaded_import_file']['tmp_name']); /** @var $factory tx_l10nmgr_translationDataFactory */ $factory = t3lib_div::makeInstance('tx_l10nmgr_translationDataFactory'); //print "<pre>"; //var_dump($GLOBALS['BE_USER']->user); //print "</pre>"; if (t3lib_div::_POST('import_oldformat') == '1') { //Support for the old Format of XML Import (without pageGrp element) $actionInfo .= $LANG->getLL('import.xml.old-format.message'); $translationData = $factory->getTranslationDataFromOldFormatCATXMLFile($uploadedTempFile); $translationData->setLanguage($this->sysLanguage); $service->saveTranslation($l10ncfgObj, $translationData); $actionInfo .= '<br/><br/>' . $this->doc->icons(1) . 'Import done<br/><br/>(Command count:' . $service->lastTCEMAINCommandsCount . ')'; } else { // Relevant processing of XML Import with the help of the Importmanager /** @var $importManager tx_l10nmgr_CATXMLImportManager */ $importManager = t3lib_div::makeInstance('tx_l10nmgr_CATXMLImportManager', $uploadedTempFile, $this->sysLanguage, $xmlString = ""); if ($importManager->parseAndCheckXMLFile() === false) { $actionInfo .= '<br/><br/>' . $this->doc->header($LANG->getLL('import.error.title')) . $importManager->getErrorMessages(); } else { if (t3lib_div::_POST('import_delL10N') == '1') { $actionInfo .= $LANG->getLL('import.xml.delL10N.message') . '<br/>'; $delCount = $importManager->delL10N($importManager->getDelL10NDataFromCATXMLNodes($importManager->xmlNodes)); $actionInfo .= sprintf($LANG->getLL('import.xml.delL10N.count.message'), $delCount) . '<br/><br/>'; } if (t3lib_div::_POST('make_preview_link') == '1') { $pageIds = $importManager->getPidsFromCATXMLNodes($importManager->xmlNodes); $actionInfo .= '<b>' . $LANG->getLL('import.xml.preview_links.title') . '</b><br/>'; /** @var $mkPreviewLinks tx_l10nmgr_mkPreviewLinkService */ $mkPreviewLinks = t3lib_div::makeInstance('tx_l10nmgr_mkPreviewLinkService', $t3_workspaceId = $importManager->headerData['t3_workspaceId'], $t3_sysLang = $importManager->headerData['t3_sysLang'], $pageIds); $actionInfo .= $mkPreviewLinks->renderPreviewLinks($mkPreviewLinks->mkPreviewLinks()); } $translationData = $factory->getTranslationDataFromCATXMLNodes($importManager->getXMLNodes()); $translationData->setLanguage($this->sysLanguage); //$actionInfo.="<pre>".var_export($GLOBALS['BE_USER'],true)."</pre>"; unset($importManager); $service->saveTranslation($l10ncfgObj, $translationData); $actionInfo .= '<br/>' . $this->doc->icons(-1) . $LANG->getLL('import.xml.done.message') . '<br/><br/>(Command count:' . $service->lastTCEMAINCommandsCount . ')'; } } t3lib_div::unlink_tempfile($uploadedTempFile); } // If export of XML is asked for, do that (this will exit and push a file for download, or upload to FTP is option is checked) if (t3lib_div::_POST('export_xml')) { // Save user prefs $BE_USER->pushModuleData('l10nmgr/cm1/checkUTF8', t3lib_div::_POST('check_utf8')); // Render the XML /** @var $viewClass tx_l10nmgr_CATXMLView */ $viewClass = t3lib_div::makeInstance('tx_l10nmgr_CATXMLView', $l10ncfgObj, $this->sysLanguage); $export_xml_forcepreviewlanguage = intval(t3lib_div::_POST('export_xml_forcepreviewlanguage')); if ($export_xml_forcepreviewlanguage > 0) { $viewClass->setForcedSourceLanguage($export_xml_forcepreviewlanguage); } if ($this->MOD_SETTINGS['onlyChangedContent']) { $viewClass->setModeOnlyChanged(); } if ($this->MOD_SETTINGS['noHidden']) { $viewClass->setModeNoHidden(); } // Check the export if (t3lib_div::_POST('check_exports') == '1' && $viewClass->checkExports() == FALSE) { /** @var $flashMessage t3lib_FlashMessage */ $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $LANG->getLL('export.process.duplicate.message'), $LANG->getLL('export.process.duplicate.title'), t3lib_FlashMessage::INFO); $actionInfo .= $flashMessage->render(); $actionInfo .= $viewClass->renderExports(); } else { // Upload to FTP if (t3lib_div::_POST('ftp_upload') == '1') { try { $filename = $this->uploadToFtp($viewClass); // Send a mail notification $this->emailNotification($filename, $l10ncfgObj, $this->sysLanguage); // Prepare a success message for display $title = $GLOBALS['LANG']->getLL('export.ftp.success'); $message = sprintf($GLOBALS['LANG']->getLL('export.ftp.success.detail'), $this->lConf['ftp_server_path'] . $filename); $status = t3lib_FlashMessage::OK; } catch (Exception $e) { // Prepare an error message for display $title = $GLOBALS['LANG']->getLL('export.ftp.error'); $message = $e->getMessage() . ' (' . $e->getCode() . ')'; $status = t3lib_FlashMessage::ERROR; } /** @var $flashMessage t3lib_FlashMessage */ $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $message, $title, $status); $actionInfo .= $flashMessage->render(); $actionInfo .= $viewClass->renderInternalMessagesAsFlashMessage($status); // Download the XML file } else { try { $filename = $this->downloadXML($viewClass); // Prepare a success message for display $link = sprintf('<a href="%s" target="_blank">%s</a>', t3lib_div::getIndpEnv('TYPO3_SITE_URL') . $filename, $filename); $title = $GLOBALS['LANG']->getLL('export.download.success'); $message = sprintf($GLOBALS['LANG']->getLL('export.download.success.detail'), $link); $status = t3lib_FlashMessage::OK; } catch (Exception $e) { // Prepare an error message for display $title = $GLOBALS['LANG']->getLL('export.download.error'); $message = $e->getMessage() . ' (' . $e->getCode() . ')'; $status = t3lib_FlashMessage::ERROR; } /** @var $flashMessage t3lib_FlashMessage */ $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $message, $title, $status); $actionInfo .= $flashMessage->render(); $actionInfo .= $viewClass->renderInternalMessagesAsFlashMessage($status); } } } if (!empty($actionInfo)) { $info .= $this->doc->header($LANG->getLL('misc.messages.title')); $info .= $actionInfo; } $info .= '</div>'; return $info; }
/** * Returns a file or folder icon for a given (file)path as HTML img tag. * * @param array $infoArr info array: eg. $pathInfo = tx_dam::path_getInfo($path) * @param boolean $addAttrib Additional attributes for the image tag.. * @param string $mode TYPO3_MODE to be used: 'FE', 'BE'. Constant TYPO3_MODE is default. * @return string Icon img tag * @see tx_dam::path_getInfo() */ function icon_getFileTypeImgTag($infoArr, $addAttrib = '', $mode = TYPO3_MODE) { global $TYPO3_CONF_VARS, $TCA; static $iconCacheSize = array(); require_once PATH_t3lib . 'class.t3lib_iconworks.php'; if (isset($infoArr['dir_name'])) { $iconfile = tx_dam::icon_getFolder($infoArr); } elseif (isset($infoArr['file_name']) or isset($infoArr['file_type']) or isset($infoArr['media_type'])) { $iconfile = tx_dam::icon_getFileType($infoArr); if ($mode === 'BE') { $tca_temp_typeicons = $TCA['tx_dam']['ctrl']['typeicons']; $tca_temp_iconfile = $TCA['tx_dam']['ctrl']['iconfile']; unset($TCA['tx_dam']['ctrl']['typeicons']); $TCA['tx_dam']['ctrl']['iconfile'] = $iconfile; $iconfile = t3lib_iconWorks::getIcon('tx_dam', $infoArr, $shaded = false); $TCA['tx_dam']['ctrl']['iconfile'] = $tca_temp_iconfile; $TCA['tx_dam']['ctrl']['typeicons'] = $tca_temp_typeicons; } } if (!$iconCacheSize[$iconfile]) { // Get width/height: $iInfo = @getimagesize(t3lib_div::resolveBackPath(PATH_site . TYPO3_mainDir . $iconfile)); $iconCacheSize[$iconfile] = $iInfo[3]; } $icon = '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], $iconfile, $iconCacheSize[$iconfile]) . ' class="typo3-icon" alt="" ' . trim($addAttrib) . ' />'; return $icon; }
/** * Indexing External URL * * @param string URL, http://.... * @param integer Page id to relate indexing to. * @param array Rootline array to relate indexing to * @param integer Configuration UID * @param integer Set ID value * @return array URLs found on this page */ function indexExtUrl($url, $pageId, $rl, $cfgUid, $setId) { // Load indexer if not yet. $this->loadIndexerClass(); // Index external URL: $indexerObj = t3lib_div::makeInstance('tx_indexedsearch_indexer'); $indexerObj->backend_initIndexer($pageId, 0, 0, '', $rl); $indexerObj->backend_setFreeIndexUid($cfgUid, $setId); $indexerObj->hash['phash'] = -1; // To avoid phash_t3 being written to file sections (otherwise they are removed when page is reindexed!!!) $indexerObj->indexExternalUrl($url); $url_qParts = parse_url($url); $baseAbsoluteHref = $url_qParts['scheme'] . '://' . $url_qParts['host']; $baseHref = $indexerObj->extractBaseHref($indexerObj->indexExternalUrl_content); if (!$baseHref) { // Extract base href from current URL $baseHref = $baseAbsoluteHref; $baseHref .= substr($url_qParts['path'], 0, strrpos($url_qParts['path'], '/')); } $baseHref = rtrim($baseHref, '/'); // Get URLs on this page: $subUrls = array(); $list = $indexerObj->extractHyperLinks($indexerObj->indexExternalUrl_content); // Traverse links: foreach ($list as $count => $linkInfo) { // Decode entities: $subUrl = t3lib_div::htmlspecialchars_decode($linkInfo['href']); $qParts = parse_url($subUrl); if (!$qParts['scheme']) { $relativeUrl = t3lib_div::resolveBackPath($subUrl); if ($relativeUrl[0] === '/') { $subUrl = $baseAbsoluteHref . $relativeUrl; } else { $subUrl = $baseHref . '/' . $relativeUrl; } } $subUrls[] = $subUrl; } return $subUrls; }
/** * Step 5: Create dynamic menu * * @param string Type of menu (main or sub), values: "field_menu" or "field_submenu" * @return void */ function wizard_step5($menuField) { $menuPart = $this->getMenuDefaultCode($menuField); $menuType = $menuField === 'field_menu' ? 'mainMenu' : 'subMenu'; $menuTypeText = $menuField === 'field_menu' ? 'main menu' : 'sub menu'; $menuTypeLetter = $menuField === 'field_menu' ? 'a' : 'b'; $menuTypeNextStep = $menuField === 'field_menu' ? 5.1 : 6; $menuTypeEntryLevel = $menuField === 'field_menu' ? 0 : 1; $this->saveMenuCode(); if (strlen($menuPart)) { // Main message: $outputString.= sprintf($GLOBALS['LANG']->getLL('newsitewizard_basicsshouldwork', 1), $menuTypeText, $menuType, $menuTypeText); // Start up HTML parser: require_once(PATH_t3lib.'class.t3lib_parsehtml.php'); $htmlParser = t3lib_div::makeinstance('t3lib_parsehtml'); // Parse into blocks $parts = $htmlParser->splitIntoBlock('td,tr,table,a,div,span,ol,ul,li,p,h1,h2,h3,h4,h5',$menuPart,1); // If it turns out to be only a single large block we expect it to be a container for the menu item. Therefore we will parse the next level and expect that to be menu items: if (count($parts)==3) { $totalWrap = array(); $totalWrap['before'] = $parts[0].$htmlParser->getFirstTag($parts[1]); $totalWrap['after'] = '</'.strtolower($htmlParser->getFirstTagName($parts[1])).'>'.$parts[2]; $parts = $htmlParser->splitIntoBlock('td,tr,table,a,div,span,ol,ul,li,p,h1,h2,h3,h4,h5',$htmlParser->removeFirstAndLastTag($parts[1]),1); } else { $totalWrap = array(); } $menuPart_HTML = trim($totalWrap['before']).chr(10).implode(chr(10),$parts).chr(10).trim($totalWrap['after']); // Traverse expected menu items: $menuWraps = array(); $GMENU = FALSE; $mouseOver = FALSE; $key = ''; foreach($parts as $k => $value) { if ($k%2) { // Only expecting inner elements to be of use: $linkTag = $htmlParser->splitIntoBlock('a',$value,1); if ($linkTag[1]) { $newValue = array(); $attribs = $htmlParser->get_tag_attributes($htmlParser->getFirstTag($linkTag[1]),1); $newValue['A-class'] = $attribs[0]['class']; if ($attribs[0]['onmouseover'] && $attribs[0]['onmouseout']) $mouseOver = TRUE; // Check if the complete content is an image - then make GMENU! $linkContent = trim($htmlParser->removeFirstAndLastTag($linkTag[1])); if (preg_match('/^<img[^>]*>$/i',$linkContent)) { $GMENU = TRUE; $attribs = $htmlParser->get_tag_attributes($linkContent,1); $newValue['I-class'] = $attribs[0]['class']; $newValue['I-width'] = $attribs[0]['width']; $newValue['I-height'] = $attribs[0]['height']; $filePath = t3lib_div::getFileAbsFileName(t3lib_div::resolveBackPath(PATH_site.$attribs[0]['src'])); if (@is_file($filePath)) { $newValue['backColorGuess'] = $this->getBackgroundColor($filePath); } else $newValue['backColorGuess'] = ''; if ($attribs[0]['onmouseover'] && $attribs[0]['onmouseout']) $mouseOver = TRUE; } $linkTag[1] = '|'; $newValue['wrap'] = preg_replace('/['.chr(10).chr(13).']*/','',implode('',$linkTag)); $md5Base = $newValue; unset($md5Base['I-width']); unset($md5Base['I-height']); $md5Base = serialize($md5Base); $md5Base = preg_replace('/name=["\'][^"\']*["\']/','',$md5Base); $md5Base = preg_replace('/id=["\'][^"\']*["\']/','',$md5Base); $md5Base = preg_replace('/\s/','',$md5Base); $key = md5($md5Base); if (!isset($menuWraps[$key])) { // Only if not yet set, set it (so it only gets set once and the first time!) $menuWraps[$key] = $newValue; } else { // To prevent from writing values in the "} elseif ($key) {" below, we clear the key: $key = ''; } } elseif ($key) { // Add this to the previous wrap: $menuWraps[$key]['bulletwrap'].= str_replace('|','&#'.ord('|').';',preg_replace('/['.chr(10).chr(13).']*/','',$value)); } } } // Construct TypoScript for the menu: reset($menuWraps); if (count($menuWraps)==1) { $menu_normal = current($menuWraps); $menu_active = next($menuWraps); } else { // If more than two, then the first is the active one. $menu_active = current($menuWraps); $menu_normal = next($menuWraps); } #debug($menuWraps); #debug($mouseOver); if ($GMENU) { $typoScript = ' lib.'.$menuType.' = HMENU lib.'.$menuType.'.entryLevel = '.$menuTypeEntryLevel.' '.(count($totalWrap) ? 'lib.'.$menuType.'.wrap = '.preg_replace('/['.chr(10).chr(13).']/','',implode('|',$totalWrap)) : '').' lib.'.$menuType.'.1 = GMENU lib.'.$menuType.'.1.NO.wrap = '.$this->makeWrap($menu_normal). ($menu_normal['I-class'] ? ' lib.'.$menuType.'.1.NO.imgParams = class="'.htmlspecialchars($menu_normal['I-class']).'" ' : '').' lib.'.$menuType.'.1.NO { XY = '.($menu_normal['I-width']?$menu_normal['I-width']:150).','.($menu_normal['I-height']?$menu_normal['I-height']:25).' backColor = '.($menu_normal['backColorGuess'] ? $menu_normal['backColorGuess'] : '#FFFFFF').' 10 = TEXT 10.text.field = title // nav_title 10.fontColor = #333333 10.fontSize = 12 10.offset = 15,15 10.fontFace = t3lib/fonts/nimbus.ttf } '; if ($mouseOver) { $typoScript.= ' lib.'.$menuType.'.1.RO < lib.'.$menuType.'.1.NO lib.'.$menuType.'.1.RO = 1 lib.'.$menuType.'.1.RO { backColor = '.t3lib_div::modifyHTMLColorAll(($menu_normal['backColorGuess'] ? $menu_normal['backColorGuess'] : '#FFFFFF'),-20).' 10.fontColor = red } '; } if (is_array($menu_active)) { $typoScript.= ' lib.'.$menuType.'.1.ACT < lib.'.$menuType.'.1.NO lib.'.$menuType.'.1.ACT = 1 lib.'.$menuType.'.1.ACT.wrap = '.$this->makeWrap($menu_active). ($menu_active['I-class'] ? ' lib.'.$menuType.'.1.ACT.imgParams = class="'.htmlspecialchars($menu_active['I-class']).'" ' : '').' lib.'.$menuType.'.1.ACT { backColor = '.($menu_active['backColorGuess'] ? $menu_active['backColorGuess'] : '#FFFFFF').' } '; } } else { $typoScript = ' lib.'.$menuType.' = HMENU lib.'.$menuType.'.entryLevel = '.$menuTypeEntryLevel.' '.(count($totalWrap) ? 'lib.'.$menuType.'.wrap = '.preg_replace('/['.chr(10).chr(13).']/','',implode('|',$totalWrap)) : '').' lib.'.$menuType.'.1 = TMENU lib.'.$menuType.'.1.NO { allWrap = '.$this->makeWrap($menu_normal). ($menu_normal['A-class'] ? ' ATagParams = class="'.htmlspecialchars($menu_normal['A-class']).'"' : '').' } '; if (is_array($menu_active)) { $typoScript.= ' lib.'.$menuType.'.1.ACT = 1 lib.'.$menuType.'.1.ACT { allWrap = '.$this->makeWrap($menu_active). ($menu_active['A-class'] ? ' ATagParams = class="'.htmlspecialchars($menu_active['A-class']).'"' : '').' } '; } } // Output: // HTML defaults: $outputString.=' <br/> <br/> ' . $GLOBALS['LANG']->getLL('newsitewizard_menuhtmlcode', 1) . ' <hr/> <pre>'.htmlspecialchars($menuPart_HTML).'</pre> <hr/> <br/>'; if (trim($menu_normal['wrap']) != '|') { $outputString .= sprintf($GLOBALS['LANG']->getLL('newsitewizard_menuenc', 1), htmlspecialchars(str_replace('|', ' ... ', $menu_normal['wrap']))); } else { $outputString .= $GLOBALS['LANG']->getLL('newsitewizard_menunoa', 1); } if (count($totalWrap)) { $outputString .= sprintf($GLOBALS['LANG']->getLL('newsitewizard_menuwrap', 1), htmlspecialchars(str_replace('|', ' ... ', implode('|', $totalWrap)))); } if ($menu_normal['bulletwrap']) { $outputString .= sprintf($GLOBALS['LANG']->getLL('newsitewizard_menudiv', 1), htmlspecialchars($menu_normal['bulletwrap'])); } if ($GMENU) { $outputString .= $GLOBALS['LANG']->getLL('newsitewizard_menuimg', 1); } if ($mouseOver) { $outputString .= $GLOBALS['LANG']->getLL('newsitewizard_menumouseover', 1); } $outputString .= '<br/><br/>'; $outputString .= $GLOBALS['LANG']->getLL('newsitewizard_menuts', 1) . ' <br/><br/>'; $outputString.='<hr/>'.$this->syntaxHLTypoScript($typoScript).'<hr/><br/>'; $outputString .= $GLOBALS['LANG']->getLL('newsitewizard_menufinetune', 1); $outputString .= '<textarea name="CFG[menuCode]"'.$GLOBALS['TBE_TEMPLATE']->formWidthText().' rows="10">'.t3lib_div::formatForTextarea($typoScript).'</textarea><br/><br/>'; $outputString .= '<input type="hidden" name="SET[wiz_step]" value="'.$menuTypeNextStep.'" />'; $outputString .= '<input type="submit" name="_" value="' . sprintf($GLOBALS['LANG']->getLL('newsitewizard_menuwritets', 1), $menuTypeText) . '" />'; } else { $outputString.= sprintf($GLOBALS['LANG']->getLL('newsitewizard_menufinished', 1), $menuTypeText) . '<br />'; $outputString.='<input type="hidden" name="SET[wiz_step]" value="'.$menuTypeNextStep.'" />'; $outputString.='<input type="submit" name="_" value="' . $GLOBALS['LANG']->getLL('newsitewizard_menunext', 1) . '" />'; } // Add output: $this->content.= $this->doc->section(sprintf($GLOBALS['LANG']->getLL('newsitewizard_step5', 1), $menuTypeLetter), $outputString, 0, 1); }
/** * generates javascript code to switch between modules * * @return string javascript code snippet to switch modules */ public function getGotoModuleJavascript() { $moduleJavascriptCommands = array(); $rawModuleData = $this->getRawModuleData(); $navFrameScripts = array(); foreach ($rawModuleData as $mainModuleKey => $mainModuleData) { if ($mainModuleData['subitems']) { foreach ($mainModuleData['subitems'] as $subModuleKey => $subModuleData) { $parentModuleName = substr($subModuleData['name'], 0, strpos($subModuleData['name'], '_')); $javascriptCommand = ''; // Setting additional JavaScript if frameset script: $additionalJavascript = ''; if ($subModuleData['parentNavigationFrameScript']) { $additionalJavascript = "+'&id='+top.rawurlencodeAndRemoveSiteUrl(top.fsMod.recentIds['" . $parentModuleName . "'])"; } if ($subModuleData['link'] && $this->linkModules) { // For condensed mode, send &cMR parameter to frameset script. if ($additionalJavascript && $GLOBALS['BE_USER']->uc['condensedMode']) { $additionalJavascript .= "+(cMR ? '&cMR=1' : '')"; } $javascriptCommand = ' modScriptURL = "' . $this->appendQuestionmarkToLink($subModuleData['link']) . '"' . $additionalJavascript . ';'; if ($subModuleData['navFrameScript']) { $javascriptCommand .= ' top.currentSubScript="' . $subModuleData['originalLink'] . '";'; } if (!$GLOBALS['BE_USER']->uc['condensedMode'] && $subModuleData['parentNavigationFrameScript']) { $additionalJavascript = "+'&id='+top.rawurlencodeAndRemoveSiteUrl(top.fsMod.recentIds['" . $parentModuleName . "'])"; $submoduleNavigationFrameScript = $subModuleData['navigationFrameScript'] ? $subModuleData['navigationFrameScript'] : $subModuleData['parentNavigationFrameScript']; $submoduleNavigationFrameScript = t3lib_div::resolveBackPath($submoduleNavigationFrameScript); // Add navigation script parameters if module requires them if ($subModuleData['navigationFrameScriptParam']) { $submoduleNavigationFrameScript = $this->appendQuestionmarkToLink($submoduleNavigationFrameScript) . $subModuleData['navigationFrameScriptParam']; } $navFrameScripts[$parentModuleName] = $submoduleNavigationFrameScript; $javascriptCommand = ' top.currentSubScript = "' . $subModuleData['originalLink'] . '"; if (top.content.list_frame && top.fsMod.currentMainLoaded == mainModName) { modScriptURL = "' . $this->appendQuestionmarkToLink($subModuleData['originalLink']) . '"' . $additionalJavascript . '; '; // Change link to navigation frame if submodule has it's own navigation if ($submoduleNavigationFrameScript) { $javascriptCommand .= 'navFrames["' . $parentModuleName . '"] = "' . $submoduleNavigationFrameScript . '";'; } $javascriptCommand .= ' } else if (top.nextLoadModuleUrl) { modScriptURL = "' . ($subModuleData['prefix'] ? $this->appendQuestionmarkToLink($subModuleData['link']) . '&exScript=' : '') . 'listframe_loader.php"; } else { modScriptURL = "' . $this->appendQuestionmarkToLink($subModuleData['link']) . '"' . $additionalJavascript . ' + additionalGetVariables; }'; } } $moduleJavascriptCommands[] = "\n\t\t\tcase '" . $subModuleData['name'] . "':" . $javascriptCommand . "\n\t\t\tbreak;"; } } elseif (!$mainModuleData['subitems'] && !empty($mainModuleData['link'])) { // main module has no sub modules but instead is linked itself (doc module f.e.) $javascriptCommand = ' modScriptURL = "' . $this->appendQuestionmarkToLink($mainModuleData['link']) . '";'; $moduleJavascriptCommands[] = "\n\t\t\tcase '" . $mainModuleData['name'] . "':" . $javascriptCommand . "\n\t\t\tbreak;"; } } $javascriptCode = 'function(modName, cMR_flag, addGetVars) { var useCondensedMode = ' . ($GLOBALS['BE_USER']->uc['condensedMode'] ? 'true' : 'false') . '; var mainModName = (modName.slice(0, modName.indexOf("_")) || modName); var additionalGetVariables = ""; if (addGetVars) { additionalGetVariables = addGetVars; }'; $javascriptCode .= ' var navFrames = {};'; foreach ($navFrameScripts as $mainMod => $frameScript) { $javascriptCode .= ' navFrames["' . $mainMod . '"] = "' . $frameScript . '";'; } $javascriptCode .= ' var cMR = (cMR_flag ? 1 : 0); var modScriptURL = ""; switch(modName) {' . LF . implode(LF, $moduleJavascriptCommands) . LF . ' } '; $javascriptCode .= ' if (!useCondensedMode && navFrames[mainModName]) { if (top.content.list_frame && top.fsMod.currentMainLoaded == mainModName) { top.content.list_frame.location = top.getModuleUrl(top.TS.PATH_typo3 + modScriptURL + additionalGetVariables); if (top.currentSubNavScript != navFrames[mainModName]) { top.currentSubNavScript = navFrames[mainModName]; top.content.nav_frame.location = top.getModuleUrl(top.TS.PATH_typo3 + navFrames[mainModName]); } } else { TYPO3.Backend.loadModule(mainModName, modName, modScriptURL + additionalGetVariables); } } else if (modScriptURL) { TYPO3.Backend.loadModule(mainModName, modName, top.getModuleUrl(modScriptURL + additionalGetVariables)); } currentModuleLoaded = modName; top.fsMod.currentMainLoaded = mainModName; TYPO3ModuleMenu.highlightModule("modmenu_" + modName, (modName == mainModName ? 1 : 0)); }'; return $javascriptCode; }
/** * Analyzes the input content for various stuff which can be used to generate the DS. * Basically this tries to intelligently guess some settings. * * @param string HTML Content string * @return array Configuration * @see substEtypeWithRealStuff() */ function substEtypeWithRealStuff_contentInfo($content) { if ($content) { if (substr($content, 0, 4) == '<img') { $attrib = t3lib_div::get_tag_attributes($content); if ((!$attrib['width'] || !$attrib['height']) && $attrib['src']) { $pathWithNoDots = t3lib_div::resolveBackPath($attrib['src']); $filePath = t3lib_div::getFileAbsFileName($pathWithNoDots); if ($filePath && @is_file($filePath)) { $imgInfo = @getimagesize($filePath); if (!$attrib['width']) { $attrib['width'] = $imgInfo[0]; } if (!$attrib['height']) { $attrib['height'] = $imgInfo[1]; } } } return array('img' => $attrib); } } return false; }
/** * Here we check for the module. * Return values: * 'notFound': If the module was not found in the path (no "conf.php" file) * false: If no access to the module (access check failed) * array(): Configuration array, in case a valid module where access IS granted exists. * * @param string Module name * @param string Absolute path to module * @return mixed See description of function */ function checkMod($name, $fullpath) { if ($name == 'user_ws' && !t3lib_extMgm::isLoaded('version')) { return FALSE; } // Check for own way of configuring module if (is_array($GLOBALS['TBE_MODULES']['_configuration'][$name]['configureModuleFunction'])) { $obj = $GLOBALS['TBE_MODULES']['_configuration'][$name]['configureModuleFunction']; if (is_callable($obj)) { return call_user_func($obj, $name, $fullpath); } } $modconf = array(); $path = preg_replace('/\\/[^\\/.]+\\/\\.\\.\\//', '/', $fullpath); // because 'path/../path' does not work if (@is_dir($path) && file_exists($path . '/conf.php')) { $MCONF = array(); $MLANG = array(); include $path . '/conf.php'; // The conf-file is included. This must be valid PHP. if (!$MCONF['shy'] && $this->checkModAccess($name, $MCONF) && $this->checkModWorkspace($name, $MCONF)) { $modconf['name'] = $name; // language processing. This will add module labels and image reference to the internal ->moduleLabels array of the LANG object. if (is_object($GLOBALS['LANG'])) { // $MLANG['default']['tabs_images']['tab'] is for modules the reference to the module icon. // Here the path is transformed to an absolute reference. if ($MLANG['default']['tabs_images']['tab']) { // Initializing search for alternative icon: $altIconKey = 'MOD:' . $name . '/' . $MLANG['default']['tabs_images']['tab']; // Alternative icon key (might have an alternative set in $TBE_STYLES['skinImg'] $altIconAbsPath = is_array($GLOBALS['TBE_STYLES']['skinImg'][$altIconKey]) ? t3lib_div::resolveBackPath(PATH_typo3 . $GLOBALS['TBE_STYLES']['skinImg'][$altIconKey][0]) : ''; // Setting icon, either default or alternative: if ($altIconAbsPath && @is_file($altIconAbsPath)) { $MLANG['default']['tabs_images']['tab'] = $this->getRelativePath(PATH_typo3, $altIconAbsPath); } else { // Setting default icon: $MLANG['default']['tabs_images']['tab'] = $this->getRelativePath(PATH_typo3, $fullpath . '/' . $MLANG['default']['tabs_images']['tab']); } // Finally, setting the icon with correct path: if (substr($MLANG['default']['tabs_images']['tab'], 0, 3) == '../') { $MLANG['default']['tabs_images']['tab'] = PATH_site . substr($MLANG['default']['tabs_images']['tab'], 3); } else { $MLANG['default']['tabs_images']['tab'] = PATH_typo3 . $MLANG['default']['tabs_images']['tab']; } } // If LOCAL_LANG references are used for labels of the module: if ($MLANG['default']['ll_ref']) { // Now the 'default' key is loaded with the CURRENT language - not the english translation... $MLANG['default']['labels']['tablabel'] = $GLOBALS['LANG']->sL($MLANG['default']['ll_ref'] . ':mlang_labels_tablabel'); $MLANG['default']['labels']['tabdescr'] = $GLOBALS['LANG']->sL($MLANG['default']['ll_ref'] . ':mlang_labels_tabdescr'); $MLANG['default']['tabs']['tab'] = $GLOBALS['LANG']->sL($MLANG['default']['ll_ref'] . ':mlang_tabs_tab'); $GLOBALS['LANG']->addModuleLabels($MLANG['default'], $name . '_'); } else { // ... otherwise use the old way: $GLOBALS['LANG']->addModuleLabels($MLANG['default'], $name . '_'); $GLOBALS['LANG']->addModuleLabels($MLANG[$GLOBALS['LANG']->lang], $name . '_'); } } // Default script setup if ($MCONF['script'] === '_DISPATCH') { if ($MCONF['extbase']) { $modconf['script'] = 'mod.php?M=Tx_' . rawurlencode($name); } else { $modconf['script'] = 'mod.php?M=' . rawurlencode($name); } } elseif ($MCONF['script'] && file_exists($path . '/' . $MCONF['script'])) { $modconf['script'] = $this->getRelativePath(PATH_typo3, $fullpath . '/' . $MCONF['script']); } else { $modconf['script'] = 'dummy.php'; } // Default tab setting if ($MCONF['defaultMod']) { $modconf['defaultMod'] = $MCONF['defaultMod']; } // Navigation Frame Script (GET params could be added) if ($MCONF['navFrameScript']) { $navFrameScript = explode('?', $MCONF['navFrameScript']); $navFrameScript = $navFrameScript[0]; if (file_exists($path . '/' . $navFrameScript)) { $modconf['navFrameScript'] = $this->getRelativePath(PATH_typo3, $fullpath . '/' . $MCONF['navFrameScript']); } } // additional params for Navigation Frame Script: "&anyParam=value&moreParam=1" if ($MCONF['navFrameScriptParam']) { $modconf['navFrameScriptParam'] = $MCONF['navFrameScriptParam']; } } else { return false; } } else { $modconf = 'notFound'; } return $modconf; }
/** * Prints a row with data for the various extension listings * * @param string Extension key * @param array Extension information array * @param array Preset table cells, eg. install/uninstall icons. * @param string <tr> tag class * @param array Array with installed extension keys (as keys) * @param boolean If set, the list is coming from remote server. * @param string Alternative link URL * @return string HTML <tr> content */ function extensionListRow($extKey, $extInfo, $cells, $bgColorClass = '', $inst_list = array(), $import = 0, $altLinkUrl = '') { $stateColors = tx_em_Tools::getStateColors(); // Icon: $imgInfo = @getImageSize(tx_em_Tools::getExtPath($extKey, $extInfo['type']) . '/ext_icon.gif'); if (is_array($imgInfo)) { $cells[] = '<td><img src="' . $GLOBALS['BACK_PATH'] . tx_em_Tools::typeRelPath($extInfo['type']) . $extKey . '/ext_icon.gif' . '" ' . $imgInfo[3] . ' alt="" /></td>'; } elseif ($extInfo['_ICON']) { $cells[] = '<td>' . $extInfo['_ICON'] . '</td>'; } else { $cells[] = '<td><img src="clear.gif" width="1" height="1" alt="" /></td>'; } // Extension title: $cells[] = '<td nowrap="nowrap"><a href="' . htmlspecialchars($altLinkUrl ? $altLinkUrl : t3lib_div::linkThisScript(array('CMD[showExt]' => $extKey, 'SET[singleDetails]' => 'info'))) . '" title="' . htmlspecialchars($extInfo['EM_CONF']['description']) . '">' . t3lib_div::fixed_lgd_cs($extInfo['EM_CONF']['title'] ? htmlspecialchars($extInfo['EM_CONF']['title']) : '<em>' . $extKey . '</em>', 40) . '</a></td>'; // Based on the display mode you will see more or less details: if (!$this->parentObject->MOD_SETTINGS['display_details']) { $cells[] = '<td>' . htmlspecialchars(t3lib_div::fixed_lgd_cs($extInfo['EM_CONF']['description'], 400)) . '<br /><img src="clear.gif" width="300" height="1" alt="" /></td>'; $cells[] = '<td nowrap="nowrap">' . ($extInfo['EM_CONF']['author_email'] ? '<a href="mailto:' . htmlspecialchars($extInfo['EM_CONF']['author_email']) . '">' : '') . htmlspecialchars($extInfo['EM_CONF']['author']) . (htmlspecialchars($extInfo['EM_CONF']['author_email']) ? '</a>' : '') . ($extInfo['EM_CONF']['author_company'] ? '<br />' . htmlspecialchars($extInfo['EM_CONF']['author_company']) : '') . '</td>'; } elseif ($this->parentObject->MOD_SETTINGS['display_details'] == 2) { $cells[] = '<td nowrap="nowrap">' . $extInfo['EM_CONF']['priority'] . '</td>'; $cells[] = '<td nowrap="nowrap">' . implode('<br />', t3lib_div::trimExplode(',', $extInfo['EM_CONF']['modify_tables'], 1)) . '</td>'; $cells[] = '<td nowrap="nowrap">' . $extInfo['EM_CONF']['module'] . '</td>'; $cells[] = '<td nowrap="nowrap">' . ($extInfo['EM_CONF']['clearCacheOnLoad'] ? $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:yes') : '') . '</td>'; $cells[] = '<td nowrap="nowrap">' . ($extInfo['EM_CONF']['internal'] ? $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:yes') : '') . '</td>'; $cells[] = '<td nowrap="nowrap">' . ($extInfo['EM_CONF']['shy'] ? $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:yes') : '') . '</td>'; } elseif ($this->parentObject->MOD_SETTINGS['display_details'] == 3) { $techInfo = $this->install->makeDetailedExtensionAnalysis($extKey, $extInfo); $cells[] = '<td>' . $this->parentObject->extensionDetails->extInformationArray_dbReq($techInfo) . '</td>'; $cells[] = '<td nowrap="nowrap">' . (is_array($techInfo['TSfiles']) ? implode('<br />', $techInfo['TSfiles']) : '') . '</td>'; $cells[] = '<td nowrap="nowrap">' . (is_array($techInfo['flags']) ? implode('<br />', $techInfo['flags']) : '') . '</td>'; $cells[] = '<td nowrap="nowrap">' . (is_array($techInfo['moduleNames']) ? implode('<br />', $techInfo['moduleNames']) : '') . '</td>'; $cells[] = '<td nowrap="nowrap">' . ($techInfo['conf'] ? $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:yes') : '') . '</td>'; $cells[] = '<td>' . tx_em_Tools::rfw((t3lib_extMgm::isLoaded($extKey) && $techInfo['tables_error'] ? '<strong>' . $GLOBALS['LANG']->getLL('extInfoArray_table_error') . '</strong><br />' . $GLOBALS['LANG']->getLL('extInfoArray_missing_fields') : '') . (t3lib_extMgm::isLoaded($extKey) && $techInfo['static_error'] ? '<strong>' . $GLOBALS['LANG']->getLL('extInfoArray_static_table_error') . '</strong><br />' . $GLOBALS['LANG']->getLL('extInfoArray_static_tables_missing_empty') : '')) . '</td>'; } elseif ($this->parentObject->MOD_SETTINGS['display_details'] == 4) { $techInfo = $this->install->makeDetailedExtensionAnalysis($extKey, $extInfo, 1); $cells[] = '<td>' . (is_array($techInfo['locallang']) ? implode('<br />', $techInfo['locallang']) : '') . '</td>'; $cells[] = '<td>' . (is_array($techInfo['classes']) ? implode('<br />', $techInfo['classes']) : '') . '</td>'; $cells[] = '<td>' . (is_array($techInfo['errors']) ? tx_em_Tools::rfw(implode('<hr />', $techInfo['errors'])) : '') . '</td>'; $cells[] = '<td>' . (is_array($techInfo['NSerrors']) ? !t3lib_div::inList($this->parentObject->nameSpaceExceptions, $extKey) ? t3lib_utility_Debug::viewarray($techInfo['NSerrors']) : tx_em_Tools::dfw($GLOBALS['LANG']->getLL('extInfoArray_exception')) : '') . '</td>'; } elseif ($this->parentObject->MOD_SETTINGS['display_details'] == 5) { $currentMd5Array = $this->parentObject->extensionDetails->serverExtensionMD5array($extKey, $extInfo); $affectedFiles = ''; $msgLines = array(); $msgLines[] = $GLOBALS['LANG']->getLL('listRow_files') . ' ' . count($currentMd5Array); if (strcmp($extInfo['EM_CONF']['_md5_values_when_last_written'], serialize($currentMd5Array))) { $msgLines[] = tx_em_Tools::rfw('<br /><strong>' . $GLOBALS['LANG']->getLL('extInfoArray_difference_detected') . '</strong>'); $affectedFiles = tx_em_Tools::findMD5ArrayDiff($currentMd5Array, unserialize($extInfo['EM_CONF']['_md5_values_when_last_written'])); if (count($affectedFiles)) { $msgLines[] = '<br /><strong>' . $GLOBALS['LANG']->getLL('extInfoArray_modified_files') . '</strong><br />' . tx_em_Tools::rfw(implode('<br />', $affectedFiles)); } } $cells[] = '<td>' . implode('<br />', $msgLines) . '</td>'; } else { // Default view: $verDiff = $inst_list[$extKey] && tx_em_Tools::versionDifference($extInfo['EM_CONF']['version'], $inst_list[$extKey]['EM_CONF']['version'], $this->parentObject->versionDiffFactor); $cells[] = '<td nowrap="nowrap"><em>' . $extKey . '</em></td>'; $cells[] = '<td nowrap="nowrap">' . ($verDiff ? '<strong>' . tx_em_Tools::rfw(htmlspecialchars($extInfo['EM_CONF']['version'])) . '</strong>' : $extInfo['EM_CONF']['version']) . '</td>'; if (!$import) { // Listing extension on LOCAL server: // Extension Download: $cells[] = '<td nowrap="nowrap"><a href="' . htmlspecialchars(t3lib_div::linkThisScript(array('CMD[doBackup]' => 1, 'SET[singleDetails]' => 'backup', 'CMD[showExt]' => $extKey))) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:download') . '">' . t3lib_iconWorks::getSpriteIcon('actions-system-extension-download') . '</a></td>'; // Manual download $manual = tx_em_Tools::typePath($extInfo['type']) . $extKey . '/doc/manual.sxw'; $manualRelPath = t3lib_div::resolveBackPath($this->parentObject->doc->backPath . tx_em_Tools::typeRelPath($extInfo['type'])) . $extKey . '/doc/manual.sxw'; if ($extInfo['EM_CONF']['docPath']) { $manual = tx_em_Tools::typePath($extInfo['type']) . $extKey . '/' . $extInfo['EM_CONF']['docPath'] . '/manual.sxw'; $manualRelPath = t3lib_div::resolveBackPath($this->parentObject->doc->backPath . tx_em_Tools::typeRelPath($extInfo['type'])) . $extKey . '/' . $extInfo['EM_CONF']['docPath'] . '/manual.sxw'; } $cells[] = '<td nowrap="nowrap">' . (tx_em_Tools::typePath($extInfo['type']) && @is_file($manual) ? '<a href="' . htmlspecialchars($manualRelPath) . '" target="_blank" title="' . $GLOBALS['LANG']->getLL('listRow_local_manual') . '">' . t3lib_iconWorks::getSpriteIcon('actions-system-extension-documentation') . '</a>' : '') . '</td>'; // Double installation (inclusion of an extension in more than one of system, global or local scopes) $doubleInstall = ''; if (strlen($extInfo['doubleInstall']) > 1) { // Separate the "SL" et al. string into an array and replace L by Local, G by Global etc. $doubleInstallations = str_replace(array('S', 'G', 'L'), array($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:sysext'), $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:globalext'), $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:localext')), str_split($extInfo['doubleInstall'])); // Last extension is the one actually used $usedExtension = array_pop($doubleInstallations); // Next extension is overridden $overriddenExtensions = array_pop($doubleInstallations); // If the array is not yet empty, the extension is actually installed 3 times (SGL) if (count($doubleInstallations) > 0) { $lastExtension = array_pop($doubleInstallations); $overriddenExtensions .= ' ' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:and') . ' ' . $lastExtension; } $doubleInstallTitle = sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_tools_em.xml:double_inclusion'), $usedExtension, $overriddenExtensions); $doubleInstall = ' <strong><abbr title="' . $doubleInstallTitle . '">' . tx_em_Tools::rfw($extInfo['doubleInstall']) . '</abbr></strong>'; } $cells[] = '<td nowrap="nowrap">' . $this->types[$extInfo['type']] . $doubleInstall . '</td>'; } else { // Listing extensions from REMOTE repository: $inst_curVer = $inst_list[$extKey]['EM_CONF']['version']; if (isset($inst_list[$extKey])) { if ($verDiff) { $inst_curVer = '<strong>' . tx_em_Tools::rfw($inst_curVer) . '</strong>'; } } $cells[] = '<td nowrap="nowrap">' . t3lib_befunc::date($extInfo['EM_CONF']['lastuploaddate']) . '</td>'; $cells[] = '<td nowrap="nowrap">' . htmlspecialchars(t3lib_div::fixed_lgd_cs($extInfo['EM_CONF']['author'], $GLOBALS['BE_USER']->uc[titleLen])) . '</td>'; $cells[] = '<td nowrap="nowrap">' . $inst_curVer . '</td>'; $cells[] = '<td nowrap="nowrap">' . $this->api->typeLabels[$inst_list[$extKey]['type']] . (strlen($inst_list[$extKey]['doubleInstall']) > 1 ? '<strong> ' . tx_em_Tools::rfw($inst_list[$extKey]['doubleInstall']) . '</strong>' : '') . '</td>'; $cells[] = '<td nowrap="nowrap">' . ($extInfo['downloadcounter_all'] ? $extInfo['downloadcounter_all'] : ' ') . '/' . ($extInfo['downloadcounter'] ? $extInfo['downloadcounter'] : ' ') . '</td>'; } $cells[] = '<td nowrap="nowrap" class="extstate" style="background-color:' . $stateColors[$extInfo['EM_CONF']['state']] . ';">' . $this->states[$extInfo['EM_CONF']['state']] . '</td>'; } // show a different background through a different class for insecure (-1) extensions, // for unreviewed (0) and reviewed extensions (1), just use the regular class if ($this->xmlHandler->getReviewState($extKey, $extInfo['EM_CONF']['version']) < 0) { $bgclass = ' class="unsupported-ext"'; } else { $bgclass = ' class="' . ($bgColorClass ? $bgColorClass : 'em-listbg1') . '"'; } return ' <tr' . $bgclass . '> ' . implode(' ', $cells) . ' </tr>'; }
function languageRows($languageList, $elementList) { // Initialization: $elements = $this->explodeElement($elementList); $firstEl = current($elements); $hookObj = t3lib_div::makeInstance('tx_l10nmgr_tcemain_hook'); $this->l10nMgrTools = t3lib_div::makeInstance('tx_l10nmgr_tools'); $this->l10nMgrTools->verbose = FALSE; // Otherwise it will show records which has fields but none editable. $inputRecord = t3lib_BEfunc::getRecord($firstEl[0], $firstEl[1], 'pid'); $this->sysLanguages = $this->l10nMgrTools->t8Tools->getSystemLanguages($firstEl[0] == 'pages' ? $firstEl[1] : $inputRecord['pid']); $languages = $this->getLanguages($languageList, $this->sysLanguages); if (count($languages)) { $tRows = array(); // Header: $cells = '<td class="bgColor2 tableheader">Element:</td>'; foreach ($languages as $l) { if ($l >= 1) { $baseRecordFlag = '<img src="' . htmlspecialchars($GLOBALS['BACK_PATH'] . $this->sysLanguages[$l]['flagIcon']) . '" alt="' . htmlspecialchars($this->sysLanguages[$l]['title']) . '" title="' . htmlspecialchars($this->sysLanguages[$l]['title']) . '" />'; $cells .= '<td class="bgColor2 tableheader">' . $baseRecordFlag . '</td>'; } } $tRows[] = $cells; foreach ($elements as $el) { $cells = ''; // Get CURRENT online record and icon based on "t3ver_oid": $rec_on = t3lib_BEfunc::getRecord($el[0], $el[1]); $icon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord($el[0], $rec_on); $icon = $this->doc->wrapClickMenuOnIcon($icon, $el[0], $rec_on['uid'], 2); $linkToIt = '<a href="#" onclick="' . htmlspecialchars('parent.list_frame.location.href="' . $GLOBALS['BACK_PATH'] . t3lib_extMgm::extRelPath('l10nmgr') . 'cm2/index.php?table=' . $el[0] . '&uid=' . $el[1] . '"; return false;') . '" target="listframe"> ' . t3lib_BEfunc::getRecordTitle($el[0], $rec_on, TRUE) . ' </a>'; if ($el[0] == 'pages') { // If another page module was specified, replace the default Page module with the new one $newPageModule = trim($GLOBALS['BE_USER']->getTSConfigVal('options.overridePageModule')); $pageModule = t3lib_BEfunc::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout'; $path_module_path = t3lib_div::resolveBackPath($GLOBALS['BACK_PATH'] . '../' . substr($GLOBALS['TBE_MODULES']['_PATHS'][$pageModule], strlen(PATH_site))); $onclick = 'parent.list_frame.location.href="' . $path_module_path . '?id=' . $el[1] . '"; return false;'; $pmLink = '<a href="#" onclick="' . htmlspecialchars($onclick) . '" target="listframe"><i>[Edit page]</i></a>'; } else { $pmLink = ''; } $cells = '<td>' . $icon . $linkToIt . $pmLink . '</td>'; foreach ($languages as $l) { if ($l >= 1) { $cells .= '<td align="center">' . $hookObj->calcStat(array($el[0], $el[1]), $l) . '</td>'; } } $tRows[] = $cells; } return '<table border="0" cellpadding="0" cellspacing="0"><tr>' . implode('</tr><tr>', $tRows) . '</tr></table>'; } }
/** * Return a JS array for special anchor classes * * @return string classesAnchor array definition */ public function buildJSClassesAnchorArray() { global $LANG, $TYPO3_CONF_VARS; $linebreak = $TYPO3_CONF_VARS['EXTCONF'][$this->htmlAreaRTE->ID]['enableCompressedScripts'] ? '' : LF; $JSClassesAnchorArray .= 'HTMLArea.classesAnchorSetup = [ ' . $linebreak; $classesAnchorIndex = 0; foreach ($this->htmlAreaRTE->RTEsetup['properties']['classesAnchor.'] as $label => $conf) { if (is_array($conf) && $conf['class']) { $JSClassesAnchorArray .= ($classesAnchorIndex++ ? ',' : '') . ' { ' . $linebreak; $index = 0; $JSClassesAnchorArray .= ($index++ ? ',' : '') . 'name : "' . str_replace('"', '', str_replace('\'', '', $conf['class'])) . '"' . $linebreak; if ($conf['type']) { $JSClassesAnchorArray .= ($index++ ? ',' : '') . 'type : "' . str_replace('"', '', str_replace('\'', '', $conf['type'])) . '"' . $linebreak; } if (trim(str_replace('\'', '', str_replace('"', '', $conf['image'])))) { $JSClassesAnchorArray .= ($index++ ? ',' : '') . 'image : "' . $this->htmlAreaRTE->siteURL . t3lib_div::resolveBackPath(TYPO3_mainDir . $this->htmlAreaRTE->getFullFileName(trim(str_replace('\'', '', str_replace('"', '', $conf['image']))))) . '"' . $linebreak; } $JSClassesAnchorArray .= ($index++ ? ',' : '') . 'addIconAfterLink : ' . ($conf['addIconAfterLink'] ? 'true' : 'false') . $linebreak; if (trim($conf['altText'])) { $string = $this->htmlAreaRTE->getLLContent(trim($conf['altText'])); $JSClassesAnchorArray .= ($index++ ? ',' : '') . 'altText : ' . str_replace('"', '\\"', str_replace('\\\'', '\'', $string)) . $linebreak; } if (trim($conf['titleText'])) { $string = $this->htmlAreaRTE->getLLContent(trim($conf['titleText'])); $JSClassesAnchorArray .= ($index++ ? ',' : '') . 'titleText : ' . str_replace('"', '\\"', str_replace('\\\'', '\'', $string)) . $linebreak; } if (trim($conf['target'])) { $JSClassesAnchorArray .= ($index++ ? ',' : '') . 'target : "' . trim($conf['target']) . '"' . $linebreak; } $JSClassesAnchorArray .= '}' . $linebreak; } } $JSClassesAnchorArray .= '];' . $linebreak; return $JSClassesAnchorArray; }
/** * Function to load a HTML template file with markers. * When calling from own extension, use syntax getHtmlTemplate('EXT:extkey/template.html') * * @param string tmpl name, usually in the typo3/template/ directory * @return string HTML of template */ function getHtmlTemplate($filename) { // setting the name of the original HTML template $this->moduleTemplateFilename = $filename; if ($GLOBALS['TBE_STYLES']['htmlTemplates'][$filename]) { $filename = $GLOBALS['TBE_STYLES']['htmlTemplates'][$filename]; } if (t3lib_div::isFirstPartOfStr($filename, 'EXT:')) { $filename = t3lib_div::getFileAbsFileName($filename, TRUE, TRUE); } else { if (!t3lib_div::isAbsPath($filename)) { $filename = t3lib_div::resolveBackPath($this->backPath . $filename); } else { if (!t3lib_div::isAllowedAbsPath($filename)) { $filename = ''; } } } $htmlTemplate = ''; if ($filename !== '') { $htmlTemplate = t3lib_div::getURL($filename); } return $htmlTemplate; }
/** * gets the raw module data * * @return array multi dimension array with module data */ public function getRawModuleData() { $modules = array(); // Remove the 'doc' module? if ($GLOBALS['BE_USER']->getTSConfigVal('options.disableDocModuleInAB')) { unset($this->loadedModules['doc']); } foreach ($this->loadedModules as $moduleName => $moduleData) { $moduleLink = ''; if (!is_array($moduleData['sub'])) { $moduleLink = $moduleData['script']; } $moduleLink = t3lib_div::resolveBackPath($moduleLink); $moduleKey = 'modmenu_' . $moduleName; $moduleIcon = $this->getModuleIcon($moduleKey); $modules[$moduleKey] = array('name' => $moduleName, 'title' => $GLOBALS['LANG']->moduleLabels['tabs'][$moduleName . '_tab'], 'onclick' => 'top.goToModule(\'' . $moduleName . '\');', 'icon' => $moduleIcon, 'link' => $moduleLink, 'description' => $GLOBALS['LANG']->moduleLabels['labels'][$moduleKey . 'label']); if (!is_array($moduleData['sub']) && $moduleData['script'] != 'dummy.php') { // Work around for modules with own main entry, but being self the only submodule $modules[$moduleKey]['subitems'][$moduleKey] = array('name' => $moduleName, 'title' => $GLOBALS['LANG']->moduleLabels['tabs'][$moduleName . '_tab'], 'onclick' => 'top.goToModule(\'' . $moduleName . '\');', 'icon' => $this->getModuleIcon($moduleName . '_tab'), 'link' => $moduleLink, 'originalLink' => $moduleLink, 'description' => $GLOBALS['LANG']->moduleLabels['labels'][$moduleKey . 'label'], 'navigationFrameScript' => NULL, 'navigationFrameScriptParam' => NULL, 'navigationComponentId' => NULL); } else { if (is_array($moduleData['sub'])) { foreach ($moduleData['sub'] as $submoduleName => $submoduleData) { $submoduleLink = t3lib_div::resolveBackPath($submoduleData['script']); $submoduleKey = $moduleName . '_' . $submoduleName . '_tab'; $submoduleIcon = $this->getModuleIcon($submoduleKey); $submoduleDescription = $GLOBALS['LANG']->moduleLabels['labels'][$submoduleKey . 'label']; $originalLink = $submoduleLink; $modules[$moduleKey]['subitems'][$submoduleKey] = array('name' => $moduleName . '_' . $submoduleName, 'title' => $GLOBALS['LANG']->moduleLabels['tabs'][$submoduleKey], 'onclick' => 'top.goToModule(\'' . $moduleName . '_' . $submoduleName . '\');', 'icon' => $submoduleIcon, 'link' => $submoduleLink, 'originalLink' => $originalLink, 'description' => $submoduleDescription, 'navigationFrameScript' => $submoduleData['navFrameScript'], 'navigationFrameScriptParam' => $submoduleData['navFrameScriptParam'], 'navigationComponentId' => $submoduleData['navigationComponentId']); if ($moduleData['navFrameScript']) { $modules[$moduleKey]['subitems'][$submoduleKey]['parentNavigationFrameScript'] = $moduleData['navFrameScript']; } } } } } return $modules; }
/** * Create file in directory and return the new (unique) filename * * @param string Directory prefix, relative, with trailing slash * @param string Filename (without path) * @param string File ID from import memory * @param string Table for which the processing occurs * @param string UID of record from table * @return string New relative filename, if any */ function processSoftReferences_saveFile_createRelFile($origDirPrefix, $fileName, $fileID, $table, $uid) { // If the fileID map contains an entry for this fileID then just return the relative filename of that entry; we don't want to write another unique filename for this one! if ($this->fileIDMap[$fileID]) { return substr($this->fileIDMap[$fileID], strlen(PATH_site)); } // Verify FileMount access to dir-prefix. Returns the best alternative relative path if any $dirPrefix = $this->verifyFolderAccess($origDirPrefix); if ($dirPrefix && (!$this->update || $origDirPrefix === $dirPrefix) && $this->checkOrCreateDir($dirPrefix)) { $fileHeaderInfo = $this->dat['header']['files'][$fileID]; $updMode = $this->update && $this->import_mapId[$table][$uid] === $uid && $this->import_mode[$table . ':' . $uid] !== 'as_new'; // Create new name for file: if ($updMode) { // Must have same ID in map array (just for security, is not really needed) and NOT be set "as_new". $newName = PATH_site . $dirPrefix . $fileName; } else { // Create unique filename: $fileProcObj = $this->getFileProcObj(); $newName = $fileProcObj->getUniqueName($fileName, PATH_site . $dirPrefix); } #debug($newName,'$newName'); // Write main file: if ($this->writeFileVerify($newName, $fileID)) { // If the resource was an HTML/CSS file with resources attached, we will write those as well! if (is_array($fileHeaderInfo['EXT_RES_ID'])) { #debug($fileHeaderInfo['EXT_RES_ID']); $tokenizedContent = $this->dat['files'][$fileID]['tokenizedContent']; $tokenSubstituted = FALSE; $fileProcObj = $this->getFileProcObj(); if ($updMode) { foreach ($fileHeaderInfo['EXT_RES_ID'] as $res_fileID) { if ($this->dat['files'][$res_fileID]['filename']) { // Resolve original filename: $relResourceFileName = $this->dat['files'][$res_fileID]['parentRelFileName']; $absResourceFileName = t3lib_div::resolveBackPath(PATH_site . $origDirPrefix . $relResourceFileName); $absResourceFileName = t3lib_div::getFileAbsFileName($absResourceFileName); if ($absResourceFileName && t3lib_div::isFirstPartOfStr($absResourceFileName, PATH_site . $this->fileadminFolderName . '/')) { $destDir = substr(dirname($absResourceFileName) . '/', strlen(PATH_site)); if ($this->verifyFolderAccess($destDir, TRUE) && $this->checkOrCreateDir($destDir)) { $this->writeFileVerify($absResourceFileName, $res_fileID); } else { $this->error('ERROR: Could not create file in directory "' . $destDir . '"'); } } else { $this->error('ERROR: Could not resolve path for "' . $relResourceFileName . '"'); } $tokenizedContent = str_replace('{EXT_RES_ID:' . $res_fileID . '}', $relResourceFileName, $tokenizedContent); $tokenSubstituted = TRUE; } } } else { // Create the resouces directory name (filename without extension, suffixed "_FILES") $resourceDir = dirname($newName) . '/' . preg_replace('/\\.[^.]*$/', '', basename($newName)) . '_FILES'; if (t3lib_div::mkdir($resourceDir)) { foreach ($fileHeaderInfo['EXT_RES_ID'] as $res_fileID) { if ($this->dat['files'][$res_fileID]['filename']) { $absResourceFileName = $fileProcObj->getUniqueName($this->dat['files'][$res_fileID]['filename'], $resourceDir); $relResourceFileName = substr($absResourceFileName, strlen(dirname($resourceDir)) + 1); $this->writeFileVerify($absResourceFileName, $res_fileID); $tokenizedContent = str_replace('{EXT_RES_ID:' . $res_fileID . '}', $relResourceFileName, $tokenizedContent); $tokenSubstituted = TRUE; } } } } // If substitutions has been made, write the content to the file again: if ($tokenSubstituted) { t3lib_div::writeFile($newName, $tokenizedContent); } } return substr($newName, strlen(PATH_site)); } } }
</tr> <tr> <td><?php echo $LANG->getLL('general.list.infodetail.incfcewithdefaultlanguage.title'); ?> </td> <td><?php echo $configurationElementArray['incfcewithdefaultlanguage']; ?> </td> </tr> </table> </div> </td> <td><?php echo '<a href="' . t3lib_div::resolveBackPath($BACK_PATH . t3lib_extMgm::extRelPath('l10nmgr')) . 'cm1/index.php?id=' . $configurationElementArray['uid'] . '&srcPID=' . t3lib_div::intval_positive($this->getPageId()) . '">' . $configurationElementArray['title'] . '</a>'; ?> </td> <td><?php echo current(t3lib_BEfunc::getRecordPath($configurationElementArray['pid'], '1', 20, 50)); ?> </td> <td><?php echo $configurationElementArray['depth']; ?> </td> <td><?php echo $configurationElementArray['tablelist']; ?> </td> <td><?php
/** * Returns the login box image, whether the default or an image from the rotation folder. * * @return string HTML image tag. */ function makeLoginBoxImage() { $loginboxImage = ''; if ($GLOBALS['TBE_STYLES']['loginBoxImage_rotationFolder']) { // Look for rotation image folder: $absPath = t3lib_div::resolveBackPath(PATH_typo3 . $GLOBALS['TBE_STYLES']['loginBoxImage_rotationFolder']); // Get rotation folder: $dir = t3lib_div::getFileAbsFileName($absPath); if ($dir && @is_dir($dir)) { // Get files for rotation into array: $files = t3lib_div::getFilesInDir($dir, 'png,jpg,gif'); // Pick random file: $randImg = array_rand($files, 1); // Get size of random file: $imgSize = @getimagesize($dir . $files[$randImg]); $imgAuthor = is_array($GLOBALS['TBE_STYLES']['loginBoxImage_author']) && $GLOBALS['TBE_STYLES']['loginBoxImage_author'][$files[$randImg]] ? htmlspecialchars($GLOBALS['TBE_STYLES']['loginBoxImage_author'][$files[$randImg]]) : ''; // Create image tag: if (is_array($imgSize)) { $loginboxImage = '<img src="' . htmlspecialchars($GLOBALS['TBE_STYLES']['loginBoxImage_rotationFolder'] . $files[$randImg]) . '" ' . $imgSize[3] . ' id="loginbox-image" alt="' . $imgAuthor . '" title="' . $imgAuthor . '" />'; } } } else { // If no rotation folder configured, print default image: if (strstr(TYPO3_version, '-dev')) { // development version $loginImage = 'loginbox_image_dev.png'; $imagecopy = 'You are running a development version of TYPO3 ' . TYPO3_branch; } else { $loginImage = 'loginbox_image.jpg'; $imagecopy = 'Photo by J.C. Franca (www.digitalphoto.com.br)'; } $loginboxImage = '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/' . $loginImage, 'width="200" height="133"') . ' id="loginbox-image" alt="' . $imagecopy . '" title="' . $imagecopy . '" />'; } // Return image tag: return $loginboxImage; }
/** * Checks if the path points to the file inside the web site * * @param string $filePath * @return boolean */ protected static function isAllowedLocalFile($filePath) { $filePath = t3lib_div::resolveBackPath($filePath); $insideWebPath = substr($filePath, 0, strlen(PATH_site)) == PATH_site; $isFile = is_file($filePath); return $insideWebPath && $isFile; }
/** * Get relative path for $destDir compared to $baseDir * * @param string Base directory * @param string Destination directory * @return string The relative path of destination compared to base. */ function getRelativePath($baseDir, $destDir) { // By René Fritz // a special case , the dirs are equals if ($baseDir == $destDir) { return './'; } $baseDir = ltrim($baseDir, '/'); // remove beginning $destDir = ltrim($destDir, '/'); $found = TRUE; $slash_pos = 0; do { $slash_pos = strpos($destDir, '/'); if (substr($destDir, 0, $slash_pos) == substr($baseDir, 0, $slash_pos)) { $baseDir = substr($baseDir, $slash_pos + 1); $destDir = substr($destDir, $slash_pos + 1); } else { $found = FALSE; } } while ($found == TRUE); $slashes = strlen($baseDir) - strlen(str_replace('/', '', $baseDir)); for ($i = 0; $i < $slashes; $i++) { $destDir = '../' . $destDir; } return t3lib_div::resolveBackPath($destDir); }
/** * Renders the $icon, supports a filename for skinImg or sprite-icon-name * @param $icon the icon passed, could be a file-reference or a sprite Icon name * @param string $alt alt attribute of the icon returned * @param string $title title attribute of the icon return * @return an tag representing to show the asked icon */ protected function getIconHtml($icon, $alt = '', $title = '') { $iconArray = $this->getIcon($icon); if (is_file(t3lib_div::resolveBackPath(PATH_typo3 . PATH_typo3_mod . $iconArray[0]))) { return '<img src="' . $iconArray[0] . '" alt="' . $alt . '" ' . ($title ? 'title="' . $title . '"' : '') . ' />'; } else { return t3lib_iconWorks::getSpriteIcon($icon, array('alt' => $alt, 'title' => $title)); } }
/** * Function to load a HTML template file with markers. * When calling from own extension, use syntax getHtmlTemplate('EXT:extkey/template.html') * * @param string tmpl name, usually in the typo3/template/ directory * @return string HTML of template */ function getHtmlTemplate($filename) { if ($GLOBALS['TBE_STYLES']['htmlTemplates'][$filename]) { $filename = $GLOBALS['TBE_STYLES']['htmlTemplates'][$filename]; } if (substr($filename, 0, 4) != 'EXT:') { $filename = t3lib_div::resolveBackPath($this->backPath . $filename); } else { $filename = t3lib_div::getFileAbsFileName($filename, true, true); } return t3lib_div::getURL($filename); }
/** * this method creates SpriteIcon names for all tables in TCA (including their possible type-icons) * where there is no "typeicon_classes" of this TCA table ctrl section (moved form t3lib_iconWorks) * * @return void */ protected function buildTcaSpriteIcons() { $tcaTables = array_keys($GLOBALS['TCA']); // delete old tempFiles @unlink($this->cssTcaFile); // backpath from the stylesheet file ($cssTcaFile) to typo3 dir // in order to set the background-image URL paths correct $iconPath = '../../' . TYPO3_mainDir; // path (relative from typo3 dir) for skin-Images if (isset($GLOBALS['TBE_STYLES']['skinImgAutoCfg']['relDir'])) { $skinPath = $GLOBALS['TBE_STYLES']['skinImgAutoCfg']['relDir']; } else { $skinPath = ''; } // check every table in the TCA, if an icon is needed foreach ($tcaTables as $tableName) { // this method is only needed for TCA tables where // typeicon_classes are not configured if (!is_array($GLOBALS['TCA'][$tableName]['ctrl']['typeicon_classes'])) { $tcaCtrl = $GLOBALS['TCA'][$tableName]['ctrl']; $template = str_replace('###TABLE###', $tableName, $this->styleSheetTemplateTca); // adding the default Icon (without types) if (isset($tcaCtrl['iconfile'])) { // in CSS wie need a path relative to the css file // [TCA][ctrl][iconfile] defines icons without path info to reside in gfx/i/ if (strpos($tcaCtrl['iconfile'], '/') !== FALSE) { $icon = $tcaCtrl['iconfile']; } else { $icon = $skinPath . 'gfx/i/' . $tcaCtrl['iconfile']; } $icon = t3lib_div::resolveBackPath($iconPath . $icon); // saving default icon $stylesString = str_replace('###TYPE###', 'default', $template); $stylesString = str_replace('###IMAGE###', $icon, $stylesString); $this->styleSheetData .= $stylesString; $this->iconNames[] = 'tcarecords-' . $tableName . '-default'; } // if records types are available, register them if (isset($tcaCtrl['typeicon_column']) && is_array($tcaCtrl['typeicons'])) { foreach ($tcaCtrl['typeicons'] as $type => $icon) { // in CSS wie need a path relative to the css file // [TCA][ctrl][iconfile] defines icons without path info to reside in gfx/i/ if (strpos($icon, '/') === FALSE) { $icon = $skinPath . 'gfx/i/' . $icon; } $icon = t3lib_div::resolveBackPath($iconPath . $icon); $stylesString = str_replace('###TYPE###', $type, $template); $stylesString = str_replace('###IMAGE###', $icon, $stylesString); // saving type icon $this->styleSheetData .= $stylesString; $this->iconNames[] = 'tcarecords-' . $tableName . '-' . $type; } } } } }
/** * Get the jquery script tag. * For backend usage only. * @param boolean If TRUE, only the URL is returned, not a full script tag * @return string HTML Script tag to load the jQuery JavaScript library */ function getJqJSBE($urlOnly = FALSE) { $file = tx_t3jquery::getJqPath() . tx_t3jquery::getJqName(); if (file_exists(PATH_site . $file)) { $url = t3lib_div::resolveBackPath($GLOBALS['BACK_PATH'] . '../' . $file); if ($urlOnly) { return $url; } else { return '<script type="text/javascript" src="' . $url . '"></script>'; } } else { t3lib_div::devLog('\'' . tx_t3jquery::getJqName() . '\' does not exists!', 't3jquery', 3); } return FALSE; }
/** * Creates a link to the deprecation log file with the absolute path as the * link text. * * @return string Link to the deprecation log file */ protected function getDeprecationLogFileLink() { $logFile = t3lib_div::getDeprecationLogFileName(); $relativePath = t3lib_div::resolveBackPath($this->backPath . substr($logFile, strlen(PATH_site))); $link = '<a href="' . $relativePath . '">' . $logFile . '</a>'; return $link; }
/** * 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, '###|###')); }
/** * Checks if the $fontFile is already at an absolute path and if not, prepends the correct path. * Use PATH_site unless we are in the backend. * Call it by t3lib_stdGraphic::prependAbsolutePath() * * @param string The font file * @return string The font file with absolute path. */ function prependAbsolutePath($fontFile) { $absPath = defined('PATH_typo3') ? dirname(PATH_thisScript) . '/' : PATH_site; $fontFile = t3lib_div::isAbsPath($fontFile) ? $fontFile : t3lib_div::resolveBackPath($absPath . $fontFile); return $fontFile; }