Merge branch 'w30_MDL-34299_m24_html5' of git://github.com/skodak/moodle

Conflicts:
	lib/db/upgrade.php
	version.php
This commit is contained in:
Dan Poltawski
2012-07-24 14:07:26 +08:00
15 changed files with 65 additions and 94 deletions
-8
View File
@@ -104,10 +104,6 @@ if (!$version or !$release) {
print_error('withoutversion', 'debug'); // without version, stop
}
// Turn off xmlstrictheaders during upgrade.
$origxmlstrictheaders = !empty($CFG->xmlstrictheaders);
$CFG->xmlstrictheaders = false;
if (!core_tables_exist()) {
$PAGE->set_pagelayout('maintenance');
$PAGE->set_popup_notification_allowed(false);
@@ -380,10 +376,6 @@ if (during_initial_install()) {
upgrade_finished('upgradesettings.php');
}
// Turn xmlstrictheaders back on now.
$CFG->xmlstrictheaders = $origxmlstrictheaders;
unset($origxmlstrictheaders);
// Check for valid admin user - no guest autologin
require_login(0, false);
$context = get_context_instance(CONTEXT_SYSTEM);
-1
View File
@@ -25,7 +25,6 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
$temp = new admin_settingpage('debugging', new lang_string('debugging', 'admin'));
$temp->add(new admin_setting_special_debug());
$temp->add(new admin_setting_configcheckbox('debugdisplay', new lang_string('debugdisplay', 'admin'), new lang_string('configdebugdisplay', 'admin'), ini_get_bool('display_errors')));
$temp->add(new admin_setting_configcheckbox('xmlstrictheaders', new lang_string('xmlstrictheaders', 'admin'), new lang_string('configxmlstrictheaders', 'admin'), 0));
$temp->add(new admin_setting_configcheckbox('debugsmtp', new lang_string('debugsmtp', 'admin'), new lang_string('configdebugsmtp', 'admin'), 0));
$temp->add(new admin_setting_configcheckbox('perfdebug', new lang_string('perfdebug', 'admin'), new lang_string('configperfdebug', 'admin'), '7', '15', '7'));
$temp->add(new admin_setting_configcheckbox('debugstringids', new lang_string('debugstringids', 'admin'), new lang_string('debugstringids_desc', 'admin'), 0));
+1 -1
View File
@@ -35,7 +35,7 @@ class block_login extends block_base {
// TODO: now that we have multiauth it is hard to find out if there is a way to change password
$forgot = $wwwroot . '/login/forgot_password.php';
if (empty($CFG->xmlstrictheaders) and !empty($CFG->loginpasswordautocomplete)) {
if (!empty($CFG->loginpasswordautocomplete)) {
$autocomplete = 'autocomplete="off"';
} else {
$autocomplete = '';
-2
View File
@@ -340,7 +340,6 @@ $string['configvariables'] = 'Variables';
$string['configverifychangedemail'] = 'Enables verification of changed email addresses using allowed and denied email domains settings. If this setting is disabled the domains are enforced only when creating new users.';
$string['configvisiblecourses'] = 'Display courses in hidden categories normally';
$string['configwarning'] = 'Be careful modifying these settings - strange values could cause problems.';
$string['configxmlstrictheaders'] = 'Set to on, each page will be generated using XML http headers and prolog, so browsers will show XHTML errors inline. This is only useful for developers.';
$string['configyuicomboloading'] = 'This options enables combined file loading optimisation for YUI libraries. This setting should be enabled on production sites for performance reasons.';
$string['configzip'] = 'Indicate the location of your zip program (Unix only, optional). If specified, this will be used to create zip archives on the server. If you leave this blank, then Moodle will use internal routines.';
$string['confirmation'] = 'Confirmation';
@@ -1063,6 +1062,5 @@ $string['warningiconvbuggy'] = 'Your version of the iconv library does not suppo
$string['webproxy'] = 'Web proxy';
$string['webproxyinfo'] = 'Fill in following options if your Moodle server can not access internet directly. Internet access is required for download of environment data, language packs, RSS feeds, timezones, etc.<br /><em>PHP cURL extension is highly recommended.</em>';
$string['xmlrpcrecommended'] = 'The xmlrpc extension is needed for hub communication, and useful for web services and Moodle networking';
$string['xmlstrictheaders'] = 'XML strict headers';
$string['yuicomboloading'] = 'YUI combo loading';
$string['ziprequired'] = 'The Zip PHP extension is now required by Moodle, info-ZIP binaries or PclZip library are not used anymore.';
+6
View File
@@ -1053,6 +1053,12 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2012071900.01);
}
if ($oldversion < 2012072400.00) {
// Remove obsolete xhtml strict setting - use THEME->doctype in theme config if necessary,
// see theme_config->doctype in lib/outputlib.php for more details.
unset_config('xmlstrictheaders');
upgrade_main_savepoint(true, 2012072400.00);
}
return true;
}
+1 -1
View File
@@ -172,7 +172,7 @@ class tinymce_texteditor extends texteditor {
$params['moodleemoticon_emoticons'] = json_encode($imgs);
}
if (empty($CFG->xmlstrictheaders) and (!empty($options['legacy']) or !empty($options['noclean']) or !empty($options['trusted']))) {
if (!empty($options['legacy']) or !empty($options['noclean']) or !empty($options['trusted'])) {
// now deal somehow with non-standard tags, people scream when we do not make moodle code xtml strict,
// but they scream even more when we strip all tags that are not strict :-(
$params['valid_elements'] = 'script[src|type],*[*]'; // for some reason the *[*] does not inlcude javascript src attribute MDL-25836
+8 -11
View File
@@ -51,17 +51,14 @@ class MoodleQuickForm_password extends HTML_QuickForm_password{
*/
function MoodleQuickForm_password($elementName=null, $elementLabel=null, $attributes=null) {
global $CFG;
if (empty($CFG->xmlstrictheaders)) {
// no standard mform in moodle should allow autocomplete of passwords
// this is valid attribute in html5, sorry, we have to ignore validation errors in legacy xhtml 1.0
if (empty($attributes)) {
$attributes = array('autocomplete'=>'off');
} else if (is_array($attributes)) {
$attributes['autocomplete'] = 'off';
} else {
if (strpos($attributes, 'autocomplete') === false) {
$attributes .= ' autocomplete="off" ';
}
// no standard mform in moodle should allow autocomplete of passwords
if (empty($attributes)) {
$attributes = array('autocomplete'=>'off');
} else if (is_array($attributes)) {
$attributes['autocomplete'] = 'off';
} else {
if (strpos($attributes, 'autocomplete') === false) {
$attributes .= ' autocomplete="off" ';
}
}
+9 -11
View File
@@ -53,19 +53,17 @@ class MoodleQuickForm_passwordunmask extends MoodleQuickForm_password {
*/
function MoodleQuickForm_passwordunmask($elementName=null, $elementLabel=null, $attributes=null) {
global $CFG;
if (empty($CFG->xmlstrictheaders)) {
// no standard mform in moodle should allow autocomplete of passwords
// this is valid attribute in html5, sorry, we have to ignore validation errors in legacy xhtml 1.0
if (empty($attributes)) {
$attributes = array('autocomplete'=>'off');
} else if (is_array($attributes)) {
$attributes['autocomplete'] = 'off';
} else {
if (strpos($attributes, 'autocomplete') === false) {
$attributes .= ' autocomplete="off" ';
}
// no standard mform in moodle should allow autocomplete of passwords
if (empty($attributes)) {
$attributes = array('autocomplete'=>'off');
} else if (is_array($attributes)) {
$attributes['autocomplete'] = 'off';
} else {
if (strpos($attributes, 'autocomplete') === false) {
$attributes .= ' autocomplete="off" ';
}
}
parent::MoodleQuickForm_password($elementName, $elementLabel, $attributes);
}
+8 -11
View File
@@ -158,17 +158,14 @@ abstract class moodleform {
*/
function moodleform($action=null, $customdata=null, $method='post', $target='', $attributes=null, $editable=true) {
global $CFG, $FULLME;
if (empty($CFG->xmlstrictheaders)) {
// no standard mform in moodle should allow autocomplete with the exception of user signup
// this is valid attribute in html5, sorry, we have to ignore validation errors in legacy xhtml 1.0
if (empty($attributes)) {
$attributes = array('autocomplete'=>'off');
} else if (is_array($attributes)) {
$attributes['autocomplete'] = 'off';
} else {
if (strpos($attributes, 'autocomplete') === false) {
$attributes .= ' autocomplete="off" ';
}
// no standard mform in moodle should allow autocomplete with the exception of user signup
if (empty($attributes)) {
$attributes = array('autocomplete'=>'off');
} else if (is_array($attributes)) {
$attributes['autocomplete'] = 'off';
} else {
if (strpos($attributes, 'autocomplete') === false) {
$attributes .= ' autocomplete="off" ';
}
}
+1 -20
View File
@@ -526,8 +526,6 @@ OET;
*/
class core_media_player_youtube extends core_media_player_external {
protected function embed_external(moodle_url $url, $name, $width, $height, $options) {
global $CFG;
$site = $this->matches[1];
$videoid = $this->matches[3];
@@ -539,27 +537,10 @@ class core_media_player_youtube extends core_media_player_external {
self::pick_video_size($width, $height);
if (empty($CFG->xmlstrictheaders)) {
return <<<OET
return <<<OET
<iframe title="$info" width="$width" height="$height"
src="$site/embed/$videoid?rel=0&wmode=transparent" frameborder="0" allowfullscreen></iframe>
OET;
}
// NOTE: we can not use any link fallback because it breaks built-in
// player on iOS devices.
$output = <<<OET
<span class="mediaplugin mediaplugin_youtube">
<object title="$info" type="application/x-shockwave-flash"
data="$site/v/$videoid&amp;fs=1&amp;rel=0" width="$width" height="$height">
<param name="movie" value="$site/v/$videoid&amp;fs=1&amp;rel=0" />
<param name="FlashVars" value="playerMode=embedded" />
<param name="allowFullScreen" value="true" />
</object>
</span>
OET;
return $output;
}
protected function get_regex() {
+9 -1
View File
@@ -275,6 +275,14 @@ class theme_config {
*/
public $enablecourseajax = true;
/**
* @var string Determines served document types
* - 'html5' the only officially supported doctype in Moodle
* - 'xhtml5' may be used in development for validation (not intended for production servers!)
* - 'xhtml' XHTML 1.0 Strict for legacy themes only
*/
public $doctype = 'html5';
//==Following properties are not configurable from theme config.php==
/**
@@ -390,7 +398,7 @@ class theme_config {
$configurable = array('parents', 'sheets', 'parents_exclude_sheets', 'plugins_exclude_sheets', 'javascripts', 'javascripts_footer',
'parents_exclude_javascripts', 'layouts', 'enable_dock', 'enablecourseajax', 'supportscssoptimisation',
'rendererfactory', 'csspostprocess', 'editor_sheets', 'rarrow', 'larrow', 'hidefromselector');
'rendererfactory', 'csspostprocess', 'editor_sheets', 'rarrow', 'larrow', 'hidefromselector', 'doctype');
foreach ($config as $key=>$value) {
if (in_array($key, $configurable)) {
+20 -22
View File
@@ -304,34 +304,22 @@ class core_renderer extends renderer_base {
* Get the DOCTYPE declaration that should be used with this page. Designed to
* be called in theme layout.php files.
*
* @return string the DOCTYPE declaration (and any XML prologue) that should be used.
* @return string the DOCTYPE declaration that should be used.
*/
public function doctype() {
global $CFG;
if ($this->page->theme->doctype === 'html5') {
$this->contenttype = 'text/html; charset=utf-8';
return "<!DOCTYPE html>\n";
$doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' . "\n";
$this->contenttype = 'text/html; charset=utf-8';
if (empty($CFG->xmlstrictheaders)) {
return $doctype;
}
// We want to serve the page with an XML content type, to force well-formedness errors to be reported.
$prolog = '<?xml version="1.0" encoding="utf-8"?>' . "\n";
if (isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'application/xhtml+xml') !== false) {
// Firefox and other browsers that can cope natively with XHTML.
} else if ($this->page->theme->doctype === 'xhtml5') {
$this->contenttype = 'application/xhtml+xml; charset=utf-8';
} else if (preg_match('/MSIE.*Windows NT/', $_SERVER['HTTP_USER_AGENT'])) {
// IE can't cope with application/xhtml+xml, but it will cope if we send application/xml with an XSL stylesheet.
$this->contenttype = 'application/xml; charset=utf-8';
$prolog .= '<?xml-stylesheet type="text/xsl" href="' . $CFG->httpswwwroot . '/lib/xhtml.xsl"?>' . "\n";
return "<!DOCTYPE html>\n";
} else {
$prolog = '';
// legacy xhtml 1.0
$this->contenttype = 'text/html; charset=utf-8';
return ('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' . "\n");
}
return $prolog . $doctype;
}
/**
@@ -341,7 +329,11 @@ class core_renderer extends renderer_base {
* @return string HTML fragment.
*/
public function htmlattributes() {
return get_html_lang(true) . ' xmlns="http://www.w3.org/1999/xhtml"';
$return = get_html_lang(true);
if ($this->page->theme->doctype !== 'html5') {
$return .= ' xmlns="http://www.w3.org/1999/xhtml"';
}
return $return;
}
/**
@@ -354,6 +346,12 @@ class core_renderer extends renderer_base {
public function standard_head_html() {
global $CFG, $SESSION;
$output = '';
if ($this->page->theme->doctype === 'html5' or $this->page->theme->doctype === 'xhtml5') {
// Make sure we set 'X-UA-Compatible' only if script did not request something else (such as MDL-29213).
if (empty($CFG->additionalhtmlhead) or stripos($CFG->additionalhtmlhead, 'X-UA-Compatible') === false) {
$output .= '<meta http-equiv="X-UA-Compatible" content="IE=edge" />' . "\n";
}
}
$output .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />' . "\n";
$output .= '<meta name="keywords" content="moodle, ' . $this->page->title . '" />' . "\n";
if (!$this->page->cacheable) {
-3
View File
@@ -57,9 +57,6 @@ class medialib_testcase extends advanced_testcase {
$CFG->core_media_enable_vimeo = false;
$CFG->core_media_enable_swf = false;
// Strict headers turned off.
$CFG->xmlstrictheaders = false;
$_SERVER = array('HTTP_USER_AGENT' => '');
$this->pretend_to_be_safari();
}
+1 -1
View File
@@ -5,7 +5,7 @@ if ($show_instructions) {
$columns = 'onecolumn';
}
if (empty($CFG->xmlstrictheaders) and !empty($CFG->loginpasswordautocomplete)) {
if (!empty($CFG->loginpasswordautocomplete)) {
$autocomplete = 'autocomplete="off"';
} else {
$autocomplete = '';
+1 -1
View File
@@ -30,7 +30,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2012071902.00; // YYYYMMDD = weekly release date of this DEV branch
$version = 2012072400.00; // YYYYMMDD = weekly release date of this DEV branch
// RR = release increments - 00 in DEV branches
// .XX = incremental changes