mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-24 02:48:56 +00:00
[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
This commit is contained in:
parent
2a28b6fc40
commit
2dca3c3c27
7 changed files with 11 additions and 61 deletions
|
@ -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 '<option value="localhost"' . (($value == 'localhost') ? ' selected="selected"' : '') . '>' . $user->lang['JQUERY_HOST_LOCAL'] . '</option>
|
||||
<option value="google"' . (($value == 'google') ? ' selected="selected"' : '') . '>' . $user->lang['JQUERY_HOST_GOOGLE'] . '</option>
|
||||
<option value="microsoft"' . (($value == 'microsoft') ? ' selected="selected"' : '') . '>' . $user->lang['JQUERY_HOST_MS'] . '</option>
|
||||
<option value="jquery"' . (($value == 'jquery') ? ' selected="selected"' : '') . '>' . $user->lang['JQUERY_HOST_JQUERY'] . '</option>';
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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'])
|
||||
);
|
||||
|
||||
|
|
|
@ -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 . '
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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',
|
||||
));
|
||||
|
|
Loading…
Add table
Reference in a new issue