Пример #1
0
 /**
  * Load the language strings into JavaScript
  */
 protected function loadJavaScriptLanguageStrings()
 {
     if (!empty($this->inlineLanguageLabelFiles)) {
         foreach ($this->inlineLanguageLabelFiles as $languageLabelFile) {
             $this->includeLanguageFileForInline($languageLabelFile['fileRef'], $languageLabelFile['selectionPrefix'], $languageLabelFile['stripFromSelectionName'], $languageLabelFile['errorMode']);
         }
     }
     $this->inlineLanguageLabelFiles = [];
     // Convert settings back to UTF-8 since json_encode() only works with UTF-8:
     if (TYPO3_MODE === 'FE' && $this->getCharSet() !== 'utf-8') {
         if ($this->inlineSettings) {
             $this->csConvObj->convArray($this->inlineSettings, $this->getCharSet(), 'utf-8');
         }
     }
 }
 /**
  * Converts the $_POST array from metaCharset (page HTML charset from input form) to renderCharset (internal processing) IF the two charsets are different.
  *
  * @return void
  * @todo Define visibility
  */
 public function convPOSTCharset()
 {
     if ($this->renderCharset != $this->metaCharset && is_array($_POST) && count($_POST)) {
         $this->csConvObj->convArray($_POST, $this->metaCharset, $this->renderCharset);
         $GLOBALS['HTTP_POST_VARS'] = $_POST;
     }
 }
Пример #3
0
    /**
     * Helper function for render the main JavaScript libraries,
     * currently: RequireJS, jQuery, PrototypeJS, Scriptaculous, SVG, ExtJs
     *
     * @return string Content with JavaScript libraries
     */
    protected function renderMainJavaScriptLibraries()
    {
        $out = '';
        // Include RequireJS
        if ($this->addRequireJs) {
            // load the paths of the requireJS configuration
            $out .= GeneralUtility::wrapJS('var require = ' . json_encode($this->requireJsConfig)) . LF;
            // directly after that, include the require.js file
            $out .= '<script src="' . $this->processJsFile($this->backPath . $this->requireJsPath . 'require.js') . '" type="text/javascript"></script>' . LF;
        }
        if ($this->addSvg) {
            $out .= '<script src="' . $this->processJsFile($this->backPath . $this->svgPath . 'svg.js') . '" data-path="' . $this->backPath . $this->svgPath . '"' . ($this->enableSvgDebug ? ' data-debug="true"' : '') . '></script>' . LF;
        }
        // Include jQuery Core for each namespace, depending on the version and source
        if (!empty($this->jQueryVersions)) {
            foreach ($this->jQueryVersions as $namespace => $jQueryVersion) {
                $out .= $this->renderJqueryScriptTag($jQueryVersion['version'], $jQueryVersion['source'], $namespace);
            }
        }
        if ($this->addPrototype) {
            $out .= '<script src="' . $this->processJsFile($this->backPath . $this->prototypePath . 'prototype.js') . '" type="text/javascript"></script>' . LF;
            unset($this->jsFiles[$this->backPath . $this->prototypePath . 'prototype.js']);
        }
        if ($this->addScriptaculous) {
            $mods = array();
            foreach ($this->addScriptaculousModules as $key => $value) {
                if ($this->addScriptaculousModules[$key]) {
                    $mods[] = $key;
                }
            }
            // Resolve dependencies
            if (in_array('dragdrop', $mods) || in_array('controls', $mods)) {
                $mods = array_merge(array('effects'), $mods);
            }
            if (count($mods)) {
                foreach ($mods as $module) {
                    $out .= '<script src="' . $this->processJsFile($this->backPath . $this->scriptaculousPath . $module . '.js') . '" type="text/javascript"></script>' . LF;
                    unset($this->jsFiles[$this->backPath . $this->scriptaculousPath . $module . '.js']);
                }
            }
            $out .= '<script src="' . $this->processJsFile($this->backPath . $this->scriptaculousPath . 'scriptaculous.js') . '" type="text/javascript"></script>' . LF;
            unset($this->jsFiles[$this->backPath . $this->scriptaculousPath . 'scriptaculous.js']);
        }
        // Include extCore, but only if ExtJS is not included
        if ($this->addExtCore && !$this->addExtJS) {
            $out .= '<script src="' . $this->processJsFile($this->backPath . $this->extCorePath . 'ext-core' . ($this->enableExtCoreDebug ? '-debug' : '') . '.js') . '" type="text/javascript"></script>' . LF;
            unset($this->jsFiles[$this->backPath . $this->extCorePath . 'ext-core' . ($this->enableExtCoreDebug ? '-debug' : '') . '.js']);
        }
        // Include extJS
        if ($this->addExtJS) {
            // Use the base adapter all the time
            $out .= '<script src="' . $this->processJsFile($this->backPath . $this->extJsPath . 'adapter/' . ($this->enableExtJsDebug ? str_replace('.js', '-debug.js', $this->extJSadapter) : $this->extJSadapter)) . '" type="text/javascript"></script>' . LF;
            $out .= '<script src="' . $this->processJsFile($this->backPath . $this->extJsPath . 'ext-all' . ($this->enableExtJsDebug ? '-debug' : '') . '.js') . '" type="text/javascript"></script>' . LF;
            // Add extJS localization
            // Load standard ISO mapping and modify for use with ExtJS
            $localeMap = $this->locales->getIsoMapping();
            $localeMap[''] = 'en';
            $localeMap['default'] = 'en';
            // Greek
            $localeMap['gr'] = 'el_GR';
            // Norwegian Bokmaal
            $localeMap['no'] = 'no_BO';
            // Swedish
            $localeMap['se'] = 'se_SV';
            $extJsLang = isset($localeMap[$this->lang]) ? $localeMap[$this->lang] : $this->lang;
            // TODO autoconvert file from UTF8 to current BE charset if necessary!!!!
            $extJsLocaleFile = $this->extJsPath . 'locale/ext-lang-' . $extJsLang . '.js';
            if (file_exists(PATH_typo3 . $extJsLocaleFile)) {
                $out .= '<script src="' . $this->processJsFile($this->backPath . $extJsLocaleFile) . '" type="text/javascript" charset="utf-8"></script>' . LF;
            }
            // Remove extjs from JScodeLibArray
            unset($this->jsFiles[$this->backPath . $this->extJsPath . 'ext-all.js'], $this->jsFiles[$this->backPath . $this->extJsPath . 'ext-all-debug.js']);
        }
        if (count($this->inlineLanguageLabelFiles)) {
            foreach ($this->inlineLanguageLabelFiles as $languageLabelFile) {
                $this->includeLanguageFileForInline($languageLabelFile['fileRef'], $languageLabelFile['selectionPrefix'], $languageLabelFile['stripFromSelectionName'], $languageLabelFile['$errorMode']);
            }
        }
        $this->inlineLanguageLabelFiles = array();
        // Convert labels/settings back to UTF-8 since json_encode() only works with UTF-8:
        if ($this->getCharSet() !== 'utf-8') {
            if ($this->inlineLanguageLabels) {
                $this->csConvObj->convArray($this->inlineLanguageLabels, $this->getCharSet(), 'utf-8');
            }
            if ($this->inlineSettings) {
                $this->csConvObj->convArray($this->inlineSettings, $this->getCharSet(), 'utf-8');
            }
        }
        if (TYPO3_MODE === 'BE') {
            $this->addAjaxUrlsToInlineSettings();
        }
        $inlineSettings = $this->inlineLanguageLabels ? 'TYPO3.lang = ' . json_encode($this->inlineLanguageLabels) . ';' : '';
        $inlineSettings .= $this->inlineSettings ? 'TYPO3.settings = ' . json_encode($this->inlineSettings) . ';' : '';
        if ($this->addExtCore || $this->addExtJS) {
            // Set clear.gif, move it on top, add handler code
            $code = '';
            if (count($this->extOnReadyCode)) {
                foreach ($this->extOnReadyCode as $block) {
                    $code .= $block;
                }
            }
            $out .= $this->inlineJavascriptWrap[0] . '
				Ext.ns("TYPO3");
				Ext.BLANK_IMAGE_URL = "' . htmlspecialchars(GeneralUtility::locationHeaderUrl($this->backPath . 'gfx/clear.gif')) . '";' . LF . $inlineSettings . 'Ext.onReady(function() {' . ($this->enableExtJSQuickTips ? 'Ext.QuickTips.init();' . LF : '') . $code . ' });' . $this->inlineJavascriptWrap[1];
            $this->extOnReadyCode = array();
            // Include TYPO3.l10n object
            if (TYPO3_MODE === 'BE') {
                $out .= '<script src="' . $this->processJsFile($this->backPath . 'sysext/lang/Resources/Public/JavaScript/Typo3Lang.js') . '" type="text/javascript" charset="utf-8"></script>' . LF;
            }
            if ($this->extJScss) {
                if (isset($GLOBALS['TBE_STYLES']['extJS']['all'])) {
                    $this->addCssLibrary($this->backPath . $GLOBALS['TBE_STYLES']['extJS']['all'], 'stylesheet', 'all', '', TRUE);
                } else {
                    $this->addCssLibrary($this->backPath . $this->extJsPath . 'resources/css/ext-all-notheme.css', 'stylesheet', 'all', '', TRUE);
                }
            }
            if ($this->extJStheme) {
                if (isset($GLOBALS['TBE_STYLES']['extJS']['theme'])) {
                    $this->addCssLibrary($this->backPath . $GLOBALS['TBE_STYLES']['extJS']['theme'], 'stylesheet', 'all', '', TRUE);
                } else {
                    $this->addCssLibrary($this->backPath . $this->extJsPath . 'resources/css/xtheme-blue.css', 'stylesheet', 'all', '', TRUE);
                }
            }
        } else {
            // no extJS loaded, but still inline settings
            if ($inlineSettings !== '') {
                // make sure the global TYPO3 is available
                $inlineSettings = 'var TYPO3 = TYPO3 || {};' . CRLF . $inlineSettings;
                $out .= $this->inlineJavascriptWrap[0] . $inlineSettings . $this->inlineJavascriptWrap[1];
            }
        }
        return $out;
    }