|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // This file is part of Moodle - http://moodle.org/ 00004 // 00005 // Moodle is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // Moodle is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00017 00028 defined('MOODLE_INTERNAL') || die(); 00029 00033 class moodle1_mod_label_handler extends moodle1_mod_handler { 00034 00048 public function get_paths() { 00049 return array( 00050 new convert_path( 00051 'label', '/MOODLE_BACKUP/COURSE/MODULES/MOD/LABEL', 00052 array( 00053 'renamefields' => array( 00054 'content' => 'intro' 00055 ), 00056 'newfields' => array( 00057 'introformat' => FORMAT_HTML 00058 ) 00059 ) 00060 ) 00061 ); 00062 } 00063 00068 public function process_label($data) { 00069 // get the course module id and context id 00070 $instanceid = $data['id']; 00071 $cminfo = $this->get_cminfo($instanceid); 00072 $moduleid = $cminfo['id']; 00073 $contextid = $this->converter->get_contextid(CONTEXT_MODULE, $moduleid); 00074 00075 // get a fresh new file manager for this instance 00076 $fileman = $this->converter->get_file_manager($contextid, 'mod_label'); 00077 00078 // convert course files embedded into the intro 00079 $fileman->filearea = 'intro'; 00080 $fileman->itemid = 0; 00081 $data['intro'] = moodle1_converter::migrate_referenced_files($data['intro'], $fileman); 00082 00083 // write inforef.xml 00084 $this->open_xml_writer("activities/label_{$moduleid}/inforef.xml"); 00085 $this->xmlwriter->begin_tag('inforef'); 00086 $this->xmlwriter->begin_tag('fileref'); 00087 foreach ($fileman->get_fileids() as $fileid) { 00088 $this->write_xml('file', array('id' => $fileid)); 00089 } 00090 $this->xmlwriter->end_tag('fileref'); 00091 $this->xmlwriter->end_tag('inforef'); 00092 $this->close_xml_writer(); 00093 00094 // write label.xml 00095 $this->open_xml_writer("activities/label_{$moduleid}/label.xml"); 00096 $this->xmlwriter->begin_tag('activity', array('id' => $instanceid, 'moduleid' => $moduleid, 00097 'modulename' => 'label', 'contextid' => $contextid)); 00098 $this->write_xml('label', $data, array('/label/id')); 00099 $this->xmlwriter->end_tag('activity'); 00100 $this->close_xml_writer(); 00101 00102 return $data; 00103 } 00104 }