MDL-19806 Upgraded calls to helpbutton, print_simple_box* and notify

This commit is contained in:
nicolasconnault 2009-08-18 05:13:51 +00:00
parent c73526ef34
commit 4102b449ef
10 changed files with 56 additions and 54 deletions

View file

@ -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.")<br/>";
}
//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

View file

@ -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&amp;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.'&amp;rid='.$recordid);
@ -257,7 +257,7 @@
echo '<input name="d" value="'.$data->id.'" type="hidden" />';
echo '<input name="rid" value="'.$rid.'" type="hidden" />';
echo '<input name="sesskey" value="'.sesskey().'" type="hidden" />';
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 '<input type="submit" value="'.get_string('saveandadd','data').'" />';
}
echo '</div>';
print_simple_box_end();
echo $OUTPUT->box_end();
echo '</div></form>';
@ -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 '<tr>';
echo '<td align="right">'.get_string('csvfile', 'data').':</td>';
echo '<td><input type="file" name="recordsfile" size="30" />';
helpbutton('importcsv', get_string('csvimport', 'data'), 'data', true, false);
echo $OUTPUT->help_icon(moodle_help_icon::make('importcsv', get_string('csvimport', 'data'), 'data'));
echo '</td><tr>';
echo '<td align="right">'.get_string('fielddelimiter', 'data').':</td>';
echo '<td><input type="text" name="fielddelimiter" size="6" />';
@ -327,7 +327,7 @@
echo '<input type="submit" value="'.get_string('uploadfile', 'data').'" />';
echo '</form>';
echo '</div>';
print_simple_box_end();
echo $OUTPUT->box_end();
} else {
echo '<div style="text-align:center">';
echo '<a href="edit.php?d='.$data->id.'&amp;import=1">'.get_string('uploadrecords', 'data').'</a>';

View file

@ -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 '<label for="fieldform_jump">'.get_string('newfield','data').'</label>';
$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 '</div>';
echo '<div class="sortdefault">';

View file

@ -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();

View file

@ -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 .= '<input type="hidden" name="field_' . $this->field->id . '_content1' . '" value="' . FORMAT_HTML . '" />';
} 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 .= '</div>';
return $str;

View file

@ -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 '<p />';

View file

@ -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 '<form id="editfield" action="'.$CFG->wwwroot.'/mod/data/field.php" method="post">'."\n";
echo '<input type="hidden" name="d" value="'.$this->data->id.'" />'."\n";
@ -286,7 +287,7 @@ class data_field_base { // Base class for Database Field Types (see field/*/
echo '</form>';
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 "<h3>$strfieldmappings ";
helpbutton('fieldmappings', $strfieldmappings, 'data');
echo $OUTPUT->help_icon(moodle_help_icon::make('fieldmappings', $strfieldmappings, 'data'));
echo '</h3><table>';
foreach ($newfields as $nid => $newfield) {

View file

@ -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 <a href='edit.php?d=$data->id'>$straddentries</a> $strtodatabase", 'notifysuccess');
echo $OUTPUT->notification("$strimportsuccess <a href='edit.php?d=$data->id'>$straddentries</a> $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 '<div style="text-align:center">';
echo '<form action="preset.php" method="post">';
@ -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 '<table class="presets" cellpadding="5">';
echo '<tr><td valign="top" colspan="2" align="center"><h3>'.$strexport.'</h3></td></tr>';
echo '<tr><td><label>'.$strexportaszip.'</label>';
helpbutton('exportzip', '', 'data', true, true);
echo $OUTPUT->help_icon(moodle_help_icon::make('exportzip', '', 'data', true));
echo '</td><td>';
$options = new object();
$options->action = 'export';
@ -306,7 +306,7 @@ print_single_button('preset.php', $options, $strexport, 'post');
echo '</td></tr>';
echo '<tr><td><label>'.$strsaveaspreset.'</label>';
helpbutton('savepreset', '', 'data', true, true);
echo $OUTPUT->help_icon(moodle_help_icon::make('savepreset', '', 'data', true));
echo '</td><td>';
$options = new object();
$options->action = 'save1';
@ -316,7 +316,7 @@ print_single_button('preset.php', $options, $strsave, 'post');
echo '</td></tr>';
echo '<tr><td valign="top" colspan="2" align="center"><h3>'.$strimport.'</h3></td></tr>';
echo '<tr><td><label for="fromfile">'.$strfromfile.'</label>';
helpbutton('importfromfile', '', 'data', true, true);
echo $OUTPUT->help_icon(moodle_help_icon::make('importfromfile', '', 'data', true));
echo '</td><td>';
echo '<form id="uploadpreset" method="post" action="preset.php">';
echo '<fieldset class="invisiblefieldset">';
@ -329,7 +329,7 @@ echo '</fieldset></form>';
echo '</td></tr>';
echo '<tr valign="top"><td><label>'.$strusestandard.'</label>';
helpbutton('usepreset', '', 'data', true, true);
echo $OUTPUT->help_icon(moodle_help_icon::make('usepreset', '', 'data', true));
echo '</td><td>';
echo '<form id="presets" method="post" action="preset.php" >';

View file

@ -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&amp;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 '<table cellpadding="4" cellspacing="0" border="0">';
/// Add the HTML editor(s).
@ -175,7 +175,7 @@
if ($mode != 'csstemplate' and $mode != 'jstemplate') {
// Add all the available fields for this data.
echo '<label for="availabletags">'.get_string('availabletags','data').'</label>';
helpbutton('tags', get_string('tags'), 'data');
echo $OUTPUT->help_icon(moodle_help_icon::make('tags', get_string('tags'), 'data'));
echo '<br />';
@ -283,7 +283,7 @@
echo '</td></tr></table>';
print_simple_box_end();
echo $OUTPUT->box_end();
echo '</div>';
echo '</form>';

View file

@ -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&amp;mode=$mode&amp;search=&amp;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&amp;mode=$mode&amp;search=&amp;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;