Пример #1
0
 protected function registerjQuery()
 {
     if (!self::$jQueryUrl) {
         // create the path to jQuery depending on the version
         $customjquery_path = vB::getDatastore()->getOption('customjquery_path');
         $remotejquery = vB::getDatastore()->getOption('remotejquery');
         $session = vB::getCurrentSession();
         if ($session) {
             $protocol = vB::getRequest()->getVbUrlScheme();
         } else {
             if (!empty($_SERVER['HTTPS'])) {
                 $protocol = 'https';
             } else {
                 $protocol = 'http';
             }
         }
         if ($customjquery_path) {
             $path = str_replace('{version}', JQUERY_VERSION, $customjquery_path);
             if (!preg_match('#^https?://#si', $customjquery_path)) {
                 $path = $protocol . '://' . $path;
             }
             self::$jQueryUrlLogin = self::$jQueryUrl = $path;
         } else {
             if ($remotejquery == 1) {
                 // Google CDN
                 self::$jQueryUrlLogin = self::$jQueryUrl = $protocol . '://ajax.googleapis.com/ajax/libs/jquery/' . JQUERY_VERSION . '/jquery.min.js';
             } else {
                 if ($remotejquery == 2) {
                     // jQuery CDN
                     self::$jQueryUrlLogin = self::$jQueryUrl = $protocol . '://code.jquery.com/jquery-' . JQUERY_VERSION . '.min.js';
                 } else {
                     if ($remotejquery == 3) {
                         // Microsoft CDN
                         self::$jQueryUrlLogin = self::$jQueryUrl = $protocol . '://ajax.aspnetcdn.com/ajax/jquery/jquery-' . JQUERY_VERSION . '.min.js';
                     } else {
                         self::$jQueryUrl = vB5_Template_Options::instance()->get('options.frontendurl') . '/js/jquery/jquery-' . JQUERY_VERSION . '.min.js';
                         self::$jQueryUrlLogin = vB5_Template_Options::instance()->get('options.frontendurl_login') . '/js/jquery/jquery-' . JQUERY_VERSION . '.min.js';
                     }
                 }
             }
         }
     }
     $this->register('jqueryurl', self::$jQueryUrl);
     $this->register('jqueryurl_login', self::$jQueryUrlLogin);
     $this->register('jqueryversion', JQUERY_VERSION);
 }