From: nicolasconnault Date: Wed, 5 Aug 2009 02:39:42 +0000 (+0000) Subject: MDL-19756 Deprecated update_course_icon() and implemented a simple $OUTPUT->edit_butt... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=cf1329808160b287eaa1273ec6be8d0ae331c8fb;p=moodle.git MDL-19756 Deprecated update_course_icon() and implemented a simple $OUTPUT->edit_button($moodleurl) method which uses $USER->editing --- diff --git a/lib/deprecatedlib.php b/lib/deprecatedlib.php index 198f9fd086..7b3b32d165 100644 --- a/lib/deprecatedlib.php +++ b/lib/deprecatedlib.php @@ -3556,9 +3556,12 @@ function update_mymoodle_icon() { /** * Returns a turn edit on/off button for tag in a self contained form. * @deprecated since Moodle 2.0 + * @param string $tagid The ID attribute + * @return string */ -function update_tag_button() { - throw new coding_exception('update_tag_button() has been completely deprecated.'); +function update_tag_button($tagid) { + // debugging('update_tag_button() has been deprecated. Please change your code to use $OUTPUT->edit_button(moodle_url).'); + return $OUTPUT->edit_button(new moodle_url($CFG->wwwroot.'/tag/index.php', array('id' => $tagid))); } @@ -3596,3 +3599,23 @@ function update_categories_search_button($search,$page,$perpage) { function print_user($user, $course, $messageselect=false, $return=false) { throw new coding_exception('print_user() has been completely deprecated. See user/index.php for new usage.'); } + +/** + * Returns a turn edit on/off button for course in a self contained form. + * Used to be an icon, but it's now a simple form button + * + * Note that the caller is responsible for capchecks. + * + * @global object + * @global object + * @param int $courseid The course to update by id as found in 'course' table + * @return string + */ +function update_course_icon($courseid) { + global $CFG, $OUTPUT; + + // debugging('update_course_button() has been deprecated. Please change your code to use $OUTPUT->edit_button(moodle_url).'); + + return $OUTPUT->edit_button(new moodle_url($CFG->wwwroot.'/course/view.php', array('id' => $courseid))); +} + diff --git a/lib/outputlib.php b/lib/outputlib.php index a524cbd7df..4bb480279a 100644 --- a/lib/outputlib.php +++ b/lib/outputlib.php @@ -2797,6 +2797,29 @@ class moodle_core_renderer extends moodle_renderer_base { } } + /** + * Prints a "Turn editing on/off" button in a form. + * @param moodle_url $url The URL + params to send through when clicking the button + * @return string HTML the button + */ + public function edit_button(moodle_url $url) { + global $USER; + if (!empty($USER->editing)) { + $string = get_string('turneditingoff'); + $edit = '0'; + } else { + $string = get_string('turneditingon'); + $edit = '1'; + } + + $form = new html_form(); + $form->url = $url; + $form->url->param('edit', $edit); + $form->button->text = $string; + + return $this->button($form); + } + /** * Outputs a HTML nested list * diff --git a/lib/weblib.php b/lib/weblib.php index cb39dfa851..b68a9b6907 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -2550,38 +2550,6 @@ function print_recent_activity_note($time, $user, $text, $link, $return=false, $ } } - -/** - * Returns a turn edit on/off button for course in a self contained form. - * Used to be an icon, but it's now a simple form button - * - * Note that the caller is responsible for capchecks. - * - * @global object - * @global object - * @param int $courseid The course to update by id as found in 'course' table - * @return string - */ -function update_course_icon($courseid) { - global $CFG, $USER; - - if (!empty($USER->editing)) { - $string = get_string('turneditingoff'); - $edit = '0'; - } else { - $string = get_string('turneditingon'); - $edit = '1'; - } - - return '
frametarget.' method="get" action="'.$CFG->wwwroot.'/course/view.php">'. - '
'. - ''. - ''. - ''. - ''. - '
'; -} - /** * Returns a little popup menu for switching roles * diff --git a/tag/index.php b/tag/index.php index d93f58e25b..1dbe56fd32 100644 --- a/tag/index.php +++ b/tag/index.php @@ -51,18 +51,7 @@ $title = get_string('tag', 'tag') .' - '. $tagname; $button = ''; if ($PAGE->user_allowed_editing() ) { - if (!empty($USER->editing)) { - $string = get_string('turneditingoff'); - $edit = '0'; - } else { - $string = get_string('turneditingon'); - $edit = '1'; - } - - $form = new html_form(); - $form->url = new moodle_url("$CFG->wwwroot/tag/index.php", array('edit' => $edit, 'id' => $tagid)); - $form->button->text = $string; - $button = $OUTPUT->button($form); + $button = $OUTPUT->edit_button(new moodle_url("$CFG->wwwroot/tag/index.php", array('id' => $tagid))); } print_header_simple($title, '', $navigation, '', '', '', $button);