From af64bc6179bd258d9f085b0d16250f4d82d2c230 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Mon, 10 Feb 2014 15:17:46 +0800 Subject: [PATCH] MDL-33099 Javascript: Deprecate the ajaxenabled function --- admin/settings/appearance.php | 1 - blocks/course_overview/renderer.php | 5 +---- course/format/formatlegacy.php | 6 +----- course/format/lib.php | 2 -- course/format/topics/lib.php | 2 -- course/format/upgrade.txt | 3 +++ course/format/weeks/lib.php | 2 -- course/lib.php | 6 ------ course/renderer.php | 2 +- course/view.php | 6 ++---- group/index.php | 31 ++++++++--------------------- lang/en/admin.php | 2 -- lib/ajax/ajaxlib.php | 28 -------------------------- lib/deprecatedlib.php | 12 +++++++++++ lib/upgrade.txt | 1 + mod/feedback/edit.php | 2 +- rating/lib.php | 4 +--- 17 files changed, 31 insertions(+), 84 deletions(-) diff --git a/admin/settings/appearance.php b/admin/settings/appearance.php index 2cf6f0f954294..418ed40c6af24 100644 --- a/admin/settings/appearance.php +++ b/admin/settings/appearance.php @@ -217,7 +217,6 @@ $ADMIN->add('appearance', $temp); $temp = new admin_settingpage('ajax', new lang_string('ajaxuse')); - $temp->add(new admin_setting_configcheckbox('enableajax', new lang_string('enableajax', 'admin'), new lang_string('configenableajax', 'admin'), 1)); $temp->add(new admin_setting_configcheckbox('useexternalyui', new lang_string('useexternalyui', 'admin'), new lang_string('configuseexternalyui', 'admin'), 0)); $temp->add(new admin_setting_configcheckbox('yuicomboloading', new lang_string('yuicomboloading', 'admin'), new lang_string('configyuicomboloading', 'admin'), 1)); $setting = new admin_setting_configcheckbox('cachejs', new lang_string('cachejs', 'admin'), new lang_string('cachejs_help', 'admin'), 1); diff --git a/blocks/course_overview/renderer.php b/blocks/course_overview/renderer.php index fcde4f4597c77..3efcd95f5e7ef 100644 --- a/blocks/course_overview/renderer.php +++ b/blocks/course_overview/renderer.php @@ -48,10 +48,7 @@ public function course_overview($courses, $overviews) { // Intialise string/icon etc if user is editing and courses > 1 if ($this->page->user_is_editing() && (count($courses) > 1)) { $userediting = true; - // If ajaxenabled then include DND JS and replace link with move image. - if (ajaxenabled()) { - $this->page->requires->js_init_call('M.block_course_overview.add_handles'); - } + $this->page->requires->js_init_call('M.block_course_overview.add_handles'); // Check if course is moving $ismovingcourse = optional_param('movecourse', FALSE, PARAM_BOOL); diff --git a/course/format/formatlegacy.php b/course/format/formatlegacy.php index f353a4b58161d..665f583382183 100644 --- a/course/format/formatlegacy.php +++ b/course/format/formatlegacy.php @@ -147,7 +147,6 @@ public function get_view_url($section, $options = array()) { * * The returned object's property (boolean)capable indicates that * the course format supports Moodle course ajax features. - * The property (array)testedbrowsers can be used as a parameter for {@link ajaxenabled()}. * * @return stdClass */ @@ -162,9 +161,6 @@ public function supports_ajax() { if (isset($formatsupport->capable)) { $ajaxsupport->capable = $formatsupport->capable; } - if (is_array($formatsupport->testedbrowsers)) { - $ajaxsupport->testedbrowsers = $formatsupport->testedbrowsers; - } } return $ajaxsupport; } @@ -360,4 +356,4 @@ public function update_course_format_options($data, $oldcourse = null) { } return $this->update_format_options($data); } -} \ No newline at end of file +} diff --git a/course/format/lib.php b/course/format/lib.php index a68ce5ae5006f..af2a6c6b60a8f 100644 --- a/course/format/lib.php +++ b/course/format/lib.php @@ -353,7 +353,6 @@ public function get_section_name($section) { * * The returned object's property (boolean)capable indicates that * the course format supports Moodle course ajax features. - * The property (array)testedbrowsers can be used as a parameter for {@link ajaxenabled()}. * * @return stdClass */ @@ -361,7 +360,6 @@ public function supports_ajax() { // no support by default $ajaxsupport = new stdClass(); $ajaxsupport->capable = false; - $ajaxsupport->testedbrowsers = array(); return $ajaxsupport; } diff --git a/course/format/topics/lib.php b/course/format/topics/lib.php index 71a04529ad767..7c1ee6ec5898d 100644 --- a/course/format/topics/lib.php +++ b/course/format/topics/lib.php @@ -115,14 +115,12 @@ public function get_view_url($section, $options = array()) { * * The returned object's property (boolean)capable indicates that * the course format supports Moodle course ajax features. - * The property (array)testedbrowsers can be used as a parameter for {@link ajaxenabled()}. * * @return stdClass */ public function supports_ajax() { $ajaxsupport = new stdClass(); $ajaxsupport->capable = true; - $ajaxsupport->testedbrowsers = array('MSIE' => 6.0, 'Gecko' => 20061111, 'Safari' => 531, 'Chrome' => 6.0); return $ajaxsupport; } diff --git a/course/format/upgrade.txt b/course/format/upgrade.txt index f29a06e068107..3bc37eda9d339 100644 --- a/course/format/upgrade.txt +++ b/course/format/upgrade.txt @@ -2,6 +2,9 @@ This files describes API changes for course formats Overview of this plugin type at http://docs.moodle.org/dev/Course_formats +=== 2.7 === +* The ->testedbrowsers array no longer needs to be defined in supports_ajax(). + === 2.6 === * core_course_renderer::course_section_cm_edit_actions has two new optional arguments and now uses and action_menu component. diff --git a/course/format/weeks/lib.php b/course/format/weeks/lib.php index ded5ef0416f4b..e361deffaf3a1 100644 --- a/course/format/weeks/lib.php +++ b/course/format/weeks/lib.php @@ -122,14 +122,12 @@ public function get_view_url($section, $options = array()) { * * The returned object's property (boolean)capable indicates that * the course format supports Moodle course ajax features. - * The property (array)testedbrowsers can be used as a parameter for {@link ajaxenabled()}. * * @return stdClass */ public function supports_ajax() { $ajaxsupport = new stdClass(); $ajaxsupport->capable = true; - $ajaxsupport->testedbrowsers = array('MSIE' => 6.0, 'Gecko' => 20061111, 'Safari' => 531, 'Chrome' => 6.0); return $ajaxsupport; } diff --git a/course/lib.php b/course/lib.php index 1ae3e9470273b..1110236f2e21b 100644 --- a/course/lib.php +++ b/course/lib.php @@ -2333,7 +2333,6 @@ function course_format_uses_sections($format) { * * The returned object's property (boolean)capable indicates that * the course format supports Moodle course ajax features. - * The property (array)testedbrowsers can be used as a parameter for {@see ajaxenabled()}. * * @param string $format * @return stdClass @@ -3119,11 +3118,6 @@ function course_page_type_list($pagetype, $parentcontext, $currentcontext) { function course_ajax_enabled($course) { global $CFG, $PAGE, $SITE; - // Ajax must be enabled globally - if (!$CFG->enableajax) { - return false; - } - // The user must be editing for AJAX to be included if (!$PAGE->user_is_editing()) { return false; diff --git a/course/renderer.php b/course/renderer.php index eb6ab4ae77615..b28a98b5b20f3 100644 --- a/course/renderer.php +++ b/course/renderer.php @@ -1503,7 +1503,7 @@ protected function coursecat_subcategories(coursecat_helper $chelper, $coursecat protected function coursecat_include_js() { global $CFG; static $jsloaded = false; - if (!$jsloaded && $CFG->enableajax) { + if (!$jsloaded) { // We must only load this module once. $this->page->requires->yui_module('moodle-course-categoryexpander', 'Y.Moodle.course.categoryexpander.init'); diff --git a/course/view.php b/course/view.php index 16b2ca026c3e9..c5ec9d0216fb9 100644 --- a/course/view.php +++ b/course/view.php @@ -219,10 +219,8 @@ redirect($CFG->wwwroot .'/'); } - $ajaxenabled = ajaxenabled(); - $completion = new completion_info($course); - if ($completion->is_enabled() && $ajaxenabled) { + if ($completion->is_enabled()) { $PAGE->requires->string_for_js('completion-title-manual-y', 'completion'); $PAGE->requires->string_for_js('completion-title-manual-n', 'completion'); $PAGE->requires->string_for_js('completion-alt-manual-y', 'completion'); @@ -251,7 +249,7 @@ $PAGE->set_heading($course->fullname); echo $OUTPUT->header(); - if ($completion->is_enabled() && $ajaxenabled) { + if ($completion->is_enabled()) { // This value tracks whether there has been a dynamic change to the page. // It is used so that if a user does this - (a) set some tickmarks, (b) // go to another page, (c) clicks Back button - the page will diff --git a/group/index.php b/group/index.php index 5e839183ab2b9..f3e7f37f6d376 100644 --- a/group/index.php +++ b/group/index.php @@ -152,20 +152,11 @@ require('tabs.php'); $disabled = 'disabled="disabled"'; -$ajaxenabled = ajaxenabled(); -if ($ajaxenabled) { - // Some buttons are enabled if single group selected - $showaddmembersform_disabled = $singlegroup ? '' : $disabled; - $showeditgroupsettingsform_disabled = $singlegroup ? '' : $disabled; - $deletegroup_disabled = count($groupids)>0 ? '' : $disabled; -} else { - // Do not disable buttons. The buttons work based on the selected group, - // which you can change without reloading the page, so it is not appropriate - // to disable them if no group is selected. - $showaddmembersform_disabled = ''; - $showeditgroupsettingsform_disabled = ''; - $deletegroup_disabled = ''; -} + +// Some buttons are enabled if single group selected. +$showaddmembersform_disabled = $singlegroup ? '' : $disabled; +$showeditgroupsettingsform_disabled = $singlegroup ? '' : $disabled; +$deletegroup_disabled = count($groupids) > 0 ? '' : $disabled; echo $OUTPUT->heading(format_string($course->shortname, true, array('context' => $context)) .' '.$strgroups, 3); echo '
'."\n"; @@ -179,11 +170,7 @@ echo "\n"; echo '

'."\n"; -if ($ajaxenabled) { // TODO: move this to JS init! - $onchange = 'M.core_group.membersCombo.refreshMembers();'; -} else { - $onchange = ''; -} +$onchange = 'M.core_group.membersCombo.refreshMembers();'; echo '