MDL-19756 Deprecated update_course_icon() and implemented a simple $OUTPUT->edit_button($moodleurl) method which uses $USER->editing

This commit is contained in:
nicolasconnault
2009-08-05 02:39:42 +00:00
parent c351150fca
commit cf13298081
4 changed files with 49 additions and 46 deletions
+25 -2
View 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)));
}
+23
View 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
*
-32
View 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
*
+1 -12
View 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);