From 56c6476233646e7c735aa4e3b98c4a6b62df5c7d Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sun, 25 Sep 2011 15:12:56 -0700 Subject: [PATCH 01/10] [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 --- phpBB/adm/style/install_footer.html | 3 +- phpBB/adm/style/overall_footer.html | 3 +- phpBB/adm/style/simple_footer.html | 3 +- phpBB/includes/acp/acp_board.php | 11 +++++++ phpBB/includes/constants.php | 1 + phpBB/includes/functions.php | 29 +++++++++++++++++++ phpBB/includes/functions_acp.php | 2 ++ phpBB/install/database_update.php | 1 + phpBB/install/schemas/schema_data.sql | 1 + phpBB/language/en/acp/board.php | 10 +++++++ .../prosilver/template/overall_footer.html | 3 +- .../prosilver/template/simple_footer.html | 3 +- .../subsilver2/template/overall_footer.html | 3 +- .../subsilver2/template/simple_footer.html | 3 +- 14 files changed, 69 insertions(+), 7 deletions(-) diff --git a/phpBB/adm/style/install_footer.html b/phpBB/adm/style/install_footer.html index 1b3134b5e1..a3b2294025 100644 --- a/phpBB/adm/style/install_footer.html +++ b/phpBB/adm/style/install_footer.html @@ -12,7 +12,8 @@ - + + diff --git a/phpBB/adm/style/overall_footer.html b/phpBB/adm/style/overall_footer.html index dc03d2cfb5..f05e9c56c5 100644 --- a/phpBB/adm/style/overall_footer.html +++ b/phpBB/adm/style/overall_footer.html @@ -20,7 +20,8 @@ - + + diff --git a/phpBB/adm/style/simple_footer.html b/phpBB/adm/style/simple_footer.html index 272fd5e3fb..0d697aec1d 100644 --- a/phpBB/adm/style/simple_footer.html +++ b/phpBB/adm/style/simple_footer.html @@ -16,7 +16,8 @@ - + + diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index f27a133eb5..45b6f219ac 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -99,6 +99,7 @@ class acp_board 'load_cpf_pm' => array('lang' => 'LOAD_CPF_PM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 'load_cpf_viewprofile' => array('lang' => 'LOAD_CPF_VIEWPROFILE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 'load_cpf_viewtopic' => array('lang' => 'LOAD_CPF_VIEWTOPIC', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), + 'load_jquery_host' => array('lang' => 'JQUERY_HOST', 'validate' => 'string', 'type' => 'select', 'method' => 'jquery_host_select', 'explain' => true), 'legend3' => 'ACP_SUBMIT_CHANGES', ) @@ -997,4 +998,14 @@ class acp_board $cache->destroy('sql', FORUMS_TABLE); } + function jquery_host_select($value, $key = '') + { + global $user; + + return ' + + + '; + } + } diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php index 8ef1a4655d..c3af3d29e1 100644 --- a/phpBB/includes/constants.php +++ b/phpBB/includes/constants.php @@ -210,6 +210,7 @@ define('CAPTCHA_MAX_CHARS', 7); // Additional constants define('VOTE_CONVERTED', 127); +define('JQUERY_VERSION', '1.6.2'); // Important follow jQuery versioning, ie: 1.6, 1.6.1, 1.6.2 // Table names define('ACL_GROUPS_TABLE', $table_prefix . 'acl_groups'); 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; + } +} diff --git a/phpBB/includes/functions_acp.php b/phpBB/includes/functions_acp.php index c3806dc786..4f9fa0db5e 100644 --- a/phpBB/includes/functions_acp.php +++ b/phpBB/includes/functions_acp.php @@ -126,6 +126,8 @@ function adm_page_footer($copyright_html = true) 'DEBUG_OUTPUT' => (defined('DEBUG')) ? $debug_output : '', 'TRANSLATION_INFO' => (!empty($user->lang['TRANSLATION_INFO'])) ? $user->lang['TRANSLATION_INFO'] : '', 'S_COPYRIGHT_HTML' => $copyright_html, + 'T_JQUERY_LINK' => (!empty($config['load_jquery_host']) && $config['load_jquery_host'] != 'localhost') ? remote_jquery_url($config['load_jquery_host']) : "{$phpbb_root_path}assets/javascript/jquery.js", + 'S_JQUERY_FALLBACK' => (!empty($config['load_jquery_host']) && $config['load_jquery_host'] != 'localhost') ? true : false, 'VERSION' => $config['version']) ); diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 18741191d8..1a47e2a656 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2090,6 +2090,7 @@ function change_database_data(&$no_updates, $version) // Changes from 3.1.0-dev to 3.1.0-A1 case '3.1.0-dev': + set_config('load_jquery_host', 'localhost'); set_config('use_system_cron', 0); $sql = 'UPDATE ' . GROUPS_TABLE . ' diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index 5506922e17..865189f345 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -165,6 +165,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_cpf_viewprofi INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_cpf_viewtopic', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_db_lastread', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_db_track', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_jquery_host', 'localhost'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_jumpbox', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_moderators', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_online', '1'); diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index abf346137d..4da069f68f 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -549,3 +549,13 @@ $lang = array_merge($lang, array( 'JAB_USERNAME' => 'Jabber username or JID', 'JAB_USERNAME_EXPLAIN' => 'Specify a registered username or a valid JID. The username will not be checked for validity. If you only specify a username, then your JID will be the username and the server you specified above. Else, specify a valid JID, for example user@jabber.org.', )); + +// jQuery settings +$lang = array_merge($lang, array( + 'JQUERY_HOST' => 'jQuery server', + 'JQUERY_HOST_EXPLAIN' => 'Load jQuery from your local server, or choose a remote copy hosted on a CDN (Content Delivery Network). If the CDN fails, phpBB will fall back to the local copy.', + 'JQUERY_HOST_LOCAL' => 'Localhost', + 'JQUERY_HOST_GOOGLE' => 'Google Ajax API CDN', + 'JQUERY_HOST_JQUERY' => 'jQuery CDN', + 'JQUERY_HOST_MS' => 'Microsoft CDN', +)); diff --git a/phpBB/styles/prosilver/template/overall_footer.html b/phpBB/styles/prosilver/template/overall_footer.html index 275e018f43..4456d6b37d 100644 --- a/phpBB/styles/prosilver/template/overall_footer.html +++ b/phpBB/styles/prosilver/template/overall_footer.html @@ -33,7 +33,8 @@ {RUN_CRON_TASK} - + + diff --git a/phpBB/styles/prosilver/template/simple_footer.html b/phpBB/styles/prosilver/template/simple_footer.html index 5899da0b7a..3458d02495 100644 --- a/phpBB/styles/prosilver/template/simple_footer.html +++ b/phpBB/styles/prosilver/template/simple_footer.html @@ -6,7 +6,8 @@ - + + diff --git a/phpBB/styles/subsilver2/template/overall_footer.html b/phpBB/styles/subsilver2/template/overall_footer.html index 3cdd071211..9b0b95372e 100644 --- a/phpBB/styles/subsilver2/template/overall_footer.html +++ b/phpBB/styles/subsilver2/template/overall_footer.html @@ -8,7 +8,8 @@
[ {DEBUG_OUTPUT} ] - + + diff --git a/phpBB/styles/subsilver2/template/simple_footer.html b/phpBB/styles/subsilver2/template/simple_footer.html index f03d1094f2..b51be3ac4c 100644 --- a/phpBB/styles/subsilver2/template/simple_footer.html +++ b/phpBB/styles/subsilver2/template/simple_footer.html @@ -5,7 +5,8 @@ Powered by phpBB® Forum Software © phpBB Group - + + From 39840ef36d4b074478de080caddd3e880bdba663 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sun, 25 Sep 2011 18:15:42 -0700 Subject: [PATCH 02/10] [ticket/10390] Move jQuery version definition Move jQuery version definition to its own block PHPBB3-10390 --- phpBB/includes/constants.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php index c3af3d29e1..06cbc7120c 100644 --- a/phpBB/includes/constants.php +++ b/phpBB/includes/constants.php @@ -30,6 +30,9 @@ define('PHPBB_VERSION', '3.1.0-dev'); // QA-related // define('PHPBB_QA', 1); +// jQuery Version +define('JQUERY_VERSION', '1.6.2'); // Important follow jQuery versioning, ie: 1.6, 1.6.1, 1.6.2 + // User related define('ANONYMOUS', 1); @@ -210,7 +213,6 @@ define('CAPTCHA_MAX_CHARS', 7); // Additional constants define('VOTE_CONVERTED', 127); -define('JQUERY_VERSION', '1.6.2'); // Important follow jQuery versioning, ie: 1.6, 1.6.1, 1.6.2 // Table names define('ACL_GROUPS_TABLE', $table_prefix . 'acl_groups'); From abb0f3f96d2fecfe2af2bde539a2b9d3a577e421 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sun, 25 Sep 2011 18:16:25 -0700 Subject: [PATCH 03/10] [ticket/10390] Improve the jQuery CDN url generation function Per p's comments, return the remote url from a variable instead of using multiple returns. Also put the logic for creating Google's version on its own line, and count the version number's dots instead of length so it will be less likely to break if jQuery goes to version 1.10. PHPBB3-10390 --- phpBB/includes/functions.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index af07938879..83cadf426d 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4781,18 +4781,21 @@ 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'; + // Google uses a 1.5.0, 1.5.1 format (it adds a .0 to new 1.X releases) + $version = (substr_count(JQUERY_VERSION, '.') == 1) ? JQUERY_VERSION . '.0' : JQUERY_VERSION; + // HTTP protocol intentionally omitted - its the best way to reference third party content that is available via both HTTP and HTTPS + $url = '//ajax.googleapis.com/ajax/libs/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'; + $url = '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'; + $url = 'http://code.jquery.com/jquery-' . JQUERY_VERSION . '.min.js'; break; } + return $url; } From d4fe81f8f0458b46b1bfe086c5a34af38e5af618 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sun, 25 Sep 2011 18:16:46 -0700 Subject: [PATCH 04/10] [ticket/10390] Fix a type-o - captialize AJAX AJAX should be capitalized where it appears in the ACP as the option: "Google AJAX API CDN" PHPBB3-10390 --- phpBB/language/en/acp/board.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index 4da069f68f..1bab87b37f 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -555,7 +555,7 @@ $lang = array_merge($lang, array( 'JQUERY_HOST' => 'jQuery server', 'JQUERY_HOST_EXPLAIN' => 'Load jQuery from your local server, or choose a remote copy hosted on a CDN (Content Delivery Network). If the CDN fails, phpBB will fall back to the local copy.', 'JQUERY_HOST_LOCAL' => 'Localhost', - 'JQUERY_HOST_GOOGLE' => 'Google Ajax API CDN', + 'JQUERY_HOST_GOOGLE' => 'Google AJAX API CDN', 'JQUERY_HOST_JQUERY' => 'jQuery CDN', 'JQUERY_HOST_MS' => 'Microsoft CDN', )); From 81e8faecbcc4f8c22a1dafdefe848ac548a6c77a Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sun, 25 Sep 2011 19:09:29 -0700 Subject: [PATCH 05/10] [ticket/10390] Reword the language for jQuery host/server options Reword some of the language used for the description and pull-down options to try and make it more clear to users that they have the option to use jQuery from their own server with the copy included with phpBB, or from one of the remote CDN servers. PHPBB3-10390 --- phpBB/language/en/acp/board.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index 1bab87b37f..7a028b4064 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -552,10 +552,10 @@ $lang = array_merge($lang, array( // jQuery settings $lang = array_merge($lang, array( - 'JQUERY_HOST' => 'jQuery server', - 'JQUERY_HOST_EXPLAIN' => 'Load jQuery from your local server, or choose a remote copy hosted on a CDN (Content Delivery Network). If the CDN fails, phpBB will fall back to the local copy.', - 'JQUERY_HOST_LOCAL' => 'Localhost', - 'JQUERY_HOST_GOOGLE' => 'Google AJAX API CDN', - 'JQUERY_HOST_JQUERY' => 'jQuery CDN', - 'JQUERY_HOST_MS' => 'Microsoft CDN', + 'JQUERY_HOST' => 'Load jQuery from your server or a hosted CDN', + 'JQUERY_HOST_EXPLAIN' => 'Load jQuery from the copy included with phpBB on your local server, or choose a remote copy hosted on a CDN (Content Delivery Network). If the CDN fails, phpBB will fall back to the copy included with phpBB.', + 'JQUERY_HOST_LOCAL' => 'Included with phpBB on my server', + 'JQUERY_HOST_GOOGLE' => 'Hosted CDN: Google AJAX API', + 'JQUERY_HOST_JQUERY' => 'Hosted CDN: jQuery', + 'JQUERY_HOST_MS' => 'Hosted CDN: Microsoft', )); From c6a2d81bd359711aeb9dc36478977e779d3bdfe9 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Mon, 26 Sep 2011 11:13:16 -0700 Subject: [PATCH 06/10] [ticket/10390] Drop http protocol for Microsoft's CDN option Like Google, Microsoft supports both http and https protocols, so we can drop the protocol alltogether from the url so the Microsoft CDN will work on both HTTP or HTTPS sites without issue. Also I cleaned up some of the comments here. PHPBB3-10390 --- phpBB/includes/functions.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 83cadf426d..8cdafbd95e 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4773,6 +4773,8 @@ function phpbb_pcre_utf8_support() /** * Build jQuery URL for remote CDNs * Reference: http://docs.jquery.com/Downloading_jQuery#CDN_Hosted_jQuery +* HTTP protocols intentionally omitted for Google and Microsoft - its the best +* way to reference third party content that is available via both HTTP and HTTPS * * @return string Returns url to a jQuery library */ @@ -4781,15 +4783,14 @@ function remote_jquery_url($host) switch($host) { case 'google': - // Google uses a 1.5.0, 1.5.1 format (it adds a .0 to new 1.X releases) + // Google uses a 1.5.0, 1.5.1 format (we need to add a .0 to new 1.X releases) $version = (substr_count(JQUERY_VERSION, '.') == 1) ? JQUERY_VERSION . '.0' : JQUERY_VERSION; - // HTTP protocol intentionally omitted - its the best way to reference third party content that is available via both HTTP and HTTPS $url = '//ajax.googleapis.com/ajax/libs/jquery/' . $version . '/jquery.min.js'; break; case 'microsoft': // Microsoft uses a 1.5, 1.5.1 format - $url = 'http://ajax.aspnetcdn.com/ajax/jQuery/jquery-' . JQUERY_VERSION . '.min.js'; + $url = '//ajax.aspnetcdn.com/ajax/jQuery/jquery-' . JQUERY_VERSION . '.min.js'; break; case 'jquery': From 2a28b6fc401e4481a3a4eb6085b45b9bd7746f43 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Mon, 26 Sep 2011 20:21:14 -0700 Subject: [PATCH 07/10] [ticket/10390] Use simpler HTML5 compliant js for the jQuery fallback HTML5 styles (ACP / Prosilver) do not need to use escaped javascript wrapped in an unescape function, so we can simplify it! Only subsilver2 will use the escaped version of the fallback code, because it is still XHTML. PHPBB3-10390 --- phpBB/adm/style/install_footer.html | 2 +- phpBB/adm/style/overall_footer.html | 2 +- phpBB/adm/style/simple_footer.html | 2 +- phpBB/styles/prosilver/template/overall_footer.html | 2 +- phpBB/styles/prosilver/template/simple_footer.html | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/phpBB/adm/style/install_footer.html b/phpBB/adm/style/install_footer.html index a3b2294025..342d8d4151 100644 --- a/phpBB/adm/style/install_footer.html +++ b/phpBB/adm/style/install_footer.html @@ -13,7 +13,7 @@ - + diff --git a/phpBB/adm/style/overall_footer.html b/phpBB/adm/style/overall_footer.html index f05e9c56c5..a190b2299a 100644 --- a/phpBB/adm/style/overall_footer.html +++ b/phpBB/adm/style/overall_footer.html @@ -21,7 +21,7 @@ - + diff --git a/phpBB/adm/style/simple_footer.html b/phpBB/adm/style/simple_footer.html index 0d697aec1d..5632d3fc9c 100644 --- a/phpBB/adm/style/simple_footer.html +++ b/phpBB/adm/style/simple_footer.html @@ -17,7 +17,7 @@ - + diff --git a/phpBB/styles/prosilver/template/overall_footer.html b/phpBB/styles/prosilver/template/overall_footer.html index 4456d6b37d..67f1b922a4 100644 --- a/phpBB/styles/prosilver/template/overall_footer.html +++ b/phpBB/styles/prosilver/template/overall_footer.html @@ -34,7 +34,7 @@ - + diff --git a/phpBB/styles/prosilver/template/simple_footer.html b/phpBB/styles/prosilver/template/simple_footer.html index 3458d02495..75b7480aa7 100644 --- a/phpBB/styles/prosilver/template/simple_footer.html +++ b/phpBB/styles/prosilver/template/simple_footer.html @@ -7,7 +7,7 @@ - + From 2dca3c3c278e99cfd6cdbea7149063d160e4cc11 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Mon, 26 Sep 2011 20:26:32 -0700 Subject: [PATCH 08/10] [ticket/10390] Serve jQuery from Google CDN Yes/No button in ACP jQuery will now be available via remote CDN from Google. Microsoft and jQuery CDNs have been removed, so we can simplify this option for the user. Default mode is NO so the copy of jQuery included with phpBB is served by default. PHPBB3-10390 --- phpBB/includes/acp/acp_board.php | 12 +-------- phpBB/includes/constants.php | 3 --- phpBB/includes/functions.php | 35 ++------------------------- phpBB/includes/functions_acp.php | 4 +-- phpBB/install/database_update.php | 3 ++- phpBB/install/schemas/schema_data.sql | 3 ++- phpBB/language/en/acp/board.php | 12 ++------- 7 files changed, 11 insertions(+), 61 deletions(-) diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index 45b6f219ac..352f1abc33 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -99,7 +99,7 @@ class acp_board 'load_cpf_pm' => array('lang' => 'LOAD_CPF_PM', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 'load_cpf_viewprofile' => array('lang' => 'LOAD_CPF_VIEWPROFILE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 'load_cpf_viewtopic' => array('lang' => 'LOAD_CPF_VIEWTOPIC', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), - 'load_jquery_host' => array('lang' => 'JQUERY_HOST', 'validate' => 'string', 'type' => 'select', 'method' => 'jquery_host_select', 'explain' => true), + 'load_jquery_cdn' => array('lang' => 'LOAD_JQUERY_CDN', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'legend3' => 'ACP_SUBMIT_CHANGES', ) @@ -998,14 +998,4 @@ class acp_board $cache->destroy('sql', FORUMS_TABLE); } - function jquery_host_select($value, $key = '') - { - global $user; - - return ' - - - '; - } - } diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php index 06cbc7120c..8ef1a4655d 100644 --- a/phpBB/includes/constants.php +++ b/phpBB/includes/constants.php @@ -30,9 +30,6 @@ define('PHPBB_VERSION', '3.1.0-dev'); // QA-related // define('PHPBB_QA', 1); -// jQuery Version -define('JQUERY_VERSION', '1.6.2'); // Important follow jQuery versioning, ie: 1.6, 1.6.1, 1.6.2 - // User related define('ANONYMOUS', 1); diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 8cdafbd95e..d769ce0374 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4569,8 +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_JQUERY_LINK' => ($config['load_jquery_cdn'] && !empty($config['load_jquery_url'])) ? $config['load_jquery_url'] : "{$web_path}assets/javascript/jquery.js", + 'S_JQUERY_FALLBACK' => ($config['load_jquery_cdn']) ? true : false, 'T_THEME_NAME' => $user->theme['theme_path'], 'T_THEME_LANG_NAME' => $user->data['user_lang'], @@ -4769,34 +4769,3 @@ 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 -* HTTP protocols intentionally omitted for Google and Microsoft - its the best -* way to reference third party content that is available via both HTTP and HTTPS -* -* @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 (we need to add a .0 to new 1.X releases) - $version = (substr_count(JQUERY_VERSION, '.') == 1) ? JQUERY_VERSION . '.0' : JQUERY_VERSION; - $url = '//ajax.googleapis.com/ajax/libs/jquery/' . $version . '/jquery.min.js'; - break; - - case 'microsoft': - // Microsoft uses a 1.5, 1.5.1 format - $url = '//ajax.aspnetcdn.com/ajax/jQuery/jquery-' . JQUERY_VERSION . '.min.js'; - break; - - case 'jquery': - // jQuery uses a 1.5, 1.5.1 format - $url = 'http://code.jquery.com/jquery-' . JQUERY_VERSION . '.min.js'; - break; - } - return $url; -} diff --git a/phpBB/includes/functions_acp.php b/phpBB/includes/functions_acp.php index 4f9fa0db5e..142be083a7 100644 --- a/phpBB/includes/functions_acp.php +++ b/phpBB/includes/functions_acp.php @@ -126,8 +126,8 @@ function adm_page_footer($copyright_html = true) 'DEBUG_OUTPUT' => (defined('DEBUG')) ? $debug_output : '', 'TRANSLATION_INFO' => (!empty($user->lang['TRANSLATION_INFO'])) ? $user->lang['TRANSLATION_INFO'] : '', 'S_COPYRIGHT_HTML' => $copyright_html, - 'T_JQUERY_LINK' => (!empty($config['load_jquery_host']) && $config['load_jquery_host'] != 'localhost') ? remote_jquery_url($config['load_jquery_host']) : "{$phpbb_root_path}assets/javascript/jquery.js", - 'S_JQUERY_FALLBACK' => (!empty($config['load_jquery_host']) && $config['load_jquery_host'] != 'localhost') ? true : false, + 'T_JQUERY_LINK' => ($config['load_jquery_cdn'] && !empty($config['load_jquery_url'])) ? $config['load_jquery_url'] : "{$phpbb_root_path}assets/javascript/jquery.js", + 'S_JQUERY_FALLBACK' => ($config['load_jquery_cdn']) ? true : false, 'VERSION' => $config['version']) ); diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 1a47e2a656..1fa01a534d 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2090,7 +2090,8 @@ function change_database_data(&$no_updates, $version) // Changes from 3.1.0-dev to 3.1.0-A1 case '3.1.0-dev': - set_config('load_jquery_host', 'localhost'); + set_config('load_jquery_cdn', 0); + set_config('load_jquery_url', '//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js'); set_config('use_system_cron', 0); $sql = 'UPDATE ' . GROUPS_TABLE . ' diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index 865189f345..843d6daaa7 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -165,7 +165,8 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_cpf_viewprofi INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_cpf_viewtopic', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_db_lastread', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_db_track', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_jquery_host', 'localhost'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_jquery_cdn', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_jquery_url', '//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_jumpbox', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_moderators', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_online', '1'); diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index 7a028b4064..07102d4db3 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -356,6 +356,8 @@ $lang = array_merge($lang, array( 'LOAD_CPF_PM' => 'Display custom profile fields in private messages', 'LOAD_CPF_VIEWPROFILE' => 'Display custom profile fields in user profiles', 'LOAD_CPF_VIEWTOPIC' => 'Display custom profile fields on topic pages', + 'LOAD_JQUERY_CDN' => 'Serve jQuery using Google’s CDN', + 'LOAD_JQUERY_CDN_EXPLAIN' => 'If this setting is enabled, jQuery will be served from Google’s AJAX API CDN instead of the copy included with phpBB on your server. If the CDN fails, phpBB will attempt to fallback to the copy included with phpBB.', 'LOAD_USER_ACTIVITY' => 'Show user’s activity', 'LOAD_USER_ACTIVITY_EXPLAIN' => 'Displays active topic/forum in user profiles and user control panel. It is recommended to disable this on boards with more than one million posts.', 'RECOMPILE_STYLES' => 'Recompile stale style components', @@ -549,13 +551,3 @@ $lang = array_merge($lang, array( 'JAB_USERNAME' => 'Jabber username or JID', 'JAB_USERNAME_EXPLAIN' => 'Specify a registered username or a valid JID. The username will not be checked for validity. If you only specify a username, then your JID will be the username and the server you specified above. Else, specify a valid JID, for example user@jabber.org.', )); - -// jQuery settings -$lang = array_merge($lang, array( - 'JQUERY_HOST' => 'Load jQuery from your server or a hosted CDN', - 'JQUERY_HOST_EXPLAIN' => 'Load jQuery from the copy included with phpBB on your local server, or choose a remote copy hosted on a CDN (Content Delivery Network). If the CDN fails, phpBB will fall back to the copy included with phpBB.', - 'JQUERY_HOST_LOCAL' => 'Included with phpBB on my server', - 'JQUERY_HOST_GOOGLE' => 'Hosted CDN: Google AJAX API', - 'JQUERY_HOST_JQUERY' => 'Hosted CDN: jQuery', - 'JQUERY_HOST_MS' => 'Hosted CDN: Microsoft', -)); From 9bea7c327846c7281dd5d1f78322ac0016c4dfc9 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Tue, 27 Sep 2011 20:15:41 -0700 Subject: [PATCH 09/10] [ticket/10390] Fix wording: fallback should be fall back PHPBB3-10390 --- phpBB/language/en/acp/board.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index 07102d4db3..7ead6c6628 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -357,7 +357,7 @@ $lang = array_merge($lang, array( 'LOAD_CPF_VIEWPROFILE' => 'Display custom profile fields in user profiles', 'LOAD_CPF_VIEWTOPIC' => 'Display custom profile fields on topic pages', 'LOAD_JQUERY_CDN' => 'Serve jQuery using Google’s CDN', - 'LOAD_JQUERY_CDN_EXPLAIN' => 'If this setting is enabled, jQuery will be served from Google’s AJAX API CDN instead of the copy included with phpBB on your server. If the CDN fails, phpBB will attempt to fallback to the copy included with phpBB.', + 'LOAD_JQUERY_CDN_EXPLAIN' => 'If this setting is enabled, jQuery will be served from Google’s AJAX API CDN instead of the copy included with phpBB on your server. If the CDN fails, phpBB will attempt to fall back to the copy included with phpBB.', 'LOAD_USER_ACTIVITY' => 'Show user’s activity', 'LOAD_USER_ACTIVITY_EXPLAIN' => 'Displays active topic/forum in user profiles and user control panel. It is recommended to disable this on boards with more than one million posts.', 'RECOMPILE_STYLES' => 'Recompile stale style components', From 2d0f96e8cc48ba6eed06f99efb33193fc495eab7 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Wed, 5 Oct 2011 21:24:34 -0700 Subject: [PATCH 10/10] [ticket/10390] Revert back to escaped script tags inside document.write Revert all script tags inside a document.write back to the escaped version so they won't trip up any XML parsers. PHPBB3-10390 --- phpBB/adm/style/install_footer.html | 2 +- phpBB/adm/style/overall_footer.html | 2 +- phpBB/adm/style/simple_footer.html | 2 +- phpBB/styles/prosilver/template/overall_footer.html | 2 +- phpBB/styles/prosilver/template/simple_footer.html | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/phpBB/adm/style/install_footer.html b/phpBB/adm/style/install_footer.html index 342d8d4151..a3b2294025 100644 --- a/phpBB/adm/style/install_footer.html +++ b/phpBB/adm/style/install_footer.html @@ -13,7 +13,7 @@ - + diff --git a/phpBB/adm/style/overall_footer.html b/phpBB/adm/style/overall_footer.html index a190b2299a..f05e9c56c5 100644 --- a/phpBB/adm/style/overall_footer.html +++ b/phpBB/adm/style/overall_footer.html @@ -21,7 +21,7 @@ - + diff --git a/phpBB/adm/style/simple_footer.html b/phpBB/adm/style/simple_footer.html index 5632d3fc9c..0d697aec1d 100644 --- a/phpBB/adm/style/simple_footer.html +++ b/phpBB/adm/style/simple_footer.html @@ -17,7 +17,7 @@ - + diff --git a/phpBB/styles/prosilver/template/overall_footer.html b/phpBB/styles/prosilver/template/overall_footer.html index 67f1b922a4..4456d6b37d 100644 --- a/phpBB/styles/prosilver/template/overall_footer.html +++ b/phpBB/styles/prosilver/template/overall_footer.html @@ -34,7 +34,7 @@ - + diff --git a/phpBB/styles/prosilver/template/simple_footer.html b/phpBB/styles/prosilver/template/simple_footer.html index 75b7480aa7..3458d02495 100644 --- a/phpBB/styles/prosilver/template/simple_footer.html +++ b/phpBB/styles/prosilver/template/simple_footer.html @@ -7,7 +7,7 @@ - +