diff options
author | Matt Friedman <maf675@gmail.com> | 2011-09-25 15:12:56 -0700 |
---|---|---|
committer | Matt Friedman <maf675@gmail.com> | 2011-09-26 11:15:22 -0700 |
commit | 56c6476233646e7c735aa4e3b98c4a6b62df5c7d (patch) | |
tree | fb428fc655e39150c57f1a23f027443b3d6c2e87 /phpBB/includes/functions.php | |
parent | 5e768036f773e461283d0f65841d2ff0618ec7b7 (diff) | |
download | forums-56c6476233646e7c735aa4e3b98c4a6b62df5c7d.tar forums-56c6476233646e7c735aa4e3b98c4a6b62df5c7d.tar.gz forums-56c6476233646e7c735aa4e3b98c4a6b62df5c7d.tar.bz2 forums-56c6476233646e7c735aa4e3b98c4a6b62df5c7d.tar.xz forums-56c6476233646e7c735aa4e3b98c4a6b62df5c7d.zip |
[ticket/10390] Allow option for jQuery to be hosted by a remote CDN
Add an option to the ACP so admins can choose to host jQuery
from the local version shipped with phpBB, or via a popular CDN.
PHPBB3-10390
Diffstat (limited to 'phpBB/includes/functions.php')
-rw-r--r-- | phpBB/includes/functions.php | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 5ccb9edd07..af07938879 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4569,6 +4569,8 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'T_STYLESHEET_LINK' => "{$web_path}styles/" . $user->theme['theme_path'] . '/theme/stylesheet.css', 'T_STYLESHEET_LANG_LINK' => "{$web_path}styles/" . $user->theme['theme_path'] . '/theme/' . $user->lang_name . '/stylesheet.css', 'T_STYLESHEET_NAME' => $user->theme['theme_name'], + 'T_JQUERY_LINK' => (!empty($config['load_jquery_host']) && $config['load_jquery_host'] != 'localhost') ? remote_jquery_url($config['load_jquery_host']) : "{$web_path}assets/javascript/jquery.js", + 'S_JQUERY_FALLBACK' => (!empty($config['load_jquery_host']) && $config['load_jquery_host'] != 'localhost') ? true : false, 'T_THEME_NAME' => $user->theme['theme_path'], 'T_THEME_LANG_NAME' => $user->data['user_lang'], @@ -4767,3 +4769,30 @@ function phpbb_pcre_utf8_support() } return $utf8_pcre_properties; } + +/** +* Build jQuery URL for remote CDNs +* Reference: http://docs.jquery.com/Downloading_jQuery#CDN_Hosted_jQuery +* +* @return string Returns url to a jQuery library +*/ +function remote_jquery_url($host) +{ + switch($host) + { + case 'google': + // Google uses a 1.5.0, 1.5.1 format (it is always a three numbered version) + return '//ajax.googleapis.com/ajax/libs/jquery/' . ((strlen(JQUERY_VERSION) == 3) ? JQUERY_VERSION . '.0' : JQUERY_VERSION) . '/jquery.min.js'; + break; + + case 'microsoft': + // Microsoft uses a 1.5, 1.5.1 format + return 'http://ajax.aspnetcdn.com/ajax/jQuery/jquery-' . JQUERY_VERSION . '.min.js'; + break; + + case 'jquery': + // jQuery uses a 1.5, 1.5.1 format + return 'http://code.jquery.com/jquery-' . JQUERY_VERSION . '.min.js'; + break; + } +} |