/**
* 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)));
}
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)));
+}
+
}
}
+ /**
+ * 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
*
}
}
-
-/**
- * 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 '<form '.$CFG->frametarget.' method="get" action="'.$CFG->wwwroot.'/course/view.php">'.
- '<div>'.
- '<input type="hidden" name="id" value="'.$courseid.'" />'.
- '<input type="hidden" name="edit" value="'.$edit.'" />'.
- '<input type="hidden" name="sesskey" value="'.sesskey().'" />'.
- '<input type="submit" value="'.$string.'" />'.
- '</div></form>';
-}
-
/**
* Returns a little popup menu for switching roles
*
$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);