From: nicolasconnault Date: Tue, 18 Aug 2009 05:20:12 +0000 (+0000) Subject: MDL-19799 Upgraded calls to helpbutton, print_simple_box* and notify X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=aa9a68674050e9481709bb202e8d7738e00781c0;p=moodle.git MDL-19799 Upgraded calls to helpbutton, print_simple_box* and notify --- diff --git a/error/index.php b/error/index.php index 629d5d8b93..450f4b54b7 100644 --- a/error/index.php +++ b/error/index.php @@ -47,7 +47,7 @@ print_header($site->fullname .':Error', $site->fullname .': Error 404', 'Error 404 - File not Found', ''); - print_simple_box('

'. get_string('pagenotexist', 'error'). '
'.s($requesturi).'

', 'center'); + echo $OUTPUT->box(get_string('pagenotexist', 'error'). '
'.s($requesturi), 'generalbox boxaligncenter'); if (isloggedin()) { ?> @@ -61,7 +61,7 @@ wwwroot); + echo $OUTPUT->continue_button($CFG->wwwroot); } echo $OUTPUT->footer(); ?> diff --git a/files/draftfiles.php b/files/draftfiles.php index 9b4db09b27..9f9fe292de 100644 --- a/files/draftfiles.php +++ b/files/draftfiles.php @@ -99,7 +99,7 @@ if (isset($_FILES['newfile']) and data_submitted() and confirm_sesskey()) { if ($delete !== '' and $file = $fs->get_file($contextid, $filearea, $itemid, $filepath, $delete)) { if (!data_submitted() or !confirm_sesskey()) { print_header(); - notify(get_string('deletecheckwarning').': '.s($file->get_filepath().$file->get_filename())); + echo $OUTPUT->notification(get_string('deletecheckwarning').': '.s($file->get_filepath().$file->get_filename())); $optionsno = array('itemid'=>$itemid, 'filepath'=>$filepath, 'subdirs'=>$subdirs); $optionsyes = array('itemid'=>$itemid, 'filepath'=>$filepath, 'delete'=>$delete, 'sesskey'=>sesskey(), 'subdirs'=>$subdirs); notice_yesno (get_string('deletecheckfiles'), 'draftfiles.php', 'draftfiles.php', $optionsyes, $optionsno, 'post', 'get'); @@ -120,7 +120,7 @@ if ($delete !== '' and $file = $fs->get_file($contextid, $filearea, $itemid, $fi print_header(); if ($notice !== '') { - notify($notice); + echo $OUTPUT->notification($notice); } echo '
'; diff --git a/files/index.php b/files/index.php index a3eba99b5e..913b44449d 100644 --- a/files/index.php +++ b/files/index.php @@ -109,7 +109,7 @@ if ($file_info and $file_info->is_directory() and $file_info->is_writable() and if ($file_info and $delete) { if (!data_submitted() or !confirm_sesskey()) { print_header(); - notify(get_string('deletecheckwarning').': '.$file_info->get_visible_name()); + echo $OUTPUT->notification(get_string('deletecheckwarning').': '.$file_info->get_visible_name()); $parent_info = $file_info->get_parent(); $optionsno = $parent_info->get_params(); @@ -136,7 +136,7 @@ if ($file_info and $delete) { html_header($context, $file_info); if ($error !== '') { - notify($error); + echo $OUTPUT->notification($error); } displaydir($file_info); diff --git a/help.php b/help.php index 36d9c22be0..4fc66f050c 100644 --- a/help.php +++ b/help.php @@ -94,13 +94,13 @@ if(preg_match('~(##emoticons_html##)~', $output, $matches)) { // Do the main output. print_header($title); -print_simple_box_start(); +echo $OUTPUT->box_start(); print $output; -print_simple_box_end(); +echo $OUTPUT->box_end(); // Display an error if necessary. if (!$helpfound) { - notify('Help file "'. $file .'" could not be found!'); + echo $OUTPUT->notification('Help file "'. $file .'" could not be found!'); } // End of page. diff --git a/lib/accesslib.php b/lib/accesslib.php index 25cb70f018..88bf5690e1 100755 --- a/lib/accesslib.php +++ b/lib/accesslib.php @@ -3269,7 +3269,7 @@ function reset_role_capabilities($roleid) { * @return boolean true if success, exception in case of any problems */ function update_capabilities($component='moodle') { - global $DB; + global $DB, $OUTPUT; $storedcaps = array(); @@ -3332,7 +3332,7 @@ function update_capabilities($component='moodle') { //assign_capability will update rather than insert if capability exists if (!assign_capability($capname, $rolecapability->permission, $rolecapability->roleid, $rolecapability->contextid, true)){ - notify('Could not clone capabilities for '.$capname); + echo $OUTPUT->notification('Could not clone capabilities for '.$capname); } } } @@ -3341,7 +3341,7 @@ function update_capabilities($component='moodle') { // we ignore legacy key if we have cloned permissions } else if (isset($capdef['legacy']) && is_array($capdef['legacy']) && !assign_legacy_capabilities($capname, $capdef['legacy'])) { - notify('Could not assign legacy capabilities for '.$capname); + echo $OUTPUT->notification('Could not assign legacy capabilities for '.$capname); } } // Are there any capabilities that have been removed from the file diff --git a/lib/completionlib.php b/lib/completionlib.php index 2407a82eb0..715dce44b5 100644 --- a/lib/completionlib.php +++ b/lib/completionlib.php @@ -166,10 +166,10 @@ class completion_info { * @return void */ public function print_help_icon() { - global $PAGE; + global $PAGE, $OUTPUT; if ($this->is_enabled() && !$PAGE->user_is_editing() && isloggedin() && !isguestuser()) { echo ''.get_string('yourprogress','completion').' '; - helpbutton('completionicons',get_string('completionicons','completion'),'completion'); + echo $OUTPUT->help_icon(moodle_help_icon::make('completionicons',get_string('completionicons','completion'),'completion')); echo ''; } } diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 494dc3c2c5..24d91932f5 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -20,7 +20,7 @@ // before any action that may take longer time to finish. function xmldb_main_upgrade($oldversion) { - global $CFG, $THEME, $USER, $DB; + global $CFG, $THEME, $USER, $DB, $OUTPUT; require_once($CFG->libdir.'/db/upgradelib.php'); // Core Upgrade-related functions @@ -113,7 +113,7 @@ function xmldb_main_upgrade($oldversion) { if ($guestroles = get_roles_with_capability('moodle/legacy:guest', CAP_ALLOW)) { if (isset($guestroles[$role->id])) { set_config('defaultuserroleid', null); - notify('Guest role removed from "Default role for all users" setting, please select another role.', 'notifysuccess'); + echo $OUTPUT->notification('Guest role removed from "Default role for all users" setting, please select another role.', 'notifysuccess'); } } } else { @@ -125,7 +125,7 @@ function xmldb_main_upgrade($oldversion) { } if ($result && $oldversion < 2008051201) { - notify('Increasing size of user idnumber field, this may take a while...', 'notifysuccess'); + echo $OUTPUT->notification('Increasing size of user idnumber field, this may take a while...', 'notifysuccess'); upgrade_set_timeout(60*20); // this may take a while /// Under MySQL and Postgres... detect old NULL contents and change them by correct empty string. MDL-14859 @@ -2141,7 +2141,7 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL"); if ($result && $oldversion < 2009051200) { /// Let's check the status of mandatory mnet_host records, fixing them /// and moving "orphan" users to default localhost record. MDL-16879 - notify('Fixing mnet records, this may take a while...', 'notifysuccess'); + echo $OUTPUT->notification('Fixing mnet records, this may take a while...', 'notifysuccess'); upgrade_fix_incorrect_mnethostids(); /// Main savepoint reached diff --git a/lib/db/upgradelib.php b/lib/db/upgradelib.php index 2b1152361b..81ad5a6887 100644 --- a/lib/db/upgradelib.php +++ b/lib/db/upgradelib.php @@ -83,7 +83,7 @@ function upgrade_migrate_files_courses() { * Internal function - do not use directly */ function upgrade_migrate_files_course($context, $path, $delete) { - global $CFG; + global $CFG, $OUTPUT; $fullpathname = $CFG->dataroot.'/'.$context->instanceid.$path; if (!file_exists($fullpathname)) { @@ -114,7 +114,7 @@ function upgrade_migrate_files_course($context, $path, $delete) { if ($item->isFile()) { if (!$item->isReadable()) { - notify(" File not readable, skipping: ".$fullpathname.$item->getFilename()); + echo $OUTPUT->notification(" File not readable, skipping: ".$fullpathname.$item->getFilename()); continue; } @@ -168,7 +168,7 @@ function upgrade_migrate_files_course($context, $path, $delete) { * Unfortunately this function uses core file related functions - it might be necessary to tweak it if something changes there :-( */ function upgrade_migrate_files_blog() { - global $DB, $CFG; + global $DB, $CFG, $OUTPUT; $fs = get_file_storage(); @@ -199,7 +199,7 @@ function upgrade_migrate_files_blog() { } if (!is_readable($pathname)) { - notify(" File not readable, skipping: ".$pathname); + echo $OUTPUT->notification(" File not readable, skipping: ".$pathname); continue; } diff --git a/lib/environmentlib.php b/lib/environmentlib.php index 38bd06c5a5..80ea1b89ed 100644 --- a/lib/environmentlib.php +++ b/lib/environmentlib.php @@ -317,7 +317,7 @@ function print_moodle_environment($result, $environment_results) { /// Finally, if any error has happened, print the summary box if (!$result) { - print_simple_box($strenvironmenterrortodo, 'center', '', '', '', 'environmentbox errorbox'); + echo $OUTPUT->box($strenvironmenterrortodo, 'environmentbox errorbox'); } } diff --git a/lib/form/editorhelp.php b/lib/form/editorhelp.php index 07fbf29ab4..9eafa7ae2a 100644 --- a/lib/form/editorhelp.php +++ b/lib/form/editorhelp.php @@ -55,7 +55,7 @@ for ($i=1; ; $i++){ } print_header(); -print_simple_box_start('center', '96%'); +echo $OUTPUT->box_start(); echo $OUTPUT->heading(get_string('editorhelptopics')); @@ -64,7 +64,7 @@ foreach ($topics as $i => $topic){ echo('
  • '.$topics[$i].'
  • '); } echo ''; -print_simple_box_end(); +echo $OUTPUT->box_end(); // End of page. echo $OUTPUT->close_window_button(); global $CFG; diff --git a/lib/form/warning.php b/lib/form/warning.php index ad9d3a5e2f..48e373c1f3 100644 --- a/lib/form/warning.php +++ b/lib/form/warning.php @@ -49,7 +49,8 @@ class MoodleQuickForm_warning extends HTML_QuickForm_static{ } function toHtml() { - return notify($this->_text, $this->_class, 'center', true); + global $OUTPUT; + return $OUTPUT->notification($this->_text, $this->_class); } /** diff --git a/lib/gdlib.php b/lib/gdlib.php index db8a2c2e6e..e749a03a21 100644 --- a/lib/gdlib.php +++ b/lib/gdlib.php @@ -175,7 +175,7 @@ function save_profile_image($id, $userform, $dir='user') { * @return boolean */ function process_profile_image($originalfile, $destination) { - global $CFG; + global $CFG, $OUTPUT; if(!(is_file($originalfile) && is_dir($destination))) { return false; @@ -263,7 +263,7 @@ function process_profile_image($originalfile, $destination) { return 1; } } else { - notify('PHP has not been configured to support JPEG images. Please correct this.'); + echo $OUTPUT->notification('PHP has not been configured to support JPEG images. Please correct this.'); } return 0; } @@ -278,7 +278,7 @@ function process_profile_image($originalfile, $destination) { * @return boolean */ function upgrade_profile_image($id, $dir='users') { - global $CFG; + global $CFG, $OUTPUT; $im = ImageCreateFromJPEG($CFG->dataroot .'/'. $dir .'/'. $id .'/f1.jpg'); @@ -333,7 +333,7 @@ function upgrade_profile_image($id, $dir='users') { return 1; } } else { - notify('PHP has not been configured to support JPEG images. Please correct this.'); + echo $OUTPUT->notification('PHP has not been configured to support JPEG images. Please correct this.'); } return 0; } diff --git a/lib/gradelib.php b/lib/gradelib.php index db3d001e80..1d67131772 100644 --- a/lib/gradelib.php +++ b/lib/gradelib.php @@ -1112,13 +1112,13 @@ function grade_update_mod_grades($modinstance, $userid=0) { * @param bool $showfeedback */ function remove_grade_letters($context, $showfeedback) { - global $DB; + global $DB, $OUTPUT; $strdeleted = get_string('deleted'); $DB->delete_records('grade_letters', array('contextid'=>$context->id)); if ($showfeedback) { - notify($strdeleted.' - '.get_string('letters', 'grades')); + echo $OUTPUT->notification($strdeleted.' - '.get_string('letters', 'grades')); } } /** @@ -1129,14 +1129,14 @@ function remove_grade_letters($context, $showfeedback) { * @param bool $showfeedback print feedback */ function remove_course_grades($courseid, $showfeedback) { - global $DB; + global $DB, $OUTPUT; $strdeleted = get_string('deleted'); $course_category = grade_category::fetch_course_category($courseid); $course_category->delete('coursedelete'); if ($showfeedback) { - notify($strdeleted.' - '.get_string('grades', 'grades').', '.get_string('items', 'grades').', '.get_string('categories', 'grades')); + echo $OUTPUT->notification($strdeleted.' - '.get_string('grades', 'grades').', '.get_string('items', 'grades').', '.get_string('categories', 'grades')); } if ($outcomes = grade_outcome::fetch_all(array('courseid'=>$courseid))) { @@ -1146,7 +1146,7 @@ function remove_course_grades($courseid, $showfeedback) { } $DB->delete_records('grade_outcomes_courses', array('courseid'=>$courseid)); if ($showfeedback) { - notify($strdeleted.' - '.get_string('outcomes', 'grades')); + echo $OUTPUT->notification($strdeleted.' - '.get_string('outcomes', 'grades')); } if ($scales = grade_scale::fetch_all(array('courseid'=>$courseid))) { @@ -1155,12 +1155,12 @@ function remove_course_grades($courseid, $showfeedback) { } } if ($showfeedback) { - notify($strdeleted.' - '.get_string('scales')); + echo $OUTPUT->notification($strdeleted.' - '.get_string('scales')); } $DB->delete_records('grade_settings', array('courseid'=>$courseid)); if ($showfeedback) { - notify($strdeleted.' - '.get_string('settings', 'grades')); + echo $OUTPUT->notification($strdeleted.' - '.get_string('settings', 'grades')); } } diff --git a/lib/moodlelib.php b/lib/moodlelib.php index a1c2f6f9a1..d385ac0242 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -2202,7 +2202,7 @@ function require_login($courseorid=0, $autologinguest=true, $cm=null, $setwantsu if (empty($USER->access['rsw'][$COURSE->context->path])) { // Normal guest notice(get_string('guestsnotallowed', '', format_string($COURSE->fullname)), get_login_url()); } else { - notify(get_string('guestsnotallowed', '', format_string($COURSE->fullname))); + echo $OUTPUT->notification(get_string('guestsnotallowed', '', format_string($COURSE->fullname))); echo '
    '.switchroles_form($COURSE->id).'
    '; echo $OUTPUT->footer(); exit; @@ -3403,7 +3403,7 @@ function guest_user() { * @return user|flase A {@link $USER} object or false if error */ function authenticate_user_login($username, $password) { - global $CFG, $DB; + global $CFG, $DB, $OUTPUT; $authsenabled = get_enabled_auth_plugins(); @@ -3469,7 +3469,7 @@ function authenticate_user_login($username, $password) { include_once($CFG->dirroot .'/sso/'. $CFG->sso .'/lib.php'); if (function_exists('sso_user_login')) { if (!sso_user_login($username, $password)) { // Perform the signon process - notify('Second sign-on failed'); + echo $OUTPUT->notification('Second sign-on failed'); } } } @@ -3813,7 +3813,7 @@ function set_login_session_preferences() { * failed, but you have no way of knowing which. */ function delete_course($courseorid, $showfeedback = true) { - global $CFG, $DB; + global $CFG, $DB, $OUTPUT; $result = true; if (is_object($courseorid)) { @@ -3833,7 +3833,7 @@ function delete_course($courseorid, $showfeedback = true) { if (!remove_course_contents($courseid, $showfeedback)) { if ($showfeedback) { - notify("An error occurred while deleting some of the course contents."); + echo $OUTPUT->notification("An error occurred while deleting some of the course contents."); } $result = false; } @@ -3843,14 +3843,14 @@ function delete_course($courseorid, $showfeedback = true) { /// Delete all roles and overiddes in the course context if (!delete_context(CONTEXT_COURSE, $courseid)) { if ($showfeedback) { - notify("An error occurred while deleting the main course context."); + echo $OUTPUT->notification("An error occurred while deleting the main course context."); } $result = false; } if (!fulldelete($CFG->dataroot.'/'.$courseid)) { if ($showfeedback) { - notify("An error occurred while deleting the course files."); + echo $OUTPUT->notification("An error occurred while deleting the course files."); } $result = false; } @@ -3876,7 +3876,7 @@ function delete_course($courseorid, $showfeedback = true) { * failed, but you have no way of knowing which. */ function remove_course_contents($courseid, $showfeedback=true) { - global $CFG, $DB; + global $CFG, $DB, $OUTPUT; require_once($CFG->libdir.'/questionlib.php'); require_once($CFG->libdir.'/gradelib.php'); @@ -3898,7 +3898,7 @@ function remove_course_contents($courseid, $showfeedback=true) { include_once($formatlib); if (function_exists($formatdelete)) { if ($showfeedback) { - notify($strdeleted.' '.$format); + echo $OUTPUT->notification($strdeleted.' '.$format); } $formatdelete($course->id); } @@ -3927,7 +3927,7 @@ function remove_course_contents($courseid, $showfeedback=true) { $count++; } else { - notify('Could not delete '. $modname .' instance '. $instance->id .' ('. format_string($instance->name) .')'); + echo $OUTPUT->notification('Could not delete '. $modname .' instance '. $instance->id .' ('. format_string($instance->name) .')'); $result = false; } if ($cm) { @@ -3938,7 +3938,7 @@ function remove_course_contents($courseid, $showfeedback=true) { } } } else { - notify('Function '.$moddelete.'() doesn\'t exist!'); + echo $OUTPUT->notification('Function '.$moddelete.'() doesn\'t exist!'); $result = false; } @@ -3947,7 +3947,7 @@ function remove_course_contents($courseid, $showfeedback=true) { } } if ($showfeedback) { - notify($strdeleted .' '. $count .' x '. $modname); + echo $OUTPUT->notification($strdeleted .' '. $count .' x '. $modname); } } } else { @@ -3978,7 +3978,7 @@ function remove_course_contents($courseid, $showfeedback=true) { foreach ($tablestoclear as $table => $col) { if ($DB->delete_records($table, array($col=>$course->id))) { if ($showfeedback) { - notify($strdeleted . ' ' . $table); + echo $OUTPUT->notification($strdeleted . ' ' . $table); } } else { $result = false; @@ -3992,7 +3992,7 @@ function remove_course_contents($courseid, $showfeedback=true) { $DB->delete_records("course_meta", array("parent_course"=>$course->id)); sync_metacourse($course->id); // have to do it here so the enrolments get nuked. sync_metacourses won't find it without the id. if ($showfeedback) { - notify("$strdeleted course_meta"); + echo $OUTPUT->notification("$strdeleted course_meta"); } } else { if ($parents = $DB->get_records("course_meta", array("child_course"=>$course->id))) { @@ -4000,7 +4000,7 @@ function remove_course_contents($courseid, $showfeedback=true) { remove_from_metacourse($parent->parent_course,$parent->child_course); // this will do the unenrolments as well. } if ($showfeedback) { - notify("$strdeleted course_meta"); + echo $OUTPUT->notification("$strdeleted course_meta"); } } } @@ -5038,11 +5038,11 @@ function get_file_packer($mimetype='application/zip') { * @return string|false Returns full path to directory if successful, false if not */ function make_user_directory($userid, $test=false) { - global $CFG; + global $CFG, $OUTPUT; if (is_bool($userid) || $userid < 0 || !preg_match('/^[0-9]{1,10}$/', $userid) || $userid > 2147483647) { if (!$test) { - notify("Given userid was not a valid integer! (" . gettype($userid) . " $userid)"); + echo $OUTPUT->notification("Given userid was not a valid integer! (" . gettype($userid) . " $userid)"); } return false; } @@ -5067,7 +5067,7 @@ function make_user_directory($userid, $test=false) { * @return array An associative array: userid=>array(basedir => $basedir, userfolder => $userfolder) */ function get_user_directories($only_non_empty=true, $legacy=false) { - global $CFG; + global $CFG, $OUTPUT; $rootdir = $CFG->dataroot."/user"; @@ -5084,7 +5084,7 @@ function get_user_directories($only_non_empty=true, $legacy=false) { $dirlist[$userid] = array('basedir' => $rootdir, 'userfolder' => $userid); } } else { - notify("no directories found under $rootdir"); + echo $OUTPUT->notification("no directories found under $rootdir"); } } else { if ($grouplist =get_directory_list($rootdir, '', true, true, false)) { // directories will be in the form 0, 1000, 2000 etc... @@ -5098,7 +5098,7 @@ function get_user_directories($only_non_empty=true, $legacy=false) { } } } else { - notify("$rootdir does not exist!"); + echo $OUTPUT->notification("$rootdir does not exist!"); return false; } return $dirlist; @@ -5231,7 +5231,7 @@ function get_max_upload_sizes($sitebytes=0, $coursebytes=0, $modulebytes=0) { * @return bool|string */ function print_file_upload_error($filearray = '', $returnerror = false) { - + global $OUTPUT; if ($filearray == '' or !isset($filearray['error'])) { if (empty($_FILES)) return false; @@ -5273,7 +5273,7 @@ function print_file_upload_error($filearray = '', $returnerror = false) { if ($returnerror) { return $errmessage; } else { - notify($errmessage); + echo $OUTPUT->notification($errmessage); return true; } @@ -7266,7 +7266,7 @@ function check_gd_version() { * @return bool */ function moodle_needs_upgrading() { - global $CFG, $DB; + global $CFG, $DB, $OUTPUT; $version = null; include_once($CFG->dirroot .'/version.php'); # defines $version and upgrades @@ -7278,7 +7278,7 @@ function moodle_needs_upgrading() { foreach ($mods as $mod => $fullmod) { $module = new object(); if (!is_readable($fullmod .'/version.php')) { - notify('Module "'. $mod .'" is not readable - check permissions'); + echo $OUTPUT->notification('Module "'. $mod .'" is not readable - check permissions'); continue; } include_once($fullmod .'/version.php'); # defines $module with version etc @@ -7348,7 +7348,7 @@ function upgrade_set_timeout($max_execution_time=300) { * @uses HOURSECS */ function notify_login_failures() { - global $CFG, $DB; + global $CFG, $DB, $OUTPUT; $recip = get_users_from_config($CFG->notifyloginfailures, 'moodle/site:config'); diff --git a/lib/outputcomponents.php b/lib/outputcomponents.php index 2a9364fceb..48a4751370 100644 --- a/lib/outputcomponents.php +++ b/lib/outputcomponents.php @@ -1963,6 +1963,21 @@ class moodle_help_icon extends labelled_html_component { parent::prepare(); } + /** + * This is a shortcut for creating a help_icon with only the 2 required params + * @param string $page The keyword that defines a help page + * @param string $text A descriptive text + * @return moodle_help_icon A moodle_help_icon object with the two common fields initialised. + */ + public static function make($page, $text, $module='moodle', $linktext=false) { + $helpicon = new moodle_help_icon(); + $helpicon->page = $page; + $helpicon->text = $text; + $helpicon->module = $module; + $helpicon->linktext = $linktext; + return $helpicon; + } + public static function make_scale_menu($courseid, $scale) { $helpbutton = new moodle_help_icon(); $strscales = get_string('scales'); diff --git a/lib/portfolio/exporter.php b/lib/portfolio/exporter.php index 657d727a8b..cc76170540 100644 --- a/lib/portfolio/exporter.php +++ b/lib/portfolio/exporter.php @@ -333,9 +333,9 @@ class portfolio_exporter { return true; } else { $this->print_header('configexport'); - print_simple_box_start(); + echo $OUTPUT->box_start(); $mform->display(); - print_simple_box_end(); + echo $OUTPUT->box_end(); echo $OUTPUT->footer(); return false;; } @@ -382,7 +382,7 @@ class portfolio_exporter { $yesurl = $CFG->wwwroot . '/portfolio/add.php?stage=' . PORTFOLIO_STAGE_QUEUEORWAIT; $nourl = $CFG->wwwroot . '/portfolio/add.php?cancel=1'; $this->print_header('confirmexport'); - print_simple_box_start(); + echo $OUTPUT->box_start(); echo $OUTPUT->heading(get_string('confirmsummary', 'portfolio'), 4); $mainsummary = array(); if (!$this->instance->get_export_config('hideformat')) { @@ -417,7 +417,7 @@ class portfolio_exporter { } print_table($table); notice_yesno($strconfirm, $yesurl, $nourl); - print_simple_box_end(); + echo $OUTPUT->box_end(); echo $OUTPUT->footer(); return false; } @@ -587,9 +587,9 @@ class portfolio_exporter { return; } - print_simple_box_start(); + echo $OUTPUT->box_start(); echo $this->caller->heading_summary(); - print_simple_box_end(); + echo $OUTPUT->box_end(); } /** @@ -791,8 +791,8 @@ class portfolio_exporter { global $CFG, $OUTPUT; $title = get_string('exportexpired', 'portfolio'); print_header($title, $title, build_navigation(get_string('exportexpired', 'portfolio'))); - notify(get_string('exportexpireddesc', 'portfolio')); - print_continue($CFG->wwwroot); + echo $OUTPUT->notification(get_string('exportexpireddesc', 'portfolio')); + echo $OUTPUT->continue_button($CFG->wwwroot); echo $OUTPUT->footer(); exit; } diff --git a/lib/portfoliolib.php b/lib/portfoliolib.php index e615e0db70..9e7117c804 100644 --- a/lib/portfoliolib.php +++ b/lib/portfoliolib.php @@ -737,6 +737,7 @@ function portfolio_instance_sanity_check($instances=null) { * */ function portfolio_report_insane($insane, $instances=false, $return=false) { + global $OUTPUT; if (empty($insane)) { return; } @@ -751,7 +752,7 @@ function portfolio_report_insane($insane, $instances=false, $return=false) { $headerstr = get_string('somepluginsdisabled', 'portfolio'); } - $output = notify($headerstr, 'notifyproblem', 'center', true); + $output = $OUTPUT->notification($headerstr, 'notifyproblem'); $table = new StdClass; $table->head = array($pluginstr, ''); $table->data = array(); diff --git a/lib/questionlib.php b/lib/questionlib.php index 78fcbe5a16..28fb0c26da 100644 --- a/lib/questionlib.php +++ b/lib/questionlib.php @@ -690,7 +690,7 @@ function question_delete_course($course, $feedback=true) { * @return boolean */ function question_delete_course_category($category, $newcategory, $feedback=true) { - global $DB; + global $DB, $OUTPUT; $context = get_context_instance(CONTEXT_COURSECAT, $category->id); if (empty($newcategory)) { @@ -753,7 +753,7 @@ function question_delete_course_category($category, $newcategory, $feedback=true $a = new stdClass; $a->oldplace = print_context_name($context); $a->newplace = print_context_name($newcontext); - notify(get_string('movedquestionsandcategories', 'question', $a), 'notifysuccess'); + echo $OUTPUT->notification(get_string('movedquestionsandcategories', 'question', $a), 'notifysuccess'); } } @@ -1508,7 +1508,7 @@ function question_get_feedback_class($fraction) { * or record that changes need to be made for a later regrade. */ function regrade_question_in_attempt($question, $attempt, $cmoptions, $verbose=false, $dryrun=false) { - global $DB; + global $DB, $OUTPUT; // load all states for this question in this attempt, ordered in sequence if ($states = $DB->get_records('question_states', @@ -1558,7 +1558,7 @@ function regrade_question_in_attempt($question, $attempt, $cmoptions, $verbose=f $error = question_process_comment($question, $replaystate, $attempt, $replaystate->manualcomment, $states[$j]->grade); if (is_string($error)) { - notify($error); + echo $OUTPUT->notification($error); } } else { $replaystate->grade = $states[$j]->grade; @@ -1570,7 +1570,7 @@ function regrade_question_in_attempt($question, $attempt, $cmoptions, $verbose=f $a = new stdClass; $a->qid = $question->id; $a->stateid = $states[$j]->id; - notify(get_string('errorduringregrade', 'question', $a)); + echo $OUTPUT->notification(get_string('errorduringregrade', 'question', $a)); } // We need rounding here because grades in the DB get truncated // e.g. 0.33333 != 0.3333333, but we want them to be equal here @@ -2928,10 +2928,11 @@ function get_filesdir_from_context($context){ * error.. */ function question_get_real_state($state){ + global $OUTPUT; $realstate = clone($state); $matches = array(); if (!preg_match('|^random([0-9]+)-(.*)|', $state->answer, $matches)){ - notify(get_string('errorrandom', 'quiz_statistics')); + echo $OUTPUT->notification(get_string('errorrandom', 'quiz_statistics')); return false; } else { $realstate->question = $matches[1]; diff --git a/lib/simpletest/filtersettingsperformancetester.php b/lib/simpletest/filtersettingsperformancetester.php index 57ea981fe5..e079b56190 100644 --- a/lib/simpletest/filtersettingsperformancetester.php +++ b/lib/simpletest/filtersettingsperformancetester.php @@ -70,11 +70,11 @@ switch (optional_param('action', '', PARAM_ACTION)) { } flush(); populate_test_database($syscontext, 10, 100, 1000, 5000, 5000); - notify('Test tables created.', 'notifysuccess'); + echo $OUTPUT->notification('Test tables created.', 'notifysuccess'); } else if ($issetup == count($requiredtables)) { - notify('Test tables are already set up.', 'notifysuccess'); + echo $OUTPUT->notification('Test tables are already set up.', 'notifysuccess'); } else { - notify('Something is wrong, please delete the test tables and try again.'); + echo $OUTPUT->notification('Something is wrong, please delete the test tables and try again.'); } break; @@ -86,12 +86,12 @@ switch (optional_param('action', '', PARAM_ACTION)) { } } $issetup = 0; - notify('Test tables dropped.', 'notifysuccess'); + echo $OUTPUT->notification('Test tables dropped.', 'notifysuccess'); break; case 'test': if ($issetup != count($requiredtables)) { - notify('Something is wrong, please delete the test tables and try again.'); + echo $OUTPUT->notification('Something is wrong, please delete the test tables and try again.'); } else { $contexts = $DB->get_records('context'); $numcalls = 1000; @@ -146,7 +146,7 @@ function print_result_line($duration, $basetime, $numcalls, $action1, $action2 = } function populate_test_database($syscontext, $numcategories, $numcourses, $nummodules, $numoverrides, $numconfigs) { - global $DB; + global $DB, $OUTPUT; set_time_limit(600); $syscontext->id = $DB->insert_record('context', $syscontext); @@ -158,7 +158,7 @@ function populate_test_database($syscontext, $numcategories, $numcourses, $nummo $categoryparents[] = $context; $categories[$context->id] = $context; } - notify('Created ' . $numcategories . ' course category contexts.', 'notifysuccess'); flush(); + echo $OUTPUT->notification('Created ' . $numcategories . ' course category contexts.', 'notifysuccess'); flush(); // Course contexts. $courses = array(); @@ -166,7 +166,7 @@ function populate_test_database($syscontext, $numcategories, $numcourses, $nummo $context = insert_context(CONTEXT_COURSE, $i, $categories[array_rand($categories)]); $courses[$context->id] = $context; } - notify('Created ' . $numcourses . ' course contexts.', 'notifysuccess'); flush(); + echo $OUTPUT->notification('Created ' . $numcourses . ' course contexts.', 'notifysuccess'); flush(); // Activities contexts. $mods = array(); @@ -180,7 +180,7 @@ function populate_test_database($syscontext, $numcategories, $numcourses, $nummo } } $DB->commit_sql(); - notify('Created ' . $nummodules . ' module contexts.', 'notifysuccess'); flush(); + echo $OUTPUT->notification('Created ' . $nummodules . ' module contexts.', 'notifysuccess'); flush(); $contexts = $categories + $courses + $mods; @@ -192,7 +192,7 @@ function populate_test_database($syscontext, $numcategories, $numcourses, $nummo filter_set_global_state($filter, $state); $counts[$state]++; } - notify('Set global setting: ' . $counts[TEXTFILTER_DISABLED] . ' disabled, ' . + echo $OUTPUT->notification('Set global setting: ' . $counts[TEXTFILTER_DISABLED] . ' disabled, ' . $counts[TEXTFILTER_OFF] . ' off and ' . $counts[TEXTFILTER_ON] . ' on.', 'notifysuccess'); flush(); // Local overrides. @@ -206,7 +206,7 @@ function populate_test_database($syscontext, $numcategories, $numcourses, $nummo } } $DB->commit_sql(); - notify('Set ' . $numoverrides . ' local overrides.', 'notifysuccess'); flush(); + echo $OUTPUT->notification('Set ' . $numoverrides . ' local overrides.', 'notifysuccess'); flush(); // Local config. $variablenames = array('frog' => 0, 'toad' => 0, 'elver' => 0, 'eft' => 0, 'tadpole' => 0); @@ -220,7 +220,7 @@ function populate_test_database($syscontext, $numcategories, $numcourses, $nummo } } $DB->commit_sql(); - notify('Set ' . $numconfigs . ' local configs.', 'notifysuccess'); flush(); + echo $OUTPUT->notification('Set ' . $numconfigs . ' local configs.', 'notifysuccess'); flush(); } function insert_context($contextlevel, $instanceid, $parent) { diff --git a/lib/simpletest/getstringperformancetester.php b/lib/simpletest/getstringperformancetester.php index 378d356883..8bd49987f2 100644 --- a/lib/simpletest/getstringperformancetester.php +++ b/lib/simpletest/getstringperformancetester.php @@ -48,7 +48,7 @@ $requiredlangs = $TEST_LANGUAGES; array_pop($requiredlangs); foreach ($requiredlangs as $lang) { if (!isset($installedlangs[$lang])) { - notify('You must install the following language packs to run these test: ' . implode(', ', $requiredlangs)); + echo $OUTPUT->notification('You must install the following language packs to run these test: ' . implode(', ', $requiredlangs)); echo $OUTPUT->footer(); die; } diff --git a/lib/tablelib.php b/lib/tablelib.php index 68079c1225..7d12d23f3f 100644 --- a/lib/tablelib.php +++ b/lib/tablelib.php @@ -920,7 +920,7 @@ class flexible_table { $select = html_select::make($downloadoptions, 'download', $this->defaultdownloadformat, false); $select->nothingvalue = ''; $html .= $OUTPUT->select($select); - $html .= helpbutton('tableexportformats', get_string('tableexportformats', 'table'), 'moodle', true, false, '', true); + $html .= $OUTPUT->help_icon(moodle_help_icon::make('tableexportformats', get_string('tableexportformats', 'table'))); $html .= '
    '; return $html; diff --git a/lib/upgradelib.php b/lib/upgradelib.php index 3952d62ce0..d0a89bd9ce 100644 --- a/lib/upgradelib.php +++ b/lib/upgradelib.php @@ -822,7 +822,7 @@ function upgrade_finished($continueurl=null) { upgrade_setup_debug(false); ignore_user_abort(false); if ($continueurl) { - print_continue($continueurl); + echo $OUTPUT->continue_button($continueurl); echo $OUTPUT->footer(); die; } @@ -907,6 +907,7 @@ function print_upgrade_part_start($plugin, $installation, $verbose) { * @param bool $installation true if installation, false menas upgrade */ function print_upgrade_part_end($plugin, $installation, $verbose) { + global $OUTPUT; upgrade_started(); if ($installation) { if (empty($plugin) or $plugin == 'moodle') { @@ -922,7 +923,7 @@ function print_upgrade_part_end($plugin, $installation, $verbose) { } } if ($verbose) { - notify(get_string('success'), 'notifysuccess'); + echo $OUTPUT->notification(get_string('success'), 'notifysuccess'); print_upgrade_separator(); } } @@ -971,7 +972,7 @@ function upgrade_language_pack($lang='') { $cd->install(); } } - notify(get_string('success'), 'notifysuccess'); + echo $OUTPUT->notification(get_string('success'), 'notifysuccess'); } } diff --git a/lib/uploadlib.php b/lib/uploadlib.php index 738fe55e14..644b7dc786 100644 --- a/lib/uploadlib.php +++ b/lib/uploadlib.php @@ -119,7 +119,7 @@ class upload_manager { * @return boolean */ function preprocess_files() { - global $CFG; + global $CFG, $OUTPUT; foreach ($_FILES as $name => $file) { $this->status = true; // only set it to true here so that we can check if this function has been called. @@ -141,7 +141,7 @@ class upload_manager { $a->name = $this->files[$name]['originalname']; $a->problem = $this->files[$name]['uploadlog']; if (!$this->config->silent) { - notify(get_string('uploadfailednotrecovering','moodle',$a)); + echo $OUTPUT->notification(get_string('uploadfailednotrecovering','moodle',$a)); } else { $this->notify .= '
    '. get_string('uploadfailednotrecovering','moodle',$a); @@ -152,7 +152,7 @@ class upload_manager { } else if (count($this->files) == 1) { if (!$this->config->silent and !$this->config->allownull) { - notify($this->files[$name]['uploadlog']); + echo $OUTPUT->notification($this->files[$name]['uploadlog']); } else { $this->notify .= '
    '. $this->files[$name]['uploadlog']; } @@ -211,7 +211,7 @@ class upload_manager { * @return boolean status; */ function save_files($destination) { - global $CFG, $USER; + global $CFG, $USER, $OUTPUT; if (!$this->status) { // preprocess_files hasn't been run $this->preprocess_files(); @@ -271,7 +271,7 @@ class upload_manager { if (empty($savedsomething)) { $this->status = false; if ((empty($this->config->allownull) && !empty($this->inputname)) || (empty($this->inputname) && empty($this->config->allownullmultiple))) { - notify(get_string('uploadnofilefound')); + echo $OUTPUT->notification(get_string('uploadnofilefound')); } return false; } @@ -298,6 +298,7 @@ class upload_manager { * @param array $exceptions Full paths of files to KEEP. */ function delete_other_files($destination, $exceptions=null) { + global $OUTPUT; $deletedsomething = false; if ($filestodel = get_directory_list($destination)) { foreach ($filestodel as $file) { @@ -309,7 +310,7 @@ class upload_manager { } if ($deletedsomething) { if (!$this->config->silent) { - notify(get_string('uploadoldfilesdeleted')); + echo $OUTPUT->notification(get_string('uploadoldfilesdeleted')); } else { $this->notify .= '
    '. get_string('uploadoldfilesdeleted'); diff --git a/lib/weblib.php b/lib/weblib.php index 38c7745468..d1c95af7fe 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -3084,8 +3084,11 @@ function emoticonhelpbutton($form, $field, $return = false) { $SESSION->inserttextform = $form; $SESSION->inserttextfield = $field; - $imagetext = ''; - $help = helpbutton('emoticons2', get_string('helpemoticons'), 'moodle', true, true, '', true, $imagetext); + $helpicon = moodle_help_icon::make('emoticons2', get_string('helpemoticons'), 'moodle', true); + $helpicon->image->src = $OUTPUT->old_icon_url('s/smiley'); + $helpicon->image->add_class('emoticon'); + $helpicon->style = "margin-left:3px; padding-right:1px;width:15px;height:15px;"; + $help = $OUTPUT->help_icon($helpicon); if (!$return){ echo $help; } else { @@ -3139,7 +3142,7 @@ function notice ($message, $link='', $course=NULL) { } echo $OUTPUT->box($message, 'generalbox', 'notice'); - print_continue($link); + echo $OUTPUT->continue_button($link); echo $OUTPUT->footer(); exit(1); // general error code diff --git a/message/edit.php b/message/edit.php index 10ba691c4e..e81ba80b1f 100644 --- a/message/edit.php +++ b/message/edit.php @@ -215,9 +215,9 @@ /// TODO XXX: This is only a quick hack ... helpfile locations should be provided as part of the provider definition if ($provider->component == 'moodle') { - $helpbtn = helpbutton('moodle_'.$provider->name, $providername, 'message', true, false, '', true); + $helpbtn = $OUTPUT->help_icon(moodle_help_icon::make('moodle_'.$provider->name, $providername, 'message')); } else { - $helpbtn = helpbutton('message_'.$provider->name, $providername, basename($provider->component), true, false, '', true); + $helpbtn = $OUTPUT->help_icon(moodle_help_icon::make('message_'.$provider->name, $providername, basename($provider->component))); } echo ''.$providername.$helpbtn.''."\n"; diff --git a/message/lib.php b/message/lib.php index f401f23fd1..ddfb9b981b 100644 --- a/message/lib.php +++ b/message/lib.php @@ -293,7 +293,7 @@ function message_get_contact($contactid) { function message_print_search_results($frm) { - global $USER, $CFG, $DB; + global $USER, $CFG, $DB, $OUTPUT; echo '
    '; @@ -349,7 +349,7 @@ function message_print_search_results($frm) { echo ''; } else { - notify(get_string('nosearchresults', 'message')); + echo $OUTPUT->notification(get_string('nosearchresults', 'message')); } @@ -476,13 +476,13 @@ function message_print_search_results($frm) { echo ''; } else { - notify(get_string('nosearchresults', 'message')); + echo $OUTPUT->notification(get_string('nosearchresults', 'message')); } /// what the ????, probably an empty search string, duh! } else { - notify(get_string('emptysearchstring', 'message')); + echo $OUTPUT->notification(get_string('emptysearchstring', 'message')); } echo '
    '; diff --git a/sso/hive/expired.php b/sso/hive/expired.php index e67dc9d6a3..bd74315aaa 100644 --- a/sso/hive/expired.php +++ b/sso/hive/expired.php @@ -10,7 +10,7 @@ //MW theres no easy way to log in seamlessly. We need the users unhashed password. // It's a security risk to carry that in $SESSION so we put up login form. print_header(); - notify('Your session has expired. Please log in again.'); + echo $OUTPUT->notification('Your session has expired. Please log in again.'); ?>