예제 #1
0
파일: index.php 프로젝트: clews/t3jquery
 /**
  * Initializes the Module
  */
 public 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 = \T3Ext\T3jquery\Utility\T3jqueryUtility::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 = \T3Ext\T3jquery\Utility\T3jqueryUtility::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 = \T3Ext\T3jquery\Utility\T3jqueryUtility::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 = \T3Ext\T3jquery\Utility\T3jqueryUtility::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 . \T3Ext\T3jquery\Utility\T3jqueryUtility::getJqPath();
     if (!is_dir($this->configDir)) {
         $this->configDir = PATH_site . 'uploads/tx_t3jquery/';
     }
     $this->createFolder();
     $this->initConfig();
     parent::init();
 }
예제 #2
0
 /**
  * Return all scripts to include for CDN
  * @param $params
  * @return array
  */
 public static function getCdnScript(&$params = array())
 {
     $confArr = T3jqueryUtility::getConf();
     // The dev version does not exist...
     if (substr($confArr['jQueryTOOLSVersion'], -3) == 'dev') {
         GeneralUtility::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 = self::$jQueryTOOLSConfig = T3jqueryUtility::getJqueryConfiguration();
         $confArr['jQueryVersion'] = $temp_config['version']['cdn'];
     }
     // CDN version for jQueryUI (t3jquery 2.0.0)
     if (preg_match("/x\$/", $confArr['jQueryUiVersion'])) {
         $temp_config = self::$jQueryTOOLSConfig = T3jqueryUtility::getJqueryUiConfiguration();
         $confArr['jQueryUiVersion'] = $temp_config['version']['cdn'];
     }
     // CDN version for TOOLS (t3jquery 2.0.0)
     if (preg_match("/x\$/", $confArr['jQueryTOOLSVersion'])) {
         $temp_config = self::$jQueryTOOLSConfig = T3jqueryUtility::getJqueryToolsConfiguration();
         $confArr['jQueryTOOLSVersion'] = $temp_config['version']['cdn'];
     }
     // CDN version for Bootstrap (t3jquery 2.0.0)
     if (preg_match("/x\$/", $confArr['jQueryBootstrapVersion'])) {
         $temp_config = self::$jQueryTOOLSConfig = T3jqueryUtility::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 (T3jqueryUtility::getIntFromVersion($confArr['jQueryBootstrapVersion']) < 3000000) {
                     if ($confArr['jQueryBootstrapVersion'] == '2.2.0') {
                         GeneralUtility::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') {
                     GeneralUtility::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 (T3jqueryUtility::getIntFromVersion($confArr['jQueryBootstrapVersion']) < 3000000) {
                     if ($confArr['jQueryBootstrapVersion'] == '2.2.0') {
                         GeneralUtility::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') {
                     GeneralUtility::devLog('jQuery \'' . $confArr['jQueryVersion'] . '\' not in MSN-CDN', 't3jquery', 1);
                     $confArr['jQueryVersion'] = '1.9.1';
                 }
                 if (T3jqueryUtility::getIntFromVersion($confArr['jQueryVersion']) < 1003002) {
                     GeneralUtility::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 (T3jqueryUtility::getIntFromVersion($confArr['jQueryUiVersion']) < 1008005) {
                     GeneralUtility::devLog('jQuery UI \'' . $confArr['jQueryUiVersion'] . '\' not in MSN-CDN', 't3jquery', 1);
                     $confArr['jQueryUiVersion'] = '1.8.5';
                 }
                 if (T3jqueryUtility::getIntFromVersion($confArr['jQueryUiVersion']) == 1008024) {
                     GeneralUtility::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 (T3jqueryUtility::getIntFromVersion($confArr['jQueryBootstrapVersion']) < 3000000) {
                     if ($confArr['jQueryBootstrapVersion'] == '2.2.0') {
                         GeneralUtility::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:
             GeneralUtility::devLog('Unknown CDN-Provider: \'' . $confArr['locationCDN'] . '\'', 't3jquery', 3);
             break;
     }
 }