See Release Notes
Long Term Support Release
1 <?php 2 3 // This file is part of Moodle - http://moodle.org/ 4 // 5 // Moodle is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // Moodle is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 17 18 /** 19 * Provides support for the conversion of moodle1 backup to the moodle2 format 20 * Based off of a template @ http://docs.moodle.org/dev/Backup_1.9_conversion_for_developers 21 * 22 * @package mod_label 23 * @copyright 2011 Aparup Banerjee <aparup@moodle.com> 24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 25 */ 26 27 defined('MOODLE_INTERNAL') || die(); 28 29 /** 30 * Label conversion handler 31 */ 32 class moodle1_mod_label_handler extends moodle1_mod_handler { 33 34 /** 35 * Declare the paths in moodle.xml we are able to convert 36 * 37 * The method returns list of {@link convert_path} instances. 38 * For each path returned, the corresponding conversion method must be 39 * defined. 40 * 41 * Note that the path /MOODLE_BACKUP/COURSE/MODULES/MOD/LABEL does not 42 * actually exist in the file. The last element with the module name was 43 * appended by the moodle1_converter class. 44 * 45 * @return array of {@link convert_path} instances 46 */ 47 public function get_paths() { 48 return array( 49 new convert_path( 50 'label', '/MOODLE_BACKUP/COURSE/MODULES/MOD/LABEL', 51 array( 52 'renamefields' => array( 53 'content' => 'intro' 54 ), 55 'newfields' => array( 56 'introformat' => FORMAT_HTML 57 ) 58 ) 59 ) 60 ); 61 } 62 63 /** 64 * This is executed every time we have one /MOODLE_BACKUP/COURSE/MODULES/MOD/LABEL 65 * data available 66 */ 67 public function process_label($data) { 68 // get the course module id and context id 69 $instanceid = $data['id']; 70 $cminfo = $this->get_cminfo($instanceid); 71 $moduleid = $cminfo['id']; 72 $contextid = $this->converter->get_contextid(CONTEXT_MODULE, $moduleid); 73 74 // get a fresh new file manager for this instance 75 $fileman = $this->converter->get_file_manager($contextid, 'mod_label'); 76 77 // convert course files embedded into the intro 78 $fileman->filearea = 'intro'; 79 $fileman->itemid = 0; 80 $data['intro'] = moodle1_converter::migrate_referenced_files($data['intro'], $fileman); 81 82 // write inforef.xml 83 $this->open_xml_writer("activities/label_{$moduleid}/inforef.xml"); 84 $this->xmlwriter->begin_tag('inforef'); 85 $this->xmlwriter->begin_tag('fileref'); 86 foreach ($fileman->get_fileids() as $fileid) { 87 $this->write_xml('file', array('id' => $fileid)); 88 } 89 $this->xmlwriter->end_tag('fileref'); 90 $this->xmlwriter->end_tag('inforef'); 91 $this->close_xml_writer(); 92 93 // write label.xml 94 $this->open_xml_writer("activities/label_{$moduleid}/label.xml"); 95 $this->xmlwriter->begin_tag('activity', array('id' => $instanceid, 'moduleid' => $moduleid, 96 'modulename' => 'label', 'contextid' => $contextid)); 97 $this->write_xml('label', $data, array('/label/id')); 98 $this->xmlwriter->end_tag('activity'); 99 $this->close_xml_writer(); 100 101 return $data; 102 } 103 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body