Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/glossary/backup/moodle1/lib.php
Go to the documentation of this file.
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 
00027 defined('MOODLE_INTERNAL') || die();
00028 
00032 class moodle1_mod_glossary_handler extends moodle1_mod_handler {
00033 
00035     protected $fileman = null;
00036 
00038     protected $moduleid = null;
00039 
00053     public function get_paths() {
00054         return array(
00055             new convert_path(
00056                 'glossary', '/MOODLE_BACKUP/COURSE/MODULES/MOD/GLOSSARY',
00057                 array(
00058                     'newfields' => array(
00059                         'introformat'       => FORMAT_MOODLE,
00060                         'completionentries' => 0,
00061                     ),
00062                 )
00063             ),
00064             new convert_path('glossary_categories', '/MOODLE_BACKUP/COURSE/MODULES/MOD/GLOSSARY/CATEGORIES'),
00065             new convert_path(
00066                 'glossary_category', '/MOODLE_BACKUP/COURSE/MODULES/MOD/GLOSSARY/CATEGORIES/CATEGORY',
00067                 array(
00068                     'dropfields' => array(
00069                         'glossaryid'
00070                     )
00071                 )
00072             )
00073         );
00074     }
00075 
00080     public function process_glossary($data) {
00081         global $CFG;
00082 
00083         // get the course module id and context id
00084         $instanceid     = $data['id'];
00085         $cminfo         = $this->get_cminfo($instanceid);
00086         $this->moduleid = $cminfo['id'];
00087         $contextid      = $this->converter->get_contextid(CONTEXT_MODULE, $this->moduleid);
00088 
00089         // replay the upgrade step 2009042006
00090         if ($CFG->texteditors !== 'textarea') {
00091             $data['intro']       = text_to_html($data['intro'], false, false, true);
00092             $data['introformat'] = FORMAT_HTML;
00093         }
00094 
00095         // get a fresh new file manager for this instance
00096         $this->fileman = $this->converter->get_file_manager($contextid, 'mod_glossary');
00097 
00098         // convert course files embedded into the intro
00099         $this->fileman->filearea = 'intro';
00100         $this->fileman->itemid   = 0;
00101         $data['intro'] = moodle1_converter::migrate_referenced_files($data['intro'], $this->fileman);
00102 
00103         // start writing glossary.xml
00104         $this->open_xml_writer("activities/glossary_{$this->moduleid}/glossary.xml");
00105         $this->xmlwriter->begin_tag('activity', array('id' => $instanceid, 'moduleid' => $this->moduleid,
00106             'modulename' => 'glossary', 'contextid' => $contextid));
00107         $this->xmlwriter->begin_tag('glossary', array('id' => $instanceid));
00108 
00109         foreach ($data as $field => $value) {
00110             if ($field <> 'id') {
00111                 $this->xmlwriter->full_tag($field, $value);
00112             }
00113         }
00114 
00115         return $data;
00116     }
00117 
00121     public function on_glossary_categories_start() {
00122         $this->xmlwriter->begin_tag('categories');
00123     }
00124 
00129     public function process_glossary_category($data) {
00130         $this->write_xml('category', $data, array('/category/id'));
00131     }
00132 
00136     public function on_glossary_categories_end() {
00137         $this->xmlwriter->end_tag('categories');
00138     }
00139 
00143     public function on_glossary_end() {
00144         // finalize glossary.xml
00145         $this->xmlwriter->end_tag('glossary');
00146         $this->xmlwriter->end_tag('activity');
00147         $this->close_xml_writer();
00148 
00149         // write inforef.xml
00150         $this->open_xml_writer("activities/glossary_{$this->moduleid}/inforef.xml");
00151         $this->xmlwriter->begin_tag('inforef');
00152         $this->xmlwriter->begin_tag('fileref');
00153         foreach ($this->fileman->get_fileids() as $fileid) {
00154             $this->write_xml('file', array('id' => $fileid));
00155         }
00156         $this->xmlwriter->end_tag('fileref');
00157         $this->xmlwriter->end_tag('inforef');
00158         $this->close_xml_writer();
00159     }
00160 }
 All Data Structures Namespaces Files Functions Variables Enumerations