/**
  * Initializes the controller before invoking an action method.
  *
  * @return void
  */
 protected function initializeAction()
 {
     $this->pageRenderer->addInlineLanguageLabelFile('EXT:scheduler_timeline/Resources/Private/Language/locallang.xml');
     $this->pageRenderer->addCssFile(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('scheduler_timeline') . 'Resources/Public/StyleSheet/timeline.css');
     $this->pageRenderer->addCssFile(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('scheduler_timeline') . 'Resources/Public/StyleSheet/bars.css');
     $this->pageRenderer->addJsLibrary('jquery', \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('scheduler_timeline') . 'Resources/Public/JavaScript/jquery-1.6.2.min.js');
     $this->pageRenderer->addJsLibrary('jquery_tooltip', \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('scheduler_timeline') . 'Resources/Public/JavaScript/tooltip.js');
     $this->pageRenderer->addJsLibrary('jquery_tooltip_dynamic', \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('scheduler_timeline') . 'Resources/Public/JavaScript/tooltip.dynamic.js');
     $this->addJsFileToPageRenderer(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('scheduler_timeline') . 'Resources/Public/JavaScript/common.js');
 }
 /**
  * test add JS library file
  */
 public function testAddJsLibrary()
 {
     $expectedRegExp = '#<script src="fileadmin/test\\.(js|\\d+\\.js|js\\?\\d+)" type="text/javascript"></script>#';
     $this->fixture->addJsLibrary('test', 'fileadmin/test.js');
     $out = $this->fixture->render();
     $this->assertRegExp($expectedRegExp, $out);
 }
Exemple #3
0
 /**
  * Insert javascript-tags for jQuery
  *
  * @param array $params
  * @param \TYPO3\CMS\Core\Page\PageRenderer $pObj
  * @return void
  */
 public function renderPreProcess($params, $pObj)
 {
     // Get plugin-configuration
     $conf = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_libjquery.']['settings.'];
     // Generate script-tag for jquery if CDN is set
     if (!empty($conf['cdn']) && array_key_exists($conf['cdn'], $this->jQueryCdnUrls)) {
         // Set version-number for CDN
         if (!(int) $conf['version'] || $conf['version'] === 'latest') {
             $versionCdn = end($this->availableLocalJqueryVersions);
         } else {
             $versionCdn = VersionNumberUtility::convertVersionNumberToInteger($conf['version']);
         }
         // Set correct version-number for local version
         if (!in_array($versionCdn, $this->availableLocalJqueryVersions)) {
             $versionLocal = $this->getNearestVersion($versionCdn);
         } else {
             $versionLocal = $versionCdn;
         }
         $fallbackTag = '';
         // Choose minified version if debug is disabled
         $minPart = (int) $conf['debug'] ? '' : '.min';
         // Deliver gzipped-version if compression is activated and client supports gzip (compression done with "gzip --best -k -S .gzip")
         $gzipPart = (int) $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['compressionLevel'] ? '.gzip' : '';
         // Set path and placeholders for local file
         $this->jQueryCdnUrls['local'] = $conf['localPath'] . 'jquery-%1$s%2$s.js';
         // Generate tags for local or CDN (and fallback)
         if ($conf['cdn'] === 'local') {
             // Get local version and replace placeholders
             $file = sprintf($this->jQueryCdnUrls['local'], VersionNumberUtility::convertIntegerToVersionNumber($versionLocal), $minPart) . $gzipPart;
             $file = str_replace(PATH_site, '', GeneralUtility::getFileAbsFileName($file));
         } else {
             // Get CDN and replace placeholders
             $file = sprintf($this->jQueryCdnUrls[$conf['cdn']], VersionNumberUtility::convertIntegerToVersionNumber($versionCdn), $minPart);
             // Generate fallback if required
             if ((int) $conf['localFallback']) {
                 // Get local fallback version and replace placeholders
                 $fileFallback = sprintf($this->jQueryCdnUrls['local'], VersionNumberUtility::convertIntegerToVersionNumber($versionLocal), $minPart) . $gzipPart;
                 // Get absolute path to the fallback-file
                 $fileFallback = str_replace(PATH_site, '', GeneralUtility::getFileAbsFileName($fileFallback));
                 // Wrap it in some javascript code which will enable the fallback
                 $fallbackTag = '<script>window.jQuery || document.write(\'<script src="' . htmlspecialchars($fileFallback) . '" type="text/javascript"><\\/script>\')</script>' . LF;
             }
         }
         $pObj->addJsLibrary('lib_jquery', $file, 'text/javascript', FALSE, TRUE, '|' . LF . $fallbackTag . '', TRUE);
     }
 }