Before I carry on too much farther, there are a couple of other fixes I need to do. One, there are two more occurrences of get_record that did not get caught with the original sweep in "lib.php". And two, there are multiple occurrences of the error function throughout. I need to change error() to print_error(). You can see these changes in the repo.
Next, I need to fix up the "index.php" script using the same navigation and display changes described in my last post. One extra bit I need to add to this script is the call:
This sets the layout of the page to a default display reserved for module index displays.$PAGE->set_pagelayout('incourse');
Similar to before, I change:
$navigation = build_navigation($strstamps);to:
print_header_simple($strstamps, '', $navigation, '', '', true, '', navmenu($course));
$PAGE->navbar->add($strstamps);In the index code, the old print_table($table) is used. This has been changed to the new html_writer::table($table) construct. Additionally, where before the $table variable could be any standard object, now it must be an instance of the html_table class. So, I add the line:
$PAGE->set_heading(format_string($course->fullname));
$PAGE->set_title(get_string('modulename', 'stampcoll').' '.get_string('activities'));
echo $OUTPUT->header();
to a place before it is used, and I change:$table = new html_table();
to:print_table($table);
I make a few more of the standard output changes, and all seems to be well.echo html_writer::table($table);
Something I missed earlier, is that I need to rename the "styles.php" file to "styles.css". This is an easy change, but there is still the possibility that the CSS is not rendering as it did in 1.9, since it may depend on styles that have changed. I'm not going to go to that level here, but keep in mind for your plug-in, that you may need to make changes to your stylesheet to have it display the way it did in Moodle 1.9.
Next up is a problem appearing on the "Edit stamps" page. I can see a broken image where I added a stamp, and the warning message:
Here, the problem is with the code $CFG->pixpath.'/t/preview.gif' and $CFG->pixpath.'/t/delete.gif. In Moodle 2, the $CFG->pixpath and $CFG->modpixpath were removed, and replaced with an $OUTPUT->pix_url() function. In this case, I replace:Notice: Undefined property: stdClass::$pixpath in /home/www/moodle.git/mod/stampcoll/editstamps.php on line 285 Notice: Undefined property: stdClass::$pixpath in /home/www/moodle.git/mod/stampcoll/editstamps.php on line 289
$CFG->pixpath.'/t/preview.gif'with:
$CFG->pixpath.'/t/delete.gif
Note that both the opening '/' and the extension of the image have been removed in the new code to conform with the function's requirements.$OUTPUT->pix_url('t/preview')$OUTPUT->pix_url('t/delete')
Next, I test the delete function using the newly visible delete icon. After the confirmation page, I see a warning display before the page redirects. The warning says:
Here, the problem is with the code structure. Because the script has already started page output, by outputting the header, Moodle is telling me I should not redirect to another page. This should be fixed by restructuring the code so that redirects are called before any page output. I'm not going to do that for now, but keep in mind that for good code, this should be done.You should really redirect before you start page output
- line 566 of /lib/outputrenderers.php: call to debugging()
- line 2503 of /lib/weblib.php: call to core_renderer->redirect_message()
- line 128 of /mod/stampcoll/editstamps.php: call to redirect()
One other issue I can see. In the 1.9 version, hovering my mouse over a stamp image, displayed information about that stamp, including any messages entered with it. This is not happening here. Something is wrong with the javascript. Looking deeper, I see that the problem here is that the code is using "Overlib", which was a Javascript library included in older Moodle versions. For Moodle 2, this was removed with the intention of using YUI libraries instead (see MDL-21533). Fixing this will require some research. I'll work on that in the next post.
Moodle 2.0 is considerably different to the previous editions. One should anticipate much more preparing and examining to be engaged in improving to 2.0. It is likely not to be as uncomplicated as improvements through previous editions.
ReplyDeletethat is a big article thank you for sharing this informative recommendation. i'm able to visit your weblog often for a few modern day call. i'm able to visit your blog regularly for a few today's say. TNF Technical Services
ReplyDelete