/**
  * Return all scripts to include for CDN
  * @param $params
  * @return array
  */
 function getCdnScript(&$params = array())
 {
     $confArr = tx_t3jquery::getConf();
     // The dev version does not exist...
     if (substr($confArr['jQueryTOOLSVersion'], -3) == 'dev') {
         t3lib_div::devLog('jQuery TOOLS Version \'' . $confArr['jQueryTOOLSVersion'] . '\' not in CDN', 't3jquery', 1);
         $confArr['jQueryTOOLSVersion'] = '1.2.5';
     }
     $temp_config = array();
     // CDN version for jQuery (t3jquery 2.0.0)
     if (preg_match("/x\$/", $confArr['jQueryVersion'])) {
         $temp_config = $this->jQueryTOOLSConfig = tx_t3jquery::getJqueryConfiguration();
         $confArr['jQueryVersion'] = $temp_config['version']['cdn'];
     }
     // CDN version for jQueryUI (t3jquery 2.0.0)
     if (preg_match("/x\$/", $confArr['jQueryUiVersion'])) {
         $temp_config = $this->jQueryTOOLSConfig = tx_t3jquery::getJqueryUiConfiguration();
         $confArr['jQueryUiVersion'] = $temp_config['version']['cdn'];
     }
     // CDN version for TOOLS (t3jquery 2.0.0)
     if (preg_match("/x\$/", $confArr['jQueryTOOLSVersion'])) {
         $temp_config = $this->jQueryTOOLSConfig = tx_t3jquery::getJqueryToolsConfiguration();
         $confArr['jQueryTOOLSVersion'] = $temp_config['version']['cdn'];
     }
     // CDN version for Bootstrap (t3jquery 2.0.0)
     if (preg_match("/x\$/", $confArr['jQueryBootstrapVersion'])) {
         $temp_config = $this->jQueryTOOLSConfig = tx_t3jquery::getJqueryBootstrapConfiguration();
         $confArr['jQueryBootstrapVersion'] = $temp_config['version']['cdn'];
     }
     switch ($confArr['locationCDN']) {
         case 'jquery':
             // in jQuery TOOLS jQuery is included
             if ($confArr['jQueryTOOLSVersion'] != '') {
                 $params['jsLibs']['jQueryTOOLS'] = array('file' => 'http://cdn.jquerytools.org/' . $confArr['jQueryTOOLSVersion'] . '/jquery.tools.min.js', 'type' => 'text/javascript', 'section' => self::getSection(), 'forceOnTop' => TRUE, 'disableCompression' => FALSE, 'excludeFromConcatenation' => TRUE);
             } else {
                 $params['jsLibs']['jQuery'] = array('file' => 'http://code.jquery.com/jquery-' . $confArr['jQueryVersion'] . '.min.js', 'type' => 'text/javascript', 'section' => self::getSection(), 'forceOnTop' => TRUE, 'disableCompression' => FALSE, 'excludeFromConcatenation' => TRUE);
             }
             if ($confArr['jQueryUiVersion'] != '') {
                 $jsFile = 'http://code.jquery.com/ui/' . $confArr['jQueryUiVersion'] . '/jquery-ui.min.js';
                 $params['jsFiles'][$jsFile] = array('file' => $jsFile, 'type' => 'text/javascript', 'section' => self::getSection(), 'forceOnTop' => TRUE, 'disableCompression' => FALSE, 'excludeFromConcatenation' => TRUE);
             }
             if ($confArr['jQueryBootstrapVersion'] != '') {
                 if (tx_t3jquery::getIntFromVersion($confArr['jQueryBootstrapVersion']) < 3000000) {
                     if ($confArr['jQueryBootstrapVersion'] == '2.2.0') {
                         t3lib_div::devLog('jQuery Bootstrap \'' . $confArr['jQueryBootstrapVersion'] . '\' not available', 't3jquery', 1);
                         $confArr['jQueryBootstrapVersion'] = '2.2.2';
                     }
                     $jsFile = '//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/' . $confArr['jQueryBootstrapVersion'] . '/js/bootstrap.min.js';
                 } else {
                     $jsFile = '//netdna.bootstrapcdn.com/bootstrap/' . $confArr['jQueryBootstrapVersion'] . '/js/bootstrap.min.js';
                 }
                 $params['jsFiles'][$jsFile] = array('file' => $jsFile, 'type' => 'text/javascript', 'section' => self::getSection(), 'forceOnTop' => TRUE, 'disableCompression' => FALSE, 'excludeFromConcatenation' => TRUE);
             }
             break;
         case 'google':
             // in jQuery TOOLS jQuery is included
             if ($confArr['jQueryTOOLSVersion'] != '') {
                 $params['jsLibs']['jQueryTOOLS'] = array('file' => 'http://cdn.jquerytools.org/' . $confArr['jQueryTOOLSVersion'] . '/jquery.tools.min.js', 'type' => 'text/javascript', 'section' => self::getSection(), 'forceOnTop' => TRUE, 'disableCompression' => FALSE, 'excludeFromConcatenation' => TRUE);
             } else {
                 if ($confArr['jQueryVersion'] == '2.0.0b1') {
                     t3lib_div::devLog('jQuery \'' . $confArr['jQueryVersion'] . '\' not in Google-CDN', 't3jquery', 1);
                     $confArr['jQueryVersion'] = '1.9.1';
                 }
                 $params['jsLibs']['jQuery'] = array('file' => '//ajax.googleapis.com/ajax/libs/jquery/' . $confArr['jQueryVersion'] . '/jquery.min.js', 'type' => 'text/javascript', 'section' => self::getSection(), 'forceOnTop' => TRUE, 'disableCompression' => FALSE, 'excludeFromConcatenation' => TRUE);
             }
             if ($confArr['jQueryUiVersion'] != '') {
                 $jsFile = '//ajax.googleapis.com/ajax/libs/jqueryui/' . $confArr['jQueryUiVersion'] . '/jquery-ui.min.js';
                 $params['jsFiles'][$jsFile] = array('file' => $jsFile, 'type' => 'text/javascript', 'section' => self::getSection(), 'forceOnTop' => TRUE, 'disableCompression' => FALSE, 'excludeFromConcatenation' => TRUE);
             }
             if ($confArr['jQueryBootstrapVersion'] != '') {
                 if (tx_t3jquery::getIntFromVersion($confArr['jQueryBootstrapVersion']) < 3000000) {
                     if ($confArr['jQueryBootstrapVersion'] == '2.2.0') {
                         t3lib_div::devLog('jQuery Bootstrap \'' . $confArr['jQueryBootstrapVersion'] . '\' not available', 't3jquery', 1);
                         $confArr['jQueryBootstrapVersion'] = '2.2.2';
                     }
                     $jsFile = '//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/' . $confArr['jQueryBootstrapVersion'] . '/js/bootstrap.min.js';
                 } else {
                     $jsFile = '//netdna.bootstrapcdn.com/bootstrap/' . $confArr['jQueryBootstrapVersion'] . '/js/bootstrap.min.js';
                 }
                 $params['jsFiles'][$jsFile] = array('file' => $jsFile, 'type' => 'text/javascript', 'section' => self::getSection(), 'forceOnTop' => TRUE, 'disableCompression' => FALSE, 'excludeFromConcatenation' => TRUE);
             }
             break;
         case 'msn':
             // in jQuery TOOLS jQuery is included
             if ($confArr['jQueryTOOLSVersion'] != '') {
                 $params['jsLibs']['jQueryTOOLS'] = array('file' => 'http://cdn.jquerytools.org/' . $confArr['jQueryTOOLSVersion'] . '/jquery.tools.min.js', 'type' => 'text/javascript', 'section' => self::getSection(), 'forceOnTop' => TRUE, 'disableCompression' => FALSE, 'excludeFromConcatenation' => TRUE);
             } else {
                 if ($confArr['jQueryVersion'] == '2.0.0b1') {
                     t3lib_div::devLog('jQuery \'' . $confArr['jQueryVersion'] . '\' not in MSN-CDN', 't3jquery', 1);
                     $confArr['jQueryVersion'] = '1.9.1';
                 }
                 if (tx_t3jquery::getIntFromVersion($confArr['jQueryVersion']) < 1003002) {
                     t3lib_div::devLog('jQuery \'' . $confArr['jQueryVersion'] . '\' not in MSN-CDN', 't3jquery', 1);
                     $confArr['jQueryVersion'] = '1.3.2';
                 }
                 // The MSN CDN does not support 1.x.0 version it's only available under 1.x
                 if (preg_match("/\\.0\$/", $confArr['jQueryVersion'])) {
                     $confArr['jQueryVersion'] = substr($confArr['jQueryVersion'], 0, -2);
                 }
                 $params['jsLibs']['jQuery'] = array('file' => '//ajax.aspnetcdn.com/ajax/jquery/jquery-' . $confArr['jQueryVersion'] . '.min.js', 'type' => 'text/javascript', 'section' => self::getSection(), 'forceOnTop' => TRUE, 'disableCompression' => FALSE, 'excludeFromConcatenation' => TRUE);
             }
             if ($confArr['jQueryUiVersion'] != '') {
                 if (tx_t3jquery::getIntFromVersion($confArr['jQueryUiVersion']) < 1008005) {
                     t3lib_div::devLog('jQuery UI \'' . $confArr['jQueryUiVersion'] . '\' not in MSN-CDN', 't3jquery', 1);
                     $confArr['jQueryUiVersion'] = '1.8.5';
                 }
                 if (tx_t3jquery::getIntFromVersion($confArr['jQueryUiVersion']) == 1008024) {
                     t3lib_div::devLog('jQuery UI \'' . $confArr['jQueryUiVersion'] . '\' not in MSN-CDN', 't3jquery', 1);
                     $confArr['jQueryUiVersion'] = '1.8.23';
                 }
                 $jsFile = '//ajax.aspnetcdn.com/ajax/jquery.ui/' . $confArr['jQueryUiVersion'] . '/jquery-ui.min.js';
                 $params['jsFiles'][$jsFile] = array('file' => $jsFile, 'type' => 'text/javascript', 'section' => self::getSection(), 'forceOnTop' => TRUE, 'disableCompression' => FALSE, 'excludeFromConcatenation' => TRUE);
             }
             if ($confArr['jQueryBootstrapVersion'] != '') {
                 if (tx_t3jquery::getIntFromVersion($confArr['jQueryBootstrapVersion']) < 3000000) {
                     if ($confArr['jQueryBootstrapVersion'] == '2.2.0') {
                         t3lib_div::devLog('jQuery Bootstrap \'' . $confArr['jQueryBootstrapVersion'] . '\' not available', 't3jquery', 1);
                         $confArr['jQueryBootstrapVersion'] = '2.2.2';
                     }
                     $jsFile = '//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/' . $confArr['jQueryBootstrapVersion'] . '/js/bootstrap.min.js';
                 } else {
                     $jsFile = '//netdna.bootstrapcdn.com/bootstrap/' . $confArr['jQueryBootstrapVersion'] . '/js/bootstrap.min.js';
                 }
                 $params['jsFiles'][$jsFile] = array('file' => $jsFile, 'type' => 'text/javascript', 'section' => self::getSection(), 'forceOnTop' => TRUE, 'disableCompression' => FALSE, 'excludeFromConcatenation' => TRUE);
             }
             break;
         default:
             t3lib_div::devLog('Unknown CDN-Provider: \'' . $confArr['locationCDN'] . '\'', 't3jquery', 3);
             break;
     }
 }
Esempio n. 2
0
	/**
	 * Initializes the Module
	 * @return	void
	 */
	function init()
	{
		// get extension configuration
		$this->confArray = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$this->extKey]);

		$this->configXML['groups'] = array();
		$this->configXML['groups_missing'] = array();
		// get the XML-Config from jQuery
		if ($this->confArray['jQueryVersion']) {
			$version = $this->confArray['jQueryVersion'];
			$array_name = 'groups';
		} else {
			$version = $this->jQueryVersionOrig;
			$array_name = 'groups_missing';
		}
		$this->jQueryConfig = tx_t3jquery::getJqueryConfiguration($version);
		if (count($this->jQueryConfig['groups']) > 0) {
			$this->configXML[$array_name] = $this->jQueryConfig['groups'];
		}
		// Get the XML-Config from jQuery UI
		if ($this->confArray['jQueryUiVersion']) {
			$version = $this->confArray['jQueryUiVersion'];
			$array_name = 'groups';
		} else {
			$version = $this->jQueryUiVersionOrig;
			$array_name = 'groups_missing';
		}
		$this->jQueryUiConfig = tx_t3jquery::getJqueryUiConfiguration($version);
		if (count($this->jQueryUiConfig['groups']) > 0) {
			foreach ($this->jQueryUiConfig['groups'] as $group) {
				$this->configXML[$array_name][] = $group;
			}
		}
		// Get the XML-Config from jQuery TOOLS
		if ($this->confArray['jQueryTOOLSVersion']) {
			$version = $this->confArray['jQueryTOOLSVersion'];
			$array_name = 'groups';
		} else {
			$version = $this->jQueryTOOLSVersionOrig;
			$array_name = 'groups_missing';
		}
		$this->jQueryTOOLSConfig = tx_t3jquery::getJqueryToolsConfiguration($version);
		if (count($this->jQueryTOOLSConfig['groups']) > 0) {
			foreach ($this->jQueryTOOLSConfig['groups'] as $group) {
				$this->configXML[$array_name][] = $group;
			}
		}
		// Get the XML-Config from jQuery Bootstrap
		if ($this->confArray['jQueryBootstrapVersion']) {
			$version = $this->confArray['jQueryBootstrapVersion'];
			$array_name = 'groups';
		} else {
			$version = $this->jQueryBootstrapVersionOrig;
			$array_name = 'groups_missing';
		}
		$this->jQueryBootstrapConfig = tx_t3jquery::getJqueryBootstrapConfiguration($version);
		if (count($this->jQueryBootstrapConfig['groups']) > 0) {
			foreach ($this->jQueryBootstrapConfig['groups'] as $group) {
				$this->configXML[$array_name][] = $group;
			}
		}
		// Define the language object
		$this->LANG = $GLOBALS['LANG'];
		// Define the used file directory
		$this->configDir = PATH_site . tx_t3jquery::getJqPath();
		if (! is_dir($this->configDir)) {
			$this->configDir = PATH_site . 'uploads/tx_t3jquery/';
		}
		$this->createFolder();
		$this->initConfig();
		parent::init();
	}