From: nicolasconnault Date: Tue, 18 Aug 2009 05:13:51 +0000 (+0000) Subject: MDL-19806 Upgraded calls to helpbutton, print_simple_box* and notify X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=4102b449efaf5f39f8e84a524ea7d85a0cc6e040;p=moodle.git MDL-19806 Upgraded calls to helpbutton, print_simple_box* and notify --- diff --git a/mod/data/db/upgrade.php b/mod/data/db/upgrade.php index 6afa147cd6..cdd54d30c4 100644 --- a/mod/data/db/upgrade.php +++ b/mod/data/db/upgrade.php @@ -21,7 +21,7 @@ // before any action that may take longer time to finish. function xmldb_data_upgrade($oldversion) { - global $CFG, $DB; + global $CFG, $DB, $OUTPUT; $dbman = $DB->get_manager(); $result = true; @@ -160,7 +160,7 @@ function xmldb_data_upgrade($oldversion) { $a->text .= $database->fullname." - " .$database->name. " (course id: ".$database->course." - database id: ".$database->id.")
"; } //TODO: MDL-17427 send this info to "upgrade log" which will be implemented in 2.0 - notify(get_string('requiredentrieschanged', 'admin', $a)); + echo $OUTPUT->notification(get_string('requiredentrieschanged', 'admin', $a)); } } unset_config('requiredentriesfixflag', 'data'); // remove old flag diff --git a/mod/data/edit.php b/mod/data/edit.php index dc6af0c908..fe87daf2f3 100755 --- a/mod/data/edit.php +++ b/mod/data/edit.php @@ -186,7 +186,7 @@ /// Of course, you can't be stopped if you are an editting teacher! =) if (data_atmaxentries($data) and !has_capability('mod/data:manageentries',$context)){ - notify (get_string('atmaxentry','data')); + echo $OUTPUT->notification(get_string('atmaxentry','data')); echo $OUTPUT->footer(); exit; } @@ -209,7 +209,7 @@ } if ($emptyform){ //nothing gets written to database - notify(get_string('emptyaddform','data')); + echo $OUTPUT->notification(get_string('emptyaddform','data')); } if (!$emptyform && $recordid = data_add_record($data, $currentgroup)) { //add instance to data_record @@ -237,7 +237,7 @@ add_to_log($course->id, 'data', 'add', "view.php?d=$data->id&rid=$recordid", $data->id, $cm->id); - notify(get_string('entrysaved','data')); + echo $OUTPUT->notification(get_string('entrysaved','data')); if (!empty($datarecord->saveandview)) { redirect($CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&rid='.$recordid); @@ -257,7 +257,7 @@ echo ''; echo ''; echo ''; - print_simple_box_start('center','80%'); + echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide'); if (!$rid){ echo $OUTPUT->heading(get_string('newentry','data'), 2); @@ -292,7 +292,7 @@ echo ''; } echo ''; - print_simple_box_end(); + echo $OUTPUT->box_end(); echo ''; @@ -300,7 +300,7 @@ if (has_capability('mod/data:manageentries',$context)) { if ($import) { - print_simple_box_start('center','80%'); + echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide'); echo $OUTPUT->heading(get_string('uploadrecords', 'data'), 3); $maxuploadsize = get_max_upload_file_size(); @@ -313,7 +313,7 @@ echo ''; echo ''.get_string('csvfile', 'data').':'; echo ''; - helpbutton('importcsv', get_string('csvimport', 'data'), 'data', true, false); + echo $OUTPUT->help_icon(moodle_help_icon::make('importcsv', get_string('csvimport', 'data'), 'data')); echo ''; echo ''.get_string('fielddelimiter', 'data').':'; echo ''; @@ -327,7 +327,7 @@ echo ''; echo ''; echo ''; - print_simple_box_end(); + echo $OUTPUT->box_end(); } else { echo '
'; echo ''.get_string('uploadrecords', 'data').''; diff --git a/mod/data/field.php b/mod/data/field.php index 158be8dd3e..c42e9d9894 100755 --- a/mod/data/field.php +++ b/mod/data/field.php @@ -241,8 +241,8 @@ data_print_header($course, $cm, $data,'fields'); if (!$DB->record_exists('data_fields', array('dataid'=>$data->id))) { - notify(get_string('nofieldindatabase','data')); // nothing in database - notify(get_string('pleaseaddsome','data', 'preset.php?id='.$cm->id)); // link to presets + echo $OUTPUT->notification(get_string('nofieldindatabase','data')); // nothing in database + echo $OUTPUT->notification(get_string('pleaseaddsome','data', 'preset.php?id='.$cm->id)); // link to presets } else { //else print quiz style list of fields @@ -281,7 +281,7 @@ echo ''; $popupurl = $CFG->wwwroot.'/mod/data/field.php?d='.$data->id.'&mode=new&sesskey='. sesskey(); echo $OUTPUT->select(html_select::make_popup_form($popupurl, 'newtype', $menufield, "fieldform")); - helpbutton('fields', get_string('addafield','data'), 'data'); + echo $OUTPUT->help_icon(moodle_help_icon::make('fields', get_string('addafield','data'), 'data')); echo '
'; echo '
'; diff --git a/mod/data/field/picture/field.class.php b/mod/data/field/picture/field.class.php index 6d9b3ac649..f0ce2f5b9e 100755 --- a/mod/data/field/picture/field.class.php +++ b/mod/data/field/picture/field.class.php @@ -136,7 +136,7 @@ class data_field_picture extends data_field_base { } function update_field() { - global $DB; + global $DB, $OUTPUT; // Get the old field data so that we can check whether the thumbnail dimensions have changed $oldfield = $DB->get_record('data_fields', array('id'=>$this->field->id)); @@ -148,7 +148,7 @@ class data_field_picture extends data_field_base { if ($contents = $DB->get_records('data_content', array('fieldid'=>$this->field->id))) { $fs = get_file_storage(); if (count($contents) > 20) { - notify(get_string('resizingimages', 'data'), 'notifysuccess'); + echo $OUTPUT->notification(get_string('resizingimages', 'data'), 'notifysuccess'); echo "\n\n"; // To make sure that ob_flush() has the desired effect ob_flush(); diff --git a/mod/data/field/textarea/field.class.php b/mod/data/field/textarea/field.class.php index 573105ddb4..6b401f47a5 100755 --- a/mod/data/field/textarea/field.class.php +++ b/mod/data/field/textarea/field.class.php @@ -43,7 +43,7 @@ class data_field_textarea extends data_field_base { if (can_use_html_editor()) { // Show a rich text html editor. $str .= $this->gen_textarea(true, $text); - $str .= helpbutton("richtext2", get_string("helprichtext"), 'moodle', true, true, '', true); + $str .= $OUTPUT->help_icon(moodle_help_icon::make("richtext2", get_string("helprichtext"), 'moodle', true)); $str .= ''; } else { @@ -57,7 +57,7 @@ class data_field_textarea extends data_field_base { $select->nothingvalue = ''; $str .= $OUTPUT->select($select); - $str .= helpbutton('textformat', get_string('helpformatting'), 'moodle', true, false, '', true); + $str .= $OUTPUT->help_icon(moodle_help_icon::make('textformat', get_string('helpformatting'), 'moodle')); } $str .= '
'; return $str; diff --git a/mod/data/import.php b/mod/data/import.php index 311aa9c10a..878d565a2d 100755 --- a/mod/data/import.php +++ b/mod/data/import.php @@ -170,9 +170,9 @@ } if ($recordsadded > 0) { - notify($recordsadded. ' '. get_string('recordssaved', 'data')); + echo $OUTPUT->notification($recordsadded. ' '. get_string('recordssaved', 'data')); } else { - notify(get_string('recordsnotsaved', 'data')); + echo $OUTPUT->notification(get_string('recordsnotsaved', 'data')); } echo '

'; diff --git a/mod/data/lib.php b/mod/data/lib.php index aece792ade..6a674619be 100755 --- a/mod/data/lib.php +++ b/mod/data/lib.php @@ -122,8 +122,9 @@ class data_field_base { // Base class for Database Field Types (see field/*/ * @return bool */ function define_default_field() { + global $OUTPUT; if (empty($this->data->id)) { - notify('Programmer error: dataid not defined in field class'); + echo $OUTPUT->notification('Programmer error: dataid not defined in field class'); } $this->field = new object; $this->field->id = 0; @@ -177,10 +178,10 @@ class data_field_base { // Base class for Database Field Types (see field/*/ * @return bool */ function insert_field() { - global $DB; + global $DB, $OUTPUT; if (empty($this->field)) { - notify('Programmer error: Field has not been defined yet! See define_field()'); + echo $OUTPUT->notification('Programmer error: Field has not been defined yet! See define_field()'); return false; } @@ -260,7 +261,7 @@ class data_field_base { // Base class for Database Field Types (see field/*/ if (empty($this->field)) { // No field has been defined yet, try and make one $this->define_default_field(); } - print_simple_box_start('center','80%'); + echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide'); echo '

'."\n"; echo ''."\n"; @@ -286,7 +287,7 @@ class data_field_base { // Base class for Database Field Types (see field/*/ echo '
'; - print_simple_box_end(); + echo $OUTPUT->box_end(); } /** @@ -807,7 +808,7 @@ function data_add_record($data, $groupid=0){ * @return bool */ function data_tags_check($dataid, $template) { - global $DB; + global $DB, $OUTPUT; // first get all the possible tags $fields = $DB->get_records('data_fields', array('dataid'=>$dataid)); @@ -817,7 +818,7 @@ function data_tags_check($dataid, $template) { $pattern="/\[\[".$field->name."\]\]/i"; if (preg_match_all($pattern, $template, $dummy)>1){ $tagsok = false; - notify ('[['.$field->name.']] - '.get_string('multipletags','data')); + echo $OUTPUT->notification('[['.$field->name.']] - '.get_string('multipletags','data')); } } // else return true @@ -855,7 +856,7 @@ function data_add_instance($data) { * @return bool */ function data_update_instance($data) { - global $DB; + global $DB, $OUTPUT; $data->timemodified = time(); $data->id = $data->instance; @@ -1825,7 +1826,7 @@ function data_convert_arrays_to_strings(&$fieldinput) { * @return boolean data module was converted or not */ function data_convert_to_roles($data, $teacherroles=array(), $studentroles=array(), $cmid=NULL) { - global $CFG, $DB; + global $CFG, $DB, $OUTPUT; if (!isset($data->participants) && !isset($data->assesspublic) && !isset($data->groupmode)) { @@ -1838,7 +1839,7 @@ function data_convert_to_roles($data, $teacherroles=array(), $studentroles=array if (empty($cmid)) { // We were not given the course_module id. Try to find it. if (!$cm = get_coursemodule_from_instance('data', $data->id)) { - notify('Could not get the course module for the data'); + echo $OUTPUT->notification('Could not get the course module for the data'); return false; } else { $cmid = $cm->id; @@ -2069,9 +2070,9 @@ function data_print_header($course, $cm, $data, $currenttab='') { // Print any notices if (!empty($displaynoticegood)) { - notify($displaynoticegood, 'notifysuccess'); // good (usually green) + echo $OUTPUT->notification($displaynoticegood, 'notifysuccess'); // good (usually green) } else if (!empty($displaynoticebad)) { - notify($displaynoticebad); // bad (usuually red) + echo $OUTPUT->notification($displaynoticebad); // bad (usuually red) } } @@ -2259,6 +2260,7 @@ class PresetImporter { * */ function import_options() { + global $OUTPUT; if (!confirm_sesskey()) { print_error('invalidsesskey'); } @@ -2282,7 +2284,7 @@ class PresetImporter { if (!empty($currentfields) && !empty($newfields)) { echo "

$strfieldmappings "; - helpbutton('fieldmappings', $strfieldmappings, 'data'); + echo $OUTPUT->help_icon(moodle_help_icon::make('fieldmappings', $strfieldmappings, 'data')); echo '

'; foreach ($newfields as $nid => $newfield) { diff --git a/mod/data/preset.php b/mod/data/preset.php index 15bba9c9ea..046ee51e57 100644 --- a/mod/data/preset.php +++ b/mod/data/preset.php @@ -123,7 +123,7 @@ switch ($action) { @rmdir($presetpath); $strdeleted = get_string('deleted', 'data'); - notify("$shortname $strdeleted", 'notifysuccess'); + echo $OUTPUT->notification("$shortname $strdeleted", 'notifysuccess'); break; /***************** Importing *****************/ @@ -175,9 +175,9 @@ switch ($action) { $straddentries = get_string('addentries', 'data'); $strtodatabase = get_string('todatabase', 'data'); if (!$DB->get_records('data_records', array('dataid'=>$data->id))) { - notify("$strimportsuccess $straddentries $strtodatabase", 'notifysuccess'); + echo $OUTPUT->notification("$strimportsuccess $straddentries $strtodatabase", 'notifysuccess'); } else { - notify("$strimportsuccess", 'notifysuccess'); + echo $OUTPUT->notification("$strimportsuccess", 'notifysuccess'); } break; @@ -235,7 +235,7 @@ switch ($action) { $name = optional_param('name', $data->name, PARAM_FILE); if (is_directory_a_preset("$CFG->dataroot/data/preset/$USER->id/$name")) { - notify("Preset already exists: Pick another name or overwrite"); + echo $OUTPUT->notification("Preset already exists: Pick another name or overwrite"); echo '
'; echo '
'; @@ -274,7 +274,7 @@ switch ($action) { if (!unzip_file($file, $CFG->dataroot.$presetdirectory, false)) { print_error('cannotunziptopreset', 'data'); } - notify(get_string('savesuccess', 'data'), 'notifysuccess'); + echo $OUTPUT->notification(get_string('savesuccess', 'data'), 'notifysuccess'); break; } @@ -296,7 +296,7 @@ echo '
'; echo ''; echo ''; echo ''; echo ''; echo ''; echo '

'.$strexport.'

'; -helpbutton('exportzip', '', 'data', true, true); +echo $OUTPUT->help_icon(moodle_help_icon::make('exportzip', '', 'data', true)); echo ''; $options = new object(); $options->action = 'export'; @@ -306,7 +306,7 @@ print_single_button('preset.php', $options, $strexport, 'post'); echo '
'; -helpbutton('savepreset', '', 'data', true, true); +echo $OUTPUT->help_icon(moodle_help_icon::make('savepreset', '', 'data', true)); echo ''; $options = new object(); $options->action = 'save1'; @@ -316,7 +316,7 @@ print_single_button('preset.php', $options, $strsave, 'post'); echo '

'.$strimport.'

'; -helpbutton('importfromfile', '', 'data', true, true); +echo $OUTPUT->help_icon(moodle_help_icon::make('importfromfile', '', 'data', true)); echo ''; echo ''; echo '
'; @@ -329,7 +329,7 @@ echo '
'; echo '
'; -helpbutton('usepreset', '', 'data', true, true); +echo $OUTPUT->help_icon(moodle_help_icon::make('usepreset', '', 'data', true)); echo ''; echo '
'; diff --git a/mod/data/templates.php b/mod/data/templates.php index 4c2e046300..c4f0d8d1e5 100755 --- a/mod/data/templates.php +++ b/mod/data/templates.php @@ -124,7 +124,7 @@ // Check for multiple tags, only need to check for add template. if ($mode != 'addtemplate' or data_tags_check($data->id, $newtemplate->{$mode})) { if ($DB->update_record('data', $newtemplate)) { - notify(get_string('templatesaved', 'data'), 'notifysuccess'); + echo $OUTPUT->notification(get_string('templatesaved', 'data'), 'notifysuccess'); } } add_to_log($course->id, 'data', 'templates saved', "templates.php?id=$cm->id&d=$data->id", $data->id, $cm->id); @@ -153,7 +153,7 @@ // Only reload if we are not resetting the template to default. $data = $DB->get_record('data', array('id'=>$d)); } - print_simple_box_start('center','80%'); + echo $OUTPUT->box_start('generalbox boxaligncenter boxwidthwide'); echo ''; /// Add the HTML editor(s). @@ -175,7 +175,7 @@ if ($mode != 'csstemplate' and $mode != 'jstemplate') { // Add all the available fields for this data. echo ''; - helpbutton('tags', get_string('tags'), 'data'); + echo $OUTPUT->help_icon(moodle_help_icon::make('tags', get_string('tags'), 'data')); echo '
'; @@ -283,7 +283,7 @@ echo '
'; - print_simple_box_end(); + echo $OUTPUT->box_end(); echo ''; echo '
'; diff --git a/mod/data/view.php b/mod/data/view.php index 1d71f4f601..1c2db455cd 100755 --- a/mod/data/view.php +++ b/mod/data/view.php @@ -331,7 +331,7 @@ add_to_log($course->id, 'data', 'record delete', "view.php?id=$cm->id", $data->id, $cm->id); - notify(get_string('recorddeleted','data'), 'notifysuccess'); + echo $OUTPUT->notification(get_string('recorddeleted','data'), 'notifysuccess'); } } @@ -381,7 +381,7 @@ $newrecord->id = $approverecord->id; $newrecord->approved = 1; if ($DB->update_record('data_records', $newrecord)) { - notify(get_string('recordapproved','data'), 'notifysuccess'); + echo $OUTPUT->notification(get_string('recordapproved','data'), 'notifysuccess'); } } } @@ -392,7 +392,7 @@ if ($data->requiredentries > 0 && $numentries < $data->requiredentries && !has_capability('mod/data:manageentries', $context)) { $data->entriesleft = $data->requiredentries - $numentries; $strentrieslefttoadd = get_string('entrieslefttoadd', 'data', $data); - notify($strentrieslefttoadd); + echo $OUTPUT->notification($strentrieslefttoadd); } /// Check the number of entries required before to view other participant's entries against the number of entries already made (doesn't apply to teachers) @@ -400,7 +400,7 @@ if ($data->requiredentriestoview > 0 && $numentries < $data->requiredentriestoview && !has_capability('mod/data:manageentries', $context)) { $data->entrieslefttoview = $data->requiredentriestoview - $numentries; $strentrieslefttoaddtoview = get_string('entrieslefttoaddtoview', 'data', $data); - notify($strentrieslefttoaddtoview); + echo $OUTPUT->notification($strentrieslefttoaddtoview); $requiredentries_allowed = false; } @@ -597,9 +597,9 @@ $a = new object(); $a->max = $maxcount; $a->reseturl = "view.php?id=$cm->id&mode=$mode&search=&advanced=0"; - notify(get_string('foundnorecords','data', $a)); + echo $OUTPUT->notification(get_string('foundnorecords','data', $a)); } else { - notify(get_string('norecords','data')); + echo $OUTPUT->notification(get_string('norecords','data')); } } else { // We have some records to print @@ -609,7 +609,7 @@ $a->num = $totalcount; $a->max = $maxcount; $a->reseturl = "view.php?id=$cm->id&mode=$mode&search=&advanced=0"; - notify(get_string('foundrecords', 'data', $a), 'notifysuccess'); + echo $OUTPUT->notification(get_string('foundrecords', 'data', $a), 'notifysuccess'); } if ($mode == 'single') { // Single template @@ -620,7 +620,7 @@ echo $OUTPUT->paging_bar(moodle_paging_bar::make($totalcount, $page, $nowperpage, $baseurl)); if (empty($data->singletemplate)){ - notify(get_string('nosingletemplate','data')); + echo $OUTPUT->notification(get_string('nosingletemplate','data')); data_generate_default_template($data, 'singletemplate', 0, false, false); } @@ -641,7 +641,7 @@ echo $OUTPUT->paging_bar(moodle_paging_bar::make($totalcount, $page, $nowperpage, $baseurl)); if (empty($data->listtemplate)){ - notify(get_string('nolisttemplate','data')); + echo $OUTPUT->notification(get_string('nolisttemplate','data')); data_generate_default_template($data, 'listtemplate', 0, false, false); } echo $data->listtemplateheader;