Development:Deprecated functions in 2.0: Difference between revisions
Line 38: | Line 38: | ||
=== doc_link (30) === | === doc_link (30) === | ||
=== helpbutton (391) === | === helpbutton (391) === | ||
Old code: | |||
<code php> | |||
helpbutton($page, $title, $module, $image, $linktext, $text, $return, $imagetext); | |||
</code> | |||
New code: | |||
<code php> | |||
$helpicon = new help_icon(); | |||
$helpicon->page = $page; // required | |||
$helpicon->text = $title; // required | |||
$helpicon->module = $module; // defaults to 'moodle' | |||
$helpicon->linktext = $linktext; | |||
echo $OUTPUT->help_icon($helpicon); | |||
</code> | |||
=== link_to_popup_window (54) === | === link_to_popup_window (54) === | ||
=== notice_yesno (79) === | === notice_yesno (79) === |
Revision as of 04:16, 5 August 2009
Note: This article is a work in progress. Please use the page comments or an appropriate moodle.org forum for any recommendations/suggestions for improvement.
This page lists the old HTML-outputting functions of pre-2.0 lib/weblib.php and their 2.0 equivalents using $OUTPUT functions.
General notes
The principle of the new rendering API is to let the developer build metadata-rich components that represent HTML elements, but may be rendered in many different ways. A menu component, for example, could be rendered as a <select> element, or as a list of radio buttons or check boxes.
The following functions have been arranged in alphabetical order, although some of them are very closely related to each other. The number of occurrences of these function calls at the time of writing are indicated in parentheses.
Functions to migrate
button_to_popup_window (4)
Old code:
choose_from_menu($options, $name, $selected, $nothing, $script, $nothingvalue, $return, $disabled, $tabindex, $id, $listbox, $multiple, $class);
New code:
$select = moodle_select::make($options, $name, $selected); // Required
$select->nothinglabel = $nothing;
$select->nothingvalue = $nothingvalue;
$select->disabled = $disabled;
$select->tabindex = $tabindex;
$select->id = $id;
$select->listbox = $listbox;
$select->multiple = $multiple;
$select->add_classes($class);
echo $OUTPUT->select($select);
choose_from_radio (6)
close_window_button (34)
continue (102)
doc_link (30)
helpbutton (391)
Old code:
helpbutton($page, $title, $module, $image, $linktext, $text, $return, $imagetext);
New code:
$helpicon = new help_icon();
$helpicon->page = $page; // required
$helpicon->text = $title; // required
$helpicon->module = $module; // defaults to 'moodle'
$helpicon->linktext = $linktext;
echo $OUTPUT->help_icon($helpicon);
link_to_popup_window (54)
notice_yesno (79)
notify (548)
page_doc_link (20)
popup_form (51)
print_arrow (15)
print_box* (380)
print_checkbox (33)
print_container* (153)
print_date_selector (11)
Old code:
print_footer($course, $usercourse, $return);
New code:
echo $OUTPUT->footer();
Notes: No parameters are required.
print_header (501)
Old code:
print_header($title, $heading, $navigation, $focus, $meta, $cache, $button, $menu, $usexml, $bodytags, $return);
New code:
$PAGE->set_heading($heading); // Required
$PAGE->set_title($title);
$PAGE->set_cacheable($cache);
$PAGE->set_focuscontrol($focus);
$PAGE->set_button($button);
echo $OUTPUT->header($navigation, $menu);
Note: Navigation code is being rewritten, this doc will then be updated with the new usage.
print_header_with_help (0)
print_heading (436)
Old code:
print_heading($text, $align, $size, $class, $return, $id);
New code:
echo $OUTPUT->heading($text, $size, $class, $id);
Note: Use a CSS class rule to control alignment.
print_heading_block (9)
print_headline (11)
print_paging_bar (41)
print_side_block (4)
print_single_button (108)
print_spacer (20)
print_table (140)
print_textarea (55)
print_textfield (2)
print_time_selector (9)
print_user_picture (77)
update_course_button (2)
update_module_button (94)
update_tag_button (4)
Non-supported functions
These functions have been completely dropped in 2.0, most likely because they were used very little or not at all. All calls to these functions in core should have been replaced.