From b453120768c5c59d1148b195983fe3e32dc6d494 Mon Sep 17 00:00:00 2001 From: nicolasconnault Date: Thu, 20 Aug 2009 08:40:19 +0000 Subject: [PATCH] MDL-19794 upgraded calls to print_table, print_single_button, print_user_picture, print_container* and notice_yesno --- course/category.php | 12 ++++++------ course/delete.php | 6 ++---- course/import/activities/mod.php | 3 ++- course/index.php | 16 +++++++++++----- course/lib.php | 16 +++++++++------- course/mod.php | 4 +++- course/pending.php | 11 ++++++----- course/report/stats/report.php | 7 ++++--- course/reset.php | 4 ++-- course/unenrol.php | 6 ++---- course/user.php | 4 ++-- 11 files changed, 49 insertions(+), 40 deletions(-) diff --git a/course/category.php b/course/category.php index 5d0df06568..2a6aa8a5c9 100644 --- a/course/category.php +++ b/course/category.php @@ -185,17 +185,17 @@ } if ($editingon && has_capability('moodle/category:manage', $context)) { - echo '
'; + echo $OUTPUT->container_start('buttons'); // Print button to update this category $options = array('id' => $category->id); - print_single_button($CFG->wwwroot.'/course/editcategory.php', $options, get_string('editcategorythis'), 'get'); + echo $OUTPUT->button(html_form::make_button($CFG->wwwroot.'/course/editcategory.php', $options, get_string('editcategorythis'), 'get')); // Print button for creating new categories $options = array('parent' => $category->id); - print_single_button($CFG->wwwroot.'/course/editcategory.php', $options, get_string('addsubcategory'), 'get'); + echo $OUTPUT->button(html_form::make_button($CFG->wwwroot.'/course/editcategory.php', $options, get_string('addsubcategory'), 'get')); - echo '
'; + echo $OUTPUT->container_end(); } /// Print out all the sub-categories @@ -432,14 +432,14 @@ $options['id'] = $category->id; $options['resort'] = 'name'; $options['sesskey'] = sesskey(); - print_single_button('category.php', $options, get_string('resortcoursesbyname'), 'get'); + echo $OUTPUT->button(html_form::make_button('category.php', $options, get_string('resortcoursesbyname'), 'get')); } if (has_capability('moodle/course:create', $context)) { /// Print button to create a new course unset($options); $options['category'] = $category->id; - print_single_button('edit.php', $options, get_string('addnewcourse'), 'get'); + echo $OUTPUT->button(html_form::make_button('edit.php', $options, get_string('addnewcourse'), 'get')); } if (!empty($CFG->enablecourserequests) && $category->id == $CFG->enablecourserequests) { diff --git a/course/delete.php b/course/delete.php index 843fe3a6cc..b513b144c9 100644 --- a/course/delete.php +++ b/course/delete.php @@ -41,10 +41,8 @@ print_header("$site->shortname: $strdeletecheck", $site->fullname, $navigation); - notice_yesno("$strdeletecoursecheck

" . format_string($course->fullname) . - " (" . format_string($course->shortname) . ")", - "delete.php?id=$course->id&delete=".md5($course->timemodified)."&sesskey=".sesskey(), - "category.php?id=$course->category"); + $message = "$strdeletecoursecheck

" . format_string($course->fullname) . " (" . format_string($course->shortname) . ")"; + echo $OUTPUT->confirm($message, "delete.php?id=$course->id&delete=".md5($course->timemodified), "category.php?id=$course->category"); echo $OUTPUT->footer(); exit; diff --git a/course/import/activities/mod.php b/course/import/activities/mod.php index 36d5cc1386..805fe6b2fc 100644 --- a/course/import/activities/mod.php +++ b/course/import/activities/mod.php @@ -80,6 +80,7 @@ if (!empty($fromcoursesearch) && !empty($creator)) { $totalcount = 0; $courses = get_courses_search(explode(" ",$fromcoursesearch),"fullname ASC",$page,50,$totalcount); + $table = new html_table(); if (is_array($courses) and count($courses) > 0) { $table->data[] = array(''.get_string('searchresults').'','',''); foreach ($courses as $scourse) { @@ -94,6 +95,6 @@ } } if (!empty($table)) { - print_table($table); + echo $OUTPUT->table($table); } ?> diff --git a/course/index.php b/course/index.php index da44a214b4..e98d1b2536 100644 --- a/course/index.php +++ b/course/index.php @@ -76,15 +76,17 @@ echo $OUTPUT->box_end(); } - echo '
'; + echo $OUTPUT->container_start('buttons'); if (has_capability('moodle/course:create', $systemcontext)) { /// Print link to create a new course /// Get the 1st available category $options = array('category' => $CFG->defaultrequestcategory); - print_single_button('edit.php', $options, get_string('addnewcourse'), 'get'); + $form = html_form::make_button('edit.php', $options, get_string('addnewcourse')); + $form->method = 'get'; + echo $OUTPUT->button($form); } print_course_request_buttons($systemcontext); - echo '
'; + echo $OUTPUT->container_end(); echo $OUTPUT->footer(); exit; } @@ -243,14 +245,18 @@ // print create course link to first category $options = array(); $options = array('category' => $CFG->defaultrequestcategory); - print_single_button('edit.php', $options, get_string('addnewcourse'), 'get'); + $form = html_form::make_button('edit.php', $options, get_string('addnewcourse')); + $form->method = 'get'; + echo $OUTPUT->button($form); } // Print button for creating new categories if (has_capability('moodle/category:manage', $systemcontext)) { $options = array(); $options['parent'] = 0; - print_single_button('editcategory.php', $options, get_string('addnewcategory'), 'get'); + $form = html_form::make_button('editcategory.php', $options, get_string('addnewcategory')); + $form->method = 'get'; + echo $OUTPUT->button($form); } print_course_request_buttons($systemcontext); diff --git a/course/lib.php b/course/lib.php index 8b15ab8115..f6370139ae 100644 --- a/course/lib.php +++ b/course/lib.php @@ -2003,17 +2003,19 @@ function print_category_info($category, $depth, $showcourses = false) { * @param object $systemcontext the system context. */ function print_course_request_buttons($systemcontext) { - global $CFG, $DB; + global $CFG, $DB, $OUTPUT; if (empty($CFG->enablecourserequests)) { return; } if (isloggedin() && !isguestuser() && !has_capability('moodle/course:create', $systemcontext) && has_capability('moodle/course:request', $systemcontext)) { /// Print a button to request a new course - print_single_button('request.php', NULL, get_string('requestcourse'), 'get'); + echo $OUTPUT->button(html_form::make_button('request.php', NULL, get_string('requestcourse'), 'get')); } /// Print a button to manage pending requests if (has_capability('moodle/site:approvecourse', $systemcontext)) { - print_single_button('pending.php', NULL, get_string('coursespending'), 'get', '_self', false, '', !$DB->record_exists('course_request', array())); + $form = html_form::make_button('pending.php', NULL, get_string('coursespending'), 'get'); + $form->button->disabled = !$DB->record_exists('course_request', array()); + echo $OUTPUT->button($form); } } @@ -2036,7 +2038,7 @@ function can_edit_in_category($categoryid = 0) { * to see it. */ function update_category_button($categoryid = 0) { - global $CFG, $PAGE; + global $CFG, $PAGE, $OUTPUT; // Check permissions. if (!can_edit_in_category($categoryid)) { @@ -2060,7 +2062,7 @@ function update_category_button($categoryid = 0) { } else { $page = 'index.php'; } - return print_single_button($CFG->wwwroot . '/course/' . $page, $options, $label, 'get', '', true); + return $OUTPUT->button(html_form::make_button($CFG->wwwroot . '/course/' . $page, $options, $label, 'get')); } /** @@ -2106,7 +2108,7 @@ function print_courses($category) { $options = array(); $options['category'] = $category->id; echo '
'; - print_single_button($CFG->wwwroot.'/course/edit.php', $options, get_string("addnewcourse")); + echo $OUTPUT->button(html_form::make_button($CFG->wwwroot.'/course/edit.php', $options, get_string("addnewcourse"))); echo '
'; } } @@ -2278,7 +2280,7 @@ function print_my_moodle() { echo "
"; print_course_search("", false, "short"); echo ""; - print_single_button("$CFG->wwwroot/course/index.php", NULL, get_string("fulllistofcourses"), "get"); + echo $OUTPUT->button(html_form::make_button("$CFG->wwwroot/course/index.php", NULL, get_string("fulllistofcourses"), "get")); echo "
\n"; } diff --git a/course/mod.php b/course/mod.php index efb582e8e8..5a4c73a657 100644 --- a/course/mod.php +++ b/course/mod.php @@ -69,7 +69,9 @@ // print_simple_box_start('center', '60%', '#FFAAAA', 20, 'noticebox'); echo $OUTPUT->box_start('noticebox'); - notice_yesno($strdeletecheckfull, 'mod.php', $return, $optionsyes, $optionsno, 'post', 'get'); + $formcontinue = html_form::make_button('mod.php', $optionsyes, get_string('yes')); + $formcancel = html_form::make_button($return, $optionsno, get_string('no'), 'get'); + echo $OUTPUT->confirm($strdeletecheckfull, $formcontinue, $formcancel); echo $OUTPUT->box_end(); echo $OUTPUT->footer(); diff --git a/course/pending.php b/course/pending.php index 4162a8204f..de6fc3be9b 100644 --- a/course/pending.php +++ b/course/pending.php @@ -161,7 +161,8 @@ echo $OUTPUT->heading(get_string('coursespending')); /// Build a table of all the requests. - $table->class = 'pendingcourserequests generaltable'; + $table = new html_table(); + $table->add_class('pendingcourserequests generaltable'); $table->align = array('center', 'center', 'center', 'center', 'center', 'center', 'center'); $table->head = array(' ', get_string('shortname'), get_string('fullname'), get_string('requestedby'), get_string('summary'), get_string('requestreason'), get_string('action')); @@ -191,15 +192,15 @@ $row[] = fullname($requester); $row[] = format_string($course->summary); $row[] = format_string($course->reason); - $row[] = print_single_button($baseurl, array('approve' => $course->id, 'sesskey' => sesskey()), get_string('approve'), 'get', '', true) . - print_single_button($baseurl, array('reject' => $course->id), get_string('rejectdots'), 'get', '', true); + $row[] = $OUTPUT->button(html_form::make_button($baseurl, array('approve' => $course->id, 'sesskey' => sesskey()), get_string('approve'), 'get')) . + $OUTPUT->button(html_form::make_button($baseurl, array('reject' => $course->id), get_string('rejectdots'), 'get')); /// Add the row to the table. $table->data[] = $row; } /// Display the table. - print_table($table); + echo $OUTPUT->table($table); /// Message about name collisions, if necessary. if (!empty($collision)) { @@ -208,6 +209,6 @@ } /// Finish off the page. - print_single_button($CFG->wwwroot . '/course/index.php', array(), get_string('backtocourselisting')); + echo $OUTPUT->button(html_form::make_button($CFG->wwwroot . '/course/index.php', array(), get_string('backtocourselisting'))); echo $OUTPUT->footer(); ?> diff --git a/course/report/stats/report.php b/course/report/stats/report.php index 6ec63ca0b7..53a9a2cecd 100644 --- a/course/report/stats/report.php +++ b/course/report/stats/report.php @@ -21,6 +21,7 @@ print_error('nostatstodisplay', '', $CFG->wwwroot.'/course/view.php?id='.$course->id); } + $table = new html_table(); $table->width = 'auto'; if ($mode == STATS_MODE_DETAILED) { @@ -66,7 +67,7 @@ .'
'."\n" .''."\n"; - print_table($table); + echo $OUTPUT->table($table); echo '
'; echo ''; @@ -121,7 +122,7 @@ } } - $table = new StdClass; + $table = new html_table(); $table->align = array('left','center','center','center'); $param->table = str_replace('user_','',$param->table); switch ($param->table) { @@ -220,7 +221,7 @@ $lastrecord[] = $lastlink; $table->data[] = $lastrecord; } - print_table($table); + echo $OUTPUT->table($table); } } diff --git a/course/reset.php b/course/reset.php index 460252e09b..15b68184dc 100755 --- a/course/reset.php +++ b/course/reset.php @@ -59,13 +59,13 @@ if ($mform->is_cancelled()) { $data[] = $line; } - $table = new object(); + $table = new html_table(); $table->head = array(get_string('resetcomponent'), get_string('resettask'), get_string('resetstatus')); $table->size = array('20%', '40%', '40%'); $table->align = array('left', 'left', 'left'); $table->width = '80%'; $table->data = $data; - print_table($table); + echo $OUTPUT->table($table); echo $OUTPUT->continue_button('view.php?id='.$course->id); // Back to course page echo $OUTPUT->footer(); diff --git a/course/unenrol.php b/course/unenrol.php index 9a095553ed..cd1070fa18 100644 --- a/course/unenrol.php +++ b/course/unenrol.php @@ -94,12 +94,10 @@ print_error('nousers'); } $strunenrolsure = get_string('unenrolsure', '', fullname($user, true)); - notice_yesno($strunenrolsure, "unenrol.php?id=$id&user=$user->id&confirm=yes&sesskey=".sesskey(), - $_SERVER['HTTP_REFERER']); + echo $OUTPUT->confirm($strunenrolsure, "unenrol.php?id=$id&user=$user->id&confirm=yes", $PAGE->url); } else { $strunenrolsure = get_string('unenrolsure', '', get_string("yourself")); - notice_yesno($strunenrolsure, "unenrol.php?id=$id&confirm=yes&sesskey=".sesskey(), - $_SERVER['HTTP_REFERER']); + echo $OUTPUT->confirm($strunenrolsure, "unenrol.php?id=$id&confirm=yes", $PAGE->url); } echo $OUTPUT->footer(); diff --git a/course/user.php b/course/user.php index 3f7d265578..2f3e8e3103 100644 --- a/course/user.php +++ b/course/user.php @@ -211,7 +211,7 @@ // What the heck is this about? -- MD $stats = stats_fix_zeros($stats,$param->timeafter,$param->table,(!empty($param->line2)),(!empty($param->line3))); - $table = new object(); + $table = new html_table(); $table->align = array('left','center','center','center'); $param->table = str_replace('user_','',$param->table); switch ($param->table) { @@ -230,7 +230,7 @@ $a[] = $stat->line3; $table->data[] = $a; } - print_table($table); + echo $OUTPUT->table($table); break; case "outline" : -- 2.39.5