Something like this:
public static function add_page_record($data, $context) {
global $DB;
$pagecontentsoptions = simplelesson_get_editor_options($context);
// Insert a dummy record and get the id.
$data->timecreated = time();
$data->timemodified = time();
$data->pagecontents = ' ';
$data->pagecontentsformat = FORMAT_HTML;
$dataid = $DB->insert_record('simplelesson_pages', $data);
$data->id = $dataid;
// Massage the data into a form for saving.
$data = file_postupdate_standard_editor(
$data,
'pagecontents',
$pagecontentsoptions,
$context,
'mod_simplelesson',
'pagecontents',
$data->id);
// Update the record with full editor data.
$DB->update_record('simplelesson_pages', $data);
return $data->id;
}
pagecontents is the editor area on the relevant form and 'pagecontents' is the file area declared in lib.php:
function simplelesson_get_file_areas($course, $cm, $context) {
return array('pagecontents' => 'for page files editor content');
}