]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-19756 Deprecated update_course_icon() and implemented a simple $OUTPUT->edit_butt...
authornicolasconnault <nicolasconnault>
Wed, 5 Aug 2009 02:39:42 +0000 (02:39 +0000)
committernicolasconnault <nicolasconnault>
Wed, 5 Aug 2009 02:39:42 +0000 (02:39 +0000)
lib/deprecatedlib.php
lib/outputlib.php
lib/weblib.php
tag/index.php

index 198f9fd08656a441aa842724db785f044c65d52f..7b3b32d165d7f1c9c6d2328c81a21d47260684a1 100644 (file)
@@ -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)));
+}
+
index a524cbd7dfd5d9ed33c8d6d916c1e078a2085ed8..4bb480279adb613067fd5f65cbc300d17d57b0c3 100644 (file)
@@ -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
      *
index cb39dfa851cf0e727b3d0757d40859a985357101..b68a9b6907f4e14798ca92a910c5a2e346801ffc 100644 (file)
@@ -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 '<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
  *
index d93f58e25b519ad01b234ad191b0266d4637422f..1dbe56fd3289be3f7f587cc59d4dd05ecaa1f0c5 100644 (file)
@@ -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);