]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-19806 Upgraded calls to helpbutton, print_simple_box* and notify
authornicolasconnault <nicolasconnault>
Tue, 18 Aug 2009 05:13:51 +0000 (05:13 +0000)
committernicolasconnault <nicolasconnault>
Tue, 18 Aug 2009 05:13:51 +0000 (05:13 +0000)
mod/data/db/upgrade.php
mod/data/edit.php
mod/data/field.php
mod/data/field/picture/field.class.php
mod/data/field/textarea/field.class.php
mod/data/import.php
mod/data/lib.php
mod/data/preset.php
mod/data/templates.php
mod/data/view.php

index 6afa147cd640c6f2ad525d9d696439904d299c84..cdd54d30c491509700d510eee5d97458106ab183 100644 (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
index dc6af0c908fede585a910c1bc31aa5a06464b9a7..fe87daf2f333cb5cd51c09b03bff5bb524719dcb 100755 (executable)
         /// 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;
             }
             }
 
             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
 
                 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);
     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);
         echo '<input type="submit" value="'.get_string('saveandadd','data').'" />';
     }
     echo '</div>';
-    print_simple_box_end();
+    echo $OUTPUT->box_end();
     echo '</div></form>';
 
 
 
     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();
             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" />';
             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>';
index 158be8dd3e17881187bea45aa159bb4dc16f820f..c42e9d989452465ffef7215d90ae00813d096c9a 100755 (executable)
         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
 
         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">';
index 6d9b3ac649852014ff9c5d9b7efa81ba29342a10..f0ce2f5b9e8a793ac7fc7524787587e2e7debd66 100755 (executable)
@@ -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();
index 573105ddb4d8a0234a4a3dda23b67c4fe9b66eb3..6b401f47a580c9e678f52b09ac5d700c20314567 100755 (executable)
@@ -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;
index 311aa9c10ad9c7761267f48c64638c69ea4f6f3b..878d565a2d8aa053516714ff888b9e745efec43b 100755 (executable)
     }
 
     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 />';
 
index aece792adec19f6a9c315ac504536851af6f95e2..6a674619beaee0bb569ddcbd23231befecd37003 100755 (executable)
@@ -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) {
index 15bba9c9ea1760c4c15597f695b6f8dcc77bd272..046ee51e579fa84b9fc15278cd63dec697d8a9dd 100644 (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" >';
index 4c2e04630073909a77bafd81ae499f41cf27b157..c4f0d8d1e59c89a7a324305659e315ed88d4cedc 100755 (executable)
             // 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);
         // 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).
     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 />';
 
 
     echo '</td></tr></table>';
 
 
-    print_simple_box_end();
+    echo $OUTPUT->box_end();
     echo '</div>';
     echo '</form>';
 
index 1d71f4f60191992b46b6a5812cd3dd3e0dfee659..1c2db455cd96b50bd7d368216d70e02bea160139 100755 (executable)
 
                     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');
                 }
             }
 
                     $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');
                     }
                 }
             }
         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)
         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;
         }
 
                 $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
                 $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
                 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);
                 }
 
                 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;