/** * Include all defined resources (JS / CSS) * * @return void */ public function addResources() { if (class_exists(t3lib_utility_VersionNumber) && t3lib_utility_VersionNumber::convertVersionNumberToInteger(TYPO3_version) >= 4003000) { $pagerender = $GLOBALS['TSFE']->getPageRenderer(); } // Fix moveJsFromHeaderToFooter (add all scripts to the footer) if ($GLOBALS['TSFE']->config['config']['moveJsFromHeaderToFooter']) { $allJsInFooter = TRUE; } else { $allJsInFooter = FALSE; } // add all defined JS files if (count($this->jsFiles) > 0) { foreach ($this->jsFiles as $jsToLoad) { if (T3JQUERY === TRUE) { $conf = array('jsfile' => $jsToLoad, 'tofooter' => $this->conf['jsInFooter'] || $allJsInFooter, 'jsminify' => $this->conf['jsMinify']); tx_t3jquery::addJS('', $conf); } else { $file = $this->getPath($jsToLoad); if ($file) { if (class_exists(t3lib_utility_VersionNumber) && t3lib_utility_VersionNumber::convertVersionNumberToInteger(TYPO3_version) >= 4003000) { if ($this->conf['jsInFooter'] || $allJsInFooter) { $pagerender->addJsFooterFile($file, 'text/javascript', $this->conf['jsMinify']); } else { $pagerender->addJsFile($file, 'text/javascript', $this->conf['jsMinify']); } } else { $temp_file = '<script type="text/javascript" src="' . $file . '"></script>'; if ($this->conf['jsInFooter'] || $allJsInFooter) { $GLOBALS['TSFE']->additionalFooterData['jsFile_' . $this->extKey . '_' . $file] = $temp_file; } else { $GLOBALS['TSFE']->additionalHeaderData['jsFile_' . $this->extKey . '_' . $file] = $temp_file; } } } else { t3lib_div::devLog("'{$jsToLoad}' does not exists!", $this->extKey, 2); } } } } // add all defined JS script if (count($this->js) > 0) { foreach ($this->js as $jsToPut) { $temp_js .= $jsToPut; } $conf = array(); $conf['jsdata'] = $temp_js; if (T3JQUERY === TRUE && class_exists(t3lib_utility_VersionNumber) && t3lib_utility_VersionNumber::convertVersionNumberToInteger($this->getExtensionVersion('t3jquery')) >= 1002000) { $conf['tofooter'] = $this->conf['jsInFooter'] || $allJsInFooter; $conf['jsminify'] = $this->conf['jsMinify']; $conf['jsinline'] = $this->conf['jsInline']; tx_t3jquery::addJS('', $conf); } else { // Add script only once $hash = md5($temp_js); if ($this->conf['jsInline']) { $GLOBALS['TSFE']->inlineJS[$hash] = $temp_js; } elseif (class_exists(t3lib_utility_VersionNumber) && t3lib_utility_VersionNumber::convertVersionNumberToInteger(TYPO3_version) >= 4003000) { if ($this->conf['jsInFooter'] || $allJsInFooter) { $pagerender->addJsFooterInlineCode($hash, $temp_js, $this->conf['jsMinify']); } else { $pagerender->addJsInlineCode($hash, $temp_js, $this->conf['jsMinify']); } } else { if ($this->conf['jsMinify']) { $temp_js = t3lib_div::minifyJavaScript($temp_js); } if ($this->conf['jsInFooter'] || $allJsInFooter) { $GLOBALS['TSFE']->additionalFooterData['js_' . $this->extKey . '_' . $hash] = t3lib_div::wrapJS($temp_js, TRUE); } else { $GLOBALS['TSFE']->additionalHeaderData['js_' . $this->extKey . '_' . $hash] = t3lib_div::wrapJS($temp_js, TRUE); } } } } // add all defined CSS files if (count($this->cssFiles) > 0) { foreach ($this->cssFiles as $cssToLoad) { // Add script only once $file = $this->getPath($cssToLoad); if ($file) { if (class_exists(t3lib_utility_VersionNumber) && t3lib_utility_VersionNumber::convertVersionNumberToInteger(TYPO3_version) >= 4003000) { $pagerender->addCssFile($file, 'stylesheet', 'all', '', $this->conf['cssMinify']); } else { $GLOBALS['TSFE']->additionalHeaderData['cssFile_' . $this->extKey . '_' . $file] = '<link rel="stylesheet" type="text/css" href="' . $file . '" media="all" />' . chr(10); } } else { t3lib_div::devLog("'{$cssToLoad}' does not exists!", $this->extKey, 2); } } } // add all defined CSS files for IE if (count($this->cssFilesInc) > 0) { foreach ($this->cssFilesInc as $cssToLoad) { // Add script only once $file = $this->getPath($cssToLoad['file']); if ($file) { // Theres no possibility to add conditions for IE by pagerenderer, so this will be added in additionalHeaderData $GLOBALS['TSFE']->additionalHeaderData['cssFile_' . $this->extKey . '_' . $file] = '<!--[if ' . $cssToLoad['rule'] . ']><link rel="stylesheet" type="text/css" href="' . $file . '" media="all" /><![endif]-->' . chr(10); } else { t3lib_div::devLog("'{$cssToLoad['file']}' does not exists!", $this->extKey, 2); } } } // add all defined CSS Script if (count($this->css) > 0) { foreach ($this->css as $cssToPut) { $temp_css .= $cssToPut; } $hash = md5($temp_css); if (class_exists(t3lib_utility_VersionNumber) && t3lib_utility_VersionNumber::convertVersionNumberToInteger(TYPO3_version) >= 4003000) { $pagerender->addCssInlineBlock($hash, $temp_css, $this->conf['cssMinify']); } else { // addCssInlineBlock $GLOBALS['TSFE']->additionalCSS['css_' . $this->extKey . '_' . $hash] .= $temp_css; } } }
/** * @param string $jsfile * @param string $jsurl * @param string $jsdata * @param string $jsready * @param boolean $forceOnTop * @param string $compress * @param string $type * @param boolean $tofooter * @param boolean $renderChildrenToData * @return string */ public function render($jsfile = NULL, $jsurl = NULL, $jsdata = NULL, $jsready = NULL, $forceOnTop = NULL, $compress = NULL, $type = "text/javascript", $tofooter = null, $renderChildrenToData = false) { $buffer_data = NULL; $buffer_ready = NULL; if ($renderChildrenToData === true) { $buffer_data = $this->renderChildren(); } else { $buffer_ready = $this->renderChildren(); } // checks if t3jquery is loaded if (T3JQUERY === true) { $config = array(); if ($jsfile !== NULL) { $config['jsfile'] = $jsfile; } if ($jsurl !== NULL) { $config['jsurl'] = $jsurl; } if ($jsdata !== NULL) { $config['jsdata'] = $buffer_data . "\n" . $jsdata; } else { $config['jsdata'] = $buffer_data; } if ($jsready !== NULL) { $config['jsready'] = $buffer_ready . "\n" . $jsready; } else { $config['jsready'] = $buffer_ready; } if ($forceOnTop !== NULL) { $config['forceOnTop'] = $forceOnTop; } if ($compress !== NULL) { $config['compress'] = $compress; } if ($type !== NULL) { $config['type'] = $type; } if ($tofooter !== NULL) { $config['tofooter'] = $tofooter; } tx_t3jquery::addJS('', $config); } return ''; }